[Bf-blender-cvs] [014325fdd2e] greasepencil-object: Move PaletteColors to Materials tab

Antonio Vazquez noreply at git.blender.org
Wed Jun 7 12:01:36 CEST 2017


Commit: 014325fdd2e42f68980b14864737fe2a87db7505
Author: Antonio Vazquez
Date:   Wed Jun 7 12:01:13 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB014325fdd2e42f68980b14864737fe2a87db7505

Move PaletteColors to Materials tab

Although the grease pencil colors aren't real materials, in order to keep UI consistency, we have moved to this tab the palette control.

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

M	release/scripts/startup/bl_ui/__init__.py
A	release/scripts/startup/bl_ui/properties_material_gpencil.py
M	release/scripts/startup/bl_ui/space_view3d_toolbar.py
M	source/blender/editors/space_buttons/buttons_context.c

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

diff --git a/release/scripts/startup/bl_ui/__init__.py b/release/scripts/startup/bl_ui/__init__.py
index cbf744c3fba..e525bd1f0e5 100644
--- a/release/scripts/startup/bl_ui/__init__.py
+++ b/release/scripts/startup/bl_ui/__init__.py
@@ -45,6 +45,7 @@ _modules = [
     "properties_game",
     "properties_mask_common",
     "properties_material",
+    "properties_material_gpencil",
     "properties_object",
     "properties_paint_common",
     "properties_grease_pencil_common",
diff --git a/release/scripts/startup/bl_ui/properties_material_gpencil.py b/release/scripts/startup/bl_ui/properties_material_gpencil.py
new file mode 100644
index 00000000000..d7834bb7dbf
--- /dev/null
+++ b/release/scripts/startup/bl_ui/properties_material_gpencil.py
@@ -0,0 +1,55 @@
+# ##### BEGIN GPL LICENSE BLOCK #####
+#
+#  This program is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU General Public License
+#  as published by the Free Software Foundation; either version 2
+#  of the License, or (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU General Public License for more details.
+#
+#  You should have received a copy of the GNU General Public License
+#  along with this program; if not, write to the Free Software Foundation,
+#  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ##### END GPL LICENSE BLOCK #####
+
+# <pep8 compliant>
+import bpy
+from bpy.types import Panel
+from bl_ui.properties_grease_pencil_common import (
+        GreasePencilPaletteColorPanel
+        )
+
+
+class MaterialButtonsPanel:
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'WINDOW'
+    bl_context = "material"
+
+    @classmethod
+    def poll(cls, context):
+        return context.object and context.object.type == 'GPENCIL'
+
+
+class MATERIAL_PT_gpencil_palettecolor(GreasePencilPaletteColorPanel, Panel):
+    bl_space_type = 'PROPERTIES'
+    bl_region_type = 'WINDOW'
+    bl_context = "material"
+
+    @classmethod
+    def poll(cls, context):
+        return context.object and context.object.type == 'GPENCIL'
+    # NOTE: this is just a wrapper around the generic GP Panel
+
+
+classes = (
+    MATERIAL_PT_gpencil_palettecolor,
+)
+
+if __name__ == "__main__":  # only for live edit.
+    from bpy.utils import register_class
+    for cls in classes:
+        register_class(cls)
\ No newline at end of file
diff --git a/release/scripts/startup/bl_ui/space_view3d_toolbar.py b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
index 8fd96f75530..8a9362516e9 100644
--- a/release/scripts/startup/bl_ui/space_view3d_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_view3d_toolbar.py
@@ -26,7 +26,6 @@ from bl_ui.properties_grease_pencil_common import (
         GreasePencilInterpolatePanel,
         GreasePencilStrokeSculptPanel,
         GreasePencilBrushPanel,
-        GreasePencilPaletteColorPanel,
         GreasePencilBrushCurvesPanel
         )
 from bl_ui.properties_paint_common import (
@@ -1981,10 +1980,6 @@ class VIEW3D_PT_tools_grease_pencil_sculpt(GreasePencilStrokeSculptPanel, Panel)
 class VIEW3D_PT_tools_grease_pencil_brush(GreasePencilBrushPanel, Panel):
     bl_space_type = 'VIEW_3D'
 
-# Grease Pencil colors (using blendpalettes)
-class VIEW3D_PT_tools_grease_pencil_palettecolor(GreasePencilPaletteColorPanel, Panel):
-    bl_space_type = 'VIEW_3D'
-
 # Grease Pencil drawingcurves
 class VIEW3D_PT_tools_grease_pencil_brushcurves(GreasePencilBrushCurvesPanel, Panel):
     bl_space_type = 'VIEW_3D'
@@ -2073,7 +2068,6 @@ classes = (
     VIEW3D_PT_tools_grease_pencil_interpolate,
     VIEW3D_PT_tools_grease_pencil_sculpt,
     VIEW3D_PT_tools_grease_pencil_brush,
-    VIEW3D_PT_tools_grease_pencil_palettecolor,
     VIEW3D_PT_tools_grease_pencil_brushcurves,
     VIEW3D_PT_tools_history,
 )
diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c
index eb22284c9a1..6d317948f21 100644
--- a/source/blender/editors/space_buttons/buttons_context.c
+++ b/source/blender/editors/space_buttons/buttons_context.c
@@ -593,6 +593,7 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
 	SpaceButs *sbuts = CTX_wm_space_buts(C);
 	ID *id;
 	int found;
+	Object *ob = CTX_data_active_object(C);
 
 	memset(path, 0, sizeof(*path));
 	path->flag = flag;
@@ -649,6 +650,12 @@ static int buttons_context_path(const bContext *C, ButsContextPath *path, int ma
 			found = buttons_context_path_particle(path);
 			break;
 		case BCONTEXT_MATERIAL:
+			/* the colors of grease pencil are not real materials, but to keep UI consistency, we
+			   simulate and generate a path */
+			if (ob && ob->type == OB_GPENCIL) {
+				found = buttons_context_path_data(path, -1);
+				break;
+			}
 			found = buttons_context_path_material(path, false, (sbuts->texuser != NULL));
 			break;
 		case BCONTEXT_TEXTURE:




More information about the Bf-blender-cvs mailing list