[Bf-blender-cvs] [9fee39af71b] greasepencil-object: Move onion skin settings to GP datablock

Antonio Vazquez noreply at git.blender.org
Fri Sep 15 10:35:19 CEST 2017


Commit: 9fee39af71b8f408a6a2e056643864791aedb257
Author: Antonio Vazquez
Date:   Fri Sep 15 10:34:59 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB9fee39af71b8f408a6a2e056643864791aedb257

Move onion skin settings to GP datablock

Now that we have GP object, it's better to move onion skining settings at object level and keeep only a flag to enable disable at layer level.

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

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	release/scripts/startup/bl_ui/space_view3d.py
M	source/blender/blenkernel/intern/gpencil.c
M	source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
M	source/blender/editors/gpencil/drawgpencil.c
M	source/blender/makesdna/DNA_gpencil_types.h
M	source/blender/makesrna/intern/rna_gpencil.c

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

diff --git a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
index 6c823e87e26..7f81e7e721f 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -946,6 +946,11 @@ class GPENCIL_UL_layer(UIList):
             row.prop(gpl, "lock", text="", emboss=False)
             row.prop(gpl, "hide", text="", emboss=False)
             row.prop(gpl, "unlock_color", text="", emboss=False)
+            if gpl.use_onion_skinning is False:
+                icon = 'GHOST_DISABLED'
+            else:
+                icon = 'GHOST_ENABLED'
+            row.prop(gpl, "use_onion_skinning", text="", icon=icon, emboss=False)
         elif self.layout_type == 'GRID':
             layout.alignment = 'CENTER'
             layout.label(text="", icon_value=icon)
@@ -1222,52 +1227,51 @@ class GreasePencilOnionPanel:
     @staticmethod
     def draw(self, context):
         layout = self.layout
-        gpl = context.active_gpencil_layer
+        gpd = context.gpencil_data
 
         col = layout.column(align=True)
-        col.active = not gpl.lock
 
         row = col.row()
-        row.prop(gpl, "use_onion_skinning")
+        row.prop(gpd, "use_onion_skinning")
         sub = row.row(align=True)
-        icon = 'RESTRICT_RENDER_OFF' if gpl.use_ghosts_always else 'RESTRICT_RENDER_ON'
-        sub.prop(gpl, "use_ghosts_always", text="", icon=icon)
-        sub.prop(gpl, "use_ghost_custom_colors", text="", icon='COLOR')
+        icon = 'RESTRICT_RENDER_OFF' if gpd.use_ghosts_always else 'RESTRICT_RENDER_ON'
+        sub.prop(gpd, "use_ghosts_always", text="", icon=icon)
+        sub.prop(gpd, "use_ghost_custom_colors", text="", icon='COLOR')
 
         split = col.split(percentage=0.5)
-        split.active = gpl.use_onion_skinning
+        split.active = gpd.use_onion_skinning
 
         # - Before Frames
         sub = split.column(align=True)
         row = sub.row(align=True)
-        row.active = gpl.use_ghost_custom_colors
-        row.prop(gpl, "before_color", text="")
+        row.active = gpd.use_ghost_custom_colors
+        row.prop(gpd, "before_color", text="")
 
         # - After Frames
         sub = split.column(align=True)
         row = sub.row(align=True)
-        row.active = gpl.use_ghost_custom_colors
-        row.prop(gpl, "after_color", text="")
-
-        row = layout.row(align=True)
-        row.active = gpl.use_onion_skinning
-        row.prop(gpl, "onion_mode", text="Mode")
+        row.active = gpd.use_ghost_custom_colors
+        row.prop(gpd, "after_color", text="")
 
         split = layout.split(percentage=0.5)
-        split.active = gpl.onion_mode in ('ABSOLUTE', 'RELATIVE')
+        split.active = gpd.onion_mode in ('ABSOLUTE', 'RELATIVE')
         sub = split.column(align=True)
-        sub.prop(gpl, "ghost_before_range", text="Before")
+        sub.prop(gpd, "ghost_before_range", text="Before")
 
         sub = split.column(align=True)
-        sub.prop(gpl, "ghost_after_range", text="After")
+        sub.prop(gpd, "ghost_after_range", text="After")
+
+        row = layout.row(align=True)
+        row.active = gpd.use_onion_skinning
+        row.prop(gpd, "onion_mode", text="Mode")
 
         split = layout.split(percentage=0.5)
-        split.active = gpl.use_onion_skinning
+        split.active = gpd.use_onion_skinning
         sub = split.column(align=True)
