Commit: a74a8dfede49be8963de64d24f906c40e90c1186
Author: Antonio Vazquez
Date:   Wed Jul 11 16:21:13 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rBa74a8dfede49be8963de64d24f906c40e90c1186

New template for grease pencil material previews

This is the initial step to prepare the use of material previews in the topbar 
as color selector.

We need a new template to hide some elements of the default template.

Still the preview of the material is not available.

===================================================================

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

===================================================================

diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py 
b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 77c6e65258b..28e960fa913 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -1003,7 +1003,7 @@ class _defs_gpencil_paint:
                 row.prop(gp_settings, "gpencil_fill_simplyfy_level", 
text="Simplify")
 
                 row = layout.row()
-                row.template_ID(gp_settings, "material")
+                row.template_greasepencil_color(gp_settings, "material", 
rows=3, cols=8)
 
                 row = layout.row(align=True)
                 row.prop(gp_settings, "gpencil_fill_draw_mode", text="")
@@ -1018,7 +1018,7 @@ class _defs_gpencil_paint:
                 row.prop(gp_settings, "use_strength_pressure", text="", 
icon='STYLUS_PRESSURE')
 
                 row = layout.row(align=True)
-                row.template_ID(gp_settings, "material")
+                row.template_greasepencil_color(gp_settings, "material", 
rows=3, cols=8)
 
     @staticmethod
     def generate_from_brushes(context):
diff --git a/source/blender/editors/include/UI_interface.h 
b/source/blender/editors/include/UI_interface.h
index 753fdd07567..07ed6f715a4 100644
--- a/source/blender/editors/include/UI_interface.h
+++ b/source/blender/editors/include/UI_interface.h
@@ -1052,6 +1052,9 @@ void uiTemplatePathBuilder(
         struct PointerRNA *root_ptr, const char *text);
 uiLayout *uiTemplateModifier(uiLayout *layout, struct bContext *C, struct 
PointerRNA *ptr);
 uiLayout *uiTemplateGpencilModifier(uiLayout *layout, struct bContext *C, 
struct PointerRNA *ptr);
+void uiTemplateGpencilColorPreview(
+       uiLayout *layout, struct bContext *C, struct PointerRNA *ptr, const 
char *propname,
+       int rows, int cols, int filter);
 
 uiLayout *uiTemplateShaderFx(uiLayout *layout, struct bContext *C, struct 
PointerRNA *ptr);
 
diff --git a/source/blender/editors/interface/interface_templates.c 
b/source/blender/editors/interface/interface_templates.c
index de0ff77ac92..566ce833770 100644
--- a/source/blender/editors/interface/interface_templates.c
+++ b/source/blender/editors/interface/interface_templates.c
@@ -951,6 +951,17 @@ void uiTemplateIDPreview(
                rows, cols, filter, false);
 }
 
+void uiTemplateGpencilColorPreview(
+       uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname,
+       int rows, int cols, int filter)
+{
+       ui_template_id(
+               layout, C, ptr, propname,
+               NULL, NULL, NULL,
+               UI_ID_BROWSE | UI_ID_PREVIEWS,
+               rows, cols, filter, false);
+}
+
 /**
  * Version of #uiTemplateID using tabs.
  */
diff --git a/source/blender/makesrna/intern/rna_ui_api.c 
b/source/blender/makesrna/intern/rna_ui_api.c
index 531a7f76bcd..a7e6cd8f1d6 100644
--- a/source/blender/makesrna/intern/rna_ui_api.c
+++ b/source/blender/makesrna/intern/rna_ui_api.c
@@ -852,6 +852,14 @@ void RNA_api_ui_layout(StructRNA *srna)
        parm = RNA_def_pointer(func, "layout", "UILayout", "", "Sub-layout to 
put items in");
        RNA_def_function_return(func, parm);
 
+       func = RNA_def_function(srna, "template_greasepencil_color", 
"uiTemplateGpencilColorPreview");
+       RNA_def_function_flag(func, FUNC_USE_CONTEXT);
+       api_ui_item_rna_common(func);
+       RNA_def_int(func, "rows", 0, 0, INT_MAX, "Number of thumbnail preview 
rows to display", "", 0, INT_MAX);
+       RNA_def_int(func, "cols", 0, 0, INT_MAX, "Number of thumbnail preview 
columns to display", "", 0, INT_MAX);
+       RNA_def_enum(func, "filter", id_template_filter_items, 
UI_TEMPLATE_ID_FILTER_ALL,
+               "", "Optionally limit the items which can be selected");
+
        func = RNA_def_function(srna, "template_constraint", 
"uiTemplateConstraint");
        RNA_def_function_ui_description(func, "Generates the UI layout for 
constraints");
        parm = RNA_def_pointer(func, "data", "Constraint", "", "Constraint 
data");

_______________________________________________
Bf-blender-cvs mailing list
Bf-blender-cvs@blender.org
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to