Page MenuHome

Initial step for new modal op info API: Get shortcuts from modal keymap.

Authored by Bastien Montagne (mont29) on Sep 9 2014, 11:55 AM.



First step for T37699.

note I hacked a bit around RNA enumitems system, to put shorter names into the 'tooltip' part... :|

Only Walk mode use it here, as a demo.

Diff Detail

rB Blender

Event Timeline

Bastien Montagne (mont29) retitled this revision from to Initial step for new modal op info API: Get shortcuts from modal keymap..
Bastien Montagne (mont29) updated this object.

Updated against latest master...

Campbell Barton (campbellbarton) requested changes to this revision.Mar 26 2015, 9:12 PM
Campbell Barton (campbellbarton) edited edge metadata.
Campbell Barton (campbellbarton) added inline comments.
348–388 ↗(On Diff #3392)

While having lower level functions like WM_modalkeymap_operator_items_to_string is good, this ends up being a bit verbose/boiler plate. It might be good to have something a bit higher level here.

A function that advances the string and adds the description text with the modal keymap.

eg, str += WM_modalkeymap_operator_items_to_string(str, WALK_MODAL_CONFIRM, "confirm", ... length info);

another alternative could be to use an array to cut down on repeating id's

/* could make this into a macro... */
 WM_modalkeymap_operator_items_to_string(op->type, WALK_MODAL_DECELERATE, key_table[WALK_MODAL_DECELERATE], SHORTCUT_LENGTH, true);

if we accept some slightly odd string usage we could even do this...

#define WM_MODALKEY(id) \
    WM_modalkeymap_operator_items_to_string_buf(op->type, id, &str_p)

char *str_p = str_buf;
BLI_snprintf(header, HEADER_LENGTH, IFACE_(
        "%s: confirm, %s: cancel, "
        "%s: gravity (%s), "
        "%s|%s|%s|%s: move around, "
        "%s: fast, %s: slow, "
        "%s|%s: up and down, %s: teleport, %s: jump, "
        "%s: increase speed, %s: decrease speed"),

Its a bit odd, but can be done so much less boiler plate then the alternatives. that it may be worth it.


BLI_strcpy_rlen seems a bit overkill here, could just do...

if (p != buf) *p++ = ' ';

again, for single chars str[totlen++] = '/'

This revision now requires changes to proceed.Mar 26 2015, 9:12 PM
Bastien Montagne (mont29) edited edge metadata.

Updated patch and addressed points/suggestions from review.

This revision is now accepted and ready to land.Jul 3 2015, 2:25 PM
This revision was automatically updated to reflect the committed changes.