3#include "MRMesh/MRphmap.h"
33 std::function<void()>
func;
46 inline static const std::string
categoryNames[6] = {
"Info",
"Edit",
"View",
"Scene",
"Objects",
"Selection " };
54 [[deprecated(
"use setShortcut( Shortcut, ShortcutAction )" )]]
58 using ShortcutList = std::vector<std::tuple<ShortcutKey, Category, std::string>>;
77 MRVIEWER_API
bool onKeyDown_(
int key,
int modifier )
override;
91 MRVIEWER_API
static std::optional<int>
parseKey( std::string_view name );
96 MRVIEWER_API
static std::optional<int>
parseModifier( std::string_view name );
100 MRVIEWER_API
static std::optional<Category>
parseCategory( std::string_view name );
Definition MRShortcutManager.h:22
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:116
HashMap< std::string, int > ShourtcutsBackMap
Definition MRShortcutManager.h:119
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 it
Reason
Definition MRShortcutManager.h:65
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
void setShortcut(const ShortcutKey &key, const ShortcutCommand &command)
deprecated: pass the category in (shortcut) and the rest in ShortcutAction
Definition MRShortcutManager.h:55
void enable(bool on)
Definition MRShortcutManager.h:72
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;
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)
std::vector< std::tuple< ShortcutKey, Category, std::string > > ShortcutList
Definition MRShortcutManager.h:58
static std::string getKeyFullString(const ShortcutKey &key, bool respectKey=true)
make string from all modifiers and with/without key and returns it
bool onKeyDown_(int key, int modifier) override
MR::ShortcutKey ShortcutKey
Definition MRShortcutManager.h:26
static std::optional< Category > parseCategory(std::string_view name)
HashMap< int, ShortcutCommand > ShourtcutsMap
Definition MRShortcutManager.h:118
bool onKeyRepeat_(int key, int modifier) override
ShourtcutsBackMap backMap_
Definition MRShortcutManager.h:124
ShourtcutsMap map_
Definition MRShortcutManager.h:123
bool isEnabled() const
processShortcut does nothing if not enabled
Definition MRShortcutManager.h:71
ShortcutCategory
Definition MRShortcutKey.h:20
virtual ~ShortcutManager()=default
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:126
bool enabled_
Definition MRShortcutManager.h:121
phmap::flat_hash_map< K, V, Hash, Eq > HashMap
Definition MRMeshFwd.h:606
@ KeyRepeat
the user just pressed the keys
Definition MRShortcutManager.h:67
@ KeyDown
Definition MRShortcutManager.h:66
only for bindings generation
Definition MRCameraOrientationPlugin.h:8
Definition MRViewerEventsListener.h:32
Definition MRShortcutKey.h:12
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:32