diff options
Diffstat (limited to 'source/blender/editors/interface/interface_templates.c')
-rw-r--r-- | source/blender/editors/interface/interface_templates.c | 78 |
1 files changed, 44 insertions, 34 deletions
diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index ef9b16f5445..ba827285ace 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -443,7 +443,8 @@ static void template_ID(bContext *C, uiLayout *layout, TemplateID *template, Str but->icon = RNA_struct_ui_icon(type); /* default dragging of icon for id browse buttons */ uiButSetDragID(but, id); - uiButSetFlag(but, UI_HAS_ICON | UI_ICON_LEFT); + uiButSetFlag(but, UI_HAS_ICON); + uiButSetDrawFlag(but, UI_BUT_ICON_LEFT); } if ((idfrom && idfrom->lib) || !editable) @@ -1482,7 +1483,6 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand TIP_("Delete the active position")); uiButSetNFunc(bt, colorband_del_cb, MEM_dupallocN(cb), coba); - /* XXX, todo for later - convert to operator - campbell */ bt = uiDefBut(block, BUT, 0, "F", 95 + xoffs, line1_y, 20, UI_UNIT_Y, NULL, 0, 0, 0, 0, TIP_("Flip colorband")); @@ -1500,8 +1500,6 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand bt = uiDefBut(block, BUT_COLORBAND, 0, "", xoffs, line2_y, 300, UI_UNIT_Y, coba, 0, 0, 0, 0, ""); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); - - if (coba->tot) { CBData *cbd = coba->data + coba->cur; @@ -1519,8 +1517,10 @@ static void colorband_buttons_large(uiLayout *layout, uiBlock *block, ColorBand } -static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand *coba, rctf *butr, RNAUpdateCb *cb) +static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand *coba, const rctf *butr, + RNAUpdateCb *cb) { + uiLayout *row; uiBut *bt; float unit = BLI_rctf_size_x(butr) / 14.0f; float xs = butr->xmin; @@ -1537,25 +1537,35 @@ static void colorband_buttons_small(uiLayout *layout, uiBlock *block, ColorBand uiButSetNFunc(bt, colorband_flip_cb, MEM_dupallocN(cb), coba); uiBlockEndAlign(block); - if (coba->tot) { - CBData *cbd = coba->data + coba->cur; - PointerRNA ptr; - RNA_pointer_create(cb->ptr.id.data, &RNA_ColorRampElement, cbd, &ptr); - uiItemR(layout, &ptr, "color", 0, "", ICON_NONE); - } + row = uiLayoutRow(layout, FALSE); bt = uiDefButS(block, MENU, 0, IFACE_("Interpolation %t|Ease %x1|Cardinal %x3|Linear %x0|B-Spline %x2|Constant %x4"), xs + 10.0f * unit, butr->ymin + UI_UNIT_Y, unit * 4, UI_UNIT_Y, &coba->ipotype, 0.0, 0.0, 0, 0, TIP_("Set interpolation between color stops")); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); + row = uiLayoutRow(layout, FALSE); + bt = uiDefBut(block, BUT_COLORBAND, 0, "", xs, butr->ymin, BLI_rctf_size_x(butr), UI_UNIT_Y, coba, 0, 0, 0, 0, ""); uiButSetNFunc(bt, rna_update_cb, MEM_dupallocN(cb), NULL); - uiBlockEndAlign(block); + if (coba->tot) { + CBData *cbd = coba->data + coba->cur; + PointerRNA ptr; + + RNA_pointer_create(cb->ptr.id.data, &RNA_ColorRampElement, cbd, &ptr); + + row = uiLayoutRow(layout, FALSE); + + uiItemR(row, &ptr, "position", 0, IFACE_("Pos"), ICON_NONE); + bt = block->buttons.last; + uiButSetFunc(bt, colorband_update_cb, bt, coba); + + uiItemR(row, &ptr, "color", 0, "", ICON_NONE); + } } -static void colorband_buttons_layout(uiLayout *layout, uiBlock *block, ColorBand *coba, rctf *butr, +static void colorband_buttons_layout(uiLayout *layout, uiBlock *block, ColorBand *coba, const rctf *butr, int small, RNAUpdateCb *cb) { if (small) @@ -2474,11 +2484,7 @@ static void uilist_draw_item_default(struct uiList *ui_list, struct bContext *UN struct PointerRNA *UNUSED(active_dataptr), const char *UNUSED(active_propname), int UNUSED(index), int UNUSED(flt_flag)) { - char *namebuf; - const char *name; - - namebuf = RNA_struct_name_get_alloc(itemptr, NULL, 0, NULL); - name = (namebuf) ? namebuf : ""; + PropertyRNA *nameprop = RNA_struct_name_property(itemptr->type); /* Simplest one! */ switch (ui_list->layout_type) { @@ -2488,14 +2494,14 @@ static void uilist_draw_item_default(struct uiList *ui_list, struct bContext *UN case UILST_LAYOUT_DEFAULT: case UILST_LAYOUT_COMPACT: default: - uiItemL(layout, name, icon); + if (nameprop) { + uiItemFullR(layout, itemptr, nameprop, RNA_NO_INDEX, 0, UI_ITEM_R_NO_BG, "", icon); + } + else { + uiItemL(layout, "", icon); + } break; } - - /* free name */ - if (namebuf) { - MEM_freeN(namebuf); - } } static void uilist_draw_filter_default(struct uiList *ui_list, struct bContext *UNUSED(C), struct uiLayout *layout) @@ -2557,7 +2563,7 @@ static void uilist_filter_items_default(struct uiList *ui_list, struct bContext dyn_data->items_shown = 0; /* Implicitly add heading/trailing wildcards if needed. */ - if (len + 3 <= 32) { + if (slen + 3 <= sizeof(filter_buff)) { filter = filter_buff; } else { @@ -2666,8 +2672,11 @@ static void prepare_list(uiList *ui_list, int len, int activei, int rows, int ma if (columns == 0) columns = 9; - if (ui_list->list_grip >= rows) { - maxrows = rows = ui_list->list_grip; + if (ui_list->list_grip >= (rows - 1) && ui_list->list_grip != 0) { + /* Only enable auto-size mode when we have dragged one row away from minimum size. + * Avoids to switch too easily to auto-size mode when resizing to minimum size... + */ + maxrows = rows = max_ii(ui_list->list_grip, rows); } else { ui_list->list_grip = 0; /* Reset to auto-size mode. */ @@ -2712,8 +2721,8 @@ static void prepare_list(uiList *ui_list, int len, int activei, int rows, int ma } void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, const char *list_id, - PointerRNA *dataptr, const char *propname, PointerRNA *active_dataptr, - const char *active_propname, int rows, int maxrows, int layout_type, int columns) + PointerRNA *dataptr, const char *propname, PointerRNA *active_dataptr, const char *active_propname, + int rows, int maxrows, int layout_type, int columns) { uiListType *ui_list_type; uiList *ui_list = NULL; @@ -2939,7 +2948,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co but = uiDefButR_prop(subblock, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, active_dataptr, activeprop, 0, 0, org_i, 0, 0, NULL); - uiButSetFlag(but, UI_BUT_NO_TOOLTIP); + uiButSetDrawFlag(but, UI_BUT_NO_TOOLTIP); sub = uiLayoutRow(overlap, FALSE); @@ -2949,7 +2958,6 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co draw_item(ui_list, C, sub, dataptr, itemptr, icon, active_dataptr, active_propname, org_i, flt_flag); - /* If we are "drawing" active item, set all labels as active. */ if (i == activei) { ui_layout_list_set_labels_active(sub); @@ -2975,7 +2983,9 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co case UILST_LAYOUT_COMPACT: row = uiLayoutRow(layout, TRUE); - if (dataptr->data && prop && dyn_data->items_shown > 0) { + if ((dataptr->data && prop) && (dyn_data->items_shown > 0) && + (activei >= 0) && (activei < dyn_data->items_shown)) + { PointerRNA *itemptr = &items_ptr[activei].item; int org_i = items_ptr[activei].org_idx; @@ -3026,7 +3036,7 @@ void uiTemplateList(uiLayout *layout, bContext *C, const char *listtype_name, co but = uiDefButR_prop(subblock, LISTROW, 0, "", 0, 0, UI_UNIT_X * 10, UI_UNIT_Y, active_dataptr, activeprop, 0, 0, org_i, 0, 0, NULL); - uiButSetFlag(but, UI_BUT_NO_TOOLTIP); + uiButSetDrawFlag(but, UI_BUT_NO_TOOLTIP); sub = uiLayoutRow(overlap, FALSE); @@ -3303,7 +3313,7 @@ void uiTemplateReportsBanner(uiLayout *layout, bContext *C) ui_abs = uiLayoutAbsolute(layout, FALSE); block = uiLayoutGetBlock(ui_abs); - width = BLF_width(style->widget.uifont_id, report->message); + width = BLF_width(style->widget.uifont_id, report->message, report->len); width = min_ii((int)(rti->widthfac * width), width); width = max_ii(width, 10); |