From: <sv...@op...> - 2024-11-25 19:56:32
|
Author: sagamusix Date: Mon Nov 25 20:56:20 2024 New Revision: 22310 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22310 Log: [Ref] CommandSet: Small cleanup. Modified: trunk/OpenMPT/mptrack/CommandSet.cpp trunk/OpenMPT/mptrack/CommandSet.h trunk/OpenMPT/mptrack/DefaultKeyBindings.h Modified: trunk/OpenMPT/mptrack/CommandSet.cpp ============================================================================== --- trunk/OpenMPT/mptrack/CommandSet.cpp Mon Nov 25 19:39:07 2024 (r22309) +++ trunk/OpenMPT/mptrack/CommandSet.cpp Mon Nov 25 20:56:20 2024 (r22310) @@ -83,9 +83,9 @@ // Setup -KeyCommand::KeyCommand(uint32 uid, const TCHAR *message, std::vector<KeyCombination> keys) +KeyCommand::KeyCommand(uint32 uid, const TCHAR *commandName, std::vector<KeyCombination> keys) : kcList{std::move(keys)} - , Message{message} + , name{commandName} , UID{uid} { } @@ -964,11 +964,11 @@ for(int i = kcVPStartNotes; i <= kcVPEndNotes; i++) { - m_commands[i - kcVPStartNotes + contextStartNotes] = {KeyCommand::Hidden, m_commands[i].Message}; + m_commands[i - kcVPStartNotes + contextStartNotes] = {KeyCommand::Hidden, m_commands[i].name}; } for(int i = kcVPStartNoteStops; i <= kcVPEndNoteStops; i++) { - m_commands[i - kcVPStartNoteStops + contextStopNotes] = {KeyCommand::Hidden, m_commands[i].Message}; + m_commands[i - kcVPStartNoteStops + contextStopNotes] = {KeyCommand::Hidden, m_commands[i].name}; } } Modified: trunk/OpenMPT/mptrack/CommandSet.h ============================================================================== --- trunk/OpenMPT/mptrack/CommandSet.h Mon Nov 25 19:39:07 2024 (r22309) +++ trunk/OpenMPT/mptrack/CommandSet.h Mon Nov 25 20:56:20 2024 (r22310) @@ -14,7 +14,6 @@ #include "openmpt/base/FlagSet.hpp" #include <bitset> #include <map> -#include <string> OPENMPT_NAMESPACE_BEGIN @@ -1197,8 +1196,6 @@ using KeyMap = std::multimap<KeyCombination, CommandID>; using KeyMapRange = std::pair<KeyMap::const_iterator, KeyMap::const_iterator>; -//KeyMap - struct KeyCommand { static constexpr uint32 Dummy = 1u << 31; @@ -1206,14 +1203,14 @@ static constexpr uint32 UIDMask = Hidden - 1u; std::vector<KeyCombination> kcList; - CString Message; + CString name; protected: uint32 UID = 0; public: KeyCommand() = default; - KeyCommand(uint32 uid, const TCHAR *message = _T(""), std::vector<KeyCombination> keys = {}); + KeyCommand(uint32 uid, const TCHAR *commandName = _T(""), std::vector<KeyCombination> keys = {}); // Unique ID for on-disk keymap format. // Note that hidden commands do not have a unique ID, because they are never written to keymap files. @@ -1234,40 +1231,10 @@ }; -enum RuleID -{ - krPreventDuplicate, - krDeleteOldOnConflict, - - krAllowNavigationWithSelection, - krAllowSelectionWithNavigation, - krAutoSelectOff, - krAllowSelectCopySelectCombos, - krLockNotesToChords, - krNoteOffOnKeyRelease, - krPropagateNotes, - krReassignDigitsToOctaves, - krAutoSpacing, - krCheckModifiers, - krPropagateSampleManipulation, - kNumRules -}; - struct CModSpecifications; class CCommandSet { -protected: - //util - void SetupCommands(); - void SetupContextHierarchy(); - void EnforceAll(KeyCombination kc, CommandID cmd, bool adding); - - CommandID FindCmd(uint32 uid) const; - bool KeyCombinationConflict(KeyCombination kc1, KeyCombination kc2, bool checkEventConflict = true) const; - - void ApplyDefaultKeybindings(KeyboardPreset preset, const Version onlyCommandsAfterVersion = {}); - public: CCommandSet(); @@ -1290,7 +1257,7 @@ mpt::span<const KeyCombination> GetKeyChoices(CommandID cmd) const { return mpt::as_span(m_commands[cmd].kcList); } bool IsHidden(UINT c) const { return m_commands[c].IsHidden(); } int GetKeyListSize(CommandID cmd) const { return (cmd != kcNull) ? static_cast<int>(m_commands[cmd].kcList.size()) : 0; } - CString GetCommandText(CommandID cmd) const { return m_commands[cmd].Message; } + CString GetCommandText(CommandID cmd) const { return m_commands[cmd].name; } CString GetKeyTextFromCommand(CommandID c, UINT key = uint32_max) const; CString FormatConflict(KeyCombination kc, CommandID conflictCommand, KeyCombination conflictCombination) const; @@ -1305,8 +1272,36 @@ static bool MustBeModifierKey(CommandID id); protected: + void SetupCommands(); + void SetupContextHierarchy(); + void EnforceAll(KeyCombination kc, CommandID cmd, bool adding); + + CommandID FindCmd(uint32 uid) const; + bool KeyCombinationConflict(KeyCombination kc1, KeyCombination kc2, bool checkEventConflict = true) const; + + void ApplyDefaultKeybindings(KeyboardPreset preset, const Version onlyCommandsAfterVersion = {}); + + enum RuleID + { + krPreventDuplicate, + krDeleteOldOnConflict, + + krAllowNavigationWithSelection, + krAllowSelectionWithNavigation, + krAutoSelectOff, + krAllowSelectCopySelectCombos, + krLockNotesToChords, + krNoteOffOnKeyRelease, + krPropagateNotes, + krReassignDigitsToOctaves, + krAutoSpacing, + krCheckModifiers, + krPropagateSampleManipulation, + kNumRules + }; + const CModSpecifications *m_currentModSpecs = nullptr; - KeyCommand m_commands[kcNumCommands]; + std::array<KeyCommand, kcNumCommands> m_commands; std::bitset<kCtxMaxInputContexts> m_isParentContext[kCtxMaxInputContexts]; std::bitset<kNumRules> m_enforceRule; }; Modified: trunk/OpenMPT/mptrack/DefaultKeyBindings.h ============================================================================== --- trunk/OpenMPT/mptrack/DefaultKeyBindings.h Mon Nov 25 19:39:07 2024 (r22309) +++ trunk/OpenMPT/mptrack/DefaultKeyBindings.h Mon Nov 25 20:56:20 2024 (r22310) @@ -1,7 +1,7 @@ /* * DefaultKeyBindings.h * -------------------- - * Purpose: The default key binding definitions, including IT and FT2 flavours + * Purpose: The default key binding definitions, including IT and FT2 flavours. * Notes : (currently none) * Authors: OpenMPT Devs * The OpenMPT source code is released under the BSD license. Read LICENSE for more details. |