UI: add scale option for template_icon_view button

The existing scale option only changed the scale if icons in the popup.
This commit is contained in:
Campbell Barton 2019-01-02 18:18:54 +11:00
parent 15e63742e2
commit a76b045326
4 changed files with 18 additions and 9 deletions

View File

@ -4426,7 +4426,7 @@ class VIEW3D_PT_shading_lighting(Panel):
if not system.edit_studio_light:
sub.scale_y = 0.6 # smaller studiolight preview
sub.template_icon_view(shading, "studio_light", scale=3)
sub.template_icon_view(shading, "studio_light", scale_popup=3.0)
else:
sub.prop(system, "edit_studio_light", text="Disable Studio Light Edit", icon='NONE', toggle=True)
@ -4446,7 +4446,7 @@ class VIEW3D_PT_shading_lighting(Panel):
elif shading.light == 'MATCAP':
sub.scale_y = 0.6 # smaller matcap preview
sub.template_icon_view(shading, "studio_light", scale=3)
sub.template_icon_view(shading, "studio_light", scale_popup=3.0)
col = split.column()
col.operator("wm.studiolight_userpref_show", emboss=False, text="", icon='PREFERENCES')
@ -4463,7 +4463,7 @@ class VIEW3D_PT_shading_lighting(Panel):
col = split.column()
sub = col.row()
sub.scale_y = 0.6
sub.template_icon_view(shading, "studio_light", scale=3)
sub.template_icon_view(shading, "studio_light", scale_popup=3)
col = split.column()
col.operator("wm.studiolight_userpref_show", emboss=False, text="", icon='PREFERENCES')

View File

@ -1087,7 +1087,9 @@ void uiTemplatePreview(
struct MTex *slot, const char *preview_id);
void uiTemplateColorRamp(uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool expand);
void uiTemplateIcon(uiLayout *layout, int icon_value, float icon_scale);
void uiTemplateIconView(uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool show_labels, float icon_scale);
void uiTemplateIconView(
uiLayout *layout, struct PointerRNA *ptr, const char *propname, bool show_labels,
float icon_scale, float icon_scale_popup);
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);

View File

@ -2650,7 +2650,9 @@ static uiBlock *ui_icon_view_menu_cb(bContext *C, ARegion *ar, void *arg_litem)
/**
* \param icon_scale: Scale of the icon, 1x == button height.
*/
void uiTemplateIconView(uiLayout *layout, PointerRNA *ptr, const char *propname, bool show_labels, float icon_scale)
void uiTemplateIconView(
uiLayout *layout, PointerRNA *ptr, const char *propname, bool show_labels,
float icon_scale, float icon_scale_popup)
{
PropertyRNA *prop = RNA_struct_find_property(ptr, propname);
IconViewMenuArgs *cb_args;
@ -2677,12 +2679,16 @@ 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;
cb_args->icon_scale = icon_scale_popup;
but = uiDefBlockButN(block, ui_icon_view_menu_cb, cb_args, "", 0, 0, UI_UNIT_X * 6, UI_UNIT_Y * 6, "");
but = uiDefBlockButN(
block, ui_icon_view_menu_cb, cb_args, "",
0, 0, UI_UNIT_X * icon_scale, UI_UNIT_Y * icon_scale, "");
}
else {
but = uiDefIconBut(block, UI_BTYPE_LABEL, 0, ICON_X, 0, 0, UI_UNIT_X * 6, UI_UNIT_Y * 6, NULL, 0.0, 0.0, 0.0, 0.0, "");
but = uiDefIconBut(
block, UI_BTYPE_LABEL, 0, ICON_X,
0, 0, UI_UNIT_X * icon_scale, UI_UNIT_Y * icon_scale, NULL, 0.0, 0.0, 0.0, 0.0, "");
}

View File

@ -941,7 +941,8 @@ 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);
RNA_def_float(func, "scale", 6.0f, 1.0f, 100.0f, "UI Units", "Scale the button icon size (by the button size)", 1.0f, 100.0f);
RNA_def_float(func, "scale_popup", 5.0f, 1.0f, 100.0f, "Scale", "Scale the popup 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");