diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2020-01-16 17:55:49 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2020-01-16 18:13:15 +0300 |
commit | d52551401e185a3e1092fb07edebd07d552e04e2 (patch) | |
tree | 0b109024b0acaedc9707f2d8034e8da82bf0d146 /source/blender/editors/interface/interface_layout.c | |
parent | 5b8c2301d8b7400013903fe0b02071ba19aafb9f (diff) |
Fix wrong usages of region align enumerations
`ARegion.alignment` unfortunately is a mixture of value and bitflag
enumerations. When checking for left/right/top/bottom region alignment,
the flags have to be masked out usually.
Most of the fixed cases here probably didn't cause issues in practice,
but could in fact break at any point when surrounding logic changes.
In fact the assert in #region_visible_rect_calc() failed in an older
file from https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=949035. This
fixes it.
Diffstat (limited to 'source/blender/editors/interface/interface_layout.c')
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 68cd450a451..179fe84264f 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1241,17 +1241,19 @@ static void ui_item_menu_hold(struct bContext *C, ARegion *butregion, uiBut *but char direction = UI_DIR_DOWN; if (!but->drawstr[0]) { - if (butregion->alignment == RGN_ALIGN_LEFT) { - direction = UI_DIR_RIGHT; - } - else if (butregion->alignment == RGN_ALIGN_RIGHT) { - direction = UI_DIR_LEFT; - } - else if (butregion->alignment == RGN_ALIGN_BOTTOM) { - direction = UI_DIR_UP; - } - else { - direction = UI_DIR_DOWN; + switch (RGN_ALIGN_ENUM_FROM_MASK(butregion->alignment)) { + case RGN_ALIGN_LEFT: + direction = UI_DIR_RIGHT; + break; + case RGN_ALIGN_RIGHT: + direction = UI_DIR_LEFT; + break; + case RGN_ALIGN_BOTTOM: + direction = UI_DIR_UP; + break; + default: + direction = UI_DIR_DOWN; + break; } } UI_block_direction_set(block, direction); |