[Bf-blender-cvs] [8791762af0a] retopo_transform: exposed cursor_warp_relative through api

jon denning noreply at git.blender.org
Sat Jul 16 13:00:38 CEST 2022


Commit: 8791762af0abe0bf6164b08f08566bded307eaba
Author: jon denning
Date:   Wed Jun 8 10:08:04 2022 -0400
Branches: retopo_transform
https://developer.blender.org/rB8791762af0abe0bf6164b08f08566bded307eaba

exposed cursor_warp_relative through api

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

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

M	source/blender/makesrna/intern/rna_wm_api.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/wm_cursors.c
M	source/blender/windowmanager/intern/wm_window.c

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

diff --git a/source/blender/makesrna/intern/rna_wm_api.c b/source/blender/makesrna/intern/rna_wm_api.c
index b9f36d35ee8..b0858ad4513 100644
--- a/source/blender/makesrna/intern/rna_wm_api.c
+++ b/source/blender/makesrna/intern/rna_wm_api.c
@@ -727,6 +727,13 @@ void RNA_api_window(StructRNA *srna)
   RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
   RNA_def_function_ui_description(func, "Set the cursor position");
 
+  func = RNA_def_function(srna, "cursor_warp_relative", "WM_cursor_warp_relative");
+  parm = RNA_def_int(func, "x", 0, INT_MIN, INT_MAX, "", "Offset of x", INT_MIN, INT_MAX);
+  RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+  parm = RNA_def_int(func, "y", 0, INT_MIN, INT_MAX, "", "Offset of y", INT_MIN, INT_MAX);
+  RNA_def_parameter_flags(parm, 0, PARM_REQUIRED);
+  RNA_def_function_ui_description(func, "Offset the cursor position");
+
   func = RNA_def_function(srna, "cursor_set", "WM_cursor_set");
   parm = RNA_def_property(func, "cursor", PROP_ENUM, PROP_NONE);
   RNA_def_property_enum_items(parm, rna_enum_window_cursor_items);
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index ac06ababfd4..cbf21f49132 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -314,6 +314,7 @@ void WM_paint_cursor_tag_redraw(struct wmWindow *win, struct ARegion *region);
  * This function requires access to the GHOST_SystemHandle (g_system).
  */
 void WM_cursor_warp(struct wmWindow *win, int x, int y);
+void WM_cursor_warp_relative(struct wmWindow *win, int x, int y);
 /**
  * Set x, y to values we can actually position the cursor to.
  */
diff --git a/source/blender/windowmanager/intern/wm_cursors.c b/source/blender/windowmanager/intern/wm_cursors.c
index fc992ef069d..3cb1b240524 100644
--- a/source/blender/windowmanager/intern/wm_cursors.c
+++ b/source/blender/windowmanager/intern/wm_cursors.c
@@ -279,14 +279,6 @@ void WM_cursor_grab_disable(wmWindow *win, const int mouse_ungrab_xy[2])
   }
 }
 
-static void wm_cursor_warp_relative(wmWindow *win, int x, int y)
-{
-  /* NOTE: don't use wmEvent coords because of continuous grab T36409. */
-  int cx, cy;
-  wm_cursor_position_get(win, &cx, &cy);
-  WM_cursor_warp(win, cx + x, cy + y);
-}
-
 bool wm_cursor_arrow_move(wmWindow *win, const wmEvent *event)
 {
   /* TODO: give it a modal keymap? Hard coded for now */
@@ -296,19 +288,19 @@ bool wm_cursor_arrow_move(wmWindow *win, const wmEvent *event)
     float fac = GHOST_GetNativePixelSize(win->ghostwin);
 
     if (event->type == EVT_UPARROWKEY) {
-      wm_cursor_warp_relative(win, 0, fac);
+      WM_cursor_warp_relative(win, 0, fac);
       return 1;
     }
     if (event->type == EVT_DOWNARROWKEY) {
-      wm_cursor_warp_relative(win, 0, -fac);
+      WM_cursor_warp_relative(win, 0, -fac);
       return 1;
     }
     if (event->type == EVT_LEFTARROWKEY) {
-      wm_cursor_warp_relative(win, -fac, 0);
+      WM_cursor_warp_relative(win, -fac, 0);
       return 1;
     }
     if (event->type == EVT_RIGHTARROWKEY) {
-      wm_cursor_warp_relative(win, fac, 0);
+      WM_cursor_warp_relative(win, fac, 0);
       return 1;
     }
   }
diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c
index c0427f9be9a..82ac0fc369c 100644
--- a/source/blender/windowmanager/intern/wm_window.c
+++ b/source/blender/windowmanager/intern/wm_window.c
@@ -2022,6 +2022,16 @@ void WM_cursor_warp(wmWindow *win, int x, int y)
   }
 }
 
+void WM_cursor_warp_relative(wmWindow *win, int x, int y)
+{
+  if (win && win->ghostwin) {
+    /* NOTE: don't use wmEvent coords because of continuous grab T36409. */
+    int cx, cy;
+    wm_cursor_position_get(win, &cx, &cy);
+    WM_cursor_warp(win, cx + x, cy + y);
+  }
+}
+
 void WM_cursor_compatible_xy(wmWindow *win, int *x, int *y)
 {
   float f = GHOST_GetNativePixelSize(win->ghostwin);



More information about the Bf-blender-cvs mailing list