[Bf-blender-cvs] [b1e4f1a8329] greasepencil-object: Remove Palette panels and fix write/read bugs
Antonio Vazquez
noreply at git.blender.org
Thu Apr 26 12:35:44 CEST 2018
Commit: b1e4f1a8329b5fcab7bb8e8abe2aa9732124ec95
Author: Antonio Vazquez
Date: Tue Apr 24 16:59:43 2018 +0200
Branches: greasepencil-object
https://developer.blender.org/rBb1e4f1a8329b5fcab7bb8e8abe2aa9732124ec95
Remove Palette panels and fix write/read bugs
Now the panels works with materials but still the drawing engine and operators is using the old palettes.
===================================================================
M release/scripts/startup/bl_ui/properties_material_gpencil.py
M source/blender/blenkernel/intern/gpencil.c
M source/blender/blenloader/intern/readfile.c
M source/blender/makesdna/DNA_object_types.h
===================================================================
diff --git a/release/scripts/startup/bl_ui/properties_material_gpencil.py b/release/scripts/startup/bl_ui/properties_material_gpencil.py
index 79bdd57b5e0..67ab780bd55 100644
--- a/release/scripts/startup/bl_ui/properties_material_gpencil.py
+++ b/release/scripts/startup/bl_ui/properties_material_gpencil.py
@@ -21,21 +21,40 @@ import bpy
from bpy.types import Panel, UIList
-class GPENCIL_UL_paletteslots(UIList):
+class GPENCIL_UL_matslots(UIList):
+
def draw_item(self, context, layout, data, item, icon, active_data, active_propname, index):
slot = item
- palette = slot.palette
- if self.layout_type in {'DEFAULT', 'COMPACT'}:
- if palette:
- layout.prop(palette, "name", text="", emboss=False, icon_value=icon)
- else:
+ ma = slot.material
+ if ma is not None:
+ gpcolor = ma.grease_pencil
+
+ if self.layout_type in {'DEFAULT', 'COMPACT'}:
+ if gpcolor.lock:
+ layout.active = False
+
+ split = layout.split(percentage=0.25)
+ row = split.row(align=True)
+ row.enabled = not gpcolor.lock
+ row.prop(gpcolor, "color_rgba", text="", emboss=gpcolor.is_stroke_visible)
+ row.prop(gpcolor, "fill_rgba", text="", emboss=gpcolor.is_fill_visible)
+ split.prop(ma, "name", text="", emboss=False)
+
+ row = layout.row(align=True)
+ row.prop(gpcolor, "lock", text="", emboss=False)
+ row.prop(gpcolor, "hide", text="", emboss=False)
+ if gpcolor.ghost is True:
+ icon = 'GHOST_DISABLED'
+ else:
+ icon = 'GHOST_ENABLED'
+ row.prop(gpcolor, "ghost", text="", icon=icon, emboss=False)
+
+ elif self.layout_type == 'GRID':
+ layout.alignment = 'CENTER'
layout.label(text="", icon_value=icon)
- elif self.layout_type == 'GRID':
- layout.alignment = 'CENTER'
- layout.label(text="", icon_value=icon)
-class MATERIAL_PT_gpencil_palette_slots(Panel):
+class MATERIAL_PT_gpencil_slots(Panel):
bl_label = "Palette Slots"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
@@ -44,79 +63,39 @@ class MATERIAL_PT_gpencil_palette_slots(Panel):
@classmethod
def poll(cls, context):
- return context.object and context.object.type == 'GPENCIL'
+ return context.object and context.object.type == 'GPENCIL' and context.object.active_material
@staticmethod
def draw(self, context):
layout = self.layout
gpd = context.gpencil_data
- row = layout.row()
- col = row.column()
- if len(gpd.palette_slots) >= 2:
- slot_rows = 5
- else:
- slot_rows = 2
- col.template_list("GPENCIL_UL_paletteslots", "", gpd, "palette_slots", gpd, "active_palette_index",
- rows=slot_rows)
-
- col = row.column()
-
- sub = col.column(align=True)
- sub.operator("gpencil.palette_slot_add", icon='ZOOMIN', text="")
- sub.operator("gpencil.palette_slot_remove", icon='ZOOMOUT', text="")
-
- sub = col.column(align=True)
- sub.operator_menu_enum("gpencil.stroke_change_palette", text="", icon='ARROW_LEFTRIGHT', property="type")
-
-
-class MATERIAL_PT_gpencil_palette_colors(Panel):
- bl_label = "Active Palette"
- bl_space_type = 'PROPERTIES'
- bl_region_type = 'WINDOW'
- bl_context = "material"
-
- @classmethod
- def poll(cls, context):
- return context.object and context.object.type == 'GPENCIL'
-
- @staticmethod
- def draw(self, context):
- layout = self.layout
-
- gpd = context.gpencil_data
- slot = gpd.active_palette_slot
- palette = context.active_gpencil_palette
+ mat = context.object.active_material
+ ob = context.object
+ slot = context.material_slot
+ space = context.space_data
- row = layout.row()
- row.template_ID(slot, "palette", new="palette.new_gpencil")
+ if ob:
+ is_sortable = len(ob.material_slots) > 1
+ rows = 1
+ if (is_sortable):
+ rows = 4
- if palette:
row = layout.row()
- col = row.column()
- if len(palette.colors) >= 2:
- color_rows = 6
- else:
- color_rows = 2
- col.template_list("GPENCIL_UL_palettecolor", "", palette, "colors", palette, "active_index",
- rows=color_rows)
- col = row.column()
+ row.template_list("GPENCIL_UL_matslots", "", ob, "material_slots", ob, "active_material_index", rows=rows)
- sub = col.column(align=True)
- sub.operator("palette.color_add", icon='ZOOMIN', text="")
- sub.operator("palette.color_delete", icon='ZOOMOUT', text="")
+ col = row.column(align=True)
+ col.operator("object.material_slot_add", icon='ZOOMIN', text="")
+ col.operator("object.material_slot_remove", icon='ZOOMOUT', text="")
- palcol = context.active_gpencil_palettecolor
- if palcol:
- sub.menu("GPENCIL_MT_palettecolor_specials", icon='DOWNARROW_HLT', text="")
+ col.menu("GPENCIL_MT_palettecolor_specials", icon='DOWNARROW_HLT', text="")
- if len(palette.colors) > 1:
+ if is_sortable:
col.separator()
- sub = col.column(align=True)
- sub.operator("palette.palettecolor_move", icon='TRIA_UP', text="").direction = 'UP'
- sub.operator("palette.palettecolor_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
+ col.operator("object.material_slot_move", icon='TRIA_UP', text="").direction = 'UP'
+ col.operator("object.material_slot_move", icon='TRIA_DOWN', text="").direction = 'DOWN'
col.separator()
@@ -124,8 +103,22 @@ class MATERIAL_PT_gpencil_palette_colors(Panel):
sub.operator("palette.palettecolor_isolate", icon='LOCKED', text="").affect_visibility = False
sub.operator("palette.palettecolor_isolate", icon='RESTRICT_VIEW_OFF', text="").affect_visibility = True
+ split = layout.split(percentage=0.65)
+
+ if ob:
+ split.template_ID(ob, "active_material", new="material.new")
+ row = split.row()
+
+ if slot:
+ row.prop(slot, "link", text="")
+ else:
+ row.label()
+ elif mat:
+ split.template_ID(space, "pin_id")
+ split.separator()
+
-class MATERIAL_PT_gpencil_palette_strokecolor(Panel):
+class MATERIAL_PT_gpencil_strokecolor(Panel):
bl_label = "Stroke"
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
@@ -134,49 +127,50 @@ class MATERIAL_PT_gpencil_palette_strokecolor(Panel):
@classmethod
def poll(cls, context):
- return context.object and context.object.type == 'GPENCIL' and context.active_gpencil_palettecolor
+ return context.object and context.object.type == 'GPENCIL' and context.object.active_material
@staticmethod
def draw(self, context):
layout = self.layout
- palette = context.active_gpencil_palette
- pcolor = palette.colors.active
-
- split = layout.split(percentage=1.0)
- split.active = not pcolor.lock
+ ma = context.object.active_material
+ if ma is not None:
+ gpcolor = ma.grease_pencil
- col = split.column(align=True)
- row = col.row(align=True)
- row.enabled = not pcolor.lock
- row.prop(pcolor, "mode", expand=True)
- col.separator()
-
- col.enabled = not pcolor.lock
- col.prop(pcolor, "stroke_style", text="")
-
- if pcolor.stroke_style == 'TEXTURE':
- row = layout.row()
- row.enabled = not pcolor.lock
- col = row.column(align=True)
- col.template_ID(pcolor, "stroke_image", open="image.open")
- col.prop(pcolor, "use_pattern", text="Use as Pattern")
-
- if pcolor.stroke_style == 'SOLID' or pcolor.use_pattern is True:
+ split = layout.split(percentage=1.0)
+ split.active = not gpcolor.lock
+
+ col = split.column(align=True)
+ row = col.row(align=True)
+ row.enabled = not gpcolor.lock
+ row.prop(gpcolor, "mode", expand=True)
+ col.separator()
+
+ col.enabled = not gpcolor.lock
+ col.prop(gpcolor, "stroke_style", text="")
+
+ if gpcolor.stroke_style == 'TEXTURE':
+ row = layout.row()
+ row.enabled = not gpcolor.lock
+ col = row.column(align=True)
+ col.template_ID(gpcolor, "stroke_image", open="image.open")
+ col.prop(gpcolor, "use_pattern", text="Use as Pattern")
+
+ if gpcolor.stroke_style == 'SOLID' or gpcolor.use_pattern is True:
+ row = layout.row()
+ col = row.column(align=True)
+ col.prop(gpcolor, "color", text="")
+ col.prop(gpcolor, "alpha", slider=True)
+
+ # Options
row = layout.row()
+ row.active = not gpcolor.lock
col = row.column(align=True)
- col.prop(pcolor, "color", text="")
- col.prop(pcolor, "alpha", slider=True)
-
- # Options
- row = layout.row()
- row.active = not pcolor.lock
- col = row.column(align=True)
- col.prop(pcolor, "pass_index")
- if pcolor.stroke_style == 'TEXTURE':
- col.prop(pcolor, "pixel_size", text="UV Factor")
+ col.prop(gpcolor, "pass_index")
+ if gpcolor.stroke_style == 'TEXTURE':
+ col.prop(gpcolor, "pixel_size", text="UV Factor")
-class MATERIAL_PT_gpencil_palette_fillcolor(Panel):
+class MATERIAL_PT_gpencil_fillcolor(Panel):
bl_label = "Fill"
bl_space_type = 'PROPERTIES
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list