GPv3: Mask toggle in dopesheet channel #121259

Merged
Falk David merged 2 commits from PratikPB2123/blender:gpv3-mask-channel-toggle into main 2024-05-01 15:10:33 +02:00
Member

Add use_mask property in dopesheet layer channel

Main PR
image image
Add `use_mask` property in dopesheet layer channel | Main | PR | | -- | -- | | ![image](/attachments/f86effea-2838-47d1-8f6f-a73c449b04cf) | ![image](/attachments/f846ccfc-4a9c-404b-bfe1-d6f919a5967d) |
Pratik Borhade added 1 commit 2024-04-30 12:43:14 +02:00
f0e5150ec4 GPv3: Mask toggle in dopesheet channel
Add `use_mask` property in dopesheet layer channel
Pratik Borhade requested review from Falk David 2024-04-30 12:43:32 +02:00
Pratik Borhade added the
Module
Grease Pencil
label 2024-04-30 12:43:40 +02:00
Pratik Borhade added this to the Grease Pencil project 2024-04-30 12:43:50 +02:00
Falk David reviewed 2024-04-30 12:48:52 +02:00
Falk David left a comment
Member

Thanks

Thanks
Falk David reviewed 2024-04-30 12:49:23 +02:00
@ -5588,0 +5593,4 @@
const std::optional<std::string> layer_mask_rna_path = RNA_path_from_ID_to_property(
&ptr, layer_mask_prop);
if (RNA_path_resolve_property(&id_ptr, layer_mask_rna_path->c_str(), &ptr, &layer_mask_prop)) {
const int icon = layer->use_masks() ? ICON_CLIPUV_DEHLT : ICON_CLIPUV_HLT;
Member

Does this work here? Thinking of the onion skinning icon.

Does this work here? Thinking of the onion skinning icon.
Author
Member

Hi, current changes are working, yes. That's why I included both on-off icons in screenshot 🙃


If we want this to work like onion_skinning, we could add RNA_def_property_ui_icon(prop, ICON_CLIPUV_DEHLT , 1); for use_masks in rna_grease_pencil.cc. This will also involve some changes inside interface_template_grease_pencil_layer_tree.cc for mask property

Hi, current changes are working, yes. That's why I included both on-off icons in screenshot 🙃 - - - If we want this to work like onion_skinning, we could add `RNA_def_property_ui_icon(prop, ICON_CLIPUV_DEHLT , 1);` for use_masks in `rna_grease_pencil.cc`. This will also involve some changes inside `interface_template_grease_pencil_layer_tree.cc` for mask property
Member

Right it might be better to make the icon part of the RNA property like you suggested. I think that should make it more consistent!

Right it might be better to make the icon part of the RNA property like you suggested. I think that should make it more consistent!
Author
Member

Actually, this doesn't work well for the use_mask property exposed in layer properties panel. The checkbox toggle shows the mask-icon. So I think it might be better to go with current definition 😅
image

Actually, this doesn't work well for the `use_mask` property exposed in layer properties panel. The checkbox toggle shows the mask-icon. So I think it might be better to go with current definition 😅 ![image](/attachments/89f8777c-3ef5-488e-8436-29e811d9e611)
Author
Member

Following diff works but changes I did in properties_data_grease_pencil.py are more like a hack to fix the wrong icon shown in the above image.
Let me know if this diff is: 1) needed in this PR 2) not needed 3) expected to be submitted as separate PR

git diff :)
diff --git a/scripts/startup/bl_ui/properties_data_grease_pencil.py b/scripts/startup/bl_ui/properties_data_grease_pencil.py
index 010ffb6dc8b..5d7d3a03aad 100644
--- a/scripts/startup/bl_ui/properties_data_grease_pencil.py
+++ b/scripts/startup/bl_ui/properties_data_grease_pencil.py
@@ -46,7 +46,7 @@ class GreasePencil_LayerMaskPanel:
         grease_pencil = ob.data
         layer = grease_pencil.layers.active

-        self.layout.prop(layer, "use_masks", text="")
+        self.layout.prop(layer, "use_masks", text="", toggle=0, invert_checkbox=True)

     def draw(self, context):
         layout = self.layout
