[Bf-blender-cvs] [df2ab4e758c] master: Mask Editor: Add toggle for mask spline drawing

Simon Lenz noreply at git.blender.org
Wed Jun 22 10:45:34 CEST 2022


Commit: df2ab4e758c73bc72a95fcc02ac1e711bbd86b17
Author: Simon Lenz
Date:   Thu Jun 16 10:13:03 2022 +0200
Branches: master
https://developer.blender.org/rBdf2ab4e758c73bc72a95fcc02ac1e711bbd86b17

Mask Editor: Add toggle for mask spline drawing

Adds an overlay option to show/hide the spline points & lines of masks in the Mask Editor.

It also moves the "smooth" option up (its position left of the selection dropdown was missleading).

{F11847272}

This emerged from a discussion in https://developer.blender.org/D12776

Differential Revision: https://developer.blender.org/D13314

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

M	release/scripts/startup/bl_ui/properties_mask_common.py
M	source/blender/blenkernel/BKE_blender_version.h
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/blenloader/intern/versioning_defaults.c
M	source/blender/editors/include/ED_clip.h
M	source/blender/editors/include/ED_image.h
M	source/blender/editors/include/ED_mask.h
M	source/blender/editors/mask/mask_add.c
M	source/blender/editors/mask/mask_draw.c
M	source/blender/editors/mask/mask_edit.c
M	source/blender/editors/mask/mask_ops.c
M	source/blender/editors/mask/mask_relationships.c
M	source/blender/editors/mask/mask_select.c
M	source/blender/editors/mask/mask_shapekey.c
M	source/blender/editors/space_clip/clip_editor.c
M	source/blender/editors/space_image/image_edit.c
M	source/blender/editors/transform/transform_convert_mask.c
M	source/blender/makesdna/DNA_mask_types.h
M	source/blender/makesdna/DNA_space_defaults.h
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/release/scripts/startup/bl_ui/properties_mask_common.py b/release/scripts/startup/bl_ui/properties_mask_common.py
index 47a25db20b1..ff4f1ee02bf 100644
--- a/release/scripts/startup/bl_ui/properties_mask_common.py
+++ b/release/scripts/startup/bl_ui/properties_mask_common.py
@@ -231,9 +231,13 @@ class MASK_PT_display:
         layout = self.layout
 
         space_data = context.space_data
+        layout.prop(space_data, "show_mask_smooth", text="Smooth")
+
         row = layout.row(align=True)
-        row.prop(space_data, "show_mask_smooth", text="Smooth")
-        row.prop(space_data, "mask_display_type", text="")
+        row.prop(space_data, "show_mask_spline", text="Spline")
+        sub = row.row()
+        sub.active = space_data.show_mask_spline
+        sub.prop(space_data, "mask_display_type", text="")
         row = layout.row(align=True)
         row.prop(space_data, "show_mask_overlay", text="Overlay")
         sub = row.row()
