diff options
author | Julian Eisel <julian@blender.org> | 2022-05-12 18:30:18 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2022-05-12 18:41:26 +0300 |
commit | 766340856db31e2b13e57e91b2ef612d6e49949c (patch) | |
tree | d6b0b5f3b65a58f5cbaf12c6443fb49bd6a3ec0c /source/blender/editors/interface/interface.cc | |
parent | d1f32b63eb0cfa5055471853db831a362ca80831 (diff) |
UI Code Quality: Use derived struct for hot-key buttons
`uiBut` contained a variable that was only used for these hot-key
buttons. This may also help getting rid of the `UI_BUT_IMMEDIATE` flag,
which is also only used for this button type. We are running out of
available bits for flags, so this would be useful.
Continuing the work from 49f088e2d093. Part of T74432.
Diffstat (limited to 'source/blender/editors/interface/interface.cc')
-rw-r--r-- | source/blender/editors/interface/interface.cc | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc index f316198a160..8774a177c7d 100644 --- a/source/blender/editors/interface/interface.cc +++ b/source/blender/editors/interface/interface.cc @@ -3832,21 +3832,22 @@ static void ui_but_update_ex(uiBut *but, const bool validate) } case UI_BTYPE_HOTKEY_EVENT: if (but->flag & UI_SELECT) { + const uiButHotkeyEvent *hotkey_but = (uiButHotkeyEvent *)but; - if (but->modifier_key) { + if (hotkey_but->modifier_key) { char *str = but->drawstr; but->drawstr[0] = '\0'; - if (but->modifier_key & KM_SHIFT) { + if (hotkey_but->modifier_key & KM_SHIFT) { str += BLI_strcpy_rlen(str, "Shift "); } - if (but->modifier_key & KM_CTRL) { + if (hotkey_but->modifier_key & KM_CTRL) { str += BLI_strcpy_rlen(str, "Ctrl "); } - if (but->modifier_key & KM_ALT) { + if (hotkey_but->modifier_key & KM_ALT) { str += BLI_strcpy_rlen(str, "Alt "); } - if (but->modifier_key & KM_OSKEY) { + if (hotkey_but->modifier_key & KM_OSKEY) { str += BLI_strcpy_rlen(str, "Cmd "); } @@ -3972,6 +3973,10 @@ static void ui_but_alloc_info(const eButType type, alloc_size = sizeof(uiButTreeRow); alloc_str = "uiButTreeRow"; break; + case UI_BTYPE_HOTKEY_EVENT: + alloc_size = sizeof(uiButHotkeyEvent); + alloc_str = "uiButHotkeyEvent"; + break; default: alloc_size = sizeof(uiBut); alloc_str = "uiBut"; |