diff options
Diffstat (limited to 'source/blender/editors/interface/interface_layout.c')
-rw-r--r-- | source/blender/editors/interface/interface_layout.c | 91 |
1 files changed, 66 insertions, 25 deletions
diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 529cb0712df..a6f8ba4560d 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -63,7 +63,9 @@ * giving more room for the text at the expense of nicely aligned text. */ #define UI_PROP_SEP_ICON_WIDTH_EXCEPTION -/************************ Structs and Defines *************************/ +/* -------------------------------------------------------------------- */ +/** \name Structs and Defines + * \{ */ #define UI_OPERATOR_ERROR_RET(_ot, _opname, return_statement) \ if (ot == NULL) { \ @@ -128,8 +130,8 @@ typedef struct uiItem { } uiItem; enum { - UI_ITEM_FIXED = 1 << 0, - UI_ITEM_MIN = 1 << 1, + UI_ITEM_AUTO_FIXED_SIZE = 1 << 0, + UI_ITEM_FIXED_SIZE = 1 << 1, UI_ITEM_BOX_ITEM = 1 << 2, /* The item is "inside" a box item */ UI_ITEM_PROP_SEP = 1 << 3, @@ -211,7 +213,11 @@ typedef struct uiLayoutItemRoot { uiLayout litem; } uiLayoutItemRoot; -/************************** Item ***************************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Item + * \{ */ static const char *ui_item_name_add_colon(const char *name, char namestr[UI_MAX_NAME_STR]) { @@ -301,7 +307,7 @@ static int ui_text_icon_width(uiLayout *layout, const char *name, int icon, bool return unit_x; /* No icon or name. */ } if (layout->alignment != UI_LAYOUT_ALIGN_EXPAND) { - layout->item.flag |= UI_ITEM_MIN; + layout->item.flag |= UI_ITEM_FIXED_SIZE; } const uiFontStyle *fstyle = UI_FSTYLE_WIDGET; float margin = compact ? 1.25 : 1.50; @@ -408,7 +414,11 @@ static void ui_item_move(uiItem *item, int delta_xmin, int delta_xmax) } } -/******************** Special RNA Items *********************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Special RNA Items + * \{ */ int uiLayoutGetLocalDir(const uiLayout *layout) { @@ -1088,7 +1098,11 @@ void UI_context_active_but_prop_get_filebrowser(const bContext *C, } } -/********************* Button Items *************************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Button Items + * \{ */ /** * Update a buttons tip with an enum's description if possible. @@ -1096,7 +1110,8 @@ void UI_context_active_but_prop_get_filebrowser(const bContext *C, static void ui_but_tip_from_enum_item(uiBut *but, const EnumPropertyItem *item) { if (but->tip == NULL || but->tip[0] == '\0') { - if (item->description && item->description[0]) { + if (item->description && item->description[0] && + !(but->optype && but->optype->get_description)) { but->tip = item->description; } } @@ -3235,7 +3250,11 @@ void uiItemTabsEnumR_prop( ui_item_enum_expand_tabs(layout, C, block, ptr, prop, NULL, UI_UNIT_Y, icon_only); } -/**************************** Layout Items ***************************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Layout Items + * \{ */ /* single-row layout */ static void ui_litem_estimate_row(uiLayout *litem) @@ -3250,7 +3269,7 @@ static void ui_litem_estimate_row(uiLayout *litem) for (item = litem->items.first; item; item = item->next) { ui_item_size(item, &itemw, &itemh); - min_size_flag = min_size_flag && (item->flag & UI_ITEM_MIN); + min_size_flag = min_size_flag && (item->flag & UI_ITEM_FIXED_SIZE); litem->w += itemw; litem->h = MAX2(itemh, litem->h); @@ -3261,7 +3280,7 @@ static void ui_litem_estimate_row(uiLayout *litem) } if (min_size_flag) { - litem->item.flag |= UI_ITEM_MIN; + litem->item.flag |= UI_ITEM_FIXED_SIZE; } } @@ -3307,7 +3326,7 @@ static void ui_litem_layout_row(uiLayout *litem) extra_pixel = 0.0f; for (item = litem->items.first; item; item = item->next) { - if (item->flag & UI_ITEM_FIXED) { + if (item->flag & UI_ITEM_AUTO_FIXED_SIZE) { continue; } @@ -3323,18 +3342,19 @@ static void ui_litem_layout_row(uiLayout *litem) x += neww; - bool min_flag = item->flag & UI_ITEM_MIN; + bool min_flag = item->flag & UI_ITEM_FIXED_SIZE; /* ignore min flag for rows with right or center alignment */ if (item->type != ITEM_BUTTON && ELEM(((uiLayout *)item)->alignment, UI_LAYOUT_ALIGN_RIGHT, UI_LAYOUT_ALIGN_CENTER) && - litem->alignment == UI_LAYOUT_ALIGN_EXPAND && ((uiItem *)litem)->flag & UI_ITEM_MIN) { + litem->alignment == UI_LAYOUT_ALIGN_EXPAND && + ((uiItem *)litem)->flag & UI_ITEM_FIXED_SIZE) { min_flag = false; } if ((neww < minw || min_flag) && w != 0) { /* fixed size */ - item->flag |= UI_ITEM_FIXED; - if (item->type != ITEM_BUTTON && item->flag & UI_ITEM_MIN) { + item->flag |= UI_ITEM_AUTO_FIXED_SIZE; + if (item->type != ITEM_BUTTON && item->flag & UI_ITEM_FIXED_SIZE) { minw = itemw; } fixedw += minw; @@ -3343,7 +3363,7 @@ static void ui_litem_layout_row(uiLayout *litem) } else { /* keep free size */ - item->flag &= ~UI_ITEM_FIXED; + item->flag &= ~UI_ITEM_AUTO_FIXED_SIZE; freew += itemw; } } @@ -3361,9 +3381,9 @@ static void ui_litem_layout_row(uiLayout *litem) ui_item_size(item, &itemw, &itemh); minw = ui_litem_min_width(itemw); - if (item->flag & UI_ITEM_FIXED) { + if (item->flag & UI_ITEM_AUTO_FIXED_SIZE) { /* fixed minimum size items */ - if (item->type != ITEM_BUTTON && item->flag & UI_ITEM_MIN) { + if (item->type != ITEM_BUTTON && item->flag & UI_ITEM_FIXED_SIZE) { minw = itemw; } itemw = ui_item_fit( @@ -3404,7 +3424,7 @@ static void ui_litem_layout_row(uiLayout *litem) uiItem *last_item = litem->items.last; extra_pixel = litem->w - (x - litem->x); if (extra_pixel > 0 && litem->alignment == UI_LAYOUT_ALIGN_EXPAND && last_free_item && - last_item && last_item->flag & UI_ITEM_FIXED) { + last_item && last_item->flag & UI_ITEM_AUTO_FIXED_SIZE) { ui_item_move(last_free_item, 0, extra_pixel); for (item = last_free_item->next; item; item = item->next) { ui_item_move(item, extra_pixel, extra_pixel); @@ -3430,7 +3450,7 @@ static void ui_litem_estimate_column(uiLayout *litem, bool is_box) for (item = litem->items.first; item; item = item->next) { ui_item_size(item, &itemw, &itemh); - min_size_flag = min_size_flag && (item->flag & UI_ITEM_MIN); + min_size_flag = min_size_flag && (item->flag & UI_ITEM_FIXED_SIZE); litem->w = MAX2(litem->w, itemw); litem->h += itemh; @@ -3441,7 +3461,7 @@ static void ui_litem_estimate_column(uiLayout *litem, bool is_box) } if (min_size_flag) { - litem->item.flag |= UI_ITEM_MIN; + litem->item.flag |= UI_ITEM_FIXED_SIZE; } } @@ -4260,7 +4280,7 @@ static void ui_litem_layout_absolute(uiLayout *litem) static void ui_litem_estimate_split(uiLayout *litem) { ui_litem_estimate_row(litem); - litem->item.flag &= ~UI_ITEM_MIN; + litem->item.flag &= ~UI_ITEM_FIXED_SIZE; } static void ui_litem_layout_split(uiLayout *litem) @@ -4733,7 +4753,11 @@ int uiLayoutGetEmboss(uiLayout *layout) } } -/********************** Layout *******************/ +/** \} */ + +/* -------------------------------------------------------------------- */ +/** \name Layout + * \{ */ static void ui_item_scale(uiLayout *litem, const float scale[2]) { @@ -5076,7 +5100,7 @@ void ui_layout_add_but(uiLayout *layout, uiBut *but) /* XXX uiBut hasn't scaled yet * we can flag the button as not expandable, depending on its size */ if (w <= 2 * UI_UNIT_X && (!but->str || but->str[0] == '\0')) { - bitem->item.flag |= UI_ITEM_MIN; + bitem->item.flag |= UI_ITEM_FIXED_SIZE; } if (layout->child_items_layout) { @@ -5096,6 +5120,21 @@ void ui_layout_add_but(uiLayout *layout, uiBut *but) } } +void uiLayoutSetFixedSize(uiLayout *layout, bool fixed_size) +{ + if (fixed_size) { + layout->item.flag |= UI_ITEM_FIXED_SIZE; + } + else { + layout->item.flag &= ~UI_ITEM_FIXED_SIZE; + } +} + +bool uiLayoutGetFixedSize(uiLayout *layout) +{ + return (layout->item.flag & UI_ITEM_FIXED_SIZE) != 0; +} + void uiLayoutSetOperatorContext(uiLayout *layout, int opcontext) { layout->root->opcontext = opcontext; @@ -5267,3 +5306,5 @@ void UI_paneltype_draw(bContext *C, PanelType *pt, uiLayout *layout) CTX_store_set(C, NULL); } } + +/** \} */ |