From 766340856db31e2b13e57e91b2ef612d6e49949c Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Thu, 12 May 2022 17:30:18 +0200 Subject: 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. --- source/blender/editors/interface/interface.cc | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'source/blender/editors/interface/interface.cc') 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"; -- cgit v1.2.3