User:Compyx: Difference between revisions

From vice-emu
Jump to navigation Jump to search
(Start collection observations on the SDL UI code on my personal Wiki paga)
Line 1: Line 1:
= Who am I =
= Personal notes, observations and rants =


I'm an old C64 scener, look me up at csdk.dk if you don't believe me ;)
== SDL UI code ==


= Personal devlog =
Since I'm tasked with updating the SDL code to use the generic UI actions and hotkeys code and use those UI actions from the menu items, hotkeys and custom joystick mappings, and the code is poorly documented, I'll be writing down some observations on how the SDL UI code works here.


== TODO list ==
=== Menu items ===


* 2016-11-05: <s>BeOS/Haiku doesn't log anything to LOG_DEFAULT except HardSID messages at startup.</s> <b>I don't care, not my port</b>
Menu items are defined with the type <b><tt>ui_menu_entry_t</tt></b> (in <tt>uimenu.h</tt>):
* 2016-11-05: <s>VSID: add HVSC Songlengths.txt support, maybe STIL as well. (For 3.1 or later)</s> <b>Fixed</b>
<syntaxhighlight lang="C">
* 2017-02-13: <s>*nix make install: fix DOS2UNIX check, doesn't seem to work very well now</s> <b>Fixed</b>
typedef struct ui_menu_entry_s {
* 2017-03-25: <s>SDL UI: rename 'screenshot' menu item to 'Save media' and move screenshot, sound recording and video recording submenu to this menu item.</s>
    char *string;
* 2017-04-06: <s>SDL UI: have the monitor 'm' command properly dump screencodes next to the hexdump</s> <b>Fixed</b>
    ui_menu_entry_type_t type;
* 2017-05-16: <s>SDL UI: turn 'Pause' into a proper toggle, right now there's no feedback and reentering the menu turns pause off, which is counter-intuitive</s> <b>Not my port</b>
    ui_callback_t callback;
* 2017-05-16: <s>SDL UI: add toggle to display/hide 'hidden' files (ie .foo on Unix).</s> <b>Not my port, may have been fixed</b>
    ui_callback_data_t data;
* 2017-05-16: Add 'last-used-dir' functionality to ports that can support it (ie SDL on Unix) <b>Added to Gtk3, mostly</b>
    ui_menu_status_type_t status;
* 2020-02-28: Fix LDFLAGS handling in configure like I did with C[PP|XX]?FLAGS.
} ui_menu_entry_t;
* 2020-02-28: Check documentation (vice.texi) and update where required.
</syntaxhighlight>
* 2020-02-28: Create test suite for C1541.
* 2020-03-01: Make the ROMset dialog actually work.


=== Code cleanup ===
The <i><tt>string</tt></i> is used to display the item text in the menus. It is used by <tt>sdl_ui_display_item()</tt> to render a menu item.
The <i><tt>type</tt></i> determines what to do when the user activates the item, types include radio buttons, toggle buttons, submenus, and dialogs.
When an item is activated the <i><tt>callback</tt></i> is called with <i><tt>data</i></tt> as its argument. The return value of the <i><tt>callback</i></tt> (a <tt>const char*</tt>) is used to update the item's state or to exit the UI (more on that later).
The <tt><i>status</tt></i> field is used for radio buttons to display the selection's state (or something like that).


The c1541 and vdrive code needs cleaning up
The various menu item types are defined as:
<syntaxhighlight lang="C">
typedef enum {
    /* Text item (no operation): if data == 1 text colors are inverted */
    MENU_ENTRY_TEXT = 0,


* CBM DOS command support needs work. The VDrive command handling is lacking some functionality as opposed to the actual CBM DOS.
    /* Resource toggle: no UI needed, callback is used */
:: Most of this should be fixed, to be sure we'd need some kind of test suite for C1541 (good luck with that)
    MENU_ENTRY_RESOURCE_TOGGLE,
 
    /* Resource radio: no UI needed, callback is used, data is the resource value */
    MENU_ENTRY_RESOURCE_RADIO,
 
    /* Resource int: needs UI, callback is used */
    MENU_ENTRY_RESOURCE_INT,
 
    /* Resource string: needs UI, callback is used */
    MENU_ENTRY_RESOURCE_STRING,
 
    /* Submenu: needs UI, data points to the submenu */
    MENU_ENTRY_SUBMENU,
 
    /* Dynamic submenu: needs UI, data points to the submenu, hotkeys disabled */
    MENU_ENTRY_DYNAMIC_SUBMENU,
 
    /* Custom dialog: needs UI */
    MENU_ENTRY_DIALOG,
 
    /* Other: no UI needed */
    MENU_ENTRY_OTHER,
 
    /* Other: no UI needed */
    MENU_ENTRY_OTHER_TOGGLE
} ui_menu_entry_type_t;
</syntaxhighlight>

Revision as of 22:55, 16 June 2023

Personal notes, observations and rants

SDL UI code

Since I'm tasked with updating the SDL code to use the generic UI actions and hotkeys code and use those UI actions from the menu items, hotkeys and custom joystick mappings, and the code is poorly documented, I'll be writing down some observations on how the SDL UI code works here.

Menu items

Menu items are defined with the type ui_menu_entry_t (in uimenu.h):

typedef struct ui_menu_entry_s {
    char *string;
    ui_menu_entry_type_t type;
    ui_callback_t callback;
    ui_callback_data_t data;
    ui_menu_status_type_t status;
} ui_menu_entry_t;

The string is used to display the item text in the menus. It is used by sdl_ui_display_item() to render a menu item. The type determines what to do when the user activates the item, types include radio buttons, toggle buttons, submenus, and dialogs. When an item is activated the callback is called with data as its argument. The return value of the callback (a const char*) is used to update the item's state or to exit the UI (more on that later). The status field is used for radio buttons to display the selection's state (or something like that).

The various menu item types are defined as:

typedef enum {
    /* Text item (no operation): if data == 1 text colors are inverted */
    MENU_ENTRY_TEXT = 0,

    /* Resource toggle: no UI needed, callback is used */
    MENU_ENTRY_RESOURCE_TOGGLE,

    /* Resource radio: no UI needed, callback is used, data is the resource value */
    MENU_ENTRY_RESOURCE_RADIO,

    /* Resource int: needs UI, callback is used */
    MENU_ENTRY_RESOURCE_INT,

    /* Resource string: needs UI, callback is used */
    MENU_ENTRY_RESOURCE_STRING,

    /* Submenu: needs UI, data points to the submenu */
    MENU_ENTRY_SUBMENU,

    /* Dynamic submenu: needs UI, data points to the submenu, hotkeys disabled */
    MENU_ENTRY_DYNAMIC_SUBMENU,

    /* Custom dialog: needs UI */
    MENU_ENTRY_DIALOG,

    /* Other: no UI needed */
    MENU_ENTRY_OTHER,

    /* Other: no UI needed */
    MENU_ENTRY_OTHER_TOGGLE
} ui_menu_entry_type_t;