diff --git a/source/blender/editors/animation/anim_channels_defines.cc b/source/blender/editors/animation/anim_channels_defines.cc
index b62512c5069..a0e8bd61b52 100644
--- a/source/blender/editors/animation/anim_channels_defines.cc
+++ b/source/blender/editors/animation/anim_channels_defines.cc
@@ -5599,7 +5599,7 @@ static void draw_grease_pencil_layer_widgets(bAnimListElem *ale,
                   layer_mask_prop,
                   array_index,
                   "",
-                  icon,
+                  ICON_CLIPUV_DEHLT,
                   offset,
                   rect->ymin,
                   ICON_WIDTH,
diff --git a/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc b/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc
index 316e237dea2..116daabcd61 100644
--- a/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc
+++ b/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc
@@ -261,7 +261,7 @@ class LayerViewItem : public AbstractTreeViewItem {
     const int icon_mask = (layer_.base.flag & GP_LAYER_TREE_NODE_HIDE_MASKS) == 0 ?
                               ICON_CLIPUV_DEHLT :
                               ICON_CLIPUV_HLT;
-    uiItemR(sub, &layer_ptr, "use_masks", UI_ITEM_R_ICON_ONLY, nullptr, icon_mask);
+    uiItemR(sub, &layer_ptr, "use_masks", UI_ITEM_R_ICON_ONLY, nullptr, ICON_NONE);

     sub = uiLayoutRow(&row, true);
     uiLayoutSetActive(sub, layer_.parent_group().use_onion_skinning());
diff --git a/source/blender/makesrna/intern/rna_grease_pencil.cc b/source/blender/makesrna/intern/rna_grease_pencil.cc
index 36d9eab488f..172a2b42737 100644
--- a/source/blender/makesrna/intern/rna_grease_pencil.cc
+++ b/source/blender/makesrna/intern/rna_grease_pencil.cc
@@ -409,6 +409,7 @@ static void rna_def_grease_pencil_layer(BlenderRNA *brna)

   /* Use Masks. */
   prop = RNA_def_property(srna, "use_masks", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_ui_icon(prop, ICON_CLIPUV_DEHLT, 1);
   RNA_def_property_boolean_negative_sdna(
       prop, "GreasePencilLayerTreeNode", "flag", GP_LAYER_TREE_NODE_HIDE_MASKS);
   RNA_def_property_ui_text(
Following diff works but changes I did in `properties_data_grease_pencil.py` are more like a hack to fix the wrong icon shown in the above image. Let me know if this diff is: 1) needed in this PR 2) not needed 3) expected to be submitted as separate PR <details> <summary> git diff :) </summary> ```Diff diff --git a/scripts/startup/bl_ui/properties_data_grease_pencil.py b/scripts/startup/bl_ui/properties_data_grease_pencil.py index 010ffb6dc8b..5d7d3a03aad 100644 --- a/scripts/startup/bl_ui/properties_data_grease_pencil.py +++ b/scripts/startup/bl_ui/properties_data_grease_pencil.py @@ -46,7 +46,7 @@ class GreasePencil_LayerMaskPanel: grease_pencil = ob.data layer = grease_pencil.layers.active - self.layout.prop(layer, "use_masks", text="") + self.layout.prop(layer, "use_masks", text="", toggle=0, invert_checkbox=True) def draw(self, context): layout = self.layout diff --git a/source/blender/editors/animation/anim_channels_defines.cc b/source/blender/editors/animation/anim_channels_defines.cc index b62512c5069..a0e8bd61b52 100644 --- a/source/blender/editors/animation/anim_channels_defines.cc +++ b/source/blender/editors/animation/anim_channels_defines.cc @@ -5599,7 +5599,7 @@ static void draw_grease_pencil_layer_widgets(bAnimListElem *ale, layer_mask_prop, array_index, "", - icon, + ICON_CLIPUV_DEHLT, offset, rect->ymin, ICON_WIDTH, diff --git a/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc b/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc index 316e237dea2..116daabcd61 100644 --- a/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc +++ b/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc @@ -261,7 +261,7 @@ class LayerViewItem : public AbstractTreeViewItem { const int icon_mask = (layer_.base.flag & GP_LAYER_TREE_NODE_HIDE_MASKS) == 0 ? ICON_CLIPUV_DEHLT : ICON_CLIPUV_HLT; - uiItemR(sub, &layer_ptr, "use_masks", UI_ITEM_R_ICON_ONLY, nullptr, icon_mask); + uiItemR(sub, &layer_ptr, "use_masks", UI_ITEM_R_ICON_ONLY, nullptr, ICON_NONE); sub = uiLayoutRow(&row, true); uiLayoutSetActive(sub, layer_.parent_group().use_onion_skinning()); diff --git a/source/blender/makesrna/intern/rna_grease_pencil.cc b/source/blender/makesrna/intern/rna_grease_pencil.cc index 36d9eab488f..172a2b42737 100644 --- a/source/blender/makesrna/intern/rna_grease_pencil.cc +++ b/source/blender/makesrna/intern/rna_grease_pencil.cc @@ -409,6 +409,7 @@ static void rna_def_grease_pencil_layer(BlenderRNA *brna) /* Use Masks. */ prop = RNA_def_property(srna, "use_masks", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_icon(prop, ICON_CLIPUV_DEHLT, 1); RNA_def_property_boolean_negative_sdna( prop, "GreasePencilLayerTreeNode", "flag", GP_LAYER_TREE_NODE_HIDE_MASKS); RNA_def_property_ui_text( ``` </details>
Member

