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.
This commit is contained in:
@@ -6153,7 +6153,7 @@ class VIEW3D_PT_overlay_motion_tracking(Panel):
|
||||
|
||||
def draw_header(self, context):
|
||||
view = context.space_data
|
||||
self.layout.prop(view, "show_reconstruction", text="")
|
||||
self.layout.prop(view, "show_reconstruction", text=self.bl_label)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user