From 618c7ffa857e2be4a96daa7645e423335028fad8 Mon Sep 17 00:00:00 2001 From: Alexandre Deckner Date: Wed, 15 Oct 2008 15:35:59 +0000 Subject: [PATCH] * There was indeed a problem with my previous attempt at fixing #353. This should be much better! git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28139 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/tracker/DeskWindow.cpp | 4 +-- src/kits/tracker/DeskWindow.h | 5 +-- src/kits/tracker/ShowingAwarePopUpMenu.cpp | 37 +++++++++++++++++++++ src/kits/tracker/ShowingAwarePopUpMenu.h | 38 ++++++++++++++++++++++ 4 files changed, 80 insertions(+), 4 deletions(-) create mode 100644 src/kits/tracker/ShowingAwarePopUpMenu.cpp create mode 100644 src/kits/tracker/ShowingAwarePopUpMenu.h diff --git a/src/kits/tracker/DeskWindow.cpp b/src/kits/tracker/DeskWindow.cpp index 54ccaa7a12..f2ecdb4d76 100644 --- a/src/kits/tracker/DeskWindow.cpp +++ b/src/kits/tracker/DeskWindow.cpp @@ -54,7 +54,7 @@ All rights reserved. #include "IconMenuItem.h" #include "MountMenu.h" #include "PoseView.h" -#include "SlowContextPopup.h" +#include "ShowingAwarePopUpMenu.h" #include "Tracker.h" #include "TemplatesMenu.h" @@ -329,7 +329,7 @@ void BDeskWindow::AddTrashContextMenu() { // setup special trash context menu - fTrashContextMenu = new BSlowContextMenu("TrashContext"); + fTrashContextMenu = new BShowingAwarePopUpMenu("TrashContext"); fTrashContextMenu->SetFont(be_plain_font); fTrashContextMenu->AddItem(new BMenuItem("Empty Trash", new BMessage(kEmptyTrash))); diff --git a/src/kits/tracker/DeskWindow.h b/src/kits/tracker/DeskWindow.h index 43ab1b5120..a057ab2795 100644 --- a/src/kits/tracker/DeskWindow.h +++ b/src/kits/tracker/DeskWindow.h @@ -41,9 +41,10 @@ All rights reserved. #include "ContainerWindow.h" #include "DesktopPoseView.h" -class BSlowContextMenu; namespace BPrivate { + +class BShowingAwarePopUpMenu; class BDeskWindow : public BContainerWindow { public: @@ -82,7 +83,7 @@ protected: private: BShelf *fDeskShelf; // shelf for replicant support - BSlowContextMenu *fTrashContextMenu; + BShowingAwarePopUpMenu *fTrashContextMenu; BRect fOldFrame; diff --git a/src/kits/tracker/ShowingAwarePopUpMenu.cpp b/src/kits/tracker/ShowingAwarePopUpMenu.cpp new file mode 100644 index 0000000000..671aa2ea00 --- /dev/null +++ b/src/kits/tracker/ShowingAwarePopUpMenu.cpp @@ -0,0 +1,37 @@ +/* + * Copyright 2008, Haiku Inc. + * Distributed under the terms of the MIT License. + * + * Authors: + * Alexandre Deckner, alex@zappotek.com + */ + +#include "ShowingAwarePopUpMenu.h" + + +BShowingAwarePopUpMenu::BShowingAwarePopUpMenu(const char *title, bool radioMode, + bool autoRename, menu_layout layout) + : BPopUpMenu(title, radioMode, autoRename, layout), + fIsShowing(false) +{ +} + + +BShowingAwarePopUpMenu::~BShowingAwarePopUpMenu() +{ +} + + +void +BShowingAwarePopUpMenu::AttachedToWindow() +{ + fIsShowing = true; + BPopUpMenu::AttachedToWindow(); +} + + +void +BShowingAwarePopUpMenu::DetachedFromWindow() +{ + fIsShowing = false; +} diff --git a/src/kits/tracker/ShowingAwarePopUpMenu.h b/src/kits/tracker/ShowingAwarePopUpMenu.h new file mode 100644 index 0000000000..ebd50c1d78 --- /dev/null +++ b/src/kits/tracker/ShowingAwarePopUpMenu.h @@ -0,0 +1,38 @@ +/* + * Copyright 2008, Haiku, Inc. All Rights Reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef _SHOWING_AWARE_POPUP_MENU_H +#define _SHOWING_AWARE_POPUP_MENU_H + +#include + + +namespace BPrivate { + +class BShowingAwarePopUpMenu : public BPopUpMenu { +public: + BShowingAwarePopUpMenu(const char *title, bool radioMode = true, + bool autoRename = true, menu_layout layout = B_ITEMS_IN_COLUMN); + virtual ~BShowingAwarePopUpMenu(); + + virtual void AttachedToWindow(); + virtual void DetachedFromWindow(); + + const bool IsShowing() const; + +private: + bool fIsShowing; +}; + +} // namespace BPrivate + +using namespace BPrivate; + +inline const bool +BShowingAwarePopUpMenu::IsShowing() const +{ + return fIsShowing; +} + +#endif