MeshLib C++ Docs
Loading...
Searching...
No Matches

#include <MRViewer/MRShortcutManager.h>

Inheritance diagram for MR::ShortcutManager:

Classes

struct  ShortcutAction
 what a shortcut does More...
struct  ShortcutCommand
 the parameter of the deprecated setShortcut overload, also the internal storage of an action More...

Public Types

enum class  Reason { Reason::KeyDown , Reason::KeyRepeat }
using ShortcutKey = MR::ShortcutKey
using Category = MR::ShortcutCategory
using ShortcutList = std::vector<std::pair<Shortcut, std::string>>
 the shortcut of every action with all its keys, and the name of the action

Public Member Functions

virtual ~ShortcutManager ()=default
virtual void setShortcut (const Shortcut &shortcut, const ShortcutAction &action)
void resetShortcut (const std::string &name)
 removes the action with given name and all its keys
void setShortcut (const ShortcutKey &key, const ShortcutCommand &command)
 deprecated: pass the category in (shortcut) and the rest in ShortcutAction
const ShortcutList & getShortcutList () const
bool isEnabled () const
 processShortcut does nothing if not enabled
void enable (bool on)
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;
bool onKeyDown_ (int key, int modifier) override
bool onKeyRepeat_ (int key, int modifier) override
std::optional< ShortcutKey > findShortcutByName (const std::string &name) const
 if action with given name is present in shortcut list - returns its first key
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 shortcut list
void clear ()
 clear all saved shortcuts
Public Member Functions inherited from MR::MultiListener< KeyDownListener, KeyRepeatListener >
virtual ~MultiListener ()=default
virtual void connect (Viewer *viewer, int group=0, boost::signals2::connect_position pos=boost::signals2::connect_position::at_back)
virtual void disconnect ()

Static Public Member Functions

static const char * getModifierString (int mod)
 make string from strictly one modifier
static std::string getKeyString (int key)
 make string from a key without modifiers, for arrow characters it uses icons font
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.g. "Ctrl+Space+1"
static std::string getKeysFullString (const std::vector< ShortcutKey > &keys)
 makes string from several keys separated by commas, e.g. "Ctrl+Shift+Z, Ctrl+Y"
static std::optional< int > parseKey (std::string_view name)
static std::optional< int > parseModifier (std::string_view name)
static std::optional< Category > parseCategory (std::string_view name)
static std::optional< ShortcutKey > parseShortcutKey (std::string_view keys)

Static Public Attributes

static const std::string categoryNames [6] = { "Info", "Edit", "View", "Scene", "Objects", "Selection " }

Protected Types

using ShourtcutsMap = HashMap<int, ShortcutCommand>
using ShourtcutsBackMap = HashMap<std::string, std::vector<int>>

Protected Member Functions

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 and modifiers; 0 if none

Static Protected Member Functions

static int mapKeyFromKeyAndMod (const ShortcutKey &key, bool respectKeyboard)
static ShortcutKey kayAndModFromMapKey (int mapKey)
 returns key with modifier (alt, ctrl, shift, etc.) from simple map key

Protected Attributes

bool enabled_ { true }
 all keys of an action in their order
ShourtcutsMap map_
ShourtcutsBackMap backMap_
std::optional< ShortcutList > listCache_

Static Protected Attributes

static constexpr int cModBits = 6
 bits of the modifiers and of the key in a map key, the held key takes the rest
static constexpr int cKeyBits = 9

Detailed Description

this class stores two maps: 1) shortcut to action 2) action name to its shortcuts it can be used to process, customize and print shortcuts indifferent to literals register


The documentation for this class was generated from the following file: