From dc6d91a93005cbc1c1bbc4df2a4cd9c89a2244b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Fri, 2 May 2008 22:13:09 +0000 Subject: [PATCH] Added a path popup menu like Tracker's and Pe's to the Status bar. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25295 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/showimage/ShowImageStatusView.cpp | 51 ++++++++++++++++++++++ src/apps/showimage/ShowImageStatusView.h | 2 + 2 files changed, 53 insertions(+) diff --git a/src/apps/showimage/ShowImageStatusView.cpp b/src/apps/showimage/ShowImageStatusView.cpp index 1b2713714f..ea43fb70cc 100644 --- a/src/apps/showimage/ShowImageStatusView.cpp +++ b/src/apps/showimage/ShowImageStatusView.cpp @@ -27,6 +27,14 @@ /*****************************************************************************/ #include "ShowImageStatusView.h" +#include "ShowImageView.h" +#include "ShowImageWindow.h" + +#include +#include +#include +#include + ShowImageStatusView::ShowImageStatusView(BRect rect, const char* name, uint32 resizingMode, uint32 flags) @@ -42,6 +50,7 @@ ShowImageStatusView::ShowImageStatusView(BRect rect, const char* name, SetFont(&font); } + void ShowImageStatusView::Draw(BRect updateRect) { @@ -82,9 +91,51 @@ ShowImageStatusView::Draw(BRect updateRect) + fh.ascent / 2.0))); } + +void +ShowImageStatusView::MouseDown(BPoint where) +{ + ShowImageWindow *window = dynamic_cast(Window()); + if (!window || window->GetShowImageView() == NULL) + return; + + BPath path; + path.SetTo(window->GetShowImageView()->Image()); + + BPopUpMenu popup("no title"); + popup.SetFont(be_plain_font); + + while (path.GetParent(&path) == B_OK && path != "/") { + popup.AddItem(new BMenuItem(path.Leaf(), NULL)); + } + + BRect bounds(Bounds()); + ConvertToScreen(&bounds); + where = bounds.LeftBottom(); + + BMenuItem *item; + item = popup.Go(where, true, false, ConvertToScreen(Bounds())); + + if (item) { + path.SetTo(window->GetShowImageView()->Image()); + path.GetParent(&path); + int index = popup.IndexOf(item); + while (index--) + path.GetParent(&path); + BMessenger tracker("application/x-vnd.Be-TRAK"); + BMessage msg(B_REFS_RECEIVED); + entry_ref ref; + get_ref_for_path(path.Path(), &ref); + msg.AddRef("refs", &ref); + tracker.SendMessage(msg); + } +} + + void ShowImageStatusView::SetText(BString &text) { fText = text; Invalidate(); } + diff --git a/src/apps/showimage/ShowImageStatusView.h b/src/apps/showimage/ShowImageStatusView.h index faac45e1a2..4dfa87424a 100644 --- a/src/apps/showimage/ShowImageStatusView.h +++ b/src/apps/showimage/ShowImageStatusView.h @@ -38,6 +38,8 @@ public: uint32 flags); virtual void Draw(BRect updateRect); + + virtual void MouseDown(BPoint where); void SetText(BString &text);