Blender  V2.93
interface_regions.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2008 Blender Foundation.
17  * All rights reserved.
18  */
19 
28 #include "BLI_listbase.h"
29 #include "BLI_utildefines.h"
30 #include "MEM_guardedalloc.h"
31 
32 #include "BKE_context.h"
33 #include "BKE_screen.h"
34 
35 #include "WM_api.h"
36 #include "wm_draw.h"
37 
38 #include "ED_screen.h"
39 
41 
43 {
44  ARegion *region = MEM_callocN(sizeof(ARegion), __func__);
45  BLI_addtail(&screen->regionbase, region);
46 
48  region->alignment = RGN_ALIGN_FLOAT;
49 
50  return region;
51 }
52 
54 {
55  wmWindow *win = CTX_wm_window(C);
56 
58  BLI_assert(BLI_findindex(&screen->regionbase, region) != -1);
59  if (win) {
60  wm_draw_region_clear(win, region);
61  }
62 
63  ED_region_exit(C, region);
64  BKE_area_region_free(NULL, region); /* NULL: no spacetype */
65  BLI_freelinkN(&screen->regionbase, region);
66 }
struct wmWindow * CTX_wm_window(const bContext *C)
Definition: context.c:699
void BKE_area_region_free(struct SpaceType *st, struct ARegion *region)
Definition: screen.c:663
#define BLI_assert(a)
Definition: BLI_assert.h:58
void BLI_freelinkN(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c:281
void BLI_addtail(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition: listbase.c: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(struct bContext *C, struct ARegion *region)
Definition: screen_edit.c:572
Read Guarded memory(de)allocation.
#define C
Definition: RandGen.cpp:39
void ui_region_temp_remove(bContext *C, bScreen *screen, ARegion *region)
ARegion * ui_region_temp_add(bScreen *screen)
void *(* MEM_callocN)(size_t len, const char *str)
Definition: mallocn.c:45
short alignment
short regiontype
ListBase regionbase
void wm_draw_region_clear(wmWindow *win, ARegion *UNUSED(region))
Definition: wm_draw.c:1080