to fix the wrong icon shown in the above image.

The image seems to have been deleted. Could you try and post it again? I'm not sure I understand what's going wrong in the data-properties mask panel.

> to fix the wrong icon shown in the above image. The image seems to have been deleted. Could you try and post it again? I'm not sure I understand what's going wrong in the data-properties mask panel.
Member

Looks like the mask icon is reversed in the icon sheet (e.g. the ON state comes before the OFF state) which is not the case for the other icons 🙄.

Here is a diff:

diff --git a/scripts/startup/bl_ui/properties_data_grease_pencil.py b/scripts/startup/bl_ui/properties_data_grease_pencil.py
index 8d1b162f214..6cbe189de9a 100644
--- a/scripts/startup/bl_ui/properties_data_grease_pencil.py
+++ b/scripts/startup/bl_ui/properties_data_grease_pencil.py
@@ -46,7 +46,7 @@ class GreasePencil_LayerMaskPanel:
         grease_pencil = ob.data
         layer = grease_pencil.layers.active
 
-        self.layout.prop(layer, "use_masks", text="")
+        self.layout.prop(layer, "use_masks", text="", toggle=0)
 
     def draw(self, context):
         layout = self.layout
diff --git a/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc b/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc
index 316e237dea2..b3b54daea95 100644
--- a/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc
+++ b/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc
@@ -258,10 +258,7 @@ class LayerViewItem : public AbstractTreeViewItem {
 
     sub = uiLayoutRow(&row, true);
     uiLayoutSetActive(sub, layer_.parent_group().use_masks());
-    const int icon_mask = (layer_.base.flag & GP_LAYER_TREE_NODE_HIDE_MASKS) == 0 ?
-                              ICON_CLIPUV_DEHLT :
-                              ICON_CLIPUV_HLT;
-    uiItemR(sub, &layer_ptr, "use_masks", UI_ITEM_R_ICON_ONLY, nullptr, icon_mask);
+    uiItemR(sub, &layer_ptr, "use_masks", UI_ITEM_R_ICON_ONLY, nullptr, ICON_NONE);
 
     sub = uiLayoutRow(&row, true);
     uiLayoutSetActive(sub, layer_.parent_group().use_onion_skinning());
diff --git a/source/blender/makesrna/intern/rna_grease_pencil.cc b/source/blender/makesrna/intern/rna_grease_pencil.cc
index 36d9eab488f..a7999626d6c 100644
--- a/source/blender/makesrna/intern/rna_grease_pencil.cc
+++ b/source/blender/makesrna/intern/rna_grease_pencil.cc
@@ -409,6 +409,7 @@ static void rna_def_grease_pencil_layer(BlenderRNA *brna)
 
   /* Use Masks. */
   prop = RNA_def_property(srna, "use_masks", PROP_BOOLEAN, PROP_NONE);
+  RNA_def_property_ui_icon(prop, ICON_CLIPUV_HLT, -1);
   RNA_def_property_boolean_negative_sdna(
       prop, "GreasePencilLayerTreeNode", "flag", GP_LAYER_TREE_NODE_HIDE_MASKS);
   RNA_def_property_ui_text(
Looks like the mask icon is reversed in the icon sheet (e.g. the ON state comes before the OFF state) which is not the case for the other icons 🙄. Here is a diff: <details> ```Diff diff --git a/scripts/startup/bl_ui/properties_data_grease_pencil.py b/scripts/startup/bl_ui/properties_data_grease_pencil.py index 8d1b162f214..6cbe189de9a 100644 --- a/scripts/startup/bl_ui/properties_data_grease_pencil.py +++ b/scripts/startup/bl_ui/properties_data_grease_pencil.py @@ -46,7 +46,7 @@ class GreasePencil_LayerMaskPanel: grease_pencil = ob.data layer = grease_pencil.layers.active - self.layout.prop(layer, "use_masks", text="") + self.layout.prop(layer, "use_masks", text="", toggle=0) def draw(self, context): layout = self.layout diff --git a/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc b/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc index 316e237dea2..b3b54daea95 100644 --- a/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc +++ b/source/blender/editors/interface/templates/interface_template_grease_pencil_layer_tree.cc @@ -258,10 +258,7 @@ class LayerViewItem : public AbstractTreeViewItem { sub = uiLayoutRow(&row, true); uiLayoutSetActive(sub, layer_.parent_group().use_masks()); - const int icon_mask = (layer_.base.flag & GP_LAYER_TREE_NODE_HIDE_MASKS) == 0 ? - ICON_CLIPUV_DEHLT : - ICON_CLIPUV_HLT; - uiItemR(sub, &layer_ptr, "use_masks", UI_ITEM_R_ICON_ONLY, nullptr, icon_mask); + uiItemR(sub, &layer_ptr, "use_masks", UI_ITEM_R_ICON_ONLY, nullptr, ICON_NONE); sub = uiLayoutRow(&row, true); uiLayoutSetActive(sub, layer_.parent_group().use_onion_skinning()); diff --git a/source/blender/makesrna/intern/rna_grease_pencil.cc b/source/blender/makesrna/intern/rna_grease_pencil.cc index 36d9eab488f..a7999626d6c 100644 --- a/source/blender/makesrna/intern/rna_grease_pencil.cc +++ b/source/blender/makesrna/intern/rna_grease_pencil.cc @@ -409,6 +409,7 @@ static void rna_def_grease_pencil_layer(BlenderRNA *brna) /* Use Masks. */ prop = RNA_def_property(srna, "use_masks", PROP_BOOLEAN, PROP_NONE); + RNA_def_property_ui_icon(prop, ICON_CLIPUV_HLT, -1); RNA_def_property_boolean_negative_sdna( prop, "GreasePencilLayerTreeNode", "flag", GP_LAYER_TREE_NODE_HIDE_MASKS); RNA_def_property_ui_text( ``` </details>
Author
Member

Didn't notice that. I'll give a try :)

Didn't notice that. I'll give a try :)
Author
Member

Thanks, that worked :D
Updated the PR.

Thanks, that worked :D Updated the PR.
filedescriptor marked this conversation as resolved
Pratik Borhade added 1 commit 2024-05-01 13:19:25 +02:00
Falk David approved these changes 2024-05-01 15:09:46 +02:00
Falk David left a comment
Member

Thanks!

Thanks!
Falk David merged commit a42e2a5a29 into main 2024-05-01 15:10:33 +02:00
Pratik Borhade deleted branch gpv3-mask-channel-toggle 2024-05-01 15:20:03 +02:00
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#121259
No description provided.