GPencil UI: Color swatches for both Stroke and Fill colors are now shown
authorJoshua Leung <aligorith@gmail.com>
Sat, 27 Dec 2014 14:02:47 +0000 (03:02 +1300)
committerJoshua Leung <aligorith@gmail.com>
Sat, 27 Dec 2014 14:05:11 +0000 (03:05 +1300)
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)

release/scripts/startup/bl_ui/properties_grease_pencil_common.py
source/blender/editors/animation/anim_channels_defines.c
source/blender/makesrna/intern/rna_gpencil.c

index 82f18a154699559e4771075f29f4d85a6e3dc4cd..75f6921b0c3bed36a171417f6609852eceee98ee 100644 (file)
@@ -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)
index baab8a050305787e5d837c913a77fbf011763b06..9f992e1063a438b24e62ba69e788f22034921196 100644 (file)
@@ -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;
                }
index 96d02016336661c2938a6c893b1f80704c8158ac..6b61b37ce5ce67d217a543c3a9b7c382754e2a2e 100644 (file)
@@ -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");