From 2d867426b1b7e28b58bf0c84119679c73f08175f Mon Sep 17 00:00:00 2001 From: Aaron Carlisle Date: Mon, 9 Aug 2021 15:30:55 -0400 Subject: 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. --- source/blender/makesrna/intern/rna_space.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'source/blender/makesrna/intern/rna_space.c') diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 8c62484f229..fe43237963d 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -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"); -- cgit v1.2.3