UI: Clip Editor: Expose 2D Cursor Location to RNA and UI

To be consistent with the image editors and 3D viewport
the cursor location can be changed from the sidebar.
This was missing from the clip editor, but support has been added in this commit.
Previously, the only way to precisely set the cursor was
to call the set cursor operator then use the redo panel to adjust the value.
This commit is contained in:
Aaron Carlisle 2021-08-09 15:30:55 -04:00
parent ce95a2b148
commit 2d867426b1
2 changed files with 48 additions and 0 deletions

View File

@ -1075,6 +1075,31 @@ class CLIP_PT_stabilization(CLIP_PT_reconstruction_panel, Panel):
layout.prop(stab, "filter_type")
class CLIP_PT_2d_cursor(Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'UI'
bl_category = "View"
bl_label = "2D Cursor"
@classmethod
def poll(cls, context):
sc = context.space_data
if CLIP_PT_clip_view_panel.poll(context):
return sc.pivot_point == 'CURSOR' or sc.mode == 'MASK'
def draw(self, context):
layout = self.layout
sc = context.space_data
layout.use_property_split = True
layout.use_property_decorate = False
col = layout.column()
col.prop(sc, "cursor_location", text="Location")
class CLIP_PT_proxy(CLIP_PT_clip_view_panel, Panel):
bl_space_type = 'CLIP_EDITOR'
bl_region_type = 'UI'
@ -1862,6 +1887,7 @@ classes = (
CLIP_PT_proxy,
CLIP_PT_footage,
CLIP_PT_stabilization,
CLIP_PT_2d_cursor,
CLIP_PT_mask,
CLIP_PT_mask_layers,
CLIP_PT_mask_display,

View File

@ -2477,6 +2477,18 @@ static void rna_SpaceClipEditor_mask_set(PointerRNA *ptr,
ED_space_clip_set_mask(NULL, sc, (Mask *)value.data);
}
static void rna_SpaceClipEditor_cursor_location_get(PointerRNA *ptr, float *values)
{
SpaceClip *sc = (SpaceClip *)(ptr->data);
copy_v2_v2(values, sc->cursor);
}
static void rna_SpaceClipEditor_cursor_location_set(PointerRNA *ptr, const float *values)
{
SpaceClip *sc = (SpaceClip *)(ptr->data);
copy_v2_v2(sc->cursor, values);
}
static void rna_SpaceClipEditor_clip_mode_update(Main *UNUSED(bmain),
Scene *UNUSED(scene),
PointerRNA *ptr)
@ -7330,6 +7342,16 @@ static void rna_def_space_clip(BlenderRNA *brna)
RNA_def_property_translation_context(prop, BLT_I18NCONTEXT_ID_MOVIECLIP);
RNA_def_property_update(prop, NC_MOVIECLIP | ND_DISPLAY, NULL);
/* transform */
prop = RNA_def_property(srna, "cursor_location", PROP_FLOAT, PROP_XYZ);
RNA_def_property_array(prop, 2);
RNA_def_property_float_funcs(prop,
"rna_SpaceClipEditor_cursor_location_get",
"rna_SpaceClipEditor_cursor_location_set",
NULL);
RNA_def_property_ui_text(prop, "2D Cursor Location", "2D cursor location for this view");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_CLIP, NULL);
/* pivot point */
prop = RNA_def_property(srna, "pivot_point", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "around");