[Bf-blender-cvs] [2d867426b1b] master: UI: Clip Editor: Expose 2D Cursor Location to RNA and UI

Aaron Carlisle noreply at git.blender.org
Mon Aug 9 21:34:08 CEST 2021


Commit: 2d867426b1b7e28b58bf0c84119679c73f08175f
Author: Aaron Carlisle
Date:   Mon Aug 9 15:30:55 2021 -0400
Branches: master
https://developer.blender.org/rB2d867426b1b7e28b58bf0c84119679c73f08175f

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.

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

M	release/scripts/startup/bl_ui/space_clip.py
M	source/blender/makesrna/intern/rna_space.c

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

diff --git a/release/scripts/startup/bl_ui/space_clip.py b/release/scripts/startup/bl_ui/space_clip.py
index 7bac0556fb9..a1e5b509295 100644
--- a/release/scripts/startup/bl_ui/space_clip.py
+++ b/release/scripts/startup/bl_ui/space_clip.py
@@ -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,
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");



More information about the Bf-blender-cvs mailing list