Skip to content

Commit

Permalink
CommandManager can move to toolkit-neutral libraries!
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-Licameli committed Nov 10, 2023
1 parent 0c8db49 commit 2b49b0e
Show file tree
Hide file tree
Showing 34 changed files with 43 additions and 44 deletions.
11 changes: 7 additions & 4 deletions libraries/lib-menus/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
Vocabulary to describe toolbar menu items, their grouping, conditions to enable
them, and their actions.
A global registry of menu descriptions and a visitor function.
A global MenuRegistry of menu descriptions and a visitor function.
It does not contain a visitor to build menus, becuase that is not
toolkit-neutral.
A per-project CommandManager with a nested Populator type that visits the
registry, and can build menus, if a subclass overrides certain virtual functions
appropriately for the UI toolkit.
]]

set(SOURCES
Expand All @@ -14,6 +15,8 @@ set(SOURCES
CommandFlag.cpp
CommandFlag.h
CommandFunctors.h
CommandManager.cpp
CommandManager.h
CommandTargets.cpp
CommandTargets.h
Keyboard.cpp
Expand All @@ -23,7 +26,7 @@ set(SOURCES
)

set( LIBRARIES
lib-project-interface
lib-project-history-interface
)

audacity_library(lib-menus "${SOURCES}" "${LIBRARIES}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ CommandManager. It holds the callback for one command.
#include "BasicUI.h"
#include "Project.h"
#include "ProjectHistory.h"
#include "AudacityMessageBox.h"
#include "HelpSystem.h"
#include "UndoManager.h"

#include <cassert>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class CommandContext;
//! Sent when menus update (such as for changing enablement of items)
struct MenuUpdateMessage {};

class AUDACITY_DLL_API CommandManager /* not final */
class MENUS_API CommandManager /* not final */
: public XMLTagHandler
, public ClientData::Base
, public Observer::Publisher<MenuUpdateMessage>
Expand All @@ -67,7 +67,7 @@ class AUDACITY_DLL_API CommandManager /* not final */

// Interception of menu item handling.
// If it returns true, bypass the usual dispatch of commands.
struct AUDACITY_DLL_API GlobalMenuHook : GlobalHook<GlobalMenuHook,
struct MENUS_API GlobalMenuHook : GlobalHook<GlobalMenuHook,
bool(const CommandID&)
>{};

Expand Down Expand Up @@ -119,7 +119,7 @@ class AUDACITY_DLL_API CommandManager /* not final */

void PurgeData();

struct AUDACITY_DLL_API Populator
struct MENUS_API Populator
: MenuRegistry::Visitor<MenuRegistry::Traits>
{
using LeafVisitor = std::function<
Expand Down Expand Up @@ -373,7 +373,7 @@ class AUDACITY_DLL_API CommandManager /* not final */
AudacityProject &mProject;

public:
struct CommandListEntry
struct MENUS_API CommandListEntry
{
static wxString FormatLabelForMenu(
const TranslatableString &translatableLabel,
Expand Down
2 changes: 1 addition & 1 deletion modules/mod-nyq-bench/NyqBench.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include <ostream>
#include <sstream>

#include "commands/CommandManager.h"
#include "CommandManager.h"
#include "effects/nyquist/Nyquist.h"

class wxFileName;
Expand Down
2 changes: 1 addition & 1 deletion src/BatchCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ processing. See also MacrosWindow and ApplyMacroDialog.

#include "CommandContext.h"
#include "commands/CommandDispatch.h"
#include "commands/CommandManager.h"
#include "CommandManager.h"

MacroCommands::MacroCommands( AudacityProject &project )
: mProject{ project }
Expand Down
2 changes: 1 addition & 1 deletion src/BatchProcessDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#include "ProjectWindow.h"
#include "SelectUtilities.h"
#include "Track.h"
#include "commands/CommandManager.h"
#include "CommandManager.h"
#include "Effect.h"
#include "effects/EffectUI.h"
#include "../images/Arrow.xpm"
Expand Down
2 changes: 0 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -258,8 +258,6 @@ list( APPEND SOURCES
commands/CommandDispatch.h
commands/CommandHandler.cpp
commands/CommandHandler.h
commands/CommandManager.cpp
commands/CommandManager.h
commands/CommandManagerWindowClasses.cpp
commands/CommandManagerWindowClasses.h
commands/CommandMisc.h
Expand Down
2 changes: 1 addition & 1 deletion src/FreqWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,7 @@ void FreqPlot::OnMouseEvent(wxMouseEvent & event)

// Remaining code hooks this add-on into the application
#include "CommandContext.h"
#include "commands/CommandManager.h"
#include "CommandManager.h"
#include "ProjectWindows.h"

namespace {
Expand Down
2 changes: 1 addition & 1 deletion src/MenuCreator.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define __AUDACITY_MENU_CREATOR__

#include "Callable.h"
#include "commands/CommandManager.h"
#include "CommandManager.h"

class AUDACITY_DLL_API MenuCreator final : public CommandManager
{
Expand Down
2 changes: 1 addition & 1 deletion src/ProjectAudioManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Paul Licameli split from ProjectManager.cpp

#include "AudioIO.h"
#include "BasicUI.h"
#include "commands/CommandManager.h"
#include "CommandManager.h"
#include "CommonCommandFlags.h"
#include "DefaultPlaybackPolicy.h"
#include "Meter.h"
Expand Down
2 changes: 1 addition & 1 deletion src/ProjectWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Paul Licameli split from AudacityProject.cpp
#include "WaveClip.h"
#include "WaveTrack.h"
#include "CommandContext.h"
#include "commands/CommandManager.h"
#include "CommandManager.h"
#include "prefs/ThemePrefs.h"
#include "prefs/TracksPrefs.h"
#include "toolbars/ToolManager.h"
Expand Down
2 changes: 1 addition & 1 deletion src/Screenshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ void ScreenshotBigDialog::UpdatePrefs()
}

#include "CommonCommandFlags.h"
#include "commands/CommandManager.h"
#include "CommandManager.h"

namespace {
void OnScreenshot(const CommandContext &context )
Expand Down
2 changes: 1 addition & 1 deletion src/SelectUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#include "ViewInfo.h"
#include "WaveTrack.h"

#include "commands/CommandManager.h"
#include "CommandManager.h"

namespace {

Expand Down
2 changes: 1 addition & 1 deletion src/SpectralDataDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
#include "ClientData.h"
#include "Clipboard.h"
#include "CommandContext.h"
#include "commands/CommandManager.h"
#include "CommandManager.h"
#include "UndoManager.h"
#include "Prefs.h"
#include "Project.h"
Expand Down
2 changes: 1 addition & 1 deletion src/commands/ScreenshotCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ small calculations of rectangles.
#include "Track.h"
#include "../widgets/VetoDialogHook.h"
#include "CommandContext.h"
#include "commands/CommandManager.h"
#include "CommandManager.h"
#include "CommandDispatch.h"
#include "../CommonCommandFlags.h"

Expand Down
2 changes: 1 addition & 1 deletion src/effects/Contrast.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ void ContrastDialog::OnReset(wxCommandEvent & /*event*/)

// Remaining code hooks this add-on into the application
#include "CommandContext.h"
#include "commands/CommandManager.h"
#include "CommandManager.h"
#include "ProjectWindows.h"

namespace {
Expand Down
4 changes: 2 additions & 2 deletions src/effects/EffectUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "AllThemeResources.h"
#include "widgets/BasicMenu.h"
#include "BasicUI.h"
#include "../commands/CommandManager.h"
#include "CommandManager.h"
#include "ConfigInterface.h"
#include "EffectManager.h"
#include "PluginManager.h"
Expand Down Expand Up @@ -1135,7 +1135,7 @@ DialogFactoryResults EffectUI::DialogFactory(wxWindow &parent,
#include "../SelectUtilities.h"
#include "../TrackPanel.h"
#include "WaveTrack.h"
#include "../commands/CommandManager.h"
#include "CommandManager.h"

/// DoEffect() takes a PluginID and executes the associated effect.
///
Expand Down
2 changes: 1 addition & 1 deletion src/menus/PluginMenus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "TempDirectory.h"
#include "UndoManager.h"
#include "CommandContext.h"
#include "../commands/CommandManager.h"
#include "CommandManager.h"
#include "../effects/EffectManager.h"
#include "../effects/EffectUI.h"
#include "RealtimeEffectManager.h"
Expand Down
2 changes: 1 addition & 1 deletion src/menus/TimelineMenus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

#include "Project.h"

#include "../commands/CommandManager.h"
#include "CommandManager.h"
#include "CommandContext.h"

namespace
Expand Down
2 changes: 1 addition & 1 deletion src/menus/ViewMenus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "UndoManager.h"
#include "ViewInfo.h"
#include "CommandContext.h"
#include "../commands/CommandManager.h"
#include "CommandManager.h"
#include "../prefs/GUIPrefs.h"
#include "../prefs/TracksPrefs.h"
#include "../tracks/ui/ChannelView.h"
Expand Down
2 changes: 1 addition & 1 deletion src/prefs/PrefsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "Prefs.h"
#include "ProjectWindows.h"
#include "ShuttleGui.h"
#include "../commands/CommandManager.h"
#include "CommandManager.h"

#include "PrefsPanel.h"

Expand Down
2 changes: 1 addition & 1 deletion src/toolbars/CutCopyPasteToolBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#include "../widgets/AButton.h"

#include "CommandContext.h"
#include "../commands/CommandManager.h"
#include "CommandManager.h"
#include "../commands/CommandDispatch.h"

#include "ToolManager.h"
Expand Down
2 changes: 1 addition & 1 deletion src/toolbars/EditToolBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
#include "../widgets/AButton.h"

#include "CommandContext.h"
#include "../commands/CommandManager.h"
#include "CommandManager.h"
#include "../commands/CommandDispatch.h"

enum {
Expand Down
2 changes: 1 addition & 1 deletion src/toolbars/ToolBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ in which buttons can be placed.
#include "AColor.h"
#include "ImageManipulation.h"
#include "Project.h"
#include "../commands/CommandManager.h"
#include "CommandManager.h"
#include "../widgets/AButton.h"
#include "../widgets/Grabber.h"
#include "Prefs.h"
Expand Down
2 changes: 1 addition & 1 deletion src/toolbars/ToolBarButtons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "Project.h"

#include "CommandContext.h"
#include "../commands/CommandManager.h"
#include "CommandManager.h"
#include "../commands/CommandDispatch.h"

// flags so 1,2,4,8 etc.
Expand Down
4 changes: 2 additions & 2 deletions src/toolbars/ToolManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

#include "AColor.h"
#include "AllThemeResources.h"
#include "commands/CommandManager.h"
#include "CommandManager.h"
#include "ImageManipulation.h"
#include "Prefs.h"
#include "Project.h"
Expand Down Expand Up @@ -1538,7 +1538,7 @@ void ToolManager::ModifyAllProjectToolbarMenus()
}
}

#include "../commands/CommandManager.h"
#include "CommandManager.h"
void ToolManager::ModifyToolbarMenus(AudacityProject &project)
{
// Refreshes can occur during shutdown and the toolmanager may already
Expand Down
2 changes: 1 addition & 1 deletion src/tracks/playabletrack/ui/PlayableTrackButtonHandles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Paul Licameli split from TrackPanel.cpp
#include "PlayableTrackButtonHandles.h"
#include "PlayableTrack.h"
#include "PlayableTrackControls.h"
#include "../../../commands/CommandManager.h"
#include "CommandManager.h"
#include "Project.h"
#include "../../../RefreshCode.h"
#include "../../../RealtimeEffectPanel.h"
Expand Down
2 changes: 1 addition & 1 deletion src/tracks/ui/CommonTrackControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Paul Licameli split from TrackControls.cpp
#include "../../TrackUtilities.h"
#include <wx/textdlg.h>
#include "../../commands/AudacityCommand.h"
#include "../../commands/CommandManager.h"
#include "CommandManager.h"
#include "ShuttleGui.h"
#include "Track.h"
#include "../../widgets/PopupMenuTable.h"
Expand Down
2 changes: 1 addition & 1 deletion src/tracks/ui/CommonTrackPanelCell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Paul Licameli split from TrackPanel.cpp
#include "../../widgets/BasicMenu.h"
#include "BasicUI.h"
#include "CommandContext.h"
#include "../../commands/CommandManager.h"
#include "CommandManager.h"
#include "../../HitTestResult.h"
#include "../../RefreshCode.h"
#include "../../TrackPanelMouseEvent.h"
Expand Down
2 changes: 1 addition & 1 deletion src/tracks/ui/Scrubbing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Paul Licameli split from TrackPanel.cpp
#include <functional>

#include "AudioIO.h"
#include "commands/CommandManager.h"
#include "CommandManager.h"
#include "../../CommonCommandFlags.h"
#include "Project.h"
#include "ProjectAudioIO.h"
Expand Down
2 changes: 1 addition & 1 deletion src/tracks/ui/SelectHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Paul Licameli split from TrackPanel.cpp
#include "ChannelView.h"

#include "AColor.h"
#include "commands/CommandManager.h"
#include "CommandManager.h"
#include "../../SpectrumAnalyst.h"
#include "../../LabelTrack.h"
#include "NumberScale.h"
Expand Down
2 changes: 1 addition & 1 deletion src/tracks/ui/TrackButtonHandles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Paul Licameli split from TrackPanel.cpp
#include "../../TrackInfo.h"
#include "../../TrackPanel.h"
#include "../../TrackUtilities.h"
#include "../../commands/CommandManager.h"
#include "CommandManager.h"
#include "../../tracks/ui/ChannelView.h"

MinimizeButtonHandle::MinimizeButtonHandle
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/KeyView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

#include "AColor.h"
#include "ShuttleGui.h"
#include "../commands/CommandManager.h"
#include "CommandManager.h"

#include <wx/dc.h>
#include <wx/menu.h>
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/PopupMenuTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class wxCommandEvent;
#include <memory>

#include "Internat.h"
#include "../commands/CommandManager.h"
#include "CommandManager.h"

class PopupMenuHandler;
struct PopupMenuSection;
Expand Down

0 comments on commit 2b49b0e

Please sign in to comment.