-        sub.prop(gpl, "use_onion_fade", text="Fade")
+        sub.prop(gpd, "use_onion_fade", text="Fade")
 
         sub = split.column(align=True)
-        sub.prop(gpl, "onion_factor", text="Opacity", slider=True)
+        sub.prop(gpd, "onion_factor", text="Opacity", slider=True)
 
 
 class GreasePencilParentLayerPanel:
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 82104ab199f..d38ccd97969 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -156,9 +156,7 @@ class VIEW3D_HT_header(Header):
                 row.operator("gpencil.paste", text="", icon='PASTEDOWN')
 
             # XXX: icon
-            gpl = context.active_gpencil_layer
-            if gpl:
-                layout.prop(gpl, "use_onion_skinning", text="Onion Skins", icon='PARTICLE_PATH')
+            layout.prop(gpd, "use_onion_skinning", text="Onion Skins", icon='PARTICLE_PATH')
 
             if gpd.use_stroke_edit_mode or gpd.is_stroke_sculpt_mode:
                 row = layout.row(align=True)
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index fac61828c37..97b90387c61 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -461,12 +461,7 @@ bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd, const char *name, bool setacti
 	gpl->opacity = 1.0f;
 
 	/* onion-skinning settings */
-	gpl->flag |= (GP_LAYER_GHOST_PREVCOL | GP_LAYER_GHOST_NEXTCOL);
-	gpl->flag |= GP_LAYER_ONION_FADE;
-	gpl->onion_factor = 0.5f;
-	
-	ARRAY_SET_ITEMS(gpl->gcolor_prev, 0.145098f, 0.419608f, 0.137255f); /* green */
-	ARRAY_SET_ITEMS(gpl->gcolor_next, 0.125490f, 0.082353f, 0.529412f); /* blue */
+	gpl->flag |= GP_LAYER_ONIONSKIN;
 	
 	/* auto-name */
 	BLI_strncpy(gpl->info, name, sizeof(gpl->info));
@@ -773,6 +768,12 @@ bGPdata *BKE_gpencil_data_addnew(const char name[])
 	gpd->batch_cache_data = NULL;
 	gpd->pixfactor = GP_DEFAULT_PIX_FACTOR;
 	ARRAY_SET_ITEMS(gpd->line_color, 0.6f, 0.6f, 0.6f, 0.3f);
+	/* onion-skinning settings */
+	gpd->onion_flag |= (GP_ONION_GHOST_PREVCOL | GP_ONION_GHOST_NEXTCOL);
+	gpd->onion_flag |= GP_ONION_FADE;
+	gpd->onion_factor = 0.5f;
+	ARRAY_SET_ITEMS(gpd->gcolor_prev, 0.145098f, 0.419608f, 0.137255f); /* green */
+	ARRAY_SET_ITEMS(gpd->gcolor_next, 0.125490f, 0.082353f, 0.529412f); /* blue */
 
 	return gpd;
 }
