From 63c07c80f5df7574ed49491b0e04bdf19a76d822 Mon Sep 17 00:00:00 2001 From: Julian Eisel Date: Tue, 25 Jul 2023 12:37:56 +0200 Subject: [PATCH] Cleanup: Use const for screen lookup helpers --- source/blender/blenkernel/BKE_screen.h | 22 ++++++++++++---------- source/blender/blenkernel/intern/screen.cc | 12 ++++++------ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/source/blender/blenkernel/BKE_screen.h b/source/blender/blenkernel/BKE_screen.h index 9d0b7de2b57..7b82203df18 100644 --- a/source/blender/blenkernel/BKE_screen.h +++ b/source/blender/blenkernel/BKE_screen.h @@ -489,37 +489,39 @@ struct ARegion *BKE_region_find_in_listbase_by_type(const struct ListBase *regio * Use #BKE_spacedata_find_region_type if that may be the case. */ struct ARegion *BKE_area_find_region_type(const struct ScrArea *area, int type); -struct ARegion *BKE_area_find_region_active_win(struct ScrArea *area); -struct ARegion *BKE_area_find_region_xy(struct ScrArea *area, int regiontype, const int xy[2]) - ATTR_NONNULL(3); +struct ARegion *BKE_area_find_region_active_win(const struct ScrArea *area); +struct ARegion *BKE_area_find_region_xy(const struct ScrArea *area, + int regiontype, + const int xy[2]) ATTR_NONNULL(3); /** * \note This is only for screen level regions (typically menus/popups). */ -struct ARegion *BKE_screen_find_region_xy(struct bScreen *screen, +struct ARegion *BKE_screen_find_region_xy(const struct bScreen *screen, int regiontype, const int xy[2]) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 3); -struct ARegion *BKE_screen_find_main_region_at_xy(struct bScreen *screen, +struct ARegion *BKE_screen_find_main_region_at_xy(const struct bScreen *screen, int space_type, const int xy[2]) ATTR_NONNULL(1, 3); /** * \note Ideally we can get the area from the context, * there are a few places however where this isn't practical. */ -struct ScrArea *BKE_screen_find_area_from_space(struct bScreen *screen, - struct SpaceLink *sl) ATTR_WARN_UNUSED_RESULT +struct ScrArea *BKE_screen_find_area_from_space(const struct bScreen *screen, + const struct SpaceLink *sl) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1, 2); /** * \note Using this function is generally a last resort, you really want to be * using the context when you can - campbell */ -struct ScrArea *BKE_screen_find_big_area(struct bScreen *screen, int spacetype, short min); +struct ScrArea *BKE_screen_find_big_area(const struct bScreen *screen, int spacetype, short min); struct ScrArea *BKE_screen_area_map_find_area_xy(const struct ScrAreaMap *areamap, int spacetype, const int xy[2]) ATTR_NONNULL(1, 3); -struct ScrArea *BKE_screen_find_area_xy(struct bScreen *screen, int spacetype, const int xy[2]) - ATTR_NONNULL(1, 3); +struct ScrArea *BKE_screen_find_area_xy(const struct bScreen *screen, + int spacetype, + const int xy[2]) ATTR_NONNULL(1, 3); void BKE_screen_gizmo_tag_refresh(struct bScreen *screen); diff --git a/source/blender/blenkernel/intern/screen.cc b/source/blender/blenkernel/intern/screen.cc index 6580a3f0592..d89fbc65457 100644 --- a/source/blender/blenkernel/intern/screen.cc +++ b/source/blender/blenkernel/intern/screen.cc @@ -986,7 +986,7 @@ ARegion *BKE_area_find_region_type(const ScrArea *area, int region_type) return nullptr; } -ARegion *BKE_area_find_region_active_win(ScrArea *area) +ARegion *BKE_area_find_region_active_win(const ScrArea *area) { if (area == nullptr) { return nullptr; @@ -1002,7 +1002,7 @@ ARegion *BKE_area_find_region_active_win(ScrArea *area) return BKE_area_find_region_type(area, RGN_TYPE_WINDOW); } -ARegion *BKE_area_find_region_xy(ScrArea *area, const int regiontype, const int xy[2]) +ARegion *BKE_area_find_region_xy(const ScrArea *area, const int regiontype, const int xy[2]) { if (area == nullptr) { return nullptr; @@ -1018,7 +1018,7 @@ ARegion *BKE_area_find_region_xy(ScrArea *area, const int regiontype, const int return nullptr; } -ARegion *BKE_screen_find_region_xy(bScreen *screen, const int regiontype, const int xy[2]) +ARegion *BKE_screen_find_region_xy(const bScreen *screen, const int regiontype, const int xy[2]) { LISTBASE_FOREACH (ARegion *, region, &screen->regionbase) { if (ELEM(regiontype, RGN_TYPE_ANY, region->regiontype)) { @@ -1030,7 +1030,7 @@ ARegion *BKE_screen_find_region_xy(bScreen *screen, const int regiontype, const return nullptr; } -ScrArea *BKE_screen_find_area_from_space(bScreen *screen, SpaceLink *sl) +ScrArea *BKE_screen_find_area_from_space(const bScreen *screen, const SpaceLink *sl) { LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (BLI_findindex(&area->spacedata, sl) != -1) { @@ -1041,7 +1041,7 @@ ScrArea *BKE_screen_find_area_from_space(bScreen *screen, SpaceLink *sl) return nullptr; } -ScrArea *BKE_screen_find_big_area(bScreen *screen, const int spacetype, const short min) +ScrArea *BKE_screen_find_big_area(const bScreen *screen, const int spacetype, const short min) { ScrArea *big = nullptr; int maxsize = 0; @@ -1078,7 +1078,7 @@ ScrArea *BKE_screen_area_map_find_area_xy(const ScrAreaMap *areamap, } return nullptr; } -ScrArea *BKE_screen_find_area_xy(bScreen *screen, const int spacetype, const int xy[2]) +ScrArea *BKE_screen_find_area_xy(const bScreen *screen, const int spacetype, const int xy[2]) { return BKE_screen_area_map_find_area_xy(AREAMAP_FROM_SCREEN(screen), spacetype, xy); }