Blender V4.3
interface_regions.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
13#include "BLI_listbase.h"
14#include "BLI_utildefines.h"
15#include "MEM_guardedalloc.h"
16
17#include "BKE_context.hh"
18#include "BKE_screen.hh"
19
20#include "wm_draw.hh"
21
22#include "ED_screen.hh"
23
25
27{
28 ARegion *region = MEM_cnew<ARegion>(__func__);
29 BLI_addtail(&screen->regionbase, region);
30
31 region->regiontype = RGN_TYPE_TEMPORARY;
32 region->alignment = RGN_ALIGN_FLOAT;
33
34 return region;
35}
36
38{
39 wmWindow *win = CTX_wm_window(C);
40
41 BLI_assert(region->regiontype == RGN_TYPE_TEMPORARY);
42 BLI_assert(BLI_findindex(&screen->regionbase, region) != -1);
43 if (win) {
44 wm_draw_region_clear(win, region);
45 }
46
47 ED_region_exit(C, region);
48 BKE_area_region_free(nullptr, region); /* nullptr: no space-type. */
49 BLI_freelinkN(&screen->regionbase, region);
50
51 if (CTX_wm_region(C) == region) {
52 CTX_wm_region_set(C, nullptr);
53 }
54 if (CTX_wm_region_popup(C) == region) {
55 CTX_wm_region_popup_set(C, nullptr);
56 }
57}
ARegion * CTX_wm_region_popup(const bContext *C)
wmWindow * CTX_wm_window(const bContext *C)
void CTX_wm_region_set(bContext *C, ARegion *region)
ARegion * CTX_wm_region(const bContext *C)
void CTX_wm_region_popup_set(bContext *C, ARegion *region_popup)
void BKE_area_region_free(SpaceType *st, ARegion *region)
Definition screen.cc:563
#define BLI_assert(a)
Definition BLI_assert.h:50
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:269
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:110
int BLI_findindex(const struct ListBase *listbase, const void *vlink) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
@ RGN_ALIGN_FLOAT
@ RGN_TYPE_TEMPORARY
void ED_region_exit(bContext *C, ARegion *region)
Read Guarded memory(de)allocation.
ARegion * ui_region_temp_add(bScreen *screen)
void ui_region_temp_remove(bContext *C, bScreen *screen, ARegion *region)
void wm_draw_region_clear(wmWindow *win, ARegion *)
Definition wm_draw.cc:1597