[Bf-blender-cvs] [9b0fffbc74f] greasepencil-object: GPencil: Add Opacity y Onion switch to Dopesheet

Antonio Vazquez noreply at git.blender.org
Wed Nov 27 16:54:22 CET 2019


Commit: 9b0fffbc74fceb298fd7eba30971ff5f34833628
Author: Antonio Vazquez
Date:   Wed Nov 27 16:52:06 2019 +0100
Branches: greasepencil-object
https://developer.blender.org/rB9b0fffbc74fceb298fd7eba30971ff5f34833628

GPencil: Add Opacity y Onion switch to Dopesheet

These options are visible when enable Show Sliders.

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

M	source/blender/editors/animation/anim_channels_defines.c

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

diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c
index 8951677b32f..79000847866 100644
--- a/source/blender/editors/animation/anim_channels_defines.c
+++ b/source/blender/editors/animation/anim_channels_defines.c
@@ -4222,7 +4222,8 @@ void ANIM_channel_draw(
      * - Slider should start before the toggles (if they're visible)
      *   to keep a clean line down the side.
      */
-    if ((draw_sliders) && ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE, ANIMTYPE_SHAPEKEY)) {
+    if ((draw_sliders) &&
+        ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE, ANIMTYPE_SHAPEKEY, ANIMTYPE_GPLAYER)) {
       /* adjust offset */
       offset += SLIDER_WIDTH;
     }
@@ -4992,7 +4993,8 @@ void ANIM_channel_draw_widgets(const bContext *C,
      * - Slider should start before the toggles (if they're visible)
      *   to keep a clean line down the side.
      */
-    if ((draw_sliders) && ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE, ANIMTYPE_SHAPEKEY)) {
+    if ((draw_sliders) &&
+        ELEM(ale->type, ANIMTYPE_FCURVE, ANIMTYPE_NLACURVE, ANIMTYPE_SHAPEKEY, ANIMTYPE_GPLAYER)) {
       /* adjust offset */
       /* TODO: make slider width dynamic,
        * so that they can be easier to use when the view is wide enough. */
@@ -5053,7 +5055,48 @@ void ANIM_channel_draw_widgets(const bContext *C,
           rna_path = BKE_keyblock_curval_rnapath_get(key, kb);
           free_path = 1;
         }
+        /* Special for Grease Pencil Layer */
+        else if (ale->type == ANIMTYPE_GPLAYER) {
+          char *gp_rna_path = NULL;
+          bGPDlayer *gpl = (bGPDlayer *)ale->data;
+          const short width = SLIDER_WIDTH / 4;
+          /* create the RNA pointer */
+          RNA_pointer_create(ale->id, &RNA_GPencilLayer, ale->data, &ptr);
+          RNA_id_pointer_create(ale->id, &id_ptr);
+          uiBut *but;
 
+          /* Get pointer to the property too and return path. */
+          prop = RNA_struct_find_property(&ptr, "opacity");
+          gp_rna_path = RNA_path_from_ID_to_property(&ptr, prop);
+          if (RNA_path_resolve_property(&id_ptr, gp_rna_path, &ptr, &prop)) {
+            but = uiDefAutoButR(block,
+                                &ptr,
+                                prop,
+                                array_index,
+                                "",
+                                ICON_NONE,
+                                offset,
+                                ymid,
+                                width * 3,
+                                channel_height);
+          }
+          prop = RNA_struct_find_property(&ptr, "use_onion_skinning");
+          gp_rna_path = RNA_path_from_ID_to_property(&ptr, prop);
+          if (RNA_path_resolve_property(&id_ptr, gp_rna_path, &ptr, &prop)) {
+            int icon = (gpl->onion_flag & GP_LAYER_ONIONSKIN) ? ICON_ONIONSKIN_ON :
+                                                                ICON_ONIONSKIN_OFF;
+            but = uiDefAutoButR(block,
+                                &ptr,
+                                prop,
+                                array_index,
+                                "",
+                                icon,
+                                offset + (width * 3),
+                                ymid,
+                                width,
+                                channel_height);
+          }
+        }
         /* only if RNA-Path found */
         if (rna_path) {
           /* get RNA pointer, and resolve the path */



More information about the Bf-blender-cvs mailing list