[Bf-blender-cvs] [6ee14c966d0] master: Anotations: Fix a several issues with stroke placement

Aaron Carlisle noreply at git.blender.org
Tue Jul 27 00:53:40 CEST 2021


Commit: 6ee14c966d05362228511756c4906e043b87e346
Author: Aaron Carlisle
Date:   Mon Jul 26 18:52:48 2021 -0400
Branches: master
https://developer.blender.org/rB6ee14c966d05362228511756c4906e043b87e346

Anotations: Fix a several issues with stroke placement

Previously, this option was not exposed in the UI, only for the clip editor.
There were also multiple rna properties that did the same thing for each of the 2D editors.

There was also an issue where the property enum items were the same as the 3d view which didnt make much sense.

Reviewed By: antoniov

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

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

M	release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M	source/blender/blenloader/intern/versioning_270.c
M	source/blender/blenloader/intern/versioning_300.c
M	source/blender/editors/gpencil/annotate_paint.c
M	source/blender/makesdna/DNA_scene_defaults.h
M	source/blender/makesdna/DNA_scene_types.h
M	source/blender/makesrna/intern/rna_scene.c

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

diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index c55f637f8b2..46a6944d2ea 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -191,6 +191,11 @@ class _defs_annotate:
                 row.prop(tool_settings.gpencil_sculpt, "lockaxis")
             elif tool_settings.gpencil_stroke_placement_view3d in {'SURFACE', 'STROKE'}:
                 row.prop(tool_settings, "use_gpencil_stroke_endpoints")
+        elif space_type in {'IMAGE_EDITOR', 'NODE_EDITOR', 'SEQUENCE_EDITOR', 'CLIP_EDITOR'}:
+            layout.separator()
+
+            row = layout.row(align=True)
+            row.prop(tool_settings, "annotation_stroke_placement_view2d", text="Placement")
 
         if tool.idname == "builtin.annotate_line":
             layout.separator()
diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c
index 776f6c54363..1d46c0d5790 100644
--- a/source/blender/blenloader/intern/versioning_270.c
+++ b/source/blender/blenloader/intern/versioning_270.c
@@ -1115,8 +1115,6 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain)
       if (!DNA_struct_elem_find(fd->filesdna, "ToolSettings", "char", "gpencil_v3d_align")) {
         ts->gpencil_v3d_align = GP_PROJECT_VIEWSPACE;
         ts->gpencil_v2d_align = GP_PROJECT_VIEWSPACE;
-        ts->gpencil_seq_align = GP_PROJECT_VIEWSPACE;
-        ts->gpencil_ima_align = GP_PROJECT_VIEWSPACE;
       }
     }
 
diff --git a/source/blender/blenloader/intern/versioning_300.c b/source/blender/blenloader/intern/versioning_300.c
index 4dcb7414bb4..e46073ba0de 100644
--- a/source/blender/blenloader/intern/versioning_300.c
+++ b/source/blender/blenloader/intern/versioning_300.c
@@ -663,6 +663,12 @@ void blo_do_versions_300(FileData *fd, Library *UNUSED(lib), Main *bmain)
         }
       }
     }
+
+    /* Set default 2D annotation placement. */
+    LISTBASE_FOREACH (Scene *, scene, &bmain->scenes) {
+      ToolSettings *ts = scene->toolsettings;
+      ts->gpencil_v2d_align = GP_PROJECT_VIEWSPACE | GP_PROJECT_CURSOR;
+    }
   }
 
   /**
diff --git a/source/blender/editors/gpencil/annotate_paint.c b/source/blender/editors/gpencil/annotate_paint.c
index 4b0c5ccd285..9bf44370c80 100644
--- a/source/blender/editors/gpencil/annotate_paint.c
+++ b/source/blender/editors/gpencil/annotate_paint.c
@@ -1320,7 +1320,7 @@ static bool annotation_session_initdata(bContext *C, tGPsdata *p)
       p->area = curarea;
       p->region = region;
       p->v2d = &region->v2d;
-      p->align_flag = &ts->gpencil_seq_align;
+      p->align_flag = &ts->gpencil_v2d_align;
 
       /* check that gpencil data is allowed to be drawn */
       if (sseq->mainb == SEQ_DRAW_SEQUENCE) {
@@ -1339,7 +1339,7 @@ static bool annotation_session_initdata(bContext *C, tGPsdata *p)
       p->area = curarea;
       p->region = region;
       p->v2d = &region->v2d;
-      p->align_flag = &ts->gpencil_ima_align;
+      p->align_flag = &ts->gpencil_v2d_align;
       break;
     }
     case SPACE_CLIP: {
diff --git a/source/blender/makesdna/DNA_scene_defaults.h b/source/blender/makesdna/DNA_scene_defaults.h
index 1a2a8892e64..61707964191 100644
--- a/source/blender/makesdna/DNA_scene_defaults.h
+++ b/source/blender/makesdna/DNA_scene_defaults.h
@@ -374,8 +374,6 @@
     /* GP Stroke Placement */ \
     .gpencil_v3d_align = GP_PROJECT_VIEWSPACE, \
     .gpencil_v2d_align = GP_PROJECT_VIEWSPACE, \
-    .gpencil_seq_align = GP_PROJECT_VIEWSPACE, \
-    .gpencil_ima_align = GP_PROJECT_VIEWSPACE, \
   }
 
 /* clang-format off */
