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_layout.c | |
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_layout.c')
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index c1bb2ed6d18..98f3b974d1d 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -961,11 +961,17 @@ static void ui_item_enum_expand_tabs(uiLayout *layout, static void ui_keymap_but_cb(bContext *UNUSED(C), void *but_v, void *UNUSED(key_v)) { uiBut *but = but_v; - - RNA_int_set(&but->rnapoin, "shift", (but->modifier_key & KM_SHIFT) ? KM_MOD_HELD : KM_NOTHING); - RNA_int_set(&but->rnapoin, "ctrl", (but->modifier_key & KM_CTRL) ? KM_MOD_HELD : KM_NOTHING); - RNA_int_set(&but->rnapoin, "alt", (but->modifier_key & KM_ALT) ? KM_MOD_HELD : KM_NOTHING); - RNA_int_set(&but->rnapoin, "oskey", (but->modifier_key & KM_OSKEY) ? KM_MOD_HELD : KM_NOTHING); + BLI_assert(but->type == UI_BTYPE_HOTKEY_EVENT); + const uiButHotkeyEvent *hotkey_but = (uiButHotkeyEvent *)but; + + RNA_int_set( + &but->rnapoin, "shift", (hotkey_but->modifier_key & KM_SHIFT) ? KM_MOD_HELD : KM_NOTHING); + RNA_int_set( + &but->rnapoin, "ctrl", (hotkey_but->modifier_key & KM_CTRL) ? KM_MOD_HELD : KM_NOTHING); + RNA_int_set( + &but->rnapoin, "alt", (hotkey_but->modifier_key & KM_ALT) ? KM_MOD_HELD : KM_NOTHING); + RNA_int_set( + &but->rnapoin, "oskey", (hotkey_but->modifier_key & KM_OSKEY) ? KM_MOD_HELD : KM_NOTHING); } /** |