Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-07-01 05:10:49 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-07-01 05:10:49 +0300
commit05129ffb3e2cea8ec51cb6ee4890f5cd5e31794c (patch)
tree60f96dd7eb056f46c417fb39fb079b30b0ede620 /source/blender/blenkernel
parent26e05cf67adb142086e9aa2655424144d14d8913 (diff)
Cleanup: move screen region find into utility function
Diffstat (limited to 'source/blender/blenkernel')
-rw-r--r--source/blender/blenkernel/BKE_screen.h3
-rw-r--r--source/blender/blenkernel/intern/screen.c17
2 files changed, 20 insertions, 0 deletions
diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h
index dcf6d6c3907..5d3e7ad5ec2 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -350,6 +350,9 @@ void BKE_region_callback_refresh_tag_gizmomap_set(void (*callback)(struct wmGizm
struct ARegion *BKE_area_find_region_type(const struct ScrArea *sa, int type);
struct ARegion *BKE_area_find_region_active_win(struct ScrArea *sa);
struct ARegion *BKE_area_find_region_xy(struct ScrArea *sa, const int regiontype, int x, int y);
+struct ARegion *BKE_screen_find_region_xy(struct bScreen *sc, const int regiontype, int x, int y)
+ ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1);
+
struct ScrArea *BKE_screen_find_area_from_space(struct bScreen *sc,
struct SpaceLink *sl) ATTR_WARN_UNUSED_RESULT
ATTR_NONNULL(1, 2);
diff --git a/source/blender/blenkernel/intern/screen.c b/source/blender/blenkernel/intern/screen.c
index 86fec1ee754..619845c9ecb 100644
--- a/source/blender/blenkernel/intern/screen.c
+++ b/source/blender/blenkernel/intern/screen.c
@@ -738,6 +738,23 @@ ARegion *BKE_area_find_region_xy(ScrArea *sa, const int regiontype, int x, int y
}
/**
+ * \note This is only for screen level regions (typically menus/popups).
+ */
+ARegion *BKE_screen_find_region_xy(bScreen *sc, const int regiontype, int x, int y)
+{
+ ARegion *ar_found = NULL;
+ for (ARegion *ar = sc->regionbase.first; ar; ar = ar->next) {
+ if ((regiontype == RGN_TYPE_ANY) || (ar->regiontype == regiontype)) {
+ if (BLI_rcti_isect_pt(&ar->winrct, x, y)) {
+ ar_found = ar;
+ break;
+ }
+ }
+ }
+ return ar_found;
+}
+
+/**
* \note, ideally we can get the area from the context,
* there are a few places however where this isn't practical.
*/