[Bf-blender-cvs] [155bb05] master: GPencil UI: Color swatches for both Stroke and Fill colors are now shown

Joshua Leung noreply at git.blender.org
Sat Dec 27 15:06:33 CET 2014


Commit: 155bb058f4e03a108b06f150b57e273e62d4f339
Author: Joshua Leung
Date:   Sun Dec 28 03:02:47 2014 +1300
Branches: master
https://developer.blender.org/rB155bb058f4e03a108b06f150b57e273e62d4f339

GPencil UI: Color swatches for both Stroke and Fill colors are now shown

The layers list and the Dopesheet channels now show color swatches for both the
stroke and fill colours now. This is useful when you've got layers that only
use either/or.

* Currently, these only get shown if the relevant opacity setting is high enough
  for that aspect to contribute to the result.

* The sizing of these items could do with some more tweaking (especially in the
  Dopesheet), as these may now be too small to accurately see and/or interact with.

* There are some potential issues when using near-gray (or actually, colours similar
  to the list backgrounds, but that issue exists in other areas of Blender anyway.


(NOTE: At this stage, these changes are still experimental, and not for 2.73 yet)

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

M	release/scripts/startup/bl_ui/properties_grease_pencil_common.py
M	source/blender/editors/animation/anim_channels_defines.c
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 82f18a1..75f6921 100644
--- a/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
+++ b/release/scripts/startup/bl_ui/properties_grease_pencil_common.py
@@ -302,9 +302,11 @@ class GPENCIL_UL_layer(UIList):
             if gpl.lock:
                 layout.active = False
 
-            split = layout.split(percentage=0.2)
-            split.prop(gpl, "color", text="")
-            split.prop(gpl, "info", text="", emboss=False)
+            split = layout.split(percentage=0.25)
+            row = split.row(align=True)
+            row.prop(gpl, "color",      text="", emboss = gpl.is_stroke_visible)
+            row.prop(gpl, "fill_color", text="", emboss = gpl.is_fill_visible)
+            split.prop(gpl, "info",  text="", emboss=False)
 
             row = layout.row(align=True)
             row.prop(gpl, "lock", text="", emboss=False)
diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index baab8a0..9f992e1 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -3966,16 +3966,24 @@ void ANIM_channel_draw_widgets(bContext *C, bAnimContext *ac, bAnimListElem *ale
 			/* color swatch for layer color */
 			bGPDlayer *gpl = (bGPDlayer *)ale->data;
 			PointerRNA ptr;
+			float w = ICON_WIDTH / 2.0f;
 			
 			RNA_pointer_create(ale->id, &RNA_GPencilLayer, ale->data, &ptr);
 			
-			UI_block_emboss_set(block, UI_EMBOSS);
+			UI_block_align_begin(block);
 			
-			uiDefButR(block, UI_BTYPE_COLOR, 1, "", offset, yminc, ICON_WIDTH, ICON_WIDTH, 
+			UI_block_emboss_set(block, RNA_boolean_get(&ptr, "is_stroke_visible") ? UI_EMBOSS : UI_EMBOSS_NONE);
+			uiDefButR(block, UI_BTYPE_COLOR, 1, "", offset, yminc, w, ICON_WIDTH, 
 			          &ptr, "color", -1, 
 			          0, 0, 0, 0, gpl->info);
 			
+			UI_block_emboss_set(block, RNA_boolean_get(&ptr, "is_fill_visible") ? UI_EMBOSS : UI_EMBOSS_NONE);
+			uiDefButR(block, UI_BTYPE_COLOR, 1, "", offset + w, yminc, w, ICON_WIDTH, 
+			          &ptr, "fill_color", -1, 
+			          0, 0, 0, 0, gpl->info);
+			
 			UI_block_emboss_set(block, UI_EMBOSS_NONE);
+			UI_block_align_end(block);
 			
 			offset += ICON_WIDTH;
 		}
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 96d0201..6b61b37 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -104,6 +104,24 @@ static void rna_GPencilLayer_line_width_range(PointerRNA *ptr, int *min, int *ma
 	}
 }
 
+static int rna_GPencilLayer_is_stroke_visible_get(PointerRNA *ptr)
+{
+	/* see drawgpencil.c -> gp_draw_data_layers() for more details
+	 * about this limit for showing/not showing
+	 */
+	bGPDlayer *gpl = (bGPDlayer *)ptr->data;
+	return (gpl->color[3] > 0.001f);
+}
+
+static int rna_GPencilLayer_is_fill_visible_get(PointerRNA *ptr)
+{
+	/* see drawgpencil.c -> gp_draw_data_layers() for more details
+	 * about this limit for showing/not showing
+	 */
+	bGPDlayer *gpl = (bGPDlayer *)ptr->data;
+	return (gpl->fill[3] > 0.001f);
+}
+
 static PointerRNA rna_GPencil_active_layer_get(PointerRNA *ptr)
 {
 	bGPdata *gpd = ptr->id.data;
@@ -764,6 +782,17 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
 	RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
 	
 	
+	/* Read-only state props (for simpler UI code) */
+	prop = RNA_def_property(srna, "is_stroke_visible", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_funcs(prop, "rna_GPencilLayer_is_stroke_visible_get", NULL);
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "Is Stroke Visible", "True when opacity of stroke is set high enough to be visible");
+	
+	prop = RNA_def_property(srna, "is_fill_visible", PROP_BOOLEAN, PROP_NONE);
+	RNA_def_property_boolean_funcs(prop, "rna_GPencilLayer_is_fill_visible_get", NULL);
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "Is Fill Visible", "True when opacity of fill is set high enough to be visible");
+	
 	/* Layers API */
 	func = RNA_def_function(srna, "clear", "rna_GPencil_layer_clear");
 	RNA_def_function_ui_description(func, "Remove all the grease pencil layer data");




More information about the Bf-blender-cvs mailing list