diff --git a/source/blender/makesdna/DNA_scene_types.h b/source/blender/makesdna/DNA_scene_types.h
index 31352b2c8f4..000db5bf5b1 100644
--- a/source/blender/makesdna/DNA_scene_types.h
+++ b/source/blender/makesdna/DNA_scene_types.h
@@ -1409,10 +1409,7 @@ typedef struct ToolSettings {
   char gpencil_v3d_align;
   /** General 2D Editor. */
   char gpencil_v2d_align;
-  /** Sequencer Preview. */
-  char gpencil_seq_align;
-  /** Image Editor. */
-  char gpencil_ima_align;
+  char _pad0[2];
 
   /* Annotations */
   /** Stroke placement settings - 3D View. */
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 5c9c7b50339..6a28cf34965 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2834,7 +2834,18 @@ static void rna_def_tool_settings(BlenderRNA *brna)
       {0, NULL, 0, NULL, NULL},
   };
 
-  static const EnumPropertyItem annotation_stroke_placement_items[] = {
+  static const EnumPropertyItem annotation_stroke_placement_view2d_items[] = {
+      {GP_PROJECT_VIEWSPACE | GP_PROJECT_CURSOR,
+       "IMAGE",
+       ICON_IMAGE_DATA,
+       "Image",
+       "Strick stroke to the image"},
+      /* Weird, GP_PROJECT_VIEWALIGN is inverted. */
+      {0, "VIEW", ICON_RESTRICT_VIEW_ON, "View", "Stick stroke to the view"},
+      {0, NULL, 0, NULL, NULL},
+  };
+
+  static const EnumPropertyItem annotation_stroke_placement_view3d_items[] = {
       {GP_PROJECT_VIEWSPACE | GP_PROJECT_CURSOR,
        "CURSOR",
        ICON_PIVOT_CURSOR,
@@ -3338,30 +3349,15 @@ static void rna_def_tool_settings(BlenderRNA *brna)
   /* Annotations - 2D Views Stroke Placement */
   prop = RNA_def_property(srna, "annotation_stroke_placement_view2d", PROP_ENUM, PROP_NONE);
   RNA_def_property_enum_bitflag_sdna(prop, NULL, "gpencil_v2d_align");
-  RNA_def_property_enum_items(prop, annotation_stroke_placement_items);
+  RNA_def_property_enum_items(prop, annotation_stroke_placement_view2d_items);
   RNA_def_property_ui_text(prop, "Stroke Placement (2D View)", "");
   RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
 
-  /* Annotations - Sequencer Preview Stroke Placement */
-  prop = RNA_def_property(
-      srna, "annotation_stroke_placement_sequencer_preview", PROP_ENUM, PROP_NONE);
-  RNA_def_property_enum_bitflag_sdna(prop, NULL, "gpencil_seq_align");
-  RNA_def_property_enum_items(prop, annotation_stroke_placement_items);
-  RNA_def_property_ui_text(prop, "Stroke Placement (Sequencer Preview)", "");
-  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
-
-  /* Annotations - Image Editor Stroke Placement */
-  prop = RNA_def_property(srna, "annotation_stroke_placement_image_editor", PROP_ENUM, PROP_NONE);
-  RNA_def_property_enum_bitflag_sdna(prop, NULL, "gpencil_ima_align");
-  RNA_def_property_enum_items(prop, annotation_stroke_placement_items);
-  RNA_def_property_ui_text(prop, "Stroke Placement (Image Editor)", "");
-  RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
-
   /* Annotations - 3D View Stroke Placement */
   /* XXX: Do we need to decouple the stroke_endpoints setting too? */
   prop = RNA_def_property(srna, "annotation_stroke_placement_view3d", PROP_ENUM, PROP_NONE);
   RNA_def_property_enum_bitflag_sdna(prop, NULL, "annotate_v3d_align");
-  RNA_def_property_enum_items(prop, annotation_stroke_placement_items);
+  RNA_def_property_enum_items(prop, annotation_stroke_placement_view3d_items);
   RNA_def_property_enum_default(prop, GP_PROJECT_VIEWSPACE | GP_PROJECT_CURSOR);
   RNA_def_property_ui_text(prop,
                            "Annotation Stroke Placement (3D View)",



More information about the Bf-blender-cvs mailing list