3#include "MRMesh/MRphmap.h"
33 std::function<void()>
func;
46 inline static const std::string
categoryNames[6] = {
"Info",
"Edit",
"View",
"Scene",
"Objects",
"Selection " };
57 [[deprecated(
"use setShortcut( Shortcut, ShortcutAction )" )]]
62 using ShortcutList = std::vector<std::pair<Shortcut, std::string>>;
81 MRVIEWER_API
bool onKeyDown_(
int key,
int modifier )
override;
97 MRVIEWER_API
static std::optional<int>
parseKey( std::string_view name );
102 MRVIEWER_API
static std::optional<int>
parseModifier( std::string_view name );
106 MRVIEWER_API
static std::optional<Category>
parseCategory( std::string_view name );
Definition MRShortcutManager.h:22
static constexpr int cKeyBits
Definition MRShortcutManager.h:129
std::function< void()> func
name of action
Definition MRShortcutManager.h:33
static ShortcutKey kayAndModFromMapKey(int mapKey)
returns key with modifier (alt, ctrl, shift, etc.) from simple map key
Definition MRShortcutManager.h:125
virtual void setShortcut(const Shortcut &shortcut, const ShortcutAction &action)
static const char * getModifierString(int mod)
make string from strictly one modifier
std::optional< ShortcutKey > findShortcutByName(const std::string &name) const
if action with given name is present in shortcut list - returns its first key
Reason
Definition MRShortcutManager.h:69
const ShortcutList & getShortcutList() const
void clear()
clear all saved shortcuts
bool repeatable
Definition MRShortcutManager.h:34
static std::string getKeyString(int key)
make string from a key without modifiers, for arrow characters it uses icons font
static const std::string categoryNames[6]
Definition MRShortcutManager.h:46
int findHeldKey_(int key, int mod) const
the held key, down now and not reserved by a UI hotkey (reserveKeyEvent), of a chord with given key a...
static constexpr int cModBits
bits of the modifiers and of the key in a map key, the held key takes the rest
Definition MRShortcutManager.h:128
void setShortcut(const ShortcutKey &key, const ShortcutCommand &command)
deprecated: pass the category in (shortcut) and the rest in ShortcutAction
Definition MRShortcutManager.h:58
void enable(bool on)
Definition MRShortcutManager.h:76
virtual bool processShortcut(const ShortcutKey &key, Reason=Reason::KeyDown) const
if given key has action in shortcut map - process it and returns true, otherwise returns false;
static std::string getKeysFullString(const std::vector< ShortcutKey > &keys)
makes string from several keys separated by commas, e.g. "Ctrl+Shift+Z, Ctrl+Y"
std::function< void()> action
name of action
Definition MRShortcutManager.h:42
std::string name
Definition MRShortcutManager.h:41
static std::optional< int > parseKey(std::string_view name)
std::string name
Definition MRShortcutManager.h:32
static int mapKeyFromKeyAndMod(const ShortcutKey &key, bool respectKeyboard)
static std::string getKeyFullString(const ShortcutKey &key, bool respectKey=true)
make string from all modifiers, the held key and with/without key and returns it, e....
bool onKeyDown_(int key, int modifier) override
MR::ShortcutKey ShortcutKey
Definition MRShortcutManager.h:26
std::vector< std::pair< Shortcut, std::string > > ShortcutList
the shortcut of every action with all its keys, and the name of the action
Definition MRShortcutManager.h:62
phmap::flat_hash_map< K, V, Hash, Eq, Allocator< std::pair< const K, V > > > HashMap
Definition MRMeshFwd.h:632
static std::optional< Category > parseCategory(std::string_view name)
HashMap< int, ShortcutCommand > ShourtcutsMap
Definition MRShortcutManager.h:134
bool onKeyRepeat_(int key, int modifier) override
ShourtcutsBackMap backMap_
Definition MRShortcutManager.h:140
ShourtcutsMap map_
Definition MRShortcutManager.h:139
bool isEnabled() const
processShortcut does nothing if not enabled
Definition MRShortcutManager.h:75
ShortcutCategory
Definition MRShortcutKey.h:25
virtual ~ShortcutManager()=default
void resetShortcut(const std::string &name)
removes the action with given name and all its keys
static std::optional< ShortcutKey > parseShortcutKey(std::string_view keys)
Category category
Definition MRShortcutManager.h:40
MR::ShortcutCategory Category
Definition MRShortcutManager.h:27
bool repeatable
Definition MRShortcutManager.h:43
static std::optional< int > parseModifier(std::string_view name)
std::optional< ShortcutList > listCache_
Definition MRShortcutManager.h:142
bool enabled_
all keys of an action in their order
Definition MRShortcutManager.h:137
std::vector< ShortcutKey > findShortcutsByName(const std::string &name) const
returns all keys of the action with given name in their order, empty if the action is not present in ...
HashMap< std::string, std::vector< int > > ShourtcutsBackMap
Definition MRShortcutManager.h:135
@ KeyRepeat
the user just pressed the keys
Definition MRShortcutManager.h:71
@ KeyDown
Definition MRShortcutManager.h:70
Only strictly necessary for the bindings (to make MR::MeshIntersectionResult a complete type).
Definition MRCameraOrientationPlugin.h:8
Definition MRViewerEventsListener.h:32
Definition MRShortcutKey.h:14
what a shortcut does
Definition MRShortcutManager.h:31
the parameter of the deprecated setShortcut overload, also the internal storage of an action
Definition MRShortcutManager.h:39
a keyboard shortcut: the keys to press and the category it is listed under
Definition MRShortcutKey.h:37