UI: add scale option for template_icon_view button
authorCampbell Barton <ideasman42@gmail.com>
Wed, 2 Jan 2019 07:18:54 +0000 (18:18 +1100)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 2 Jan 2019 07:18:54 +0000 (18:18 +1100)
The existing scale option only changed the scale if icons in the popup.

release/scripts/startup/bl_ui/space_view3d.py
source/blender/editors/include/UI_interface.h
source/blender/editors/interface/interface_templates.c
source/blender/makesrna/intern/rna_ui_api.c

index 9c2f25b4fb131262cbfa4142132ce6460f8fba58..3fe3612e9fd61192a3727741475da4fa4032471d 100644 (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')
index 31956877d1b69bb0160a1f9ed6fcb5db23adb95a..b1dc5821d7a26097b602d64ab20e20a6ce2c5c27 100644 (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);
index 0d3aa43cd568c804602d809e7244456638a7d8fa..ec055ddb05bec202585fb072f8a65f4e02d73ca1 100644 (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, "");
        }
 
 
index fdf2b5f311bda5bcbed7f23b425046c2b4a3c332..0db0408d09fbd4ac037da63f296bde9f5cb22ff8 100644 (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");