mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-17 00:20:06 +02:00
Some fixes for PopupMenuTable
This commit is contained in:
commit
3a764279ba
@ -608,9 +608,8 @@ protected:
|
|||||||
WaveTrackMenuTable &WaveTrackMenuTable::Instance( Track * pTrack )
|
WaveTrackMenuTable &WaveTrackMenuTable::Instance( Track * pTrack )
|
||||||
{
|
{
|
||||||
static WaveTrackMenuTable instance;
|
static WaveTrackMenuTable instance;
|
||||||
wxCommandEvent evt;
|
|
||||||
// Clear it out so we force a repopulate
|
// Clear it out so we force a repopulate
|
||||||
instance.Invalidate( evt );
|
instance.Clear();
|
||||||
// Ensure we know how to populate.
|
// Ensure we know how to populate.
|
||||||
// Messy, but the design does not seem to offer an alternative.
|
// Messy, but the design does not seem to offer an alternative.
|
||||||
// We won't use pTrack after populate.
|
// We won't use pTrack after populate.
|
||||||
|
@ -64,6 +64,7 @@ void PopupMenuTable::Menu::Extend(PopupMenuTable *pTable)
|
|||||||
}
|
}
|
||||||
|
|
||||||
pTable->InitMenu(this);
|
pTable->InitMenu(this);
|
||||||
|
tables.push_back( pTable );
|
||||||
}
|
}
|
||||||
|
|
||||||
void PopupMenuTable::Menu::DisconnectTable(PopupMenuTable *pTable)
|
void PopupMenuTable::Menu::DisconnectTable(PopupMenuTable *pTable)
|
||||||
|
@ -25,7 +25,6 @@ class wxString;
|
|||||||
#include "../MemoryX.h"
|
#include "../MemoryX.h"
|
||||||
|
|
||||||
#include "../Internat.h"
|
#include "../Internat.h"
|
||||||
#include "../TranslatableStringArray.h"
|
|
||||||
|
|
||||||
class PopupMenuTable;
|
class PopupMenuTable;
|
||||||
|
|
||||||
@ -53,7 +52,7 @@ struct PopupMenuTableEntry
|
|||||||
bool IsValid() const { return type != Invalid; }
|
bool IsValid() const { return type != Invalid; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class PopupMenuTable : public TranslatableArray< std::vector<PopupMenuTableEntry> >
|
class PopupMenuTable : public wxEvtHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef PopupMenuTableEntry Entry;
|
typedef PopupMenuTableEntry Entry;
|
||||||
@ -95,6 +94,20 @@ public:
|
|||||||
// No memory management responsibility is assumed by this function.
|
// No memory management responsibility is assumed by this function.
|
||||||
static std::unique_ptr<Menu> BuildMenu
|
static std::unique_ptr<Menu> BuildMenu
|
||||||
(wxEvtHandler *pParent, PopupMenuTable *pTable, void *pUserData = NULL);
|
(wxEvtHandler *pParent, PopupMenuTable *pTable, void *pUserData = NULL);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void Populate() = 0;
|
||||||
|
void Clear() { mContents.clear(); }
|
||||||
|
|
||||||
|
using Entries = std::vector<PopupMenuTableEntry>;
|
||||||
|
const Entries& Get()
|
||||||
|
{
|
||||||
|
if (mContents.empty())
|
||||||
|
Populate();
|
||||||
|
return mContents;
|
||||||
|
}
|
||||||
|
|
||||||
|
Entries mContents;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -114,17 +127,18 @@ Then in MyTable.cpp,
|
|||||||
|
|
||||||
void MyTable::InitUserData(void *pUserData)
|
void MyTable::InitUserData(void *pUserData)
|
||||||
{
|
{
|
||||||
|
// Remember pData
|
||||||
auto pData = static_cast<MyData*>(pUserData);
|
auto pData = static_cast<MyData*>(pUserData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyTable::InitMenu(Menu *pMenu)
|
void MyTable::InitMenu(Menu *pMenu)
|
||||||
{
|
{
|
||||||
// Remember pData, enable or disable menu items
|
// enable or disable menu items
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyTable::DestroyMenu()
|
void MyTable::DestroyMenu()
|
||||||
{
|
{
|
||||||
// Do cleanup
|
// Do cleanup
|
||||||
}
|
}
|
||||||
|
|
||||||
BEGIN_POPUP_MENU(MyTable)
|
BEGIN_POPUP_MENU(MyTable)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user