From 7fc79615e0c88aff445178f17e9c267f11a0d791 Mon Sep 17 00:00:00 2001 From: Joshua Leung Date: Sat, 16 Mar 2013 03:59:03 +0000 Subject: Any ID Selector Template: ID Type dropdown now shows icon only as originally intended Finally, I've figured out a way to get the ID Selector Template to only show the icon for the type of ID block (i.e. the intended design), instead of icon+text. This improves the layout a bit, as previously the type selector and ID-block pointer and label would all be the same sizes (roughly 1/3rd of the overall width each), which meant that there wasn't much room left to actually see which datablock had been selected. Additionally, I've fixed a few more layout types which still didn't correctly propagate the red-alert flags. --- .../blender/editors/interface/interface_layout.c | 3 +++ .../editors/interface/interface_templates.c | 24 ++++++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index ea6ecadd924..2ca26ae5317 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -2369,6 +2369,7 @@ uiLayout *uiLayoutAbsolute(uiLayout *layout, int align) litem->active = 1; litem->enabled = 1; litem->context = layout->context; + litem->redalert = layout->redalert; BLI_addtail(&layout->items, litem); uiBlockSetCurLayout(layout->root->block, litem); @@ -2396,6 +2397,7 @@ uiLayout *uiLayoutOverlap(uiLayout *layout) litem->active = 1; litem->enabled = 1; litem->context = layout->context; + litem->redalert = layout->redalert; BLI_addtail(&layout->items, litem); uiBlockSetCurLayout(layout->root->block, litem); @@ -2415,6 +2417,7 @@ uiLayout *uiLayoutSplit(uiLayout *layout, float percentage, int align) split->litem.enabled = 1; split->litem.context = layout->context; split->litem.space = layout->root->style->columnspace; + split->litem.redalert = layout->redalert; split->litem.w = layout->w; split->percentage = percentage; BLI_addtail(&layout->items, split); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index ba278c21adb..103c9a0c9e9 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -669,7 +669,7 @@ void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, co const char *text) { PropertyRNA *propID, *propType; - uiLayout *row; + uiLayout *split, *row, *sub; /* get properties... */ propID = RNA_struct_find_property(ptr, propname); @@ -685,22 +685,34 @@ void uiTemplateAnyID(uiLayout *layout, PointerRNA *ptr, const char *propname, co } /* Start drawing UI Elements using standard defines */ - row = uiLayoutRow(layout, TRUE); + split = uiLayoutSplit(layout, 0.33f, FALSE); /* NOTE: split amount here needs to be synced with normal labels */ + + /* FIRST PART ................................................ */ + row = uiLayoutRow(split, FALSE); /* Label - either use the provided text, or will become "ID-Block:" */ if (text) { if (text[0]) uiItemL(row, text, ICON_NONE); } - else + else { uiItemL(row, IFACE_("ID-Block:"), ICON_NONE); + } + + /* SECOND PART ................................................ */ + row = uiLayoutRow(split, TRUE); /* ID-Type Selector - just have a menu of icons */ - /* FIXME: the icon-only setting doesn't work when we supply a blank name */ - uiItemFullR(row, ptr, propType, 0, 0, UI_ITEM_R_ICON_ONLY, "", ICON_NONE); + sub = uiLayoutRow(row, TRUE); /* HACK: special group just for the enum, otherwise we */ + uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_LEFT); /* we get ugly layout with text included too... */ + + uiItemFullR(sub, ptr, propType, 0, 0, UI_ITEM_R_ICON_ONLY, "", ICON_NONE); /* ID-Block Selector - just use pointer widget... */ - uiItemFullR(row, ptr, propID, 0, 0, 0, "", ICON_NONE); + sub = uiLayoutRow(row, TRUE); /* HACK: special group to counteract the effects of the previous */ + uiLayoutSetAlignment(sub, UI_LAYOUT_ALIGN_EXPAND); /* enum, which now pushes everything too far right */ + + uiItemFullR(sub, ptr, propID, 0, 0, 0, "", ICON_NONE); } /********************* RNA Path Builder Template ********************/ -- cgit v1.2.3