diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp index 922d8d49b7..85a26a291e 100644 --- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp +++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.cpp @@ -1,6 +1,6 @@ /* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. - * Copyright 2011, Rene Gollent, rene@gollent.com. + * Copyright 2011-2012, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ @@ -19,6 +19,7 @@ #include "table/TableColumns.h" +#include "ActionMenuItem.h" #include "Architecture.h" #include "FunctionID.h" #include "FunctionInstance.h" @@ -487,7 +488,9 @@ public: } status_t Init(Settings* rendererSettings, - SettingsMenu* rendererSettingsMenu) + SettingsMenu* rendererSettingsMenu, + ContextActionList* preSettingsActions = NULL, + ContextActionList* postSettingsActions = NULL) { fRendererSettings = rendererSettings; fRendererSettings->AcquireReference(); @@ -500,10 +503,23 @@ public: if (fContextMenu == NULL) return B_NO_MEMORY; - status_t error = fRendererSettingsMenu->AddToMenu(fContextMenu, 0); + status_t error = B_OK; + if (preSettingsActions != NULL) { + error = _AddActionItems(preSettingsActions); + if (error != B_OK) + return error; + } + + error = fRendererSettingsMenu->AddToMenu(fContextMenu, 0); if (error != B_OK) return error; + if (postSettingsActions != NULL) { + error = _AddActionItems(postSettingsActions); + if (error != B_OK) + return error; + } + AutoLocker settingsLocker(fRendererSettings); fRendererSettings->AddListener(this); @@ -516,6 +532,13 @@ public: { fRendererSettingsMenu->PrepareToShow(fParentLooper); + for (int32 i = 0; i < fContextMenu->CountItems(); i++) { + ActionMenuItem* item = dynamic_cast( + fContextMenu->ItemAt(i)); + if (item != NULL) + item->PrepareToShow(fParentLooper, fContextMenu); + } + fMenuPreparedToShow = true; BRect mouseRect(screenWhere, screenWhere); @@ -529,6 +552,15 @@ public: if (fMenuPreparedToShow) { stillActive = fRendererSettingsMenu->Finish(fParentLooper, force); + for (int32 i = 0; i < fContextMenu->CountItems(); i++) { + ActionMenuItem* item = dynamic_cast( + fContextMenu->ItemAt(i)); + if (item != NULL) { + stillActive |= item->Finish(fParentLooper, fContextMenu, + force); + } + } + fMenuPreparedToShow = stillActive; } @@ -559,6 +591,24 @@ private: } } + status_t _AddActionItems(ContextActionList* actions) + { + if (fContextMenu == NULL) + return B_BAD_VALUE; + + int32 index = fContextMenu->CountItems(); + for (int32 i = 0; ActionMenuItem* item = actions->ItemAt(i); i++) { + if (!fContextMenu->AddItem(item, index + i)) { + for (i--; i >= 0; i--) + fContextMenu->RemoveItem(fContextMenu->ItemAt(index + i)); + + return B_NO_MEMORY; + } + } + + return B_OK; + } + private: ModelNode* fNode; BLooper* fParentLooper; diff --git a/src/apps/debugger/user_interface/gui/team_window/VariablesView.h b/src/apps/debugger/user_interface/gui/team_window/VariablesView.h index 0310dbd4de..d1fa54b55b 100644 --- a/src/apps/debugger/user_interface/gui/team_window/VariablesView.h +++ b/src/apps/debugger/user_interface/gui/team_window/VariablesView.h @@ -11,6 +11,7 @@ #include "table/TreeTable.h" +class ActionMenuItem; class CpuState; class SettingsMenu; class StackFrame; @@ -61,6 +62,7 @@ private: class VariableTableModel; class ContextMenu; class TableCellContextMenuTracker; + typedef BObjectList ContextActionList; private: void _Init();