diff options
author | Campbell Barton <ideasman42@gmail.com> | 2020-04-14 16:44:15 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2020-04-14 16:50:00 +0300 |
commit | 7bfb7450a2f3e51e68192d170d92672ac1f99332 (patch) | |
tree | bc087574bef6cddaba6dd4bccd92b73ee8b7f98a /source/blender | |
parent | de47bf69da1a220181074c966a5ee23ef5ed2f82 (diff) |
Fix showing check-boxes in menu-search
Diffstat (limited to 'source/blender')
4 files changed, 19 insertions, 18 deletions
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 9142aebd1ef..51fe990bd02 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -917,6 +917,7 @@ bool ui_but_is_toggle(const uiBut *but) ATTR_WARN_UNUSED_RESULT; bool ui_but_is_interactive(const uiBut *but, const bool labeledit) ATTR_WARN_UNUSED_RESULT; bool ui_but_is_popover_once_compat(const uiBut *but) ATTR_WARN_UNUSED_RESULT; bool ui_but_has_array_value(const uiBut *but) ATTR_WARN_UNUSED_RESULT; +int ui_but_icon(const uiBut *but); void ui_but_pie_dir(RadialDirection dir, float vec[2]); bool ui_but_is_cursor_warp(const uiBut *but) ATTR_WARN_UNUSED_RESULT; diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c index 70b4660e392..6d05fe15f97 100644 --- a/source/blender/editors/interface/interface_query.c +++ b/source/blender/editors/interface/interface_query.c @@ -161,6 +161,21 @@ bool UI_but_has_tooltip_label(const uiBut *but) return false; } +int ui_but_icon(const 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; + } +} + /** \} */ /* -------------------------------------------------------------------- */ diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index f730e4c0e52..1c1d7b8c766 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -6818,7 +6818,7 @@ static bool menu_items_from_ui_create_item_from_button(struct MenuSearch_Data *d if (item != NULL) { /* Handle shared settings. */ item->drawstr = strdup_memarena(memarena, but->drawstr); - item->icon = but->icon; + item->icon = ui_but_icon(but); item->state = (but->flag & (UI_BUT_DISABLED | UI_BUT_INACTIVE | UI_BUT_REDALERT)); item->mt = mt; item->drawstr_submenu = drawstr_submenu ? strdup_memarena(memarena, drawstr_submenu) : NULL; diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index 86a5fd5dabb..fe2debd4344 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -2376,21 +2376,6 @@ static void widget_draw_text(const uiFontStyle *fstyle, } } -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; - } -} - static void widget_draw_extra_icons(const uiWidgetColors *wcol, uiBut *but, rcti *rect, @@ -2433,7 +2418,7 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle, /* Big previews with optional text label below */ if (but->flag & UI_BUT_ICON_PREVIEW && ui_block_is_menu(but->block)) { - const BIFIconID icon = widget_icon_id(but); + const BIFIconID icon = ui_but_icon(but); int icon_size = BLI_rcti_size_y(rect); int text_size = 0; @@ -2470,7 +2455,7 @@ static void widget_draw_text_icon(const uiFontStyle *fstyle, } #endif - const BIFIconID icon = widget_icon_id(but); + const BIFIconID icon = ui_but_icon(but); int icon_size_init = is_tool ? ICON_DEFAULT_HEIGHT_TOOLBAR : ICON_DEFAULT_HEIGHT; const float icon_size = icon_size_init / (but->block->aspect * U.inv_dpi_fac); const float icon_padding = 2 * UI_DPI_FAC; |