From 091c175c5c128d4107563d03054c5b32dc17e7c7 Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Fri, 15 Nov 2024 02:00:11 +0100 Subject: [PATCH] Refactor: Move region runtime to separate C++ runtime struct This allows using C++ types in the region runtime data, which will make it easier to move the remaining runtime data out of the `ARegion` DNA type and improve code readability in these areas. Pull Request: https://projects.blender.org/blender/blender/pulls/130196 --- source/blender/blenkernel/BKE_screen.hh | 31 ++++++++++++++ source/blender/blenkernel/intern/screen.cc | 19 ++++++--- .../blenloader/intern/versioning_250.cc | 41 ++++++++----------- .../blenloader/intern/versioning_260.cc | 2 +- .../blenloader/intern/versioning_270.cc | 3 +- .../blenloader/intern/versioning_280.cc | 10 ++--- .../blenloader/intern/versioning_300.cc | 1 + .../blenloader/intern/versioning_common.cc | 13 +++--- source/blender/editors/interface/interface.cc | 20 ++++----- .../interface/regions/interface_region_hud.cc | 6 +-- .../regions/interface_region_popup.cc | 6 +-- .../interface/regions/interface_regions.cc | 2 +- .../interface_template_search_menu.cc | 4 +- source/blender/editors/screen/area.cc | 18 ++++---- .../editors/space_action/space_action.cc | 8 ++-- .../editors/space_buttons/space_buttons.cc | 8 ++-- .../blender/editors/space_clip/space_clip.cc | 12 +++--- .../editors/space_console/space_console.cc | 4 +- .../blender/editors/space_file/space_file.cc | 12 +++--- .../editors/space_graph/space_graph.cc | 8 ++-- .../editors/space_image/space_image.cc | 14 +++---- .../blender/editors/space_info/space_info.cc | 4 +- source/blender/editors/space_nla/space_nla.cc | 8 ++-- .../blender/editors/space_node/space_node.cc | 8 ++-- .../editors/space_outliner/space_outliner.cc | 4 +- .../editors/space_script/space_script.cc | 4 +- .../space_sequencer/space_sequencer.cc | 14 +++---- .../space_spreadsheet/space_spreadsheet.cc | 10 ++--- .../space_statusbar/space_statusbar.cc | 2 +- .../blender/editors/space_text/space_text.cc | 8 ++-- .../blender/editors/space_text/text_header.cc | 2 +- .../editors/space_topbar/space_topbar.cc | 6 +-- .../editors/space_userpref/space_userpref.cc | 8 ++-- .../editors/space_view3d/space_view3d.cc | 14 +++---- source/blender/makesdna/DNA_screen_types.h | 28 +++---------- 35 files changed, 186 insertions(+), 176 deletions(-) diff --git a/source/blender/blenkernel/BKE_screen.hh b/source/blender/blenkernel/BKE_screen.hh index 5ef883db81d..d867b06a13a 100644 --- a/source/blender/blenkernel/BKE_screen.hh +++ b/source/blender/blenkernel/BKE_screen.hh @@ -12,6 +12,7 @@ #include "BLI_compiler_attrs.h" #include "BLI_math_vector_types.hh" +#include "BLI_rect.h" #include "BLI_vector.hh" #include "RNA_types.hh" @@ -31,6 +32,7 @@ struct AssetShelfType; struct BlendDataReader; struct BlendLibReader; struct BlendWriter; +struct GHash; struct Header; struct ID; struct LayoutPanelState; @@ -417,6 +419,32 @@ struct Panel_Runtime { LayoutPanels layout_panels; }; +namespace blender::bke { + +struct ARegionRuntime { + /** Panel category to use between 'layout' and 'draw'. */ + const char *category = nullptr; + + /** + * The visible part of the region, use with region overlap not to draw + * on top of the overlapping regions. + * + * Lazy initialize, zero'd when unset, relative to #ARegion.winrct x/y min. */ + rcti visible_rect = {}; + + /* The offset needed to not overlap with window scroll-bars. Only used by HUD regions for now. */ + int offset_x = 0; + int offset_y = 0; + + /** Maps #uiBlock::name to uiBlock for faster lookups. */ + GHash *block_name_map = nullptr; + + /* Dummy panel used in popups so they can support layout panels. */ + Panel *popup_block_panel = nullptr; +}; + +} // namespace blender::bke + /* #uiList types. */ /** Draw an item in the `ui_list`. */ @@ -613,6 +641,9 @@ void BKE_spacedata_id_unref(ScrArea *area, SpaceLink *sl, ID *id); /* Area/regions. */ ARegion *BKE_area_region_copy(const SpaceType *st, const ARegion *region); + +ARegion *BKE_area_region_new(); + /** * Doesn't free the region itself. */ diff --git a/source/blender/blenkernel/intern/screen.cc b/source/blender/blenkernel/intern/screen.cc index 2ddf9befe70..034258bcc64 100644 --- a/source/blender/blenkernel/intern/screen.cc +++ b/source/blender/blenkernel/intern/screen.cc @@ -336,7 +336,7 @@ ARegion *BKE_area_region_copy(const SpaceType *st, const ARegion *region) { ARegion *newar = static_cast(MEM_dupallocN(region)); - memset(&newar->runtime, 0x0, sizeof(newar->runtime)); + newar->runtime = MEM_new(__func__); newar->prev = newar->next = nullptr; BLI_listbase_clear(&newar->handlers); @@ -373,6 +373,13 @@ ARegion *BKE_area_region_copy(const SpaceType *st, const ARegion *region) return newar; } +ARegion *BKE_area_region_new() +{ + ARegion *region = MEM_cnew(__func__); + region->runtime = MEM_new(__func__); + return region; +} + /* from lb_src to lb_dst, lb_dst is supposed to be freed */ static void region_copylist(SpaceType *st, ListBase *lb_dst, ListBase *lb_src) { @@ -593,11 +600,12 @@ void BKE_area_region_free(SpaceType *st, ARegion *region) region_free_gizmomap_callback(region->gizmo_map); } - if (region->runtime.block_name_map != nullptr) { - BLI_ghash_free(region->runtime.block_name_map, nullptr, nullptr); - region->runtime.block_name_map = nullptr; + if (region->runtime->block_name_map != nullptr) { + BLI_ghash_free(region->runtime->block_name_map, nullptr, nullptr); + region->runtime->block_name_map = nullptr; } + MEM_delete(region->runtime); BLI_freelistN(®ion->ui_lists); BLI_freelistN(®ion->ui_previews); BLI_freelistN(®ion->panels_category); @@ -1186,8 +1194,6 @@ static void direct_link_panel_list(BlendDataReader *reader, ListBase *lb) static void direct_link_region(BlendDataReader *reader, ARegion *region, int spacetype) { - memset(®ion->runtime, 0x0, sizeof(region->runtime)); - direct_link_panel_list(reader, ®ion->panels); BLO_read_struct_list(reader, PanelCategoryStack, ®ion->panels_category_active); @@ -1247,6 +1253,7 @@ static void direct_link_region(BlendDataReader *reader, ARegion *region, int spa } } + region->runtime = MEM_new(__func__); region->v2d.sms = nullptr; region->v2d.alpha_hor = region->v2d.alpha_vert = 255; /* visible by default */ BLI_listbase_clear(®ion->panels_category); diff --git a/source/blender/blenloader/intern/versioning_250.cc b/source/blender/blenloader/intern/versioning_250.cc index 5806beedb3b..53a9fcc14c0 100644 --- a/source/blender/blenloader/intern/versioning_250.cc +++ b/source/blender/blenloader/intern/versioning_250.cc @@ -80,8 +80,7 @@ /* 2.50 patch */ static void area_add_header_region(ScrArea *area, ListBase *lb) { - ARegion *region = static_cast( - MEM_callocN(sizeof(ARegion), "area region from do_versions")); + ARegion *region = BKE_area_region_new(); BLI_addtail(lb, region); region->regiontype = RGN_TYPE_HEADER; @@ -132,16 +131,14 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb) /* first channels for ipo action nla... */ switch (sl->spacetype) { case SPACE_GRAPH: - region = static_cast( - MEM_callocN(sizeof(ARegion), "area region from do_versions")); + region = BKE_area_region_new(); BLI_addtail(lb, region); region->regiontype = RGN_TYPE_CHANNELS; region->alignment = RGN_ALIGN_LEFT; region->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); /* for some reason, this doesn't seem to go auto like for NLA... */ - region = static_cast( - MEM_callocN(sizeof(ARegion), "area region from do_versions")); + region = BKE_area_region_new(); BLI_addtail(lb, region); region->regiontype = RGN_TYPE_UI; region->alignment = RGN_ALIGN_RIGHT; @@ -150,8 +147,7 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb) break; case SPACE_ACTION: - region = static_cast( - MEM_callocN(sizeof(ARegion), "area region from do_versions")); + region = BKE_area_region_new(); BLI_addtail(lb, region); region->regiontype = RGN_TYPE_CHANNELS; region->alignment = RGN_ALIGN_LEFT; @@ -160,8 +156,7 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb) break; case SPACE_NLA: - region = static_cast( - MEM_callocN(sizeof(ARegion), "area region from do_versions")); + region = BKE_area_region_new(); BLI_addtail(lb, region); region->regiontype = RGN_TYPE_CHANNELS; region->alignment = RGN_ALIGN_LEFT; @@ -169,8 +164,7 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb) region->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; /* for some reason, some files still don't get this auto */ - region = static_cast( - MEM_callocN(sizeof(ARegion), "area region from do_versions")); + region = BKE_area_region_new(); BLI_addtail(lb, region); region->regiontype = RGN_TYPE_UI; region->alignment = RGN_ALIGN_RIGHT; @@ -179,7 +173,7 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb) break; case SPACE_NODE: - region = static_cast(MEM_callocN(sizeof(ARegion), "nodetree area for node")); + region = BKE_area_region_new(); BLI_addtail(lb, region); region->regiontype = RGN_TYPE_UI; region->alignment = RGN_ALIGN_LEFT; @@ -189,12 +183,12 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb) region->flag = RGN_FLAG_HIDDEN; break; case SPACE_FILE: - region = static_cast(MEM_callocN(sizeof(ARegion), "nodetree area for node")); + region = BKE_area_region_new(); BLI_addtail(lb, region); region->regiontype = RGN_TYPE_CHANNELS; region->alignment = RGN_ALIGN_LEFT; - region = static_cast(MEM_callocN(sizeof(ARegion), "ui area for file")); + region = BKE_area_region_new(); BLI_addtail(lb, region); region->regiontype = RGN_TYPE_UI; region->alignment = RGN_ALIGN_TOP; @@ -207,15 +201,14 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb) break; } } - region = static_cast( - MEM_callocN(sizeof(ARegion), "preview area for sequencer")); + region = BKE_area_region_new(); BLI_insertlinkbefore(lb, region_main, region); sequencer_init_preview_region(region); break; } case SPACE_VIEW3D: /* toolbar */ - region = static_cast(MEM_callocN(sizeof(ARegion), "toolbar for view3d")); + region = BKE_area_region_new(); BLI_addtail(lb, region); region->regiontype = RGN_TYPE_TOOLS; @@ -223,8 +216,7 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb) region->flag = RGN_FLAG_HIDDEN; /* tool properties */ - region = static_cast( - MEM_callocN(sizeof(ARegion), "tool properties for view3d")); + region = BKE_area_region_new(); BLI_addtail(lb, region); region->regiontype = RGN_TYPE_TOOL_PROPS; @@ -232,7 +224,7 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb) region->flag = RGN_FLAG_HIDDEN; /* buttons/list view */ - region = static_cast(MEM_callocN(sizeof(ARegion), "buttons for view3d")); + region = BKE_area_region_new(); BLI_addtail(lb, region); region->regiontype = RGN_TYPE_UI; @@ -241,7 +233,7 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb) #if 0 case SPACE_PROPERTIES: /* context UI region */ - region = MEM_callocN(sizeof(ARegion), "area region from do_versions"); + region = BKE_area_region_new(); BLI_addtail(lb, region); region->regiontype = RGN_TYPE_UI; region->alignment = RGN_ALIGN_RIGHT; @@ -252,7 +244,7 @@ static void area_add_window_regions(ScrArea *area, SpaceLink *sl, ListBase *lb) } /* main region */ - region = static_cast(MEM_callocN(sizeof(ARegion), "area region from do_versions")); + region = BKE_area_region_new(); BLI_addtail(lb, region); region->winrct = area->totrct; @@ -1212,8 +1204,7 @@ void blo_do_versions_250(FileData *fd, Library * /*lib*/, Main *bmain) break; } } - ARegion *region = static_cast( - MEM_callocN(sizeof(ARegion), "preview area for sequencer")); + ARegion *region = BKE_area_region_new(); BLI_insertlinkbefore(regionbase, region_main, region); sequencer_init_preview_region(region); } diff --git a/source/blender/blenloader/intern/versioning_260.cc b/source/blender/blenloader/intern/versioning_260.cc index e88529df586..b7cd7a490e0 100644 --- a/source/blender/blenloader/intern/versioning_260.cc +++ b/source/blender/blenloader/intern/versioning_260.cc @@ -2637,7 +2637,7 @@ void blo_do_versions_260(FileData *fd, Library * /*lib*/, Main *bmain) continue; } - ARegion *arnew = MEM_cnew("node tools"); + ARegion *arnew = BKE_area_region_new(); BLI_insertlinkafter(&area->regionbase, region, arnew); arnew->regiontype = RGN_TYPE_TOOLS; diff --git a/source/blender/blenloader/intern/versioning_270.cc b/source/blender/blenloader/intern/versioning_270.cc index 44792a5ebf2..4564b0c16e7 100644 --- a/source/blender/blenloader/intern/versioning_270.cc +++ b/source/blender/blenloader/intern/versioning_270.cc @@ -234,8 +234,7 @@ static void do_version_action_editor_properties_region(ListBase *regionbase) } if (region->regiontype == RGN_TYPE_WINDOW) { /* add new region here */ - ARegion *region_new = static_cast( - MEM_callocN(sizeof(ARegion), "buttons for action")); + ARegion *region_new = BKE_area_region_new(); BLI_insertlinkbefore(regionbase, region, region_new); diff --git a/source/blender/blenloader/intern/versioning_280.cc b/source/blender/blenloader/intern/versioning_280.cc index f8f4aae1f77..db3beff0634 100644 --- a/source/blender/blenloader/intern/versioning_280.cc +++ b/source/blender/blenloader/intern/versioning_280.cc @@ -452,6 +452,7 @@ static void do_versions_fix_annotations(bGPdata *gpd) static void do_versions_remove_region(ListBase *regionbase, ARegion *region) { + MEM_delete(region->runtime); BLI_freelinkN(regionbase, region); } @@ -4241,8 +4242,7 @@ void blo_do_versions_280(FileData *fd, Library * /*lib*/, Main *bmain) if (sl->spacetype == SPACE_PROPERTIES) { ListBase *regionbase = (sl == area->spacedata.first) ? &area->regionbase : &sl->regionbase; - ARegion *region = static_cast( - MEM_callocN(sizeof(ARegion), "navigation bar for properties")); + ARegion *region = BKE_area_region_new(); ARegion *region_header = nullptr; for (region_header = static_cast(regionbase->first); @@ -4471,8 +4471,7 @@ void blo_do_versions_280(FileData *fd, Library * /*lib*/, Main *bmain) ListBase *regionbase = (slink == area->spacedata.first) ? &area->regionbase : &slink->regionbase; - navigation_region = static_cast( - MEM_callocN(sizeof(ARegion), "userpref navigation-region do_versions")); + navigation_region = BKE_area_region_new(); /* Order matters, addhead not addtail! */ BLI_insertlinkbefore(regionbase, main_region, navigation_region); @@ -4743,8 +4742,7 @@ void blo_do_versions_280(FileData *fd, Library * /*lib*/, Main *bmain) &sl->regionbase; ARegion *region_navbar = BKE_spacedata_find_region_type(sl, area, RGN_TYPE_NAV_BAR); - execute_region = static_cast( - MEM_callocN(sizeof(ARegion), "execute region for properties")); + execute_region = BKE_area_region_new(); BLI_assert(region_navbar); diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index b98aaf2e122..7df94e7499a 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -4007,6 +4007,7 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) ARegion *channels_region = BKE_region_find_in_listbase_by_type(regionbase, RGN_TYPE_CHANNELS); if (channels_region) { + MEM_delete(channels_region->runtime); BLI_freelinkN(regionbase, channels_region); } } diff --git a/source/blender/blenloader/intern/versioning_common.cc b/source/blender/blenloader/intern/versioning_common.cc index c2b2a2d6214..dedf1336555 100644 --- a/source/blender/blenloader/intern/versioning_common.cc +++ b/source/blender/blenloader/intern/versioning_common.cc @@ -31,6 +31,7 @@ #include "BKE_node.hh" #include "BKE_node_runtime.hh" #include "BKE_node_tree_update.hh" +#include "BKE_screen.hh" #include "NOD_socket.hh" @@ -60,7 +61,7 @@ short do_versions_new_to_old_idcode_get(const short id_code_new) ARegion *do_versions_add_region_if_not_found(ListBase *regionbase, int region_type, - const char *allocname, + const char * /*allocname*/, int link_after_region_type) { ARegion *link_after_region = nullptr; @@ -73,7 +74,7 @@ ARegion *do_versions_add_region_if_not_found(ListBase *regionbase, } } - ARegion *new_region = static_cast(MEM_callocN(sizeof(ARegion), allocname)); + ARegion *new_region = BKE_area_region_new(); new_region->regiontype = region_type; BLI_insertlinkafter(regionbase, link_after_region, new_region); return new_region; @@ -81,7 +82,7 @@ ARegion *do_versions_add_region_if_not_found(ListBase *regionbase, ARegion *do_versions_ensure_region(ListBase *regionbase, int region_type, - const char *allocname, + const char * /*allocname*/, int link_after_region_type) { ARegion *link_after_region = nullptr; @@ -94,7 +95,7 @@ ARegion *do_versions_ensure_region(ListBase *regionbase, } } - ARegion *new_region = MEM_cnew(allocname); + ARegion *new_region = BKE_area_region_new(); new_region->regiontype = region_type; BLI_insertlinkafter(regionbase, link_after_region, new_region); return new_region; @@ -364,9 +365,9 @@ void version_socket_update_is_used(bNodeTree *ntree) } } -ARegion *do_versions_add_region(int regiontype, const char *name) +ARegion *do_versions_add_region(int regiontype, const char * /*name*/) { - ARegion *region = (ARegion *)MEM_callocN(sizeof(ARegion), name); + ARegion *region = BKE_area_region_new(); region->regiontype = regiontype; return region; } diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc index bfb47793e5a..bea4c78afee 100644 --- a/source/blender/editors/interface/interface.cc +++ b/source/blender/editors/interface/interface.cc @@ -3736,9 +3736,9 @@ void UI_blocklist_free(const bContext *C, ARegion *region) while (uiBlock *block = static_cast(BLI_pophead(lb))) { UI_block_free(C, block); } - if (region->runtime.block_name_map != nullptr) { - BLI_ghash_free(region->runtime.block_name_map, nullptr, nullptr); - region->runtime.block_name_map = nullptr; + if (region->runtime->block_name_map != nullptr) { + BLI_ghash_free(region->runtime->block_name_map, nullptr, nullptr); + region->runtime->block_name_map = nullptr; } } @@ -3752,11 +3752,11 @@ void UI_blocklist_free_inactive(const bContext *C, ARegion *region) block->active = false; } else { - if (region->runtime.block_name_map != nullptr) { + if (region->runtime->block_name_map != nullptr) { uiBlock *b = static_cast( - BLI_ghash_lookup(region->runtime.block_name_map, block->name.c_str())); + BLI_ghash_lookup(region->runtime->block_name_map, block->name.c_str())); if (b == block) { - BLI_ghash_remove(region->runtime.block_name_map, b->name.c_str(), nullptr, nullptr); + BLI_ghash_remove(region->runtime->block_name_map, b->name.c_str(), nullptr, nullptr); } } BLI_remlink(lb, block); @@ -3774,10 +3774,10 @@ void UI_block_region_set(uiBlock *block, ARegion *region) /* each listbase only has one block with this name, free block * if is already there so it can be rebuilt from scratch */ if (lb) { - if (region->runtime.block_name_map == nullptr) { - region->runtime.block_name_map = BLI_ghash_str_new(__func__); + if (region->runtime->block_name_map == nullptr) { + region->runtime->block_name_map = BLI_ghash_str_new(__func__); } - oldblock = (uiBlock *)BLI_ghash_lookup(region->runtime.block_name_map, block->name.c_str()); + oldblock = (uiBlock *)BLI_ghash_lookup(region->runtime->block_name_map, block->name.c_str()); if (oldblock) { oldblock->active = false; @@ -3787,7 +3787,7 @@ void UI_block_region_set(uiBlock *block, ARegion *region) /* at the beginning of the list! for dynamical menus/blocks */ BLI_addhead(lb, block); - BLI_ghash_reinsert(region->runtime.block_name_map, + BLI_ghash_reinsert(region->runtime->block_name_map, const_cast(block->name.c_str()), block, nullptr, diff --git a/source/blender/editors/interface/regions/interface_region_hud.cc b/source/blender/editors/interface/regions/interface_region_hud.cc index 226c5f0868d..8b25f2ccf54 100644 --- a/source/blender/editors/interface/regions/interface_region_hud.cc +++ b/source/blender/editors/interface/regions/interface_region_hud.cc @@ -240,7 +240,7 @@ ARegionType *ED_area_type_hud(int space_type) static ARegion *hud_region_add(ScrArea *area) { - ARegion *region = MEM_cnew(__func__); + ARegion *region = BKE_area_region_new(); ARegion *region_win = BKE_area_find_region_type(area, RGN_TYPE_WINDOW); if (region_win) { BLI_insertlinkbefore(&area->regionbase, region_win, region); @@ -354,8 +354,8 @@ void ED_area_type_hud_ensure(bContext *C, ScrArea *area) float x, y; UI_view2d_scroller_size_get(®ion_win->v2d, true, &x, &y); - region->runtime.offset_x = x; - region->runtime.offset_y = y; + region->runtime->offset_x = x; + region->runtime->offset_y = y; } /* Reset zoom level (not well supported). */ diff --git a/source/blender/editors/interface/regions/interface_region_popup.cc b/source/blender/editors/interface/regions/interface_region_popup.cc index 943311dc4b1..d620dba5520 100644 --- a/source/blender/editors/interface/regions/interface_region_popup.cc +++ b/source/blender/editors/interface/regions/interface_region_popup.cc @@ -610,7 +610,7 @@ void ui_layout_panel_popup_scroll_apply(Panel *panel, const float dy) void UI_popup_dummy_panel_set(ARegion *region, uiBlock *block) { - Panel *&panel = region->runtime.popup_block_panel; + Panel *&panel = region->runtime->popup_block_panel; if (!panel) { /* Dummy popup panel type. */ static PanelType panel_type = []() { @@ -996,8 +996,8 @@ void ui_popup_block_free(bContext *C, uiPopupBlockHandle *handle) handle->popup_create_vars.arg_free(handle->popup_create_vars.arg); } - if (handle->region->runtime.popup_block_panel) { - BKE_panel_free(handle->region->runtime.popup_block_panel); + if (handle->region->runtime->popup_block_panel) { + BKE_panel_free(handle->region->runtime->popup_block_panel); } ui_popup_block_remove(C, handle); diff --git a/source/blender/editors/interface/regions/interface_regions.cc b/source/blender/editors/interface/regions/interface_regions.cc index 7c3436cb024..26cf9679da0 100644 --- a/source/blender/editors/interface/regions/interface_regions.cc +++ b/source/blender/editors/interface/regions/interface_regions.cc @@ -25,7 +25,7 @@ ARegion *ui_region_temp_add(bScreen *screen) { - ARegion *region = MEM_cnew(__func__); + ARegion *region = BKE_area_region_new(); BLI_addtail(&screen->regionbase, region); region->regiontype = RGN_TYPE_TEMPORARY; diff --git a/source/blender/editors/interface/templates/interface_template_search_menu.cc b/source/blender/editors/interface/templates/interface_template_search_menu.cc index 3b78d1b6ae3..3ff45d422df 100644 --- a/source/blender/editors/interface/templates/interface_template_search_menu.cc +++ b/source/blender/editors/interface/templates/interface_template_search_menu.cc @@ -800,14 +800,14 @@ static MenuSearch_Data *menu_items_from_ui_create(bContext *C, if (region) { BLI_ghash_remove( - region->runtime.block_name_map, sub_block->name.c_str(), nullptr, nullptr); + region->runtime->block_name_map, sub_block->name.c_str(), nullptr, nullptr); BLI_remlink(®ion->uiblocks, sub_block); } UI_block_free(nullptr, sub_block); } } if (region) { - BLI_ghash_remove(region->runtime.block_name_map, block->name.c_str(), nullptr, nullptr); + BLI_ghash_remove(region->runtime->block_name_map, block->name.c_str(), nullptr, nullptr); BLI_remlink(®ion->uiblocks, block); } UI_block_free(nullptr, block); diff --git a/source/blender/editors/screen/area.cc b/source/blender/editors/screen/area.cc index 653438c6457..c64e506870b 100644 --- a/source/blender/editors/screen/area.cc +++ b/source/blender/editors/screen/area.cc @@ -1545,8 +1545,8 @@ static void region_rect_recursive( BLI_rcti_resize(&overlap_remainder_margin, max_ii(0, BLI_rcti_size_x(overlap_remainder) - UI_UNIT_X / 2), max_ii(0, BLI_rcti_size_y(overlap_remainder) - UI_UNIT_Y / 2)); - region->winrct.xmin = overlap_remainder_margin.xmin + region->runtime.offset_x; - region->winrct.ymin = overlap_remainder_margin.ymin + region->runtime.offset_y; + region->winrct.xmin = overlap_remainder_margin.xmin + region->runtime->offset_x; + region->winrct.ymin = overlap_remainder_margin.ymin + region->runtime->offset_y; region->winrct.xmax = region->winrct.xmin + prefsizex - 1; region->winrct.ymax = region->winrct.ymin + prefsizey - 1; @@ -1786,7 +1786,7 @@ static void region_rect_recursive( } /* Clear, initialize on demand. */ - memset(®ion->runtime.visible_rect, 0, sizeof(region->runtime.visible_rect)); + memset(®ion->runtime->visible_rect, 0, sizeof(region->runtime->visible_rect)); } static void area_calc_totrct(ScrArea *area, const rcti *window_rect) @@ -3105,7 +3105,7 @@ void ED_region_panels_layout_ex(const bContext *C, } } - region->runtime.category = nullptr; + region->runtime->category = nullptr; ScrArea *area = CTX_wm_area(C); View2D *v2d = ®ion->v2d; @@ -3257,7 +3257,7 @@ void ED_region_panels_layout_ex(const bContext *C, } if (use_category_tabs) { - region->runtime.category = category; + region->runtime->category = category; } } @@ -3292,14 +3292,14 @@ void ED_region_panels_draw(const bContext *C, ARegion *region) UI_view2d_view_restore(C); /* Set in layout. */ - if (region->runtime.category) { - UI_panel_category_draw_all(region, region->runtime.category); + if (region->runtime->category) { + UI_panel_category_draw_all(region, region->runtime->category); } /* scrollers */ bool use_mask = false; rcti mask; - if (region->runtime.category && + if (region->runtime->category && (RGN_ALIGN_ENUM_FROM_MASK(region->alignment) == RGN_ALIGN_RIGHT) && UI_panel_category_is_visible(region)) { @@ -4002,7 +4002,7 @@ static void region_visible_rect_calc(ARegion *region, rcti *rect) const rcti *ED_region_visible_rect(ARegion *region) { - rcti *rect = ®ion->runtime.visible_rect; + rcti *rect = ®ion->runtime->visible_rect; if (rect->xmin == 0 && rect->ymin == 0 && rect->xmax == 0 && rect->ymax == 0) { region_visible_rect_calc(region, rect); } diff --git a/source/blender/editors/space_action/space_action.cc b/source/blender/editors/space_action/space_action.cc index 1db66cf0459..02c85348534 100644 --- a/source/blender/editors/space_action/space_action.cc +++ b/source/blender/editors/space_action/space_action.cc @@ -71,14 +71,14 @@ static SpaceLink *action_create(const ScrArea *area, const Scene *scene) TIME_CACHE_RIGIDBODY | TIME_CACHE_SIMULATION_NODES; /* header */ - region = MEM_cnew("header for action"); + region = BKE_area_region_new(); BLI_addtail(&saction->regionbase, region); region->regiontype = RGN_TYPE_HEADER; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; /* channel list region */ - region = MEM_cnew("channel region for action"); + region = BKE_area_region_new(); BLI_addtail(&saction->regionbase, region); region->regiontype = RGN_TYPE_CHANNELS; region->alignment = RGN_ALIGN_LEFT; @@ -88,14 +88,14 @@ static SpaceLink *action_create(const ScrArea *area, const Scene *scene) region->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; /* ui buttons */ - region = MEM_cnew("buttons region for action"); + region = BKE_area_region_new(); BLI_addtail(&saction->regionbase, region); region->regiontype = RGN_TYPE_UI; region->alignment = RGN_ALIGN_RIGHT; /* main region */ - region = MEM_cnew("main region for action"); + region = BKE_area_region_new(); BLI_addtail(&saction->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; diff --git a/source/blender/editors/space_buttons/space_buttons.cc b/source/blender/editors/space_buttons/space_buttons.cc index 954b70a8758..5985e89931c 100644 --- a/source/blender/editors/space_buttons/space_buttons.cc +++ b/source/blender/editors/space_buttons/space_buttons.cc @@ -55,14 +55,14 @@ static SpaceLink *buttons_create(const ScrArea * /*area*/, const Scene * /*scene sbuts->mainb = sbuts->mainbuser = BCONTEXT_OBJECT; /* header */ - region = static_cast(MEM_callocN(sizeof(ARegion), "header for buts")); + region = BKE_area_region_new(); BLI_addtail(&sbuts->regionbase, region); region->regiontype = RGN_TYPE_HEADER; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; /* navigation bar */ - region = static_cast(MEM_callocN(sizeof(ARegion), "navigation bar for buts")); + region = BKE_area_region_new(); BLI_addtail(&sbuts->regionbase, region); region->regiontype = RGN_TYPE_NAV_BAR; @@ -70,14 +70,14 @@ static SpaceLink *buttons_create(const ScrArea * /*area*/, const Scene * /*scene #if 0 /* context region */ - region = MEM_callocN(sizeof(ARegion), "context region for buts"); + region = BKE_area_region_new(); BLI_addtail(&sbuts->regionbase, region); region->regiontype = RGN_TYPE_CHANNELS; region->alignment = RGN_ALIGN_TOP; #endif /* main region */ - region = static_cast(MEM_callocN(sizeof(ARegion), "main region for buts")); + region = BKE_area_region_new(); BLI_addtail(&sbuts->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; diff --git a/source/blender/editors/space_clip/space_clip.cc b/source/blender/editors/space_clip/space_clip.cc index 702903ba9fb..6dc5b7999b4 100644 --- a/source/blender/editors/space_clip/space_clip.cc +++ b/source/blender/editors/space_clip/space_clip.cc @@ -162,28 +162,28 @@ static SpaceLink *clip_create(const ScrArea * /*area*/, const Scene * /*scene*/) sc = DNA_struct_default_alloc(SpaceClip); /* header */ - region = MEM_cnew("header for clip"); + region = BKE_area_region_new(); BLI_addtail(&sc->regionbase, region); region->regiontype = RGN_TYPE_HEADER; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; /* tools view */ - region = MEM_cnew("tools for clip"); + region = BKE_area_region_new(); BLI_addtail(&sc->regionbase, region); region->regiontype = RGN_TYPE_TOOLS; region->alignment = RGN_ALIGN_LEFT; /* properties view */ - region = MEM_cnew("properties for clip"); + region = BKE_area_region_new(); BLI_addtail(&sc->regionbase, region); region->regiontype = RGN_TYPE_UI; region->alignment = RGN_ALIGN_RIGHT; /* channels view */ - region = MEM_cnew("channels for clip"); + region = BKE_area_region_new(); BLI_addtail(&sc->regionbase, region); region->regiontype = RGN_TYPE_CHANNELS; @@ -193,13 +193,13 @@ static SpaceLink *clip_create(const ScrArea * /*area*/, const Scene * /*scene*/) region->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; /* preview view */ - region = MEM_cnew("preview for clip"); + region = BKE_area_region_new(); BLI_addtail(&sc->regionbase, region); region->regiontype = RGN_TYPE_PREVIEW; /* main region */ - region = MEM_cnew("main region for clip"); + region = BKE_area_region_new(); BLI_addtail(&sc->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; diff --git a/source/blender/editors/space_console/space_console.cc b/source/blender/editors/space_console/space_console.cc index 4d54b364288..bf69d0ae566 100644 --- a/source/blender/editors/space_console/space_console.cc +++ b/source/blender/editors/space_console/space_console.cc @@ -46,14 +46,14 @@ static SpaceLink *console_create(const ScrArea * /*area*/, const Scene * /*scene sconsole->lheight = 14; /* header */ - region = static_cast(MEM_callocN(sizeof(ARegion), "header for console")); + region = BKE_area_region_new(); BLI_addtail(&sconsole->regionbase, region); region->regiontype = RGN_TYPE_HEADER; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; /* main region */ - region = static_cast(MEM_callocN(sizeof(ARegion), "main region for text")); + region = BKE_area_region_new(); BLI_addtail(&sconsole->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; diff --git a/source/blender/editors/space_file/space_file.cc b/source/blender/editors/space_file/space_file.cc index e0a8106824d..f1017897758 100644 --- a/source/blender/editors/space_file/space_file.cc +++ b/source/blender/editors/space_file/space_file.cc @@ -59,41 +59,41 @@ static SpaceLink *file_create(const ScrArea * /*area*/, const Scene * /*scene*/) sfile->spacetype = SPACE_FILE; /* header */ - region = static_cast(MEM_callocN(sizeof(ARegion), "header for file")); + region = BKE_area_region_new(); BLI_addtail(&sfile->regionbase, region); region->regiontype = RGN_TYPE_HEADER; /* Ignore user preference "USER_HEADER_BOTTOM" here (always show top for new types). */ region->alignment = RGN_ALIGN_TOP; /* Tools region */ - region = static_cast(MEM_callocN(sizeof(ARegion), "tools region for file")); + region = BKE_area_region_new(); BLI_addtail(&sfile->regionbase, region); region->regiontype = RGN_TYPE_TOOLS; region->alignment = RGN_ALIGN_LEFT; /* ui list region */ - region = static_cast(MEM_callocN(sizeof(ARegion), "ui region for file")); + region = BKE_area_region_new(); BLI_addtail(&sfile->regionbase, region); region->regiontype = RGN_TYPE_UI; region->alignment = RGN_ALIGN_TOP; region->flag = RGN_FLAG_DYNAMIC_SIZE | RGN_FLAG_NO_USER_RESIZE; /* execute region */ - region = static_cast(MEM_callocN(sizeof(ARegion), "execute region for file")); + region = BKE_area_region_new(); BLI_addtail(&sfile->regionbase, region); region->regiontype = RGN_TYPE_EXECUTE; region->alignment = RGN_ALIGN_BOTTOM; region->flag = RGN_FLAG_DYNAMIC_SIZE | RGN_FLAG_NO_USER_RESIZE; /* tools props region */ - region = static_cast(MEM_callocN(sizeof(ARegion), "tool props for file")); + region = BKE_area_region_new(); BLI_addtail(&sfile->regionbase, region); region->regiontype = RGN_TYPE_TOOL_PROPS; region->alignment = RGN_ALIGN_RIGHT; region->flag = RGN_FLAG_HIDDEN; /* main region */ - region = static_cast(MEM_callocN(sizeof(ARegion), "main region for file")); + region = BKE_area_region_new(); BLI_addtail(&sfile->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; region->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); diff --git a/source/blender/editors/space_graph/space_graph.cc b/source/blender/editors/space_graph/space_graph.cc index 0fa9099a114..5960f616b5b 100644 --- a/source/blender/editors/space_graph/space_graph.cc +++ b/source/blender/editors/space_graph/space_graph.cc @@ -70,14 +70,14 @@ static SpaceLink *graph_create(const ScrArea * /*area*/, const Scene *scene) sipo->flag |= SIPO_SHOW_MARKERS; /* header */ - region = static_cast(MEM_callocN(sizeof(ARegion), "header for graphedit")); + region = BKE_area_region_new(); BLI_addtail(&sipo->regionbase, region); region->regiontype = RGN_TYPE_HEADER; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; /* channels */ - region = static_cast(MEM_callocN(sizeof(ARegion), "channels region for graphedit")); + region = BKE_area_region_new(); BLI_addtail(&sipo->regionbase, region); region->regiontype = RGN_TYPE_CHANNELS; @@ -86,14 +86,14 @@ static SpaceLink *graph_create(const ScrArea * /*area*/, const Scene *scene) region->v2d.scroll = (V2D_SCROLL_RIGHT | V2D_SCROLL_BOTTOM); /* ui buttons */ - region = static_cast(MEM_callocN(sizeof(ARegion), "buttons region for graphedit")); + region = BKE_area_region_new(); BLI_addtail(&sipo->regionbase, region); region->regiontype = RGN_TYPE_UI; region->alignment = RGN_ALIGN_RIGHT; /* main region */ - region = static_cast(MEM_callocN(sizeof(ARegion), "main region for graphedit")); + region = BKE_area_region_new(); BLI_addtail(&sipo->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; diff --git a/source/blender/editors/space_image/space_image.cc b/source/blender/editors/space_image/space_image.cc index ad6fc0cfb8e..0fde74abedf 100644 --- a/source/blender/editors/space_image/space_image.cc +++ b/source/blender/editors/space_image/space_image.cc @@ -120,27 +120,27 @@ static SpaceLink *image_create(const ScrArea * /*area*/, const Scene * /*scene*/ simage->mask_info = *DNA_struct_default_get(MaskSpaceInfo); /* header */ - region = static_cast(MEM_callocN(sizeof(ARegion), "header for image")); + region = BKE_area_region_new(); BLI_addtail(&simage->regionbase, region); region->regiontype = RGN_TYPE_HEADER; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; /* asset shelf */ - region = MEM_cnew("asset shelf for view3d"); + region = BKE_area_region_new(); BLI_addtail(&simage->regionbase, region); region->regiontype = RGN_TYPE_ASSET_SHELF; region->alignment = RGN_ALIGN_BOTTOM; region->flag |= RGN_FLAG_HIDDEN; /* asset shelf header */ - region = MEM_cnew("asset shelf header for view3d"); + region = BKE_area_region_new(); BLI_addtail(&simage->regionbase, region); region->regiontype = RGN_TYPE_ASSET_SHELF_HEADER; region->alignment = RGN_ALIGN_BOTTOM | RGN_ALIGN_HIDE_WITH_PREV; /* tool header */ - region = static_cast(MEM_callocN(sizeof(ARegion), "tool header for image")); + region = BKE_area_region_new(); BLI_addtail(&simage->regionbase, region); region->regiontype = RGN_TYPE_TOOL_HEADER; @@ -148,7 +148,7 @@ static SpaceLink *image_create(const ScrArea * /*area*/, const Scene * /*scene*/ region->flag = RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER; /* buttons/list view */ - region = static_cast(MEM_callocN(sizeof(ARegion), "buttons for image")); + region = BKE_area_region_new(); BLI_addtail(&simage->regionbase, region); region->regiontype = RGN_TYPE_UI; @@ -156,7 +156,7 @@ static SpaceLink *image_create(const ScrArea * /*area*/, const Scene * /*scene*/ region->flag = RGN_FLAG_HIDDEN; /* scopes/uv sculpt/paint */ - region = static_cast(MEM_callocN(sizeof(ARegion), "buttons for image")); + region = BKE_area_region_new(); BLI_addtail(&simage->regionbase, region); region->regiontype = RGN_TYPE_TOOLS; @@ -164,7 +164,7 @@ static SpaceLink *image_create(const ScrArea * /*area*/, const Scene * /*scene*/ region->flag = RGN_FLAG_HIDDEN; /* main area */ - region = static_cast(MEM_callocN(sizeof(ARegion), "main area for image")); + region = BKE_area_region_new(); BLI_addtail(&simage->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; diff --git a/source/blender/editors/space_info/space_info.cc b/source/blender/editors/space_info/space_info.cc index c3aa588f7dd..8e83158eaa6 100644 --- a/source/blender/editors/space_info/space_info.cc +++ b/source/blender/editors/space_info/space_info.cc @@ -44,14 +44,14 @@ static SpaceLink *info_create(const ScrArea * /*area*/, const Scene * /*scene*/) sinfo->rpt_mask = INFO_RPT_OP; /* header */ - region = static_cast(MEM_callocN(sizeof(ARegion), "header for info")); + region = BKE_area_region_new(); BLI_addtail(&sinfo->regionbase, region); region->regiontype = RGN_TYPE_HEADER; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; /* main region */ - region = static_cast(MEM_callocN(sizeof(ARegion), "main region for info")); + region = BKE_area_region_new(); BLI_addtail(&sinfo->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; diff --git a/source/blender/editors/space_nla/space_nla.cc b/source/blender/editors/space_nla/space_nla.cc index 68a4ecca110..77d0254c6ae 100644 --- a/source/blender/editors/space_nla/space_nla.cc +++ b/source/blender/editors/space_nla/space_nla.cc @@ -61,14 +61,14 @@ static SpaceLink *nla_create(const ScrArea *area, const Scene *scene) snla->flag = SNLA_SHOW_MARKERS; /* header */ - region = MEM_cnew("header for nla"); + region = BKE_area_region_new(); BLI_addtail(&snla->regionbase, region); region->regiontype = RGN_TYPE_HEADER; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; /* track list region */ - region = MEM_cnew("track list for nla"); + region = BKE_area_region_new(); BLI_addtail(&snla->regionbase, region); region->regiontype = RGN_TYPE_CHANNELS; region->alignment = RGN_ALIGN_LEFT; @@ -78,14 +78,14 @@ static SpaceLink *nla_create(const ScrArea *area, const Scene *scene) region->v2d.flag = V2D_VIEWSYNC_AREA_VERTICAL; /* ui buttons */ - region = MEM_cnew("buttons region for nla"); + region = BKE_area_region_new(); BLI_addtail(&snla->regionbase, region); region->regiontype = RGN_TYPE_UI; region->alignment = RGN_ALIGN_RIGHT; /* main region */ - region = MEM_cnew("main region for nla"); + region = BKE_area_region_new(); BLI_addtail(&snla->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; diff --git a/source/blender/editors/space_node/space_node.cc b/source/blender/editors/space_node/space_node.cc index 87c6a015d40..4332d23094e 100644 --- a/source/blender/editors/space_node/space_node.cc +++ b/source/blender/editors/space_node/space_node.cc @@ -409,21 +409,21 @@ static SpaceLink *node_create(const ScrArea * /*area*/, const Scene * /*scene*/) NODE_TREE_TYPES_END; /* header */ - ARegion *region = MEM_cnew("header for node"); + ARegion *region = BKE_area_region_new(); BLI_addtail(&snode->regionbase, region); region->regiontype = RGN_TYPE_HEADER; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; /* buttons/list view */ - region = MEM_cnew("buttons for node"); + region = BKE_area_region_new(); BLI_addtail(&snode->regionbase, region); region->regiontype = RGN_TYPE_UI; region->alignment = RGN_ALIGN_RIGHT; /* toolbar */ - region = MEM_cnew("node tools"); + region = BKE_area_region_new(); BLI_addtail(&snode->regionbase, region); region->regiontype = RGN_TYPE_TOOLS; @@ -432,7 +432,7 @@ static SpaceLink *node_create(const ScrArea * /*area*/, const Scene * /*scene*/) region->flag = RGN_FLAG_HIDDEN; /* main region */ - region = MEM_cnew("main region for node"); + region = BKE_area_region_new(); BLI_addtail(&snode->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; diff --git a/source/blender/editors/space_outliner/space_outliner.cc b/source/blender/editors/space_outliner/space_outliner.cc index 69a4f6652fd..5343db9943c 100644 --- a/source/blender/editors/space_outliner/space_outliner.cc +++ b/source/blender/editors/space_outliner/space_outliner.cc @@ -382,14 +382,14 @@ static SpaceLink *outliner_create(const ScrArea * /*area*/, const Scene * /*scen space_outliner->filter = SO_FILTER_NO_VIEW_LAYERS; /* header */ - region = MEM_cnew("header for outliner"); + region = BKE_area_region_new(); BLI_addtail(&space_outliner->regionbase, region); region->regiontype = RGN_TYPE_HEADER; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; /* main region */ - region = MEM_cnew("main region for outliner"); + region = BKE_area_region_new(); BLI_addtail(&space_outliner->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; diff --git a/source/blender/editors/space_script/space_script.cc b/source/blender/editors/space_script/space_script.cc index 020c20227f8..3eed26521e6 100644 --- a/source/blender/editors/space_script/space_script.cc +++ b/source/blender/editors/space_script/space_script.cc @@ -43,14 +43,14 @@ static SpaceLink *script_create(const ScrArea * /*area*/, const Scene * /*scene* sscript->spacetype = SPACE_SCRIPT; /* header */ - region = static_cast(MEM_callocN(sizeof(ARegion), "header for script")); + region = BKE_area_region_new(); BLI_addtail(&sscript->regionbase, region); region->regiontype = RGN_TYPE_HEADER; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; /* main region */ - region = static_cast(MEM_callocN(sizeof(ARegion), "main region for script")); + region = BKE_area_region_new(); BLI_addtail(&sscript->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; diff --git a/source/blender/editors/space_sequencer/space_sequencer.cc b/source/blender/editors/space_sequencer/space_sequencer.cc index 4381a186965..0f97398c650 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.cc +++ b/source/blender/editors/space_sequencer/space_sequencer.cc @@ -104,14 +104,14 @@ static SpaceLink *sequencer_create(const ScrArea * /*area*/, const Scene *scene) sseq->draw_flag |= SEQ_DRAW_TRANSFORM_PREVIEW; /* Header. */ - region = MEM_cnew("header for sequencer"); + region = BKE_area_region_new(); BLI_addtail(&sseq->regionbase, static_cast(region)); region->regiontype = RGN_TYPE_HEADER; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; /* Tool header. */ - region = MEM_cnew("tool header for sequencer"); + region = BKE_area_region_new(); BLI_addtail(&sseq->regionbase, static_cast(region)); region->regiontype = RGN_TYPE_TOOL_HEADER; @@ -119,7 +119,7 @@ static SpaceLink *sequencer_create(const ScrArea * /*area*/, const Scene *scene) region->flag = RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER; /* Buttons/list view. */ - region = MEM_cnew("buttons for sequencer"); + region = BKE_area_region_new(); BLI_addtail(&sseq->regionbase, static_cast(region)); region->regiontype = RGN_TYPE_UI; @@ -127,14 +127,14 @@ static SpaceLink *sequencer_create(const ScrArea * /*area*/, const Scene *scene) region->flag = RGN_FLAG_HIDDEN; /* Toolbar. */ - region = MEM_cnew("tools for sequencer"); + region = BKE_area_region_new(); BLI_addtail(&sseq->regionbase, static_cast(region)); region->regiontype = RGN_TYPE_TOOLS; region->alignment = RGN_ALIGN_LEFT; /* Channels. */ - region = MEM_cnew("channels for sequencer"); + region = BKE_area_region_new(); BLI_addtail(&sseq->regionbase, static_cast(region)); region->regiontype = RGN_TYPE_CHANNELS; @@ -143,7 +143,7 @@ static SpaceLink *sequencer_create(const ScrArea * /*area*/, const Scene *scene) /* Preview region. */ /* NOTE: if you change values here, also change them in sequencer_init_preview_region. */ - region = MEM_cnew("preview region for sequencer"); + region = BKE_area_region_new(); BLI_addtail(&sseq->regionbase, static_cast(region)); region->regiontype = RGN_TYPE_PREVIEW; region->alignment = RGN_ALIGN_TOP; @@ -164,7 +164,7 @@ static SpaceLink *sequencer_create(const ScrArea * /*area*/, const Scene *scene) region->v2d.keeptot = V2D_KEEPTOT_FREE; /* Main region. */ - region = MEM_cnew("main region for sequencer"); + region = BKE_area_region_new(); BLI_addtail(&sseq->regionbase, static_cast(region)); region->regiontype = RGN_TYPE_WINDOW; diff --git a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc index 6f250619946..23255cdd2fa 100644 --- a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc +++ b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc @@ -54,7 +54,7 @@ static SpaceLink *spreadsheet_create(const ScrArea * /*area*/, const Scene * /*s { /* Header. */ - ARegion *region = MEM_cnew("spreadsheet header"); + ARegion *region = BKE_area_region_new(); BLI_addtail(&spreadsheet_space->regionbase, region); region->regiontype = RGN_TYPE_HEADER; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; @@ -62,7 +62,7 @@ static SpaceLink *spreadsheet_create(const ScrArea * /*area*/, const Scene * /*s { /* Footer. */ - ARegion *region = MEM_cnew("spreadsheet footer region"); + ARegion *region = BKE_area_region_new(); BLI_addtail(&spreadsheet_space->regionbase, region); region->regiontype = RGN_TYPE_FOOTER; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM; @@ -70,7 +70,7 @@ static SpaceLink *spreadsheet_create(const ScrArea * /*area*/, const Scene * /*s { /* Dataset Region */ - ARegion *region = MEM_cnew("spreadsheet dataset region"); + ARegion *region = BKE_area_region_new(); BLI_addtail(&spreadsheet_space->regionbase, region); region->regiontype = RGN_TYPE_TOOLS; region->alignment = RGN_ALIGN_LEFT; @@ -78,7 +78,7 @@ static SpaceLink *spreadsheet_create(const ScrArea * /*area*/, const Scene * /*s { /* Properties region. */ - ARegion *region = MEM_cnew("spreadsheet right region"); + ARegion *region = BKE_area_region_new(); BLI_addtail(&spreadsheet_space->regionbase, region); region->regiontype = RGN_TYPE_UI; region->alignment = RGN_ALIGN_RIGHT; @@ -87,7 +87,7 @@ static SpaceLink *spreadsheet_create(const ScrArea * /*area*/, const Scene * /*s { /* Main window. */ - ARegion *region = MEM_cnew("spreadsheet main region"); + ARegion *region = BKE_area_region_new(); BLI_addtail(&spreadsheet_space->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; } diff --git a/source/blender/editors/space_statusbar/space_statusbar.cc b/source/blender/editors/space_statusbar/space_statusbar.cc index 811ded68566..939e569fdd4 100644 --- a/source/blender/editors/space_statusbar/space_statusbar.cc +++ b/source/blender/editors/space_statusbar/space_statusbar.cc @@ -37,7 +37,7 @@ static SpaceLink *statusbar_create(const ScrArea * /*area*/, const Scene * /*sce sstatusbar->spacetype = SPACE_STATUSBAR; /* header region */ - region = static_cast(MEM_callocN(sizeof(*region), "header for statusbar")); + region = BKE_area_region_new(); BLI_addtail(&sstatusbar->regionbase, region); region->regiontype = RGN_TYPE_HEADER; region->alignment = RGN_ALIGN_NONE; diff --git a/source/blender/editors/space_text/space_text.cc b/source/blender/editors/space_text/space_text.cc index 1f20384b1f6..370ee37db64 100644 --- a/source/blender/editors/space_text/space_text.cc +++ b/source/blender/editors/space_text/space_text.cc @@ -57,20 +57,20 @@ static SpaceLink *text_create(const ScrArea * /*area*/, const Scene * /*scene*/) stext->runtime = MEM_new(__func__); /* header */ - region = static_cast(MEM_callocN(sizeof(ARegion), "header for text")); + region = BKE_area_region_new(); BLI_addtail(&stext->regionbase, region); region->regiontype = RGN_TYPE_HEADER; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; /* footer */ - region = static_cast(MEM_callocN(sizeof(ARegion), "footer for text")); + region = BKE_area_region_new(); BLI_addtail(&stext->regionbase, region); region->regiontype = RGN_TYPE_FOOTER; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_TOP : RGN_ALIGN_BOTTOM; /* properties region */ - region = static_cast(MEM_callocN(sizeof(ARegion), "properties region for text")); + region = BKE_area_region_new(); BLI_addtail(&stext->regionbase, region); region->regiontype = RGN_TYPE_UI; @@ -78,7 +78,7 @@ static SpaceLink *text_create(const ScrArea * /*area*/, const Scene * /*scene*/) region->flag = RGN_FLAG_HIDDEN; /* main region */ - region = static_cast(MEM_callocN(sizeof(ARegion), "main region for text")); + region = BKE_area_region_new(); BLI_addtail(&stext->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; diff --git a/source/blender/editors/space_text/text_header.cc b/source/blender/editors/space_text/text_header.cc index cc19b75eb18..a1dc844cb85 100644 --- a/source/blender/editors/space_text/text_header.cc +++ b/source/blender/editors/space_text/text_header.cc @@ -46,7 +46,7 @@ static ARegion *text_has_properties_region(ScrArea *area) return nullptr; } - arnew = static_cast(MEM_callocN(sizeof(ARegion), "properties region")); + arnew = BKE_area_region_new(); BLI_insertlinkafter(&area->regionbase, region, arnew); arnew->regiontype = RGN_TYPE_UI; diff --git a/source/blender/editors/space_topbar/space_topbar.cc b/source/blender/editors/space_topbar/space_topbar.cc index 1f9d838a733..f6ef6276df7 100644 --- a/source/blender/editors/space_topbar/space_topbar.cc +++ b/source/blender/editors/space_topbar/space_topbar.cc @@ -46,17 +46,17 @@ static SpaceLink *topbar_create(const ScrArea * /*area*/, const Scene * /*scene* stopbar->spacetype = SPACE_TOPBAR; /* header */ - region = static_cast(MEM_callocN(sizeof(ARegion), "left aligned header for topbar")); + region = BKE_area_region_new(); BLI_addtail(&stopbar->regionbase, region); region->regiontype = RGN_TYPE_HEADER; region->alignment = RGN_ALIGN_TOP; - region = static_cast(MEM_callocN(sizeof(ARegion), "right aligned header for topbar")); + region = BKE_area_region_new(); BLI_addtail(&stopbar->regionbase, region); region->regiontype = RGN_TYPE_HEADER; region->alignment = RGN_ALIGN_RIGHT | RGN_SPLIT_PREV; /* main regions */ - region = static_cast(MEM_callocN(sizeof(ARegion), "main region of topbar")); + region = BKE_area_region_new(); BLI_addtail(&stopbar->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; diff --git a/source/blender/editors/space_userpref/space_userpref.cc b/source/blender/editors/space_userpref/space_userpref.cc index f078ae17e4c..c6054fa70c9 100644 --- a/source/blender/editors/space_userpref/space_userpref.cc +++ b/source/blender/editors/space_userpref/space_userpref.cc @@ -40,7 +40,7 @@ static SpaceLink *userpref_create(const ScrArea *area, const Scene * /*scene*/) spref->spacetype = SPACE_USERPREF; /* header */ - region = static_cast(MEM_callocN(sizeof(ARegion), "header for userpref")); + region = BKE_area_region_new(); BLI_addtail(&spref->regionbase, region); region->regiontype = RGN_TYPE_HEADER; @@ -48,7 +48,7 @@ static SpaceLink *userpref_create(const ScrArea *area, const Scene * /*scene*/) region->alignment = RGN_ALIGN_BOTTOM; /* navigation region */ - region = static_cast(MEM_callocN(sizeof(ARegion), "navigation region for userpref")); + region = BKE_area_region_new(); BLI_addtail(&spref->regionbase, region); region->regiontype = RGN_TYPE_NAV_BAR; @@ -60,7 +60,7 @@ static SpaceLink *userpref_create(const ScrArea *area, const Scene * /*scene*/) } /* execution region */ - region = static_cast(MEM_callocN(sizeof(ARegion), "execution region for userpref")); + region = BKE_area_region_new(); BLI_addtail(&spref->regionbase, region); region->regiontype = RGN_TYPE_EXECUTE; @@ -68,7 +68,7 @@ static SpaceLink *userpref_create(const ScrArea *area, const Scene * /*scene*/) region->flag |= RGN_FLAG_DYNAMIC_SIZE | RGN_FLAG_NO_USER_RESIZE; /* main region */ - region = static_cast(MEM_callocN(sizeof(ARegion), "main region for userpref")); + region = BKE_area_region_new(); BLI_addtail(&spref->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; diff --git a/source/blender/editors/space_view3d/space_view3d.cc b/source/blender/editors/space_view3d/space_view3d.cc index f36aa20c4b9..e74bf08f8f1 100644 --- a/source/blender/editors/space_view3d/space_view3d.cc +++ b/source/blender/editors/space_view3d/space_view3d.cc @@ -208,14 +208,14 @@ static SpaceLink *view3d_create(const ScrArea * /*area*/, const Scene *scene) } /* header */ - region = MEM_cnew("header for view3d"); + region = BKE_area_region_new(); BLI_addtail(&v3d->regionbase, region); region->regiontype = RGN_TYPE_HEADER; region->alignment = (U.uiflag & USER_HEADER_BOTTOM) ? RGN_ALIGN_BOTTOM : RGN_ALIGN_TOP; /* tool header */ - region = MEM_cnew("tool header for view3d"); + region = BKE_area_region_new(); BLI_addtail(&v3d->regionbase, region); region->regiontype = RGN_TYPE_TOOL_HEADER; @@ -223,7 +223,7 @@ static SpaceLink *view3d_create(const ScrArea * /*area*/, const Scene *scene) region->flag = RGN_FLAG_HIDDEN | RGN_FLAG_HIDDEN_BY_USER; /* asset shelf */ - region = MEM_cnew("asset shelf for view3d"); + region = BKE_area_region_new(); BLI_addtail(&v3d->regionbase, region); region->regiontype = RGN_TYPE_ASSET_SHELF; @@ -231,13 +231,13 @@ static SpaceLink *view3d_create(const ScrArea * /*area*/, const Scene *scene) region->flag |= RGN_FLAG_HIDDEN; /* asset shelf header */ - region = MEM_cnew("asset shelf header for view3d"); + region = BKE_area_region_new(); BLI_addtail(&v3d->regionbase, region); region->regiontype = RGN_TYPE_ASSET_SHELF_HEADER; region->alignment = RGN_ALIGN_BOTTOM | RGN_ALIGN_HIDE_WITH_PREV; /* tool shelf */ - region = MEM_cnew("toolshelf for view3d"); + region = BKE_area_region_new(); BLI_addtail(&v3d->regionbase, region); region->regiontype = RGN_TYPE_TOOLS; @@ -245,7 +245,7 @@ static SpaceLink *view3d_create(const ScrArea * /*area*/, const Scene *scene) region->flag = RGN_FLAG_HIDDEN; /* buttons/list view */ - region = MEM_cnew("buttons for view3d"); + region = BKE_area_region_new(); BLI_addtail(&v3d->regionbase, region); region->regiontype = RGN_TYPE_UI; @@ -253,7 +253,7 @@ static SpaceLink *view3d_create(const ScrArea * /*area*/, const Scene *scene) region->flag = RGN_FLAG_HIDDEN; /* main region */ - region = MEM_cnew("main region for view3d"); + region = BKE_area_region_new(); BLI_addtail(&v3d->regionbase, region); region->regiontype = RGN_TYPE_WINDOW; diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index 457c83c8a51..9e52afc309b 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -35,10 +35,13 @@ struct wmTooltipState; struct Panel_Runtime; #ifdef __cplusplus namespace blender::bke { +struct ARegionRuntime; struct FileHandlerType; -} +} // namespace blender::bke +using ARegionRuntimeHandle = blender::bke::ARegionRuntime; using FileHandlerTypeHandle = blender::bke::FileHandlerType; #else +typedef struct ARegionRuntimeHandle ARegionRuntimeHandle; typedef struct FileHandlerTypeHandle FileHandlerTypeHandle; #endif @@ -450,27 +453,6 @@ typedef struct ScrArea { ScrArea_Runtime runtime; } ScrArea; -typedef struct ARegion_Runtime { - /** Panel category to use between 'layout' and 'draw'. */ - const char *category; - - /** - * The visible part of the region, use with region overlap not to draw - * on top of the overlapping regions. - * - * Lazy initialize, zero'd when unset, relative to #ARegion.winrct x/y min. */ - rcti visible_rect; - - /* The offset needed to not overlap with window scroll-bars. Only used by HUD regions for now. */ - int offset_x, offset_y; - - /** Maps #uiBlock::name to uiBlock for faster lookups. */ - struct GHash *block_name_map; - - /* Dummy panel used in popups so they can support layout panels. */ - Panel *popup_block_panel; -} ARegion_Runtime; - typedef struct ARegion { struct ARegion *next, *prev; @@ -542,7 +524,7 @@ typedef struct ARegion { /** XXX 2.50, need spacedata equivalent? */ void *regiondata; - ARegion_Runtime runtime; + ARegionRuntimeHandle *runtime; } ARegion; /** #ScrArea.flag */