mirror of
https://github.com/cookiengineer/audacity
synced 2025-07-25 08:58:06 +02:00
No extra indirection accessing SnapPoint or CommandManager structures...
... also simplify memory management of CommandFunctor, using std::shared_ptr
This commit is contained in:
commit
111bb1d217
@ -198,9 +198,9 @@ void AudacityProjectCommandFunctor::operator()(int index, const wxEvent * evt)
|
|||||||
(mProject->*(mCommandFunction)) ();
|
(mProject->*(mCommandFunction)) ();
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FN(X) new AudacityProjectCommandFunctor(this, &AudacityProject:: X )
|
#define FN(X) CommandFunctorPointer{safenew AudacityProjectCommandFunctor(this, &AudacityProject:: X )}
|
||||||
#define FNI(X, I) new AudacityProjectCommandFunctor(this, &AudacityProject:: X, I)
|
#define FNI(X, I) CommandFunctorPointer{safenew AudacityProjectCommandFunctor(this, &AudacityProject:: X, I)}
|
||||||
#define FNS(X, S) new AudacityProjectCommandFunctor(this, &AudacityProject:: X, S)
|
#define FNS(X, S) CommandFunctorPointer{safenew AudacityProjectCommandFunctor(this, &AudacityProject:: X, S)}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Effects menu arrays
|
// Effects menu arrays
|
||||||
|
33
src/Snap.cpp
33
src/Snap.cpp
@ -21,9 +21,9 @@
|
|||||||
|
|
||||||
WX_DEFINE_USER_EXPORTED_OBJARRAY(TrackClipArray);
|
WX_DEFINE_USER_EXPORTED_OBJARRAY(TrackClipArray);
|
||||||
|
|
||||||
static int CompareSnapPoints(SnapPoint *s1, SnapPoint *s2)
|
inline bool operator < (SnapPoint s1, SnapPoint s2)
|
||||||
{
|
{
|
||||||
return (s1->t - s2->t > 0? 1 : -1);
|
return s1.t < s2.t;
|
||||||
}
|
}
|
||||||
|
|
||||||
SnapManager::SnapManager(TrackList *tracks,
|
SnapManager::SnapManager(TrackList *tracks,
|
||||||
@ -32,8 +32,7 @@ SnapManager::SnapManager(TrackList *tracks,
|
|||||||
const TrackArray *trackExclusions,
|
const TrackArray *trackExclusions,
|
||||||
bool noTimeSnap,
|
bool noTimeSnap,
|
||||||
int pixelTolerance)
|
int pixelTolerance)
|
||||||
: mConverter(NumericConverter::TIME),
|
: mConverter(NumericConverter::TIME)
|
||||||
mSnapPoints(CompareSnapPoints)
|
|
||||||
{
|
{
|
||||||
mTracks = tracks;
|
mTracks = tracks;
|
||||||
mZoomInfo = zoomInfo;
|
mZoomInfo = zoomInfo;
|
||||||
@ -57,10 +56,6 @@ SnapManager::SnapManager(TrackList *tracks,
|
|||||||
|
|
||||||
SnapManager::~SnapManager()
|
SnapManager::~SnapManager()
|
||||||
{
|
{
|
||||||
for (size_t i = 0, cnt = mSnapPoints.GetCount(); i < cnt; ++i)
|
|
||||||
{
|
|
||||||
delete mSnapPoints[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SnapManager::Reinit()
|
void SnapManager::Reinit()
|
||||||
@ -80,12 +75,7 @@ void SnapManager::Reinit()
|
|||||||
mRate = rate;
|
mRate = rate;
|
||||||
mFormat = format;
|
mFormat = format;
|
||||||
|
|
||||||
// Clear snap points
|
mSnapPoints.clear();
|
||||||
for (size_t i = 0, cnt = mSnapPoints.GetCount(); i < cnt; ++i)
|
|
||||||
{
|
|
||||||
delete mSnapPoints[i];
|
|
||||||
}
|
|
||||||
mSnapPoints.Clear();
|
|
||||||
|
|
||||||
// Grab time-snapping prefs (unless otherwise requested)
|
// Grab time-snapping prefs (unless otherwise requested)
|
||||||
mSnapToTime = false;
|
mSnapToTime = false;
|
||||||
@ -99,7 +89,7 @@ void SnapManager::Reinit()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add a SnapPoint at t=0
|
// Add a SnapPoint at t=0
|
||||||
mSnapPoints.Add(new SnapPoint(0.0, NULL));
|
mSnapPoints.push_back(SnapPoint{});
|
||||||
|
|
||||||
TrackListIterator iter(mTracks);
|
TrackListIterator iter(mTracks);
|
||||||
for (Track *track = iter.First(); track; track = iter.Next())
|
for (Track *track = iter.First(); track; track = iter.Next())
|
||||||
@ -162,6 +152,9 @@ void SnapManager::Reinit()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sort all by time
|
||||||
|
std::sort(mSnapPoints.begin(), mSnapPoints.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adds to mSnapPoints, filtering by TimeConverter
|
// Adds to mSnapPoints, filtering by TimeConverter
|
||||||
@ -174,14 +167,14 @@ void SnapManager::CondListAdd(double t, Track *track)
|
|||||||
|
|
||||||
if (!mSnapToTime || mConverter.GetValue() == t)
|
if (!mSnapToTime || mConverter.GetValue() == t)
|
||||||
{
|
{
|
||||||
mSnapPoints.Add(new SnapPoint(t, track));
|
mSnapPoints.push_back(SnapPoint{ t, track });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the time of the SnapPoint at a given index
|
// Return the time of the SnapPoint at a given index
|
||||||
double SnapManager::Get(size_t index)
|
double SnapManager::Get(size_t index)
|
||||||
{
|
{
|
||||||
return mSnapPoints[index]->t;
|
return mSnapPoints[index].t;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the difference in time between t and the point at a given index
|
// Returns the difference in time between t and the point at a given index
|
||||||
@ -213,7 +206,7 @@ size_t SnapManager::Find(double t, size_t i0, size_t i1)
|
|||||||
// Find the SnapPoint nearest to time t
|
// Find the SnapPoint nearest to time t
|
||||||
size_t SnapManager::Find(double t)
|
size_t SnapManager::Find(double t)
|
||||||
{
|
{
|
||||||
size_t cnt = mSnapPoints.GetCount();
|
size_t cnt = mSnapPoints.size();
|
||||||
size_t index = Find(t, 0, cnt);
|
size_t index = Find(t, 0, cnt);
|
||||||
|
|
||||||
// At this point, either index is the closest, or the next one
|
// At this point, either index is the closest, or the next one
|
||||||
@ -242,7 +235,7 @@ bool SnapManager::SnapToPoints(Track *currentTrack,
|
|||||||
{
|
{
|
||||||
*outT = t;
|
*outT = t;
|
||||||
|
|
||||||
size_t cnt = mSnapPoints.GetCount();
|
size_t cnt = mSnapPoints.size();
|
||||||
if (cnt == 0)
|
if (cnt == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -284,7 +277,7 @@ bool SnapManager::SnapToPoints(Track *currentTrack,
|
|||||||
size_t countInThisTrack = 0;
|
size_t countInThisTrack = 0;
|
||||||
for (i = left; i <= right; ++i)
|
for (i = left; i <= right; ++i)
|
||||||
{
|
{
|
||||||
if (mSnapPoints[i]->track == currentTrack)
|
if (mSnapPoints[i].track == currentTrack)
|
||||||
{
|
{
|
||||||
indexInThisTrack = i;
|
indexInThisTrack = i;
|
||||||
countInThisTrack++;
|
countInThisTrack++;
|
||||||
|
@ -57,16 +57,17 @@ const int kPixelTolerance = 4;
|
|||||||
class SnapPoint
|
class SnapPoint
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SnapPoint(double t, Track *track)
|
explicit
|
||||||
|
SnapPoint(double t_ = 0.0, Track *track_ = nullptr)
|
||||||
|
: t(t_), track(track_)
|
||||||
{
|
{
|
||||||
this->t = t;
|
|
||||||
this->track = track;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double t;
|
double t;
|
||||||
Track *track;
|
Track *track;
|
||||||
};
|
};
|
||||||
|
|
||||||
WX_DEFINE_SORTED_ARRAY(SnapPoint *, SnapPointArray);
|
using SnapPointArray = std::vector < SnapPoint > ;
|
||||||
|
|
||||||
class SnapManager
|
class SnapManager
|
||||||
{
|
{
|
||||||
|
@ -413,29 +413,12 @@ CommandManager::~CommandManager()
|
|||||||
|
|
||||||
void CommandManager::PurgeData()
|
void CommandManager::PurgeData()
|
||||||
{
|
{
|
||||||
// Delete callback functors BEFORE clearing mCommandList!
|
|
||||||
// These are the items created within 'FN()'
|
|
||||||
size_t i;
|
|
||||||
CommandFunctor * pCallback = NULL;
|
|
||||||
for(i=0; i<mCommandList.GetCount(); i++)
|
|
||||||
{
|
|
||||||
CommandListEntry *tmpEntry = mCommandList[i];
|
|
||||||
// JKC: We only want to DELETE each callbacks once.
|
|
||||||
// AddItemList() may have inserted the same callback
|
|
||||||
// several times over.
|
|
||||||
if( tmpEntry->callback != pCallback )
|
|
||||||
{
|
|
||||||
pCallback = tmpEntry->callback;
|
|
||||||
delete pCallback;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// mCommandList contains pointers to CommandListEntrys
|
// mCommandList contains pointers to CommandListEntrys
|
||||||
// mMenuBarList contains pointers to MenuBarListEntrys.
|
// mMenuBarList contains MenuBarListEntrys.
|
||||||
// mSubMenuList contains pointers to SubMenuListEntrys
|
// mSubMenuList contains SubMenuListEntrys
|
||||||
WX_CLEAR_ARRAY( mCommandList );
|
WX_CLEAR_ARRAY( mCommandList );
|
||||||
WX_CLEAR_ARRAY( mMenuBarList );
|
mMenuBarList.clear();
|
||||||
WX_CLEAR_ARRAY( mSubMenuList );
|
mSubMenuList.clear();
|
||||||
|
|
||||||
mCommandNameHash.clear();
|
mCommandNameHash.clear();
|
||||||
mCommandKeyHash.clear();
|
mCommandKeyHash.clear();
|
||||||
@ -458,14 +441,10 @@ wxMenuBar *CommandManager::AddMenuBar(const wxString & sMenu)
|
|||||||
if (menuBar)
|
if (menuBar)
|
||||||
return menuBar;
|
return menuBar;
|
||||||
|
|
||||||
MenuBarListEntry *tmpEntry = new MenuBarListEntry;
|
const auto result = new wxMenuBar{};
|
||||||
|
mMenuBarList.emplace_back(sMenu, result);
|
||||||
|
|
||||||
tmpEntry->menubar = new wxMenuBar();
|
return result;
|
||||||
tmpEntry->name = sMenu;
|
|
||||||
|
|
||||||
mMenuBarList.Add(tmpEntry);
|
|
||||||
|
|
||||||
return tmpEntry->menubar;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -474,10 +453,10 @@ wxMenuBar *CommandManager::AddMenuBar(const wxString & sMenu)
|
|||||||
///
|
///
|
||||||
wxMenuBar * CommandManager::GetMenuBar(const wxString & sMenu) const
|
wxMenuBar * CommandManager::GetMenuBar(const wxString & sMenu) const
|
||||||
{
|
{
|
||||||
for(unsigned int i = 0; i < mMenuBarList.GetCount(); i++)
|
for (const auto &entry : mMenuBarList)
|
||||||
{
|
{
|
||||||
if(!mMenuBarList[i]->name.Cmp(sMenu))
|
if(!entry.name.Cmp(sMenu))
|
||||||
return mMenuBarList[i]->menubar;
|
return entry.menubar;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -489,10 +468,10 @@ wxMenuBar * CommandManager::GetMenuBar(const wxString & sMenu) const
|
|||||||
/// last on in the mMenuBarList.
|
/// last on in the mMenuBarList.
|
||||||
wxMenuBar * CommandManager::CurrentMenuBar() const
|
wxMenuBar * CommandManager::CurrentMenuBar() const
|
||||||
{
|
{
|
||||||
if(mMenuBarList.IsEmpty())
|
if(mMenuBarList.empty())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return mMenuBarList[mMenuBarList.GetCount()-1]->menubar;
|
return mMenuBarList.back().menubar;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -527,15 +506,10 @@ void CommandManager::EndMenu()
|
|||||||
/// the function's argument.
|
/// the function's argument.
|
||||||
wxMenu* CommandManager::BeginSubMenu(const wxString & tName)
|
wxMenu* CommandManager::BeginSubMenu(const wxString & tName)
|
||||||
{
|
{
|
||||||
SubMenuListEntry *tmpEntry = new SubMenuListEntry;
|
const auto result = new wxMenu{};
|
||||||
|
mSubMenuList.emplace_back(tName, result);
|
||||||
tmpEntry->menu = new wxMenu();
|
|
||||||
tmpEntry->name = tName;
|
|
||||||
|
|
||||||
mSubMenuList.Add(tmpEntry);
|
|
||||||
mbSeparatorAllowed = false;
|
mbSeparatorAllowed = false;
|
||||||
|
return result;
|
||||||
return(tmpEntry->menu);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -545,19 +519,15 @@ wxMenu* CommandManager::BeginSubMenu(const wxString & tName)
|
|||||||
/// after BeginSubMenu() is called but before EndSubMenu() is called.
|
/// after BeginSubMenu() is called but before EndSubMenu() is called.
|
||||||
void CommandManager::EndSubMenu()
|
void CommandManager::EndSubMenu()
|
||||||
{
|
{
|
||||||
size_t submenu_count = mSubMenuList.GetCount()-1;
|
|
||||||
|
|
||||||
//Save the submenu's information
|
//Save the submenu's information
|
||||||
SubMenuListEntry *tmpSubMenu = mSubMenuList[submenu_count];
|
SubMenuListEntry tmpSubMenu = mSubMenuList.back();
|
||||||
|
|
||||||
//Pop off the NEW submenu so CurrentMenu returns the parent of the submenu
|
//Pop off the NEW submenu so CurrentMenu returns the parent of the submenu
|
||||||
mSubMenuList.RemoveAt(submenu_count);
|
mSubMenuList.pop_back();
|
||||||
|
|
||||||
//Add the submenu to the current menu
|
//Add the submenu to the current menu
|
||||||
CurrentMenu()->Append(0, tmpSubMenu->name, tmpSubMenu->menu, tmpSubMenu->name);
|
CurrentMenu()->Append(0, tmpSubMenu.name, tmpSubMenu.menu, tmpSubMenu.name);
|
||||||
mbSeparatorAllowed = true;
|
mbSeparatorAllowed = true;
|
||||||
|
|
||||||
delete tmpSubMenu;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -566,10 +536,10 @@ void CommandManager::EndSubMenu()
|
|||||||
/// end of the mSubMenuList (or NULL, if it doesn't exist).
|
/// end of the mSubMenuList (or NULL, if it doesn't exist).
|
||||||
wxMenu * CommandManager::CurrentSubMenu() const
|
wxMenu * CommandManager::CurrentSubMenu() const
|
||||||
{
|
{
|
||||||
if(mSubMenuList.IsEmpty())
|
if(mSubMenuList.empty())
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return mSubMenuList[mSubMenuList.GetCount()-1]->menu;
|
return mSubMenuList.back().menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -596,7 +566,7 @@ wxMenu * CommandManager::CurrentMenu() const
|
|||||||
/// given functor will be called
|
/// given functor will be called
|
||||||
void CommandManager::InsertItem(const wxString & name,
|
void CommandManager::InsertItem(const wxString & name,
|
||||||
const wxString & label_in,
|
const wxString & label_in,
|
||||||
CommandFunctor *callback,
|
const CommandFunctorPointer &callback,
|
||||||
const wxString & after,
|
const wxString & after,
|
||||||
int checkmark)
|
int checkmark)
|
||||||
{
|
{
|
||||||
@ -665,7 +635,7 @@ void CommandManager::InsertItem(const wxString & name,
|
|||||||
|
|
||||||
void CommandManager::AddCheck(const wxChar *name,
|
void CommandManager::AddCheck(const wxChar *name,
|
||||||
const wxChar *label,
|
const wxChar *label,
|
||||||
CommandFunctor *callback,
|
const CommandFunctorPointer &callback,
|
||||||
int checkmark)
|
int checkmark)
|
||||||
{
|
{
|
||||||
AddItem(name, label, callback, wxT(""), (unsigned int)NoFlagsSpecifed, (unsigned int)NoFlagsSpecifed, checkmark);
|
AddItem(name, label, callback, wxT(""), (unsigned int)NoFlagsSpecifed, (unsigned int)NoFlagsSpecifed, checkmark);
|
||||||
@ -673,7 +643,7 @@ void CommandManager::AddCheck(const wxChar *name,
|
|||||||
|
|
||||||
void CommandManager::AddCheck(const wxChar *name,
|
void CommandManager::AddCheck(const wxChar *name,
|
||||||
const wxChar *label,
|
const wxChar *label,
|
||||||
CommandFunctor *callback,
|
const CommandFunctorPointer &callback,
|
||||||
int checkmark,
|
int checkmark,
|
||||||
unsigned int flags,
|
unsigned int flags,
|
||||||
unsigned int mask)
|
unsigned int mask)
|
||||||
@ -683,7 +653,7 @@ void CommandManager::AddCheck(const wxChar *name,
|
|||||||
|
|
||||||
void CommandManager::AddItem(const wxChar *name,
|
void CommandManager::AddItem(const wxChar *name,
|
||||||
const wxChar *label,
|
const wxChar *label,
|
||||||
CommandFunctor *callback,
|
const CommandFunctorPointer &callback,
|
||||||
unsigned int flags,
|
unsigned int flags,
|
||||||
unsigned int mask)
|
unsigned int mask)
|
||||||
{
|
{
|
||||||
@ -692,7 +662,7 @@ void CommandManager::AddItem(const wxChar *name,
|
|||||||
|
|
||||||
void CommandManager::AddItem(const wxChar *name,
|
void CommandManager::AddItem(const wxChar *name,
|
||||||
const wxChar *label_in,
|
const wxChar *label_in,
|
||||||
CommandFunctor *callback,
|
const CommandFunctorPointer &callback,
|
||||||
const wxChar *accel,
|
const wxChar *accel,
|
||||||
unsigned int flags,
|
unsigned int flags,
|
||||||
unsigned int mask,
|
unsigned int mask,
|
||||||
@ -726,7 +696,7 @@ void CommandManager::AddItem(const wxChar *name,
|
|||||||
/// all of the items at once.
|
/// all of the items at once.
|
||||||
void CommandManager::AddItemList(const wxString & name,
|
void CommandManager::AddItemList(const wxString & name,
|
||||||
const wxArrayString & labels,
|
const wxArrayString & labels,
|
||||||
CommandFunctor *callback)
|
const CommandFunctorPointer &callback)
|
||||||
{
|
{
|
||||||
for (size_t i = 0, cnt = labels.GetCount(); i < cnt; i++) {
|
for (size_t i = 0, cnt = labels.GetCount(); i < cnt; i++) {
|
||||||
CommandListEntry *entry = NewIdentifier(name,
|
CommandListEntry *entry = NewIdentifier(name,
|
||||||
@ -746,7 +716,7 @@ void CommandManager::AddItemList(const wxString & name,
|
|||||||
/// given function pointer will be called (via the CommandManagerListener)
|
/// given function pointer will be called (via the CommandManagerListener)
|
||||||
void CommandManager::AddCommand(const wxChar *name,
|
void CommandManager::AddCommand(const wxChar *name,
|
||||||
const wxChar *label,
|
const wxChar *label,
|
||||||
CommandFunctor *callback,
|
const CommandFunctorPointer &callback,
|
||||||
unsigned int flags,
|
unsigned int flags,
|
||||||
unsigned int mask)
|
unsigned int mask)
|
||||||
{
|
{
|
||||||
@ -755,7 +725,7 @@ void CommandManager::AddCommand(const wxChar *name,
|
|||||||
|
|
||||||
void CommandManager::AddCommand(const wxChar *name,
|
void CommandManager::AddCommand(const wxChar *name,
|
||||||
const wxChar *label_in,
|
const wxChar *label_in,
|
||||||
CommandFunctor *callback,
|
const CommandFunctorPointer &callback,
|
||||||
const wxChar *accel,
|
const wxChar *accel,
|
||||||
unsigned int flags,
|
unsigned int flags,
|
||||||
unsigned int mask)
|
unsigned int mask)
|
||||||
@ -769,7 +739,7 @@ void CommandManager::AddCommand(const wxChar *name,
|
|||||||
|
|
||||||
void CommandManager::AddGlobalCommand(const wxChar *name,
|
void CommandManager::AddGlobalCommand(const wxChar *name,
|
||||||
const wxChar *label_in,
|
const wxChar *label_in,
|
||||||
CommandFunctor *callback,
|
const CommandFunctorPointer &callback,
|
||||||
const wxChar *accel)
|
const wxChar *accel)
|
||||||
{
|
{
|
||||||
CommandListEntry *entry = NewIdentifier(name, label_in, accel, NULL, callback, false, 0, 0);
|
CommandListEntry *entry = NewIdentifier(name, label_in, accel, NULL, callback, false, 0, 0);
|
||||||
@ -806,7 +776,7 @@ int CommandManager::NextIdentifier(int ID)
|
|||||||
CommandListEntry *CommandManager::NewIdentifier(const wxString & name,
|
CommandListEntry *CommandManager::NewIdentifier(const wxString & name,
|
||||||
const wxString & label,
|
const wxString & label,
|
||||||
wxMenu *menu,
|
wxMenu *menu,
|
||||||
CommandFunctor *callback,
|
const CommandFunctorPointer &callback,
|
||||||
bool multi,
|
bool multi,
|
||||||
int index,
|
int index,
|
||||||
int count)
|
int count)
|
||||||
@ -825,7 +795,7 @@ CommandListEntry *CommandManager::NewIdentifier(const wxString & name,
|
|||||||
const wxString & label,
|
const wxString & label,
|
||||||
const wxString & accel,
|
const wxString & accel,
|
||||||
wxMenu *menu,
|
wxMenu *menu,
|
||||||
CommandFunctor *callback,
|
const CommandFunctorPointer &callback,
|
||||||
bool multi,
|
bool multi,
|
||||||
int index,
|
int index,
|
||||||
int count)
|
int count)
|
||||||
@ -833,8 +803,8 @@ CommandListEntry *CommandManager::NewIdentifier(const wxString & name,
|
|||||||
CommandListEntry *entry = new CommandListEntry;
|
CommandListEntry *entry = new CommandListEntry;
|
||||||
|
|
||||||
wxString labelPrefix;
|
wxString labelPrefix;
|
||||||
if (!mSubMenuList.IsEmpty()) {
|
if (!mSubMenuList.empty()) {
|
||||||
labelPrefix = mSubMenuList[mSubMenuList.GetCount() - 1]->name;
|
labelPrefix = mSubMenuList.back().name;
|
||||||
}
|
}
|
||||||
|
|
||||||
// wxMac 2.5 and higher will do special things with the
|
// wxMac 2.5 and higher will do special things with the
|
||||||
|
@ -34,16 +34,26 @@ public:
|
|||||||
|
|
||||||
struct MenuBarListEntry
|
struct MenuBarListEntry
|
||||||
{
|
{
|
||||||
|
MenuBarListEntry(const wxString &name_, wxMenuBar *menubar_)
|
||||||
|
: name(name_), menubar(menubar_)
|
||||||
|
{}
|
||||||
|
|
||||||
wxString name;
|
wxString name;
|
||||||
wxMenuBar *menubar;
|
wxMenuBar *menubar;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SubMenuListEntry
|
struct SubMenuListEntry
|
||||||
{
|
{
|
||||||
|
SubMenuListEntry(const wxString &name_, wxMenu *menu_)
|
||||||
|
: name(name_), menu(menu_)
|
||||||
|
{}
|
||||||
|
|
||||||
wxString name;
|
wxString name;
|
||||||
wxMenu *menu;
|
wxMenu *menu;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
using CommandFunctorPointer = std::shared_ptr <CommandFunctor>;
|
||||||
|
|
||||||
struct CommandListEntry
|
struct CommandListEntry
|
||||||
{
|
{
|
||||||
int id;
|
int id;
|
||||||
@ -54,7 +64,7 @@ struct CommandListEntry
|
|||||||
wxString labelPrefix;
|
wxString labelPrefix;
|
||||||
wxString labelTop;
|
wxString labelTop;
|
||||||
wxMenu *menu;
|
wxMenu *menu;
|
||||||
CommandFunctor *callback;
|
CommandFunctorPointer callback;
|
||||||
bool multi;
|
bool multi;
|
||||||
int index;
|
int index;
|
||||||
int count;
|
int count;
|
||||||
@ -66,8 +76,8 @@ struct CommandListEntry
|
|||||||
wxUint32 mask;
|
wxUint32 mask;
|
||||||
};
|
};
|
||||||
|
|
||||||
WX_DEFINE_USER_EXPORTED_ARRAY(MenuBarListEntry *, MenuBarList, class AUDACITY_DLL_API);
|
using MenuBarList = std::vector < MenuBarListEntry >;
|
||||||
WX_DEFINE_USER_EXPORTED_ARRAY(SubMenuListEntry *, SubMenuList, class AUDACITY_DLL_API);
|
using SubMenuList = std::vector < SubMenuListEntry >;
|
||||||
WX_DEFINE_USER_EXPORTED_ARRAY(CommandListEntry *, CommandList, class AUDACITY_DLL_API);
|
WX_DEFINE_USER_EXPORTED_ARRAY(CommandListEntry *, CommandList, class AUDACITY_DLL_API);
|
||||||
|
|
||||||
WX_DECLARE_STRING_HASH_MAP_WITH_DECL(CommandListEntry *, CommandNameHash, class AUDACITY_DLL_API);
|
WX_DECLARE_STRING_HASH_MAP_WITH_DECL(CommandListEntry *, CommandNameHash, class AUDACITY_DLL_API);
|
||||||
@ -105,35 +115,35 @@ class AUDACITY_DLL_API CommandManager: public XMLTagHandler
|
|||||||
|
|
||||||
void InsertItem(const wxString & name,
|
void InsertItem(const wxString & name,
|
||||||
const wxString & label,
|
const wxString & label,
|
||||||
CommandFunctor *callback,
|
const CommandFunctorPointer &callback,
|
||||||
const wxString & after,
|
const wxString & after,
|
||||||
int checkmark = -1);
|
int checkmark = -1);
|
||||||
|
|
||||||
void AddItemList(const wxString & name,
|
void AddItemList(const wxString & name,
|
||||||
const wxArrayString & labels,
|
const wxArrayString & labels,
|
||||||
CommandFunctor *callback);
|
const CommandFunctorPointer &callback);
|
||||||
|
|
||||||
void AddCheck(const wxChar *name,
|
void AddCheck(const wxChar *name,
|
||||||
const wxChar *label,
|
const wxChar *label,
|
||||||
CommandFunctor *callback,
|
const CommandFunctorPointer &callback,
|
||||||
int checkmark = 0);
|
int checkmark = 0);
|
||||||
|
|
||||||
void AddCheck(const wxChar *name,
|
void AddCheck(const wxChar *name,
|
||||||
const wxChar *label,
|
const wxChar *label,
|
||||||
CommandFunctor *callback,
|
const CommandFunctorPointer &callback,
|
||||||
int checkmark,
|
int checkmark,
|
||||||
unsigned int flags,
|
unsigned int flags,
|
||||||
unsigned int mask);
|
unsigned int mask);
|
||||||
|
|
||||||
void AddItem(const wxChar *name,
|
void AddItem(const wxChar *name,
|
||||||
const wxChar *label,
|
const wxChar *label,
|
||||||
CommandFunctor *callback,
|
const CommandFunctorPointer &callback,
|
||||||
unsigned int flags = NoFlagsSpecifed,
|
unsigned int flags = NoFlagsSpecifed,
|
||||||
unsigned int mask = NoFlagsSpecifed);
|
unsigned int mask = NoFlagsSpecifed);
|
||||||
|
|
||||||
void AddItem(const wxChar *name,
|
void AddItem(const wxChar *name,
|
||||||
const wxChar *label_in,
|
const wxChar *label_in,
|
||||||
CommandFunctor *callback,
|
const CommandFunctorPointer &callback,
|
||||||
const wxChar *accel,
|
const wxChar *accel,
|
||||||
unsigned int flags = NoFlagsSpecifed,
|
unsigned int flags = NoFlagsSpecifed,
|
||||||
unsigned int mask = NoFlagsSpecifed,
|
unsigned int mask = NoFlagsSpecifed,
|
||||||
@ -145,20 +155,20 @@ class AUDACITY_DLL_API CommandManager: public XMLTagHandler
|
|||||||
// keyboard shortcut.
|
// keyboard shortcut.
|
||||||
void AddCommand(const wxChar *name,
|
void AddCommand(const wxChar *name,
|
||||||
const wxChar *label,
|
const wxChar *label,
|
||||||
CommandFunctor *callback,
|
const CommandFunctorPointer &callback,
|
||||||
unsigned int flags = NoFlagsSpecifed,
|
unsigned int flags = NoFlagsSpecifed,
|
||||||
unsigned int mask = NoFlagsSpecifed);
|
unsigned int mask = NoFlagsSpecifed);
|
||||||
|
|
||||||
void AddCommand(const wxChar *name,
|
void AddCommand(const wxChar *name,
|
||||||
const wxChar *label,
|
const wxChar *label,
|
||||||
CommandFunctor *callback,
|
const CommandFunctorPointer &callback,
|
||||||
const wxChar *accel,
|
const wxChar *accel,
|
||||||
unsigned int flags = NoFlagsSpecifed,
|
unsigned int flags = NoFlagsSpecifed,
|
||||||
unsigned int mask = NoFlagsSpecifed);
|
unsigned int mask = NoFlagsSpecifed);
|
||||||
|
|
||||||
void AddGlobalCommand(const wxChar *name,
|
void AddGlobalCommand(const wxChar *name,
|
||||||
const wxChar *label,
|
const wxChar *label,
|
||||||
CommandFunctor *callback,
|
const CommandFunctorPointer &callback,
|
||||||
const wxChar *accel);
|
const wxChar *accel);
|
||||||
//
|
//
|
||||||
// Command masks
|
// Command masks
|
||||||
@ -242,7 +252,7 @@ protected:
|
|||||||
CommandListEntry *NewIdentifier(const wxString & name,
|
CommandListEntry *NewIdentifier(const wxString & name,
|
||||||
const wxString & label,
|
const wxString & label,
|
||||||
wxMenu *menu,
|
wxMenu *menu,
|
||||||
CommandFunctor *callback,
|
const CommandFunctorPointer &callback,
|
||||||
bool multi,
|
bool multi,
|
||||||
int index,
|
int index,
|
||||||
int count);
|
int count);
|
||||||
@ -250,7 +260,7 @@ protected:
|
|||||||
const wxString & label,
|
const wxString & label,
|
||||||
const wxString & accel,
|
const wxString & accel,
|
||||||
wxMenu *menu,
|
wxMenu *menu,
|
||||||
CommandFunctor *callback,
|
const CommandFunctorPointer &callback,
|
||||||
bool multi,
|
bool multi,
|
||||||
int index,
|
int index,
|
||||||
int count);
|
int count);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user