UI Actions

From vice-emu
Revision as of 10:56, 25 March 2023 by Compyx (talk | contribs) (Create UI actions page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Rationale

In the Gtk3 UI the concept of "UI actions" was introduced to allow for a unified interface to trigger certain actions in the emulator and its user interface . UI actions decouple hotkeys from menu items so hotkeys can be defined that do not have a corresponding menu item. This interface will also allow calling actions from customizable joystick mappings, reusing the code triggered by menu items and/or hotkeys.

Since most user interactions are independent of what UI toolkit is used it makes sense to generalize these interactions and make all current and future UIs use this UI actions system. For example "soft reset" or "attach disk to unit #8" may use different dialogs, menu items or hotkeys, the underlying logic (and code) will be the same. So providing a predefined -- and extendable -- set of UI actions will aid in development of future UIs.

Mechanism

The UI actions API code resides in src/arch/uiactions.h and src/arch/uiactions.c. The code is documented using Doxygen docblocks, so the documentation can be generated with doc/mkdoxy.sh or just read in the files themselves.

UI actions are triggered using a unique ID and calling a function: void ui_action_trigger(int action);. The IDs are available in the src/arch/uiactions.h header, these are all prefixed with ACTION_.

At emulator boot the UI code calls void ui_actions_init(void) to initialize the UI actions system, sets a UI-specific dispatch function with void ui_actions_set_dispatch(void (*dispatch)(const ui_action_map_t *)) and registers UI action handlers with void ui_actions_register(const ui_action_map_t *mappings).