diff --git a/source/blender/blenkernel/BKE_blender_version.h b/source/blender/blenkernel/BKE_blender_version.h
index 20eb33c5d15..04767a742ce 100644
--- a/source/blender/blenkernel/BKE_blender_version.h
+++ b/source/blender/blenkernel/BKE_blender_version.h
@@ -25,7 +25,7 @@ extern "C" {
 
 /* Blender file format version. */
 #define BLENDER_FILE_VERSION BLENDER_VERSION
-#define BLENDER_FILE_SUBVERSION 2
+#define BLENDER_FILE_SUBVERSION 3
 
 /* Minimum Blender version that supports reading file written with the current
  * version. Older Blender versions will test this and show a warning if the file
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 5af42f9f1f6..eac27bc57ed 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -30,6 +30,7 @@
 #include "DNA_gpencil_modifier_types.h"
 #include "DNA_lineart_types.h"
 #include "DNA_listBase.h"
+#include "DNA_mask_types.h"
 #include "DNA_material_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_modifier_types.h"
@@ -3096,6 +3097,21 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
     }
   }
 
+  if (!MAIN_VERSION_ATLEAST(bmain, 303, 3)) {
+    LISTBASE_FOREACH (bScreen *, screen, &bmain->screens) {
+      LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) {
+        LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) {
+          if (sl->spacetype == SPACE_CLIP) {
+            ((SpaceClip *)sl)->mask_info.draw_flag |= MASK_DRAWFLAG_SPLINE;
+          }
+          else if (sl->spacetype == SPACE_IMAGE) {
+            ((SpaceImage *)sl)->mask_info.draw_flag |= MASK_DRAWFLAG_SPLINE;
+          }
+        }
+      }
+    }
+  }
+
   /**
    * Versioning code until next subversion bump goes here.
    *
diff --git a/source/blender/blenloader/intern/versioning_defaults.c b/source/blender/blenloader/intern/versioning_defaults.c
index 91b2f509a7f..6ce53e4a648 100644
--- a/source/blender/blenloader/intern/versioning_defaults.c
+++ b/source/blender/blenloader/intern/versioning_defaults.c
@@ -23,6 +23,7 @@
 #include "DNA_curveprofile_types.h"
 #include "DNA_gpencil_types.h"
 #include "DNA_light_types.h"
+#include "DNA_mask_types.h"
 #include "DNA_material_types.h"
 #include "DNA_mesh_types.h"
 #include "DNA_meshdata_types.h"
@@ -185,6 +186,7 @@ static void blo_update_defaults_screen(bScreen *screen,
       SpaceClip *sclip = area->spacedata.first;
       sclip->around = V3D_AROUND_CENTER_MEDIAN;
       sclip->mask_info.blend_factor = 0.7f;
+      sclip->mask_info.draw_flag = MASK_DRAWFLAG_SPLINE;
     }
   }
 
diff --git a/source/blender/editors/include/ED_clip.h b/source/blender/editors/include/ED_clip.h
index 74735018814..0f981e270a0 100644
--- a/source/blender/editors/include/ED_clip.h
+++ b/source/blender/editors/include/ED_clip.h
@@ -48,12 +48,27 @@ bool ED_space_clip_tracking_poll(struct bContext *C);
  * It is not required to have mask opened for editing. */
 bool ED_space_clip_maskedit_poll(struct bContext *C);
 
+/* Returns true when the following conditions are met:
+ * - Current space is Space Clip.
+ * - It is set to Mask mode.
+ * - Mask has visible and editable splines.
+ *
+ * It is not required to have mask opened for editing. */
+bool ED_space_clip_maskedit_visible_splines_poll(struct bContext *C);
+
 /* Returns true when the following conditions are met:
  * - Current space is Space Clip.
  * - It is set to Mask mode.
  * - The space has mask opened. */
 bool ED_space_clip_maskedit_mask_poll(struct bContext *C);
 
+/* Returns true when the following conditions are met:
+ * - Current space is Space Clip.
+ * - It is set to Mask mode.
+ * - The space has mask opened.
+ * - Mask has visible and editable splines. */
+bool ED_space_clip_maskedit_mask_visible_splines_poll(struct bContext *C);
+
 void ED_space_clip_get_size(struct SpaceClip *sc, int *width, int *height);
 void ED_space_clip_get_size_fl(struct SpaceClip *sc, float size[2]);
 void ED_space_clip_get_zoom(struct SpaceClip *sc,
diff --git a/source/blender/editors/include/ED_image.h b/source/blender/editors/include/ED_image.h
index 3e5d4c3adf4..91ae8286531 100644
--- a/source/blender/editors/include/ED_image.h
+++ b/source/blender/editors/include/ED_image.h
@@ -150,9 +150,26 @@ bool ED_space_image_maskedit_poll(struct bContext *C);
  * - Current space is Image Editor.
  * - The image editor is not a UV Editor.
  * - It is set to Mask mode.
+ * - Mask has visible and editable splines.
+ *
+ * It is not required to have mask opened for editing. */
+bool ED_space_image_maskedit_visible_splines_poll(struct bContext *C);
+
+/* Returns true when the following conditions are met:
+ * - Current space is Image Editor.
+ * - The image editor is not an UV Editor.
+ * - It is set to Mask mode.
  * - The space has mask opened. */
 bool ED_space_image_maskedit_mask_poll(struct bContext *C);
 
+/* Returns true when the following conditions are met:
+ * - Current space is Image Editor.
+ * - The image editor is not an UV Editor.
+ * - It is set to Mask mode.
+ * - The space has mask opened.
+ * - Mask has visible and editable splines. */
+bool ED_space_image_maskedit_mask_visible_splines_poll(struct bContext *C);
+
 bool ED_space_image_cursor_poll(struct bContext *C);
 
 /**
diff --git a/source/blender/editors/include/ED_mask.h b/source/blender/editors/include/ED_mask.h
index 6d4d4fcff48..8cadbfde185 100644
--- a/source/blender/editors/include/ED_mask.h
+++ b/source/blender/editors/include/ED_mask.h
@@ -29,12 +29,27 @@ struct wmKeyConfig;
  * It is not required to have mask opened for editing. */
 bool ED_maskedit_poll(struct bContext *C);
 
+/* Returns true when the following conditions are met:
+ * - Current space supports mask editing.
+ * - The space is configured to interact with mask.
+ * - Mask has visible and editable splines.
+ *
+ * It is not required to have mask opened for editing. */
+bool ED_maskedit_visible_splines_poll(struct bContext *C);
+
 /* Returns true when the following conditions are met:
  * - Current space supports mask editing.
  * - The space is configured to interact with mask.
  * - The space has mask open for editing. */
 bool ED_maskedit_mask_poll(struct bContext *C);
 
+/* Returns true when the following conditions are met:
+ * - Current space supports mask editing.
+ * - The space is configured to interact with mask.
+ * - The space has mask opened.
+ * - Mask has visible and editable splines. */
+bool ED_maskedit_mask_visible_splines_poll(struct bContext *C);
+
 void ED_mask_deselect_all(const struct bContext *C);
 
 void ED_operatortypes_mask(void);
diff --git a/source/blender/editors/mask/mask_add.c b/source/blender/editors/mask/mask_add.c
index 42f3acaa6bc..37c1815fca3 100644
--- a/source/blender/editors/mask/mask_add.c
+++ b/source/blender/editors/mask/mask_add.c
@@ -583,7 +583,7 @@ void MASK_OT_add_vertex(wmOperatorType *ot)
   /* api callbacks */
   ot->exec = add_vertex_exec;
   ot->invoke = add_vertex_invoke;
-  ot->poll = ED_maskedit_poll;
+  ot->poll = ED_maskedit_visible_splines_poll;
 
   /* flags */
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -862,7 +862,7 @@ void MASK_OT_primitive_circle_add(wmOperatorType *ot)
   /* api callbacks */
   ot->exec = primitive_circle_add_exec;
   ot->invoke = primitive_add_invoke;
-  ot->poll = ED_maskedit_poll;
+  ot->poll = ED_maskedit_visible_splines_poll;
 
   /* flags */
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
@@ -897,7 +897,7 @@ void MASK_OT_primitive_square_add(wmOperatorType *ot)
   /* api callbacks */
   ot->exec = primitive_square_add_exec;
   ot->invoke = primitive_add_invoke;
-  ot->poll = ED_maskedit_poll;
+  ot->poll = ED_maskedit_visible_splines_poll;
 
   /* flags */
   ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
diff --git a/source/blender/editors/mask/mask_draw.c b/source/blender/editors/mask/mask_draw.c
index 1bd224fe763..a18419ad422 100644
--- a/source/blender/editors/mask/mask_draw.c
+++ b/source/blender/editors/mask/mask_draw.c
@@ -776,7 +776,9 @@ void ED_mask_draw_region(
   }
 
   /* draw! */
-  draw_mask_layers(C, mask_eval, draw_flag, draw_type, width, height);
+  if (draw_flag & MASK_DRAWFLAG_SPLINE) {
+    draw_mask_layers(C, mask_eval, draw_flag, draw_type, width, height);
+  }
 
   if (do_draw_cb) {
     ED_region_draw_cb_draw(C, region, REGION_DRAW_POST_VIEW);
diff --git a/source/blender/editors/mask/mask_edit.c b/source/blender/editors/mask/mask_edit.c
index b2d49bcc642..915f90a1537 100644
--- a/source/blender/editors/mask/mask_edit.c
+++ b/source/blender/editors/mask/mask_edit.c
@@ -42,6 +42,22 @@ bool ED_maskedit_poll(bContext *C)
   return false;
 }
 
+bool ED_maskedit_visible_splines_poll(bContext *C)
+{
+  ScrArea *area = CTX_wm_area(C);
+  if (area) {
+    switch (area->spacetype) {
+      case SPACE_CLIP:
+        return ED_space_clip_maskedit_visible_splines_poll(C);
+      case SPACE_SEQ:
+        return ED_space_sequencer_maskedit_poll(C);
+      case SPACE_IMAGE:
+        return ED_space_image_maskedit_visible_splines_poll(C);
+    }
+  }
+  return false;
+}
+
 bool ED_maskedit_mask_poll(bContext *C)
 {
   ScrArea *area = CTX_wm_area(C);
@@ -58,6 +74,22 @@ bool ED_maskedit_mask_poll(bContext *C)
   return f

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list