diff --git a/src/apps/Jamfile b/src/apps/Jamfile index 4a4d1a5273..c27c475bf8 100644 --- a/src/apps/Jamfile +++ b/src/apps/Jamfile @@ -36,6 +36,7 @@ HaikuSubInclude mediaconverter ; HaikuSubInclude mediaplayer ; HaikuSubInclude midiplayer ; HaikuSubInclude networkstatus ; +HaikuSubInclude overlayimage ; HaikuSubInclude packageinstaller ; HaikuSubInclude pairs ; HaikuSubInclude people ; diff --git a/src/apps/overlayimage/Jamfile b/src/apps/overlayimage/Jamfile new file mode 100644 index 0000000000..67fa61b67b --- /dev/null +++ b/src/apps/overlayimage/Jamfile @@ -0,0 +1,16 @@ +SubDir HAIKU_TOP src apps overlayimage ; + +Application OverlayImage : + OverlayApp.cpp + OverlayView.cpp + OverlayWindow.cpp + + : be liblocale.so libtranslation.so $(TARGET_LIBSTDC++) + : OverlayImage.rdef +; + +DoCatalogs OverlayImage : + x-vnd.Haiku-OverlayImage + : + OverlayWindow.cpp +; diff --git a/src/apps/overlayimage/OverlayApp.cpp b/src/apps/overlayimage/OverlayApp.cpp new file mode 100644 index 0000000000..2745381d90 --- /dev/null +++ b/src/apps/overlayimage/OverlayApp.cpp @@ -0,0 +1,34 @@ +/* + * Copyright 1999-2010, Be Incorporated. All Rights Reserved. + * This file may be used under the terms of the Be Sample Code License. + * + * OverlayImage is based on the code presented in this article: + * http://www.haiku-os.org/documents/dev/replishow_a_replicable_image_viewer + * + * Authors: + * Seth Flexman + * Hartmuth Reh + * Humdinger + */ + +#include "OverlayApp.h" +#include "OverlayWindow.h" + + +OverlayApp::OverlayApp() + : BApplication("application/x-vnd.Haiku-OverlayImage") +{ + be_locale->GetAppCatalog(&fCatalog); + + OverlayWindow *theWindow = new OverlayWindow(); + theWindow->Show(); +} + + +int +main() +{ + OverlayApp theApp; + theApp.Run(); + return (0); +} diff --git a/src/apps/overlayimage/OverlayApp.h b/src/apps/overlayimage/OverlayApp.h new file mode 100644 index 0000000000..37ba2b89b4 --- /dev/null +++ b/src/apps/overlayimage/OverlayApp.h @@ -0,0 +1,29 @@ +/* + * Copyright 1999-2010, Be Incorporated. All Rights Reserved. + * This file may be used under the terms of the Be Sample Code License. + * + * OverlayImage is based on the code presented in this article: + * http://www.haiku-os.org/documents/dev/replishow_a_replicable_image_viewer + * + * Authors: + * Seth Flexman + * Hartmuth Reh + * Humdinger + */ + +#ifndef OVERLAY_APP_H +#define OVERLAY_APP_H + +#include +#include +#include + + +class OverlayApp : public BApplication { +public: + OverlayApp(); +private: + BCatalog fCatalog; +}; + +#endif // OVERLAY_APP_H diff --git a/src/apps/overlayimage/OverlayImage.rdef b/src/apps/overlayimage/OverlayImage.rdef new file mode 100644 index 0000000000..a4a635f5fe --- /dev/null +++ b/src/apps/overlayimage/OverlayImage.rdef @@ -0,0 +1,35 @@ +resource app_signature "application/x-vnd.Haiku-OverlayImage"; + +resource app_flags B_MULTIPLE_LAUNCH; + +resource app_version { + major = 0, + middle = 9, + minor = 0, + + /* 0 = development 1 = alpha 2 = beta + 3 = gamma 4 = golden master 5 = final */ + variety = 5, + + internal = 0, + + short_info = "Replicantable Image Viewer", + long_info = "View an image and put it as replicant e.g. on the Desktop" +}; + +resource vector_icon { + $"6E6369660502000603399E0F3D9C0ABF82B23B84A84B88504870C900F0D733BC" + $"FFFEEAFFE0F154050105FF04019203FF00A7050606AE0B284033C3AE2A44BE00" + $"C5EC4454543C4430C5A6BACF3E2E3C28020ABB1EBB84BB1EBB84BB1EBB842E3A" + $"3038B784BE6B2C40B68DBF7130413A423243404044404242C222BEF54C3E4E40" + $"C43EBEAA4E3CC3EFBE67C6B9BDE84A36C673BC10C0FDBB773A3ABF31BC71363C" + $"323C343CB8EDBDDB020248404A404640484444444C440202C65EBE74C6D2BE67" + $"C5EDBE81C653BF0DC5C5BEDAC6DEBF400A04304A30504250424A080A03010002" + $"4014CABE1A903E2F65402966C834CE48FF1D0A01010012BC3AE4C02527402527" + $"BC3AE443BD604C697101178400040A00010002BC3FE0C029F24029F2BC3FE043" + $"99B24C6BC80A0403010203023F66E5B3B70FB829F03FF40743681746AB1E0A02" + $"0104023CF34B3F5F71BFB7D13CAD2B4B19BAC8C4530A010104123CF34B3F5F71" + $"BFB7D13CAD2B4B19BAC8C45301178200040A02010402BF34E93E641CBE641CBF" + $"34E94CFF874AC2190A01010412BF34E93E641CBE641CBF34E94CFF874AC21901" + $"17820004" +}; diff --git a/src/apps/overlayimage/OverlayView.cpp b/src/apps/overlayimage/OverlayView.cpp new file mode 100644 index 0000000000..3877dabdb7 --- /dev/null +++ b/src/apps/overlayimage/OverlayView.cpp @@ -0,0 +1,146 @@ +/* + * Copyright 1999-2010, Be Incorporated. All Rights Reserved. + * This file may be used under the terms of the Be Sample Code License. + * + * OverlayImage is based on the code presented in this article: + * http://www.haiku-os.org/documents/dev/replishow_a_replicable_image_viewer + * + * Authors: + * Seth Flexman + * Hartmuth Reh + * Humdinger + */ + +#include "OverlayView.h" + +#include +#include + +const float kDraggerSize = 7; + + +OverlayView::OverlayView(BRect frame) + : + BView(frame, "OverlayImage", B_FOLLOW_NONE, B_WILL_DRAW) +{ + fBitmap = NULL; + fReplicated = false; + + frame.left = frame.right - kDraggerSize; + frame.top = frame.bottom - kDraggerSize; + BDragger *dragger = new BDragger(frame, this, B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); + AddChild(dragger); + + SetViewColor(B_TRANSPARENT_COLOR); +} + + +OverlayView::OverlayView(BMessage *archive) + : + BView(archive) +{ + fReplicated = true; + fBitmap = new BBitmap(archive); +} + + +OverlayView::~OverlayView() +{ + delete fBitmap; +} + + +void +OverlayView::Draw(BRect) +{ + SetDrawingMode(B_OP_ALPHA); + SetViewColor(B_TRANSPARENT_COLOR); + + if (fBitmap) + DrawBitmap(fBitmap, B_ORIGIN); +} + + +void +OverlayView::MessageReceived(BMessage *msg) +{ + switch (msg->what) { + case B_SIMPLE_DATA: + { + if (fReplicated) + break; + + entry_ref ref; + msg->FindRef("refs", &ref); + BEntry entry(&ref); + BPath path(&entry); + + delete fBitmap; + fBitmap = BTranslationUtils::GetBitmap(path.Path()); + + if (fBitmap != NULL) { + BRect rect = fBitmap->Bounds(); + if (!fReplicated) + Window()->ResizeTo(rect.right, rect.bottom); + + ResizeTo(rect.right, rect.bottom); + Invalidate(); + } + break; + } + case B_ABOUT_REQUESTED: + OverlayAboutRequested(); + break; + + default: + BView::MessageReceived(msg); + break; + } +} + + +BArchivable *OverlayView::Instantiate(BMessage *data) +{ + return new OverlayView(data); +} + + +status_t +OverlayView::Archive(BMessage *archive, bool deep) const +{ + BView::Archive(archive, deep); + + archive->AddString("add_on", "application/x-vnd.Haiku-OverlayImage"); + archive->AddString("class", "OverlayImage"); + + if (fBitmap) { + fBitmap->Lock(); + fBitmap->Archive(archive); + fBitmap->Unlock(); + } + //archive->PrintToStream(); + + return B_OK; +} + + +void +OverlayView::OverlayAboutRequested() +{ + BAlert *alert = new BAlert("about", + "OverlayImage\n" + "Copyright 1999-2010" "\n\n\t" + "originally by Seth Flaxman" "\n\t" + "modified by Hartmuth Reh" "\n\t" + "further modified by Humdinger" "\n", + "OK"); + + BTextView *view = alert->TextView(); + BFont font; + view->SetStylable(true); + view->GetFont(&font); + font.SetSize(font.Size() + 4); + font.SetFace(B_BOLD_FACE); + view->SetFontAndColor(0, 9, &font); + alert->Go(); +} diff --git a/src/apps/overlayimage/OverlayView.h b/src/apps/overlayimage/OverlayView.h new file mode 100644 index 0000000000..4f2427f028 --- /dev/null +++ b/src/apps/overlayimage/OverlayView.h @@ -0,0 +1,47 @@ +/* + * Copyright 1999-2010, Be Incorporated. All Rights Reserved. + * This file may be used under the terms of the Be Sample Code License. + * + * OverlayImage is based on the code presented in this article: + * http://www.haiku-os.org/documents/dev/replishow_a_replicable_image_viewer + * + * Authors: + * Seth Flexman + * Hartmuth Reh + * Humdinger + */ + +#ifndef OVERLAY_VIEW_H +#define OVERLAY_VIEW_H + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + + +class _EXPORT OverlayView; + +class OverlayView : public BView { +public: + OverlayView(BRect frame); + OverlayView(BMessage *data); + ~OverlayView(); + virtual void Draw(BRect); + virtual void MessageReceived(BMessage *msg); + static BArchivable *Instantiate(BMessage *archive); + virtual status_t Archive(BMessage *data, bool deep = true) const; + void OverlayAboutRequested(); + +private: + BBitmap *fBitmap; + bool fReplicated; +}; + +#endif // OVERLAY_VIEW_H diff --git a/src/apps/overlayimage/OverlayWindow.cpp b/src/apps/overlayimage/OverlayWindow.cpp new file mode 100644 index 0000000000..81f433d61f --- /dev/null +++ b/src/apps/overlayimage/OverlayWindow.cpp @@ -0,0 +1,54 @@ +/* + * Copyright 1999-2010, Be Incorporated. All Rights Reserved. + * This file may be used under the terms of the Be Sample Code License. + * + * OverlayImage is based on the code presented in this article: + * http://www.haiku-os.org/documents/dev/replishow_a_replicable_image_viewer + * + * Authors: + * Seth Flexman + * Hartmuth Reh + * Humdinger + */ + +#include "OverlayView.h" +#include "OverlayWindow.h" + +#include +#include +#include +#include +#include + +#undef B_TRANSLATE_CONTEXT +#define B_TRANSLATE_CONTEXT "Main window" + + +OverlayWindow::OverlayWindow() + : + BWindow(BRect(100, 100, 450, 350), "OverlayImage", + B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE) +{ + OverlayView *replView = new OverlayView(Bounds()); + AddChild(replView); + + BView *bgView = new BView(Bounds(), "bgView", B_FOLLOW_ALL, B_WILL_DRAW); + bgView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR)); + AddChild(bgView); + + BString text; + text << B_TRANSLATE("Enable \"Show replicants\" in Deskbar."); + text << "\n"; + text << B_TRANSLATE("Drag & drop an image."); + text << "\n"; + text << B_TRANSLATE("Drag the replicant to the Desktop."); + replView->SetToolTip(text); +} + + +bool +OverlayWindow::QuitRequested() +{ + be_app->PostMessage(B_QUIT_REQUESTED); + return true; +} diff --git a/src/apps/overlayimage/OverlayWindow.h b/src/apps/overlayimage/OverlayWindow.h new file mode 100644 index 0000000000..7a0c6b5c34 --- /dev/null +++ b/src/apps/overlayimage/OverlayWindow.h @@ -0,0 +1,26 @@ +/* + * Copyright 1999-2010, Be Incorporated. All Rights Reserved. + * This file may be used under the terms of the Be Sample Code License. + * + * OverlayImage is based on the code presented in this article: + * http://www.haiku-os.org/documents/dev/replishow_a_replicable_image_viewer + * + * Authors: + * Seth Flexman + * Hartmuth Reh + * Humdinger + */ + +#ifndef OVERLAY_WINDOW_H +#define OVERLAY_WINDOW_H + +#include + + +class OverlayWindow : public BWindow { +public: + OverlayWindow(); + virtual bool QuitRequested(); +}; + +#endif // OVERLAY_WINDOW_H