Add support for actions to TableCellContextMenuTracker.
- VariablesView's context menu tracker now optionally accepts contextual actions to add to the menu in addition to the current renderer settings.
This commit is contained in:
parent
8293199831
commit
0712121cdb
@ -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<Settings> 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<ActionMenuItem*>(
|
||||
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<ActionMenuItem*>(
|
||||
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;
|
||||
|
@ -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<ActionMenuItem> ContextActionList;
|
||||
|
||||
private:
|
||||
void _Init();
|
||||
|
Loading…
Reference in New Issue
Block a user