HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UI_HotkeyHelper.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UI_HotkeyHelper.h (UI Library, C++)
7  *
8  * COMMENTS: Helper class for hotkey handling
9  */
10 
11 #ifndef __UI_HOTKEYHELPER_H__
12 #define __UI_HOTKEYHELPER_H__
13 
14 #include "UI_API.h"
15 #include <UT/UT_PtrProxy.h>
16 #include <UT/UT_StringMap.h>
17 #include "UI_Object.h"
18 
19 class UI_Event;
20 
21 /// Hotkey handler method. Returns true if successfully consumed.
22 typedef bool (UI_Object::*UI_HotkeyMethod)(int key, UI_Event *);
23 
24 
25 /// The UI_HotkeyHelper class allows one to maintain a table of hotkeys and
26 /// their associated handler functions (of type UI_HotkeyMethod) so that we
27 /// can easily perform functions like dispatching hotkey handlers as well as
28 /// testing to see if a hotkey is going to be handled without invoking the
29 /// handler.
31 {
32 public:
33  struct Entry
34  {
35  const char * mySymbol;
37  bool myEchoFlag;
38  };
39 
40  /// Default constructor
41  UI_HotkeyHelper(UI_Object *client);
42  /// Construct via array of hotkey entries terminated by nullptr mySymbol.
43  UI_HotkeyHelper(UI_Object *client, const Entry *hotkey_entries);
44  /// Destructor
45  virtual ~UI_HotkeyHelper();
46 
47  /// Adds an array of hotkey entries terminated by nullptr mySymbol.
48  void addHotkeys(const Entry *hotkey_entries);
49  /// Add a single hotkey entry
50  void addHotkey(const Entry &entry);
51  /// Remove a hotkey entry
52  void removeHotkey(const char *symbol);
53 
54  /// Invoke the handler for the given UI hotkey event.
55  /// Returns true if consumed, false otherwise.
56  bool processHotkey(int key, UI_Event *event);
57 
58  /// Will we handle the given UI hotkey symbol?
59  bool willProcessHotkey(int key, UI_Event *event);
60 
61 private: // methods
62 
63  UI_HotkeyHelper(const UI_HotkeyHelper &copy); // not yet done
64  UI_HotkeyHelper & operator=(const UI_HotkeyHelper &copy); // not yet done
65 
66  struct TableEntry
67  {
68  TableEntry(UI_HotkeyMethod method, bool echo)
69  : myMethod(method), myEchoFlag(echo) {}
70 
71  UI_HotkeyMethod myMethod;
72  bool myEchoFlag;
73  };
74 
75 private: // data
76 
77  UT_RefProxy<UI_Object> myClient;
79 
80 };
81 
82 #endif // __UI_HOTKEYHELPER_H__
OIIO_UTIL_API bool copy(string_view from, string_view to, std::string &err)
UI_HotkeyMethod myMethod
struct _cl_event * event
Definition: glcorearb.h:2961
const char * mySymbol
bool myEchoFlag
bool(UI_Object::* UI_HotkeyMethod)(int key, UI_Event *)
Hotkey handler method. Returns true if successfully consumed.
LeafData & operator=(const LeafData &)=delete
#define UI_API
Definition: UI_API.h:10