diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-10-29 18:58:34 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-10-29 21:04:07 +0300 |
commit | b5667c2ca7f7cc33903b7f664dfbd3bccd8cdd22 (patch) | |
tree | 189f7a60d860c563c6abf37899aae3fcf85c46cf /source/blender/editors/interface/interface_widgets.c | |
parent | 4c7f08e5ebc107e13501a5b1e82a44edeaf7b7c3 (diff) |
UI: allow off/on icons to be in reverse order.
The same icons are reused for "hide" and "show" properties, which need
to be in reverse order compared to each other.
Diffstat (limited to 'source/blender/editors/interface/interface_widgets.c')
-rw-r--r-- | source/blender/editors/interface/interface_widgets.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 99022a14b6a..b8a661c5542 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2016,6 +2016,21 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b } } +static BIFIconID widget_icon_id(uiBut *but) +{ + if (!(but->flag & UI_HAS_ICON)) { + return ICON_NONE; + } + + /* Consecutive icons can be toggle between. */ + if (but->drawflag & UI_BUT_ICON_REVERSE) { + return but->icon - but->iconadd; + } + else { + return but->icon + but->iconadd; + } +} + /* draws text and icons for buttons */ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *but, rcti *rect) { @@ -2039,7 +2054,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB /* Big previews with optional text label below */ if (but->flag & UI_BUT_ICON_PREVIEW && ui_block_is_menu(but->block)) { - const BIFIconID icon = (but->flag & UI_HAS_ICON) ? but->icon + but->iconadd : ICON_NONE; + const BIFIconID icon = widget_icon_id(but); int icon_size = BLI_rcti_size_y(rect); int text_size = 0; @@ -2076,7 +2091,7 @@ static void widget_draw_text_icon(uiFontStyle *fstyle, uiWidgetColors *wcol, uiB } #endif - const BIFIconID icon = (but->flag & UI_HAS_ICON) ? but->icon + but->iconadd : ICON_NONE; + const BIFIconID icon = widget_icon_id(but); int icon_size_init = is_tool ? ICON_DEFAULT_HEIGHT_TOOLBAR : ICON_DEFAULT_HEIGHT; const float icon_size = icon_size_init / (but->block->aspect / UI_DPI_FAC); const float icon_padding = 2 * UI_DPI_FAC; |