diff --git a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
index 33589b84790..8221115a13f 100644
--- a/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
+++ b/source/blender/draw/engines/gpencil/gpencil_draw_cache_impl.c
@@ -848,8 +848,8 @@ static void gpencil_draw_onionskins(GpencilBatchCache *cache, GPENCIL_e_data *e_
 	/* -------------------------------
 	 * 1) Draw Previous Frames First
 	 * ------------------------------- */
-	if (gpl->flag & GP_LAYER_GHOST_PREVCOL) {
-		copy_v3_v3(color, gpl->gcolor_prev);
+	if (gpd->onion_flag & GP_ONION_GHOST_PREVCOL) {
+		copy_v3_v3(color, gpd->gcolor_prev);
 	}
 	else {
 		copy_v3_v3(color, default_color);
@@ -858,30 +858,30 @@ static void gpencil_draw_onionskins(GpencilBatchCache *cache, GPENCIL_e_data *e_
 	idx = 0;
 	for (bGPDframe *gf = gpf->prev; gf; gf = gf->prev) {
 		/* only selected frames */
-		if ((gpl->onion_mode == GP_ONION_MODE_SELECTED) && ((gf->flag & GP_FRAME_SELECT) == 0)) {
+		if ((gpd->onion_mode == GP_ONION_MODE_SELECTED) && ((gf->flag & GP_FRAME_SELECT) == 0)) {
 			continue;
 		}
 		/* absolute range */
-		if (gpl->onion_mode == GP_ONION_MODE_ABSOLUTE) {
-			if ((gpf->framenum - gf->framenum) > gpl->gstep) {
+		if (gpd->onion_mode == GP_ONION_MODE_ABSOLUTE) {
+			if ((gpf->framenum - gf->framenum) > gpd->gstep) {
 				break;
 			}
 		}
 		/* relative range */
-		if (gpl->onion_mode == GP_ONION_MODE_RELATIVE) {
+		if (gpd->onion_mode == GP_ONION_MODE_RELATIVE) {
 			++idx;
-			if (idx > gpl->gstep) {
+			if (idx > gpd->gstep) {
 				break;
 			}
 
 		}
 		/* alpha decreases with distance from curframe index */
-		if (gpl->onion_mode != GP_ONION_MODE_SELECTED) {
-			if (gpl->onion_mode == GP_ONION_MODE_ABSOLUTE) {
-				fac = 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpl->gstep + 1));
+		if (gpd->onion_mode != GP_ONION_MODE_SELECTED) {
+			if (gpd->onion_mode == GP_ONION_MODE_ABSOLUTE) {
+				fac = 1.0f - ((float)(gpf->framenum - gf->framenum) / (float)(gpd->gstep + 1));
 			}
 			else {
-				fac = 1.0f - ((float)idx / (float)(gpl->gstep + 1));
+				fac = 1.0f - ((float)idx / (float)(gpd->gstep + 1));
 			}
 			color[3] = alpha * fac * 0.66f;
 		}
@@ -891,20 +891,20 @@ static void gpencil_draw_onionskins(GpencilBatchCache *cache, GPENCIL_e_data *e_
 			color[3] = fac;
 		}
 		/* if fade is disabled, opacity is equal in all frames */
-		if ((gpl->flag & GP_LAYER_ONION_FADE) == 0) {
+		if ((gpd->onion_flag & GP_ONION_FADE) == 0) {
 			color[3] = 0.66f;
 		}
 		/* add override opacity factor */
-		color[3] += gpl->onion_factor - 0.5f;
+		color[3] += gpd->onion_factor - 0.5f;
 
 		CLAMP(color[3], 0.3f, 1.0f);
-		gpencil_draw_onion_strokes(cache, e_data, vedata, ob, gpd, gpl, gf, color, gpl->flag & GP_LAYER_GHOST_PREVCOL);
+		gpencil_draw_onion_strokes(cache, e_data, vedata, ob, gpd, gpl, gf, color, gpd->onion_flag & GP_ONION_GHOST_PREVCOL);
 	}
 	/* -------------------------------
 	 * 2) Now draw next frames
 	 * ------------------------------- */
-	if (gpl->flag & GP_LAYER_GHOST_NEXTCOL) {
-		copy_v3_v3(color, gpl->gcolor_next);
+	if (gpd->onion_flag & GP_ONION_GHOST_NEXTCOL) {
+		copy_v3_v3(color, gpd->gcolor_next);
 	}
 	else {
 		copy_v3_v3(color, default_color);
@@ -913,30 +913,30 @@ static void gpencil_draw_onionskins(GpencilBatchCache *cache, GPENCIL_e_data *e_
 	idx = 0;
 	for (bGPDframe *gf = gpf->next; gf; gf = gf->next) {
 		/* only selected frames */
-		if ((gpl->onion_mode == GP_ONION_MODE_SELECTED) && ((gf->flag & GP_FRAME_SELECT) == 0)) {
+		if ((gpd->onion_mode == GP_ONION_MODE_SELECTED) && ((gf->flag & GP_FRAME_SELECT) == 0)) {
 			continue;
 		}
 		/* absolute range */
-		if (gpl->onion_mode == GP_ONION_MODE_ABSOLUTE) {
-			if ((gf->framenum - gpf->framenum) > gpl->gstep_next) {
+		if (gpd->onion_mode == GP_ONION_MODE_ABSOLUTE) {
+			if ((gf->framenum - gpf->framenum) > gpd->gstep_next) {
 				break;
 			}
 		}
 		/* relative range */
-		if (gpl->onion_mode == GP_ONION_MODE_RELATIVE) {
+		if (gpd->onion_mode == GP_ONION_MODE_RELATIVE) {
 			++idx;
-			if (idx > gpl->gstep_next) {
+			if (idx > gpd->gstep_next) {
 				break;
 			}
 
 		}
 		/* alpha decreases with distance from curframe index */
-		if (gpl

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list