Commit Graph

167 Commits

Author SHA1 Message Date
Paul Licameli
7e697d1d8f Replace many inclusions of Types.h with Identifier.h 2021-05-27 09:51:32 -04:00
Paul Licameli
5fef82dccf Define Setting classes, bundling config path with settings value...
... the intention being, that no string literal for a path, or its default
value, shall ever occur twice in the code, relying on long-distance coincidence
of literal values.  Instead, a named Setting object is constructed once, then
read and written.

For now, the Tie... functions in ShuttleGuiBase will take references to
implicitly constructed temporary Setting objects.  But all should later be
made static objects, and the constructors made explicit.
2021-05-17 08:46:08 -04:00
Paul Licameli
406b23cae7 More uses of AUDACITY_DLL_API...
... in many places where the function call will later need to be between
modules (or libraries, or the executable) and the annotation will be a necessity
to keep the linkage working on Windows.

That's all that this sweeping commit does.
2021-05-10 10:46:55 -04:00
Paul Licameli
e653b4aaf8 Eliminate Experimental.h, configure compile options instead...
... This makes it impossible to forget to include the EXPERIMENTAL definitions
(such as when cutting and pasting code) and so get unintended quiet changes of
behavior.

The EXPERIMENTAL flags are now specified instead in new file Experimental.cmake
2021-04-27 12:40:07 -04:00
JohnColket
a3d9f41fb4
Bug 2582 - Enh: Repeat last Process, Part 2 (#734) 2021-02-03 11:02:49 +00:00
luzpaz
7a3bdcf3f2
Fix typos (user facing and non-user facing) (#727)
Found via `codespell v2.1.dev0`  
`codespell -q 3 -S *.po,./lib-src -L parm,parms,toke`
2021-01-24 09:46:08 +00:00
Paul Licameli
4a271ba549 Move namespace Registry into new source files 2020-05-28 05:45:11 -04:00
Paul Licameli
3313b33050 Move helper structure definitions out of CommandManager.h...
... and remove an indirection in handling one of them
2020-05-26 09:49:22 -04:00
Paul Licameli
2c8c5799f6 Correct menu ordering after "Reset Configuration" command, see f5afb28 2020-05-25 14:24:14 -04:00
Paul Licameli
8ce72748bf CommandManager stores only stripped menu names (no & characters)...
... Keyboard preference dialog does not need to repeat the stripping
2020-05-23 22:42:21 -04:00
Paul Licameli
1ef29b7a51 Don't encode command options as part of accelerator string...
... also restore the intended meaning of "allowDup" (for debugging checks only),
which had never been properly implemented because the label, not the
accelerator, was scanned for it; see commit f2f7568
2020-05-23 22:41:35 -04:00
Paul Licameli
d373e27840 Remove some unused forward declarations and #include directives 2020-05-23 05:32:01 -04:00
Leland Lucius
1ca911ed38 Convert all __WXDEBUG__ tests to use new _DEBUG symbol
This symbol is based on the NDEBUG symbol that's automatically
defined by CMake.
2020-04-25 02:36:27 -05:00
Yuri Chornoivan
d1ada5f08c Fix minor typos 2020-04-11 10:06:24 +01:00
Paul Licameli
0bbc974a7b Fix Windows build warning 2020-02-21 14:19:01 -05:00
David Bailes
b67c82171c Bug 2329 - Keyboard shortcuts: new or changed defaults can create duplicates
Problem:
If a new version of Audacity introduces a new default shortcut, or changes an existing one, then this may be the same shortcut as a user has previously assigned to another command. Both commands will have the same shortcut, and the shortcut will only execute one of those commands.

Fix:
Check for any such duplicates when a user opens a version of audacity using an audacity.cfg file which was created with a different version.
For each duplicate found, remove the shortcut from the command which has a new or changed default.
If duplicates where found, open a message box informing the user of the removed shortcuts.
2020-02-19 15:02:08 +00:00
Paul Licameli
e5540c6118 Don't crash on exit when a module attaches a menu item...
... such as Nyquist Workbench.

I don't fully understand why, but destroying the menu registry items very late,
during the destruction of static objects, causes a crash in memory deallocation,
at least on Mac.

So destroy the menu registry explicitly in application shut-down.
2020-02-17 16:08:59 -05:00
Paul Licameli
4cfbf07227 Registry passed to Visit can be const 2020-02-14 22:08:35 -05:00
Paul Licameli
540f2c5e67 Restore separators after "Move Track to Bottom" in TCP menus 2020-02-06 17:52:45 -05:00
Paul Licameli
446ee8ef6e Separate subclass ToolbarMenuVisitor from MenuVisitor 2020-02-04 12:15:24 -05:00
Paul Licameli
a43c9a5337 Identifier not wxString in ctors of registry items 2020-02-04 12:15:24 -05:00
Paul Licameli
db224895b0 Bug2302: Don't make separators at bottoms of menus on Win & Linux...
... Fix it by demoting the logic for separators from the menu tree diagnostic
into the common MenuVisitor class, then reusing that.
2020-02-04 00:41:31 -05:00
Paul Licameli
7f4d61257a Command manager stores checkmark predicates...
... and we use them to simplify (the misnamed) MenuManager::ModifyToolbarMenus.

It looked wrong that statically constructed menu descriptions should ever hold
constant boolean checkmark values, rather than functions to re-eveluate the
checkmark state as needed.
2020-02-01 12:53:55 -05:00
Paul Licameli
a729dfec3b Reusable preference-populating code for other registries than Menus 2020-02-01 07:11:38 -05:00
Paul Licameli
d233cbd881 Improvements and comments in visitation and merging of registry items 2020-01-31 21:11:58 -05:00
Binary Wisdom
9bce51a60e Bug 624: Keyboard Prefs: importing XML file can cause duplicated bindings
The fix follows the agreed behavior (see emails from around October 25) . For the sake of convenience see the agreed behavior below:

_"- first, check the xml-file. If it contains illegal shortcut duplicates, refuse importing. Shortcut duplicates are LEGAL if default settings also have those operations with the matching shortcuts. A refusal to import shortcuts must happen with the message that warns the user of a failure and explains the reason.

if the xml-file looks ok, import the shortcuts. As discussed before, because different versions of Audacity might have different sets of operations with shortcuts, it is still possible to end up with illegal shortcut duplicates for a perfectly correct xml-file. This situation must be monitored. In case of any conflicts, the shortcut from the xml-file is used, and the pre-existing shortcut is wiped clean.
When telling the user the commands which have had their shortcut removed, I think it would be useful to tell the user the name of the command, the shortcut, and and name of the command which still has that shortcut."_

I didn't find a clean way to intercept the imported content before it makes its way to the shortcut preferences, so I had to jump through some hoops right in KeyConfigPrefs::OnImport().
In general, I tried to keep changes minimal.
2020-01-31 11:32:23 +00:00
Paul Licameli
56cd24a062 Rewrite insertion of menu items by null and Nyquist modules...
... using the new registration system, and without the fragile hacks making
assumptions about the positions of menus within the menu bar.
2020-01-30 15:09:30 -05:00
Paul Licameli
baada94567 Define AttachedItem registration struct for menu items 2020-01-30 15:04:08 -05:00
Paul Licameli
c5495b3300 Ordering hints for insertion of newly discovered registry items...
... Now, a first-time registered item can specify that it go at the start or end
of the nodes under its parent, or before or after some named node.

Still it might happen that multiple first-time registrations might use the same
ordering hint, and so we must still sort by component name to resolve that
collision arbitrarily.
2020-01-30 14:46:35 -05:00
Paul Licameli
564a3ac708 Define the registry merging procedure...
... before we populate the registry.

This could apply to menu items, or more generally to other registries.

A registry is a tree of items identified by path names. Various code,
that need not coordinate, can specify items to attach to the tree, and the
merging procedure collects them into a single tree that can be visited.

Pathnames imply only an unordered tree.  Some visitation ordering must be
imposed on the nodes, and can be remembered in preferences for stability between
runs, independently of accidents of the unspecified sequence of initialization
of file-scope static objects in the various plug-ins.  It can be arbitrary --
not constrained to some fixed intrinsic criterion like alphabetical order.

Merging consults the preferences, and also updates them if previously unknown
items are found and inserted.  For now, such unknowns just go to the end of
the sequence of siblings, sorted by their path component names.
2020-01-30 14:18:26 -05:00
Paul Licameli
a84da3dee1 Remove Separator items from menu descriptions; use Section(...) 2020-01-30 12:12:48 -05:00
Paul Licameli
c7fac7ae09 Use class MenuSection in visitors 2020-01-30 11:50:48 -05:00
Paul Licameli
d84c994088 Redefine return type of MenuTable::Items 2020-01-30 09:06:20 -05:00
Paul Licameli
9639ba84f4 Reimplement commit 512c27d, fixing menus & shortcut keys on Windows 2020-01-29 13:39:19 -05:00
Paul Licameli
3c9cd7925a Fix crash on Linux startup since commit f6e5696 2020-01-28 17:39:40 -05:00
Paul Licameli
103a6050a0 Registry::Visit doesn't require an AudacityProject 2020-01-26 16:22:49 -05:00
Paul Licameli
c7bfa7a2a6 Parametrize ComputedItem::Factory by the type of argument it expects 2020-01-26 16:22:02 -05:00
Paul Licameli
bbccce4386 More rework of the class hierarchy of Registry items 2020-01-26 16:20:15 -05:00
Paul Licameli
356e5d545e Define abstract Visitor for menu items, and concrete subclass...
... The general visitation procedure will find reuse with other specific
actions, and maybe for other non-menu trees too
2020-01-25 15:10:01 -05:00
Paul Licameli
90a22b3982 Split out namespace Registry for non-menu-specific tree manipulation 2020-01-25 15:09:16 -05:00
Paul Licameli
393a098b69 Store a string identifier in each menu item...
... which is not yet used for anything.

It could be used to describe textual paths for attaching plug-in menu items.

Strings are only path local, not necessarily globally unique, and may be
left empty for separators and for groups that should be transparent to
path identification.

It may also be empty for certain sub-menus, such as those that group effects
according to the changeable criteria in Preferences.
2020-01-24 18:05:56 -05:00
Paul Licameli
33b4b409e8 Change class hierarchy of MenuTable::BaseItem...
... There are now four immediate subclasses (SharedItem and Computed Item,
which are final, and SingleItem and GroupItem, which are abstract), which may
serve future purposes more general than menu items.  There are further
subclasses specific to menu management.

The former concrete class GroupItem is renamed TransparentGroupItem.

Also allows direct construction of items in lists from shared pointers.
2020-01-24 18:05:56 -05:00
Paul Licameli
93c2bb9322 Delay evaluation of checkmark states...
... so that more menu item descriptions can be statically constructed once only
2020-01-24 18:05:56 -05:00
Paul Licameli
512c27d422 Simplify the FN macros in src/menus/*.cpp...
... Eliminate repetitious passing of the finder function into each of the
calls to Command and CommandGroup.
2020-01-24 18:05:56 -05:00
Paul Licameli
702b8b1e9d More specific return types for builders of menu descriptions 2020-01-24 18:05:56 -05:00
Paul Licameli
04a9ce8ba6 Remove some GetActiveProject calls in CommandManager.cpp ...
... The remaining ones, for use in a global event handler, are appropriate
2020-01-08 13:20:00 -05:00
Paul Licameli
54e2bbd8ff Remove TranslatedInternalString, use ComponentInterfaceSymbol 2019-12-16 10:58:05 -05:00
Paul Licameli
5639f834c8 CommandManager stores labels as TranslatableString 2019-12-16 10:58:05 -05:00
Paul Licameli
f2f7568383 Fix checks for tabs in CommandManager & don't write labels to file...
... Because label wasn't used when reading back, and it was, questionably,
writing localized strings out.

CommandManager serialization is used only for exporting and importing keystroke
shortcuts, and not in save and load of projects.

There was apparently confusion too about tab characters separating command name
from a menu accelerator, but such are not stored in the label field of
CommandListEntry.  Those tabs were only added by certain accessor functions,
which are here renamed.
2019-12-15 14:54:57 -05:00
Paul Licameli
a8de4d9e50 Construct MenuItem with untranslated label, so it can be static...
... and other storage of TranslatableString instead of naked wxString, for
management of menu items, in CommandManager
2019-12-12 15:49:00 -05:00