diff options
author | Julian Eisel <julian@blender.org> | 2020-07-20 20:46:08 +0300 |
---|---|---|
committer | Julian Eisel <julian@blender.org> | 2020-07-20 20:54:43 +0300 |
commit | ed870f87b94224c195cbe2df14445e4808b7b5f3 (patch) | |
tree | 53e89876830445dc44fcf05c595a35dd91363a02 /source/blender/editors/interface/interface_layout.c | |
parent | d40c39fca0fc3b87d852f672844687eb824c3d42 (diff) |
Fix weird placement of "Motion Tracking" in 3D View overlay popup
There was a weird looking gap between the checkbox and the "Motion Tracking"
label. Plus, the label could not be clicked to change the value, unlike
usually.
Issue is that the row is actually a sub-panel header. The checkbox being drawn
with the draw_header() callback, and the label being added as separate item by
the popover panel code. This adds a hack so the checkbox can add the panel
label itself (the popup drawing skips adding the label then). That addresses
mentioned issues.
Diffstat (limited to 'source/blender/editors/interface/interface_layout.c')
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index f027a62cbfd..b707aaa0ee9 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -5540,6 +5540,26 @@ void UI_menutype_draw(bContext *C, MenuType *mt, struct uiLayout *layout) } } +static bool ui_layout_has_panel_label(const uiLayout *layout, const PanelType *pt) +{ + LISTBASE_FOREACH (uiItem *, subitem, &layout->items) { + if (subitem->type == ITEM_BUTTON) { + uiButtonItem *bitem = (uiButtonItem *)subitem; + if (!(bitem->but->flag & UI_HIDDEN) && STREQ(bitem->but->str, pt->label)) { + return true; + } + } + else { + uiLayout *litem = (uiLayout *)subitem; + if (ui_layout_has_panel_label(litem, pt)) { + return true; + } + } + } + + return false; +} + static void ui_paneltype_draw_impl(bContext *C, PanelType *pt, uiLayout *layout, bool show_header) { Panel *panel = MEM_callocN(sizeof(Panel), "popover panel"); @@ -5556,7 +5576,13 @@ static void ui_paneltype_draw_impl(bContext *C, PanelType *pt, uiLayout *layout, pt->draw_header(C, panel); panel->layout = NULL; } - uiItemL(row, CTX_IFACE_(pt->translation_context, pt->label), ICON_NONE); + + /* draw_header() is often used to add a checkbox to the header. If we add the label like below + * the label is disconnected from the checkbox, adding a weird looking gap. As workaround, let + * the checkbox add the label instead. */ + if (!ui_layout_has_panel_label(row, pt)) { + uiItemL(row, CTX_IFACE_(pt->translation_context, pt->label), ICON_NONE); + } } panel->layout = layout; |