Hot Door CORE 0.8.2
Adobe® Illustrator® Plug-in Library
|
Class through which all messages ultimately pass; holds registered callbacks for messages, notifiers, timers, etc. and calls them at the proper time. More...
#include <hdicoreDispatcher.h>
Public Types | |
enum | Error { NoDispatchError = 0 , UnhandledMessageError = 10 , UnknownMessageTypeError = 20 , RedundantMessageReceivedError = 30 } |
Describes a variety of dispatch-related errors. | |
enum | VirtualKey { CommandKey = 10 , OptionKey = 20 , AltKey = OptionKey , ControlKey = 30 , ShiftKey = 40 , CapsLockKey = 50 , SpaceKey = 110 , TabKey = 100 , ReturnKey = 120 , EscapeKey = 200 , ClearKey = 210 , DeleteKey = 220 , ForwardDeleteKey = 230 , UpArrowKey = 300 , DownArrowKey = 310 , LeftArrowKey = 320 , RightArrowKey = 330 , HomeKey = 400 , EndKey = 410 , PageUpKey = 420 , PageDownKey = 430 , HelpKey = 440 , F1Key = 500 , F2Key = 510 , F3Key = 520 , F4Key = 530 , F5Key = 540 , F6Key = 550 , F7Key = 560 , F8Key = 570 , F9Key = 580 , F10Key = 590 , F11Key = 600 , F12Key = 610 , F13Key = 620 , F14Key = 630 , F15Key = 640 , F16Key = 650 , F17Key = 660 , F18Key = 670 , F19Key = 680 , F20Key = 690 , NumPad0Key = 800 , NumPad1Key = 810 , NumPad2Key = 820 , NumPad3Key = 830 , NumPad4Key = 840 , NumPad5Key = 850 , NumPad6Key = 860 , NumPad7Key = 870 , NumPad8Key = 880 , NumPad9Key = 890 , NumPadDecimalKey = 1000 , NumPadPlusKey = 1010 , NumPadMinusKey = 1020 , NumPadMultiplyKey = 1030 , NumPadDivideKey = 1040 , LD_0Key = 2010 , LD_1Key = 2020 , LD_2Key = 2030 , LD_3Key = 2040 , LD_4Key = 2050 , LD_5Key = 2060 , LD_6Key = 2070 , LD_7Key = 2080 , LD_8Key = 2090 , LD_9Key = 2100 , LD_AKey = 2110 , LD_BKey = 2120 , LD_CKey = 2130 , LD_DKey = 2140 , LD_EKey = 2150 , LD_FKey = 2160 , LD_GKey = 2170 , LD_HKey = 2180 , LD_IKey = 2190 , LD_JKey = 2200 , LD_KKey = 2210 , LD_LKey = 2220 , LD_MKey = 2230 , LD_NKey = 2240 , LD_OKey = 2250 , LD_PKey = 2260 , LD_QKey = 2270 , LD_RKey = 2280 , LD_SKey = 2290 , LD_TKey = 2300 , LD_UKey = 2310 , LD_VKey = 2320 , LD_WKey = 2330 , LD_XKey = 2340 , LD_YKey = 2350 , LD_ZKey = 2360 , LD_SlashKey = 2370 , LD_BackslashKey = 2380 , LD_CommaKey = 2390 , LD_PeriodKey = 2400 , LD_SemicolonKey = 2410 , LD_MinusKey = 2420 , LD_EqualKey = 2430 , LD_LeftBracketKey = 2440 , LD_RightBracketKey = 2450 , LD_GraveKey = 2460 , LD_QuoteKey = 2470 } |
Describes which keys can be monitored for presses at anytime. | |
typedef std::vector< std::shared_ptr< Notifier > > | NotifierVector |
Public Member Functions | |
bool | registerMessageCallback (const MessageType type_, const Callback &callback_) |
Registers a new callback for a given message type. | |
void | unregisterMessageCallback (const MessageType type_) |
Unregisters a callback for a given message type. | |
bool | registerMessageCallback (const std::string &caller_, const std::string &selector_, const Callback &callback_) |
Registers a new callback for a given caller/selector pair. | |
void | unregisterMessageCallback (const std::string &caller_, const std::string &selector_) |
Unregisters a callback for a given caller/selector pair. | |
Error | message (const MessageType type_, void *const msg_) |
Notifies the dispatcher of an incoming message, causing it to call the appropriate callback or return UnhandledMessageError in the case no callback is registered. | |
Error | message (const std::string &caller_, const std::string &selector_, void *const msg_) |
Notifies the dispatcher of an incoming (custom) message, causing it to call the appropriate callback or return UnhandledMessageError in the case no callback is registered. | |
Message *const | lastMessage () |
Gets a Message object that wraps around the last message data received. | |
void | scheduleCallback (const Callback &callback_, const double delay_=0.0) |
Executes a given callback after a delay. | |
void | registerTimer (const Timer &timer_) |
Registers a Timer object. | |
bool | unregisterTimer (const Timer &timer_) |
Unregisters a given timer. | |
ToolMessage *const | lastToolMessage () |
Gets the last tool message received, regardless of whether subsequent non-tool messages have been received. | |
void | registerNotifier (const Notifier ¬ifier_) |
Registers a Notifier object for a given Illustrator notifier subscription. | |
NotifierVector | registeredNotifiersOfType (const NotifierType type_) |
Gets registered notifiers by their type. | |
bool | unregisterNotifier (const Notifier ¬ifier_) |
Unregisters a given notifier. | |
void | registerAnnotator (const Annotator &annotator_) |
Registers an Annotator object. | |
bool | unregisterAnnotator (const Annotator &annotator_) |
Unregisters a given annotator. | |
uint32_t | addKeyDownMonitor (const VirtualKey key_, const Callback &cb_) |
Creates an app-wide key-down monitor that executes a callback when a specific key has been pressed. | |
uint32_t | addKeyUpMonitor (const VirtualKey key_, const Callback &cb_) |
Creates an app-wide key-up monitor that executes a callback when a specific key has been released. | |
bool | getKeyDownMonitor (const VirtualKey key_, uint32_t &id__, std::unique_ptr< Callback > &cb__) const |
Gets an existing key-down monitor, if any. | |
bool | getKeyUpMonitor (const VirtualKey key_, uint32_t &id__, std::unique_ptr< Callback > &cb__) const |
Gets an existing key-up monitor, if any. | |
void | removeKeyDownMonitor (const uint32_t id_) |
Removes a key-down monitor previously created with addKeyDownMonitor() | |
void | removeKeyUpMonitor (const uint32_t id_) |
Removes a key-up monitor previously created with addKeyUpMonitor() | |
bool | isKeyDown (const VirtualKey key_, bool &down__) |
Gets whether the given key is down. | |
Friends | |
class | Plugin |
Class through which all messages ultimately pass; holds registered callbacks for messages, notifiers, timers, etc. and calls them at the proper time.
uint32_t hdi::core::Dispatcher::addKeyDownMonitor | ( | const VirtualKey | key_, |
const Callback & | cb_ | ||
) |
Creates an app-wide key-down monitor that executes a callback when a specific key has been pressed.
key_ | Key that should be monitored for pressing |
cb_ | Callback to execute when key_ has been pressed (may be called repeatedly if the user holds down the key) |
uint32_t hdi::core::Dispatcher::addKeyUpMonitor | ( | const VirtualKey | key_, |
const Callback & | cb_ | ||
) |
Creates an app-wide key-up monitor that executes a callback when a specific key has been released.
key_ | Key that should be monitored for release |
cb_ | Callback to execute when key_ has been release |
bool hdi::core::Dispatcher::getKeyDownMonitor | ( | const VirtualKey | key_, |
uint32_t & | id__, | ||
std::unique_ptr< Callback > & | cb__ | ||
) | const |
Gets an existing key-down monitor, if any.
key_ | Virtual key in question |
id__ | Return-by-reference for the monitor's ID number |
cb__ | Return-by-reference for the monitor's callback |
bool hdi::core::Dispatcher::getKeyUpMonitor | ( | const VirtualKey | key_, |
uint32_t & | id__, | ||
std::unique_ptr< Callback > & | cb__ | ||
) | const |
Gets an existing key-up monitor, if any.
key_ | Virtual key in question |
id__ | Return-by-reference for the monitor's ID number |
cb__ | Return-by-reference for the monitor's callback |
bool hdi::core::Dispatcher::isKeyDown | ( | const VirtualKey | key_, |
bool & | down__ | ||
) |
Gets whether the given key is down.
key_ | The key in question |
down__ | Return-by-reference for whether the key is down; true means down, false means up |
Message *const hdi::core::Dispatcher::lastMessage | ( | ) |
Gets a Message object that wraps around the last message data received.
ToolMessage *const hdi::core::Dispatcher::lastToolMessage | ( | ) |
Gets the last tool message received, regardless of whether subsequent non-tool messages have been received.
Error hdi::core::Dispatcher::message | ( | const MessageType | type_, |
void *const | msg_ | ||
) |
Notifies the dispatcher of an incoming message, causing it to call the appropriate callback or return UnhandledMessageError in the case no callback is registered.
type_ | Type of message that is being received |
msg_ | Message data sent along with the message; this will automatically be processed by the dispatcher and made available by the lastMessage() method |
Error hdi::core::Dispatcher::message | ( | const std::string & | caller_, |
const std::string & | selector_, | ||
void *const | msg_ | ||
) |
Notifies the dispatcher of an incoming (custom) message, causing it to call the appropriate callback or return UnhandledMessageError in the case no callback is registered.
caller_ | Caller ID string |
selector_ | Selector ID string for caller_ |
msg_ | Message data sent along with the message; this will automatically be processed by the dispatcher and made available by the lastMessage() method |
void hdi::core::Dispatcher::registerAnnotator | ( | const Annotator & | annotator_ | ) |
Registers an Annotator object.
annotator_ | New annotator, whose callback will be called when the proper notification is received by the dispatcher |
NotifierVector hdi::core::Dispatcher::registeredNotifiersOfType | ( | const NotifierType | type_ | ) |
Gets registered notifiers by their type.
type_ | Type of the notifiers to find |
bool hdi::core::Dispatcher::registerMessageCallback | ( | const MessageType | type_, |
const Callback & | callback_ | ||
) |
Registers a new callback for a given message type.
type_ | Type of message to which callback_ will be associated (only one callback per message is allowed) |
callback_ | Callback to perform when the caller/selector pair associated with type_ is received in a message |
bool hdi::core::Dispatcher::registerMessageCallback | ( | const std::string & | caller_, |
const std::string & | selector_, | ||
const Callback & | callback_ | ||
) |
Registers a new callback for a given caller/selector pair.
caller_ | Caller ID string |
selector_ | Selector ID string for caller_ |
callback_ | Callback to perform when the caller/selector pair is received in a message |
void hdi::core::Dispatcher::registerNotifier | ( | const Notifier & | notifier_ | ) |
Registers a Notifier object for a given Illustrator notifier subscription.
notifier_ | New notifier, whose callback will be called when the proper notification is received by the dispatcher |
void hdi::core::Dispatcher::registerTimer | ( | const Timer & | timer_ | ) |
Registers a Timer object.
timer_ | New timer, whose callback will be called when the proper notification is received by the dispatcher |
void hdi::core::Dispatcher::removeKeyDownMonitor | ( | const uint32_t | id_ | ) |
Removes a key-down monitor previously created with addKeyDownMonitor()
id_ | ID for the keypress monitor (returned by earlier call to addKeyDownMonitor() method) |
void hdi::core::Dispatcher::removeKeyUpMonitor | ( | const uint32_t | id_ | ) |
Removes a key-up monitor previously created with addKeyUpMonitor()
id_ | ID for the keypress monitor (returned by earlier call to addKeyUpMonitor() method) |
void hdi::core::Dispatcher::scheduleCallback | ( | const Callback & | callback_, |
const double | delay_ = 0.0 |
||
) |
Executes a given callback after a delay.
callback_ | Callback object to execute on delay |
delay_ | Number of seconds to wait before executing (approximately - the OS may wait longer) |
bool hdi::core::Dispatcher::unregisterAnnotator | ( | const Annotator & | annotator_ | ) |
Unregisters a given annotator.
annotator_ | Annotator to be unregistered |
void hdi::core::Dispatcher::unregisterMessageCallback | ( | const MessageType | type_ | ) |
Unregisters a callback for a given message type.
type_ | Type of message from which the caller is unsubscribing |
void hdi::core::Dispatcher::unregisterMessageCallback | ( | const std::string & | caller_, |
const std::string & | selector_ | ||
) |
Unregisters a callback for a given caller/selector pair.
caller_ | Caller ID string from which the caller is unsubscribing |
selector_ | Selector ID string for caller_ |
bool hdi::core::Dispatcher::unregisterNotifier | ( | const Notifier & | notifier_ | ) |
Unregisters a given notifier.
notifier_ | Notifier to be unregistered |