forked from bartvdbraak/blender
Add icon scale argument for ui-template-previews
This commit is contained in:
parent
e7b3803317
commit
0119539e4b
@ -889,7 +889,7 @@ uiLayout *uiTemplateConstraint(uiLayout *layout, struct PointerRNA *ptr);
|
||||
void uiTemplatePreview(uiLayout *layout, struct bContext *C, struct ID *id, int show_buttons, struct ID *parent,
|
||||
struct MTex *slot, const char *preview_id);
|
||||
void uiTemplateColorRamp(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int expand);
|
||||
void uiTemplateIconView(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int show_labels);
|
||||
void uiTemplateIconView(uiLayout *layout, struct PointerRNA *ptr, const char *propname, int show_labels, float icon_scale);
|
||||
void uiTemplateHistogram(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
|
||||
void uiTemplateWaveform(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
|
||||
void uiTemplateVectorscope(uiLayout *layout, struct PointerRNA *ptr, const char *propname);
|
||||
|
@ -1614,7 +1614,8 @@ void uiTemplateColorRamp(uiLayout *layout, PointerRNA *ptr, const char *propname
|
||||
typedef struct IconViewMenuArgs {
|
||||
PointerRNA ptr;
|
||||
PropertyRNA *prop;
|
||||
int show_labels;
|
||||
bool show_labels;
|
||||
float icon_scale;
|
||||
} IconViewMenuArgs;
|
||||
|
||||
/* ID Search browse menu, open */
|
||||
@ -1627,9 +1628,12 @@ static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *ar, void *arg_litem)
|
||||
EnumPropertyItem *item;
|
||||
int a;
|
||||
bool free;
|
||||
int w, h;
|
||||
|
||||
/* arg_litem is malloced, can be freed by parent button */
|
||||
args = *((IconViewMenuArgs *) arg_litem);
|
||||
w = UI_UNIT_X * (args.icon_scale);
|
||||
h = UI_UNIT_X * (args.icon_scale + args.show_labels);
|
||||
|
||||
block = UI_block_begin(C, ar, "_popup", UI_EMBOSS_PULLDOWN);
|
||||
UI_block_flag_enable(block, UI_BLOCK_LOOP);
|
||||
@ -1638,9 +1642,6 @@ static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *ar, void *arg_litem)
|
||||
|
||||
for (a = 0; item[a].identifier; a++) {
|
||||
int x, y;
|
||||
/* XXX hardcoded size to 5 units */
|
||||
const int w = UI_UNIT_X * 5;
|
||||
const int h = args.show_labels ? 6 * UI_UNIT_Y : UI_UNIT_Y * 5;
|
||||
|
||||
x = (a % 8) * w;
|
||||
y = (a / 8) * h;
|
||||
@ -1670,7 +1671,10 @@ static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *ar, void *arg_litem)
|
||||
return block;
|
||||
}
|
||||
|
||||
void uiTemplateIconView(uiLayout *layout, PointerRNA *ptr, const char *propname, int show_labels)
|
||||
/**
|
||||
* \param icon_scale: Scale of the icon, 1x == button height.
|
||||
*/
|
||||
void uiTemplateIconView(uiLayout *layout, PointerRNA *ptr, const char *propname, int show_labels, float icon_scale)
|
||||
{
|
||||
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
|
||||
IconViewMenuArgs *cb_args;
|
||||
@ -1695,6 +1699,7 @@ void uiTemplateIconView(uiLayout *layout, PointerRNA *ptr, const char *propname,
|
||||
cb_args->ptr = *ptr;
|
||||
cb_args->prop = prop;
|
||||
cb_args->show_labels = show_labels;
|
||||
cb_args->icon_scale = icon_scale;
|
||||
|
||||
but = uiDefBlockButN(block, ui_icon_view_menu_cb, cb_args, "", 0, 0, UI_UNIT_X * 6, UI_UNIT_Y * 6, "");
|
||||
|
||||
|
@ -724,6 +724,7 @@ void RNA_api_ui_layout(StructRNA *srna)
|
||||
RNA_def_function_ui_description(func, "Enum. Large widget showing Icon previews");
|
||||
api_ui_item_rna_common(func);
|
||||
RNA_def_boolean(func, "show_labels", false, "", "Show enum label in preview buttons");
|
||||
RNA_def_float(func, "scale", 5.0f, 1.0f, 100.0f, "Scale", "Scale the icon size (by the button size)", 1.0f, 100.0f);
|
||||
|
||||
func = RNA_def_function(srna, "template_histogram", "uiTemplateHistogram");
|
||||
RNA_def_function_ui_description(func, "Item. A histogramm widget to analyze imaga data");
|
||||
|
@ -473,7 +473,7 @@ void uiLayoutSetEnabled(uiLayout *layout, bool enabled) RET_NONE
|
||||
void uiLayoutSetAlignment(uiLayout *layout, char alignment) RET_NONE
|
||||
void uiLayoutSetScaleX(struct uiLayout *layout, float scale) RET_NONE
|
||||
void uiLayoutSetScaleY(struct uiLayout *layout, float scale) RET_NONE
|
||||
void uiTemplateIconView(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, int show_labels) RET_NONE
|
||||
void uiTemplateIconView(struct uiLayout *layout, struct PointerRNA *ptr, const char *propname, int show_labels, float icon_scale) RET_NONE
|
||||
void ED_base_object_free_and_unlink(struct Main *bmain, struct Scene *scene, struct Base *base) RET_NONE
|
||||
void ED_mesh_update(struct Mesh *mesh, struct bContext *C, int calc_edges, int calc_tessface) RET_NONE
|
||||
void ED_mesh_vertices_add(struct Mesh *mesh, struct ReportList *reports, int count) RET_NONE
|
||||
|
Loading…
Reference in New Issue
Block a user