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
This commit is contained in:
parent
05315af81d
commit
6ee14c966d
Notes:
blender-bot
2023-02-14 05:51:15 +01:00
Referenced by commit 223f048138
, Fix annotations placement option in the Movie Clip editor
Referenced by issue #96781, Regression: Blender crash when using a particle system + grease pencil line art modifier
|
@ -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()
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1320,7 +1320,7 @@ static bool annotation_session_initdata(bContext *C, tGPsdata *p)
|
|||
p->area = curarea;
|
||||
p->region = region;
|
||||
p->v2d = ®ion->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 = ®ion->v2d;
|
||||
p->align_flag = &ts->gpencil_ima_align;
|
||||
p->align_flag = &ts->gpencil_v2d_align;
|
||||
break;
|
||||
}
|
||||
case SPACE_CLIP: {
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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. */
|
||||
|
|
|
@ -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)",
|
||||
|
|
Loading…
Reference in New Issue