[Bf-blender-cvs] [310f288bb03] master: UI: add ui_window_to_block_rctf, ui_window_to_region_rcti

Campbell Barton noreply at git.blender.org
Tue Apr 23 08:55:14 CEST 2019


Commit: 310f288bb03b4197f54b7d7b6d611669f2604d04
Author: Campbell Barton
Date:   Tue Apr 23 16:39:14 2019 +1000
Branches: master
https://developer.blender.org/rB310f288bb03b4197f54b7d7b6d611669f2604d04

UI: add ui_window_to_block_rctf, ui_window_to_region_rcti

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

M	source/blender/editors/interface/interface.c
M	source/blender/editors/interface/interface_intern.h

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

diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c
index 3edf8e5135a..a5abbb2b86f 100644
--- a/source/blender/editors/interface/interface.c
+++ b/source/blender/editors/interface/interface.c
@@ -213,6 +213,16 @@ void ui_window_to_block_fl(const ARegion *ar, uiBlock *block, float *x, float *y
   }
 }
 
+void ui_window_to_block_rctf(const struct ARegion *ar,
+                             uiBlock *block,
+                             rctf *rct_dst,
+                             const rctf *rct_src)
+{
+  *rct_dst = *rct_src;
+  ui_window_to_block_fl(ar, block, &rct_dst->xmin, &rct_dst->ymin);
+  ui_window_to_block_fl(ar, block, &rct_dst->xmax, &rct_dst->ymax);
+}
+
 void ui_window_to_block(const ARegion *ar, uiBlock *block, int *x, int *y)
 {
   float fx, fy;
@@ -232,6 +242,14 @@ void ui_window_to_region(const ARegion *ar, int *x, int *y)
   *y -= ar->winrct.ymin;
 }
 
+void ui_window_to_region_rcti(const ARegion *ar, rcti *rect_dst, const rcti *rct_src)
+{
+  rect_dst->xmin = rct_src->xmin - ar->winrct.xmin;
+  rect_dst->xmax = rct_src->xmax - ar->winrct.xmin;
+  rect_dst->ymin = rct_src->ymin - ar->winrct.ymin;
+  rect_dst->ymax = rct_src->ymax - ar->winrct.ymin;
+}
+
 void ui_region_to_window(const ARegion *ar, int *x, int *y)
 {
   *x += ar->winrct.xmin;
diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h
index 344b3ec3526..d6f18b4cd87 100644
--- a/source/blender/editors/interface/interface_intern.h
+++ b/source/blender/editors/interface/interface_intern.h
@@ -460,7 +460,12 @@ extern void ui_block_to_window_rctf(const struct ARegion *ar,
 extern float ui_block_to_window_scale(const struct ARegion *ar, uiBlock *block);
 extern void ui_window_to_block_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y);
 extern void ui_window_to_block(const struct ARegion *ar, uiBlock *block, int *x, int *y);
+extern void ui_window_to_block_rctf(const struct ARegion *ar,
+                                    uiBlock *block,
+                                    rctf *rct_dst,
+                                    const rctf *rct_src);
 extern void ui_window_to_region(const ARegion *ar, int *x, int *y);
+extern void ui_window_to_region_rcti(const ARegion *ar, rcti *rect_dst, const rcti *rct_src);
 extern void ui_region_to_window(const struct ARegion *ar, int *x, int *y);
 extern void ui_region_winrct_get_no_margin(const struct ARegion *ar, struct rcti *r_rect);



More information about the Bf-blender-cvs mailing list