Blender V5.3
space_project.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2026 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "BLI_listbase.hh"
10#include "BLI_string.hh"
11
12#include "BKE_screen.hh"
13
14#include "ED_screen.hh"
15#include "ED_space_api.hh"
16
17#include "DNA_space_types.h"
18
19#include "MEM_guardedalloc.h"
20
21#include "WM_api.hh"
22#include "WM_types.hh"
23
24#include "UI_interface.hh"
26#include "UI_view2d.hh"
27
28#include "BLO_read_write.hh"
29
30#include "project_intern.hh"
31
32namespace blender {
33
34static SpaceLink *project_create(const ScrArea * /*area*/, const Scene * /*scene*/)
35{
36 SpaceProject *project_space = MEM_new<SpaceProject>("project space");
37 project_space->spacetype = SPACE_PROJECT;
38
39 {
40 /* Header. */
41 ARegion *region = BKE_area_region_new();
42
43 BLI_addtail(&project_space->regionbase, region);
45 /* Always on bottom for new windows. */
47 }
48
49 {
50 /* Navigation region. */
51 ARegion *region = BKE_area_region_new();
52 BLI_addtail(&project_space->regionbase, region);
53 region->regiontype = RGN_TYPE_UI;
54 region->alignment = RGN_ALIGN_LEFT;
55 region->flag &= ~RGN_FLAG_HIDDEN;
56 }
57
58 {
59 /* Execution region. */
60 ARegion *region = BKE_area_region_new();
61
62 BLI_addtail(&project_space->regionbase, region);
66 }
67
68 {
69 /* Main region. */
70 ARegion *region = BKE_area_region_new();
71 BLI_addtail(&project_space->regionbase, region);
73 }
74
75 return (SpaceLink *)project_space;
76}
77
78static void project_free(SpaceLink * /*sl*/) {}
79
80static void project_init(wmWindowManager * /*wm*/, ScrArea * /*area*/) {}
81
83{
84 SpaceProject *space_project = MEM_dupalloc(reinterpret_cast<SpaceProject *>(sl));
85
86 return (SpaceLink *)space_project;
87}
88
90{
92}
93
108
109static void project_keymap(wmKeyConfig * /*keyconf*/) {}
110
111/* -------------------------------------------------------------------- */
114
121
122static void project_main_region_layout(const bContext *C, ARegion *region)
123{
124 ED_region_panels_layout(C, region);
125}
126
127static void project_main_region_draw(const bContext *C, ARegion *region)
128{
129 ED_region_panels(C, region);
130}
131
132static void project_main_region_listener(const wmRegionListenerParams * /*params*/) {}
133
135
136/* -------------------------------------------------------------------- */
139
141{
142 const ARegion *region_header = BKE_area_find_region_type(params->area, RGN_TYPE_HEADER);
143 return !region_header->runtime->visible;
144}
145
151
153
155
156/* -------------------------------------------------------------------- */
159
161{
162 ED_region_header_init(region);
163}
164
165static void project_header_region_draw(const bContext *C, ARegion *region)
166{
167 ED_region_header(C, region);
168}
169
171
173
174/* -------------------------------------------------------------------- */
177
184
186{
187 ED_region_panels(C, region);
188}
189
191
193
195{
196 std::unique_ptr<SpaceType> st = std::make_unique<SpaceType>();
197 ARegionType *art;
198
199 st->spaceid = SPACE_PROJECT;
200 STRNCPY(st->name, "Project Settings");
201 st->struct_size = sizeof(SpaceProject);
202
203 st->create = project_create;
204 st->free = project_free;
205 st->init = project_init;
206 st->duplicate = project_duplicate;
207 st->operatortypes = project_operatortypes;
208 st->keymap = project_keymap;
209 st->blend_write = project_space_blend_write;
210
211 /* regions: main window */
212 art = MEM_new_zeroed<ARegionType>("spacetype project region");
220
221 BLI_addhead(&st->regiontypes, art);
222
223 /* regions: header */
224 art = MEM_new_zeroed<ARegionType>("spacetype project region");
226 art->prefsizey = HEADERY;
231
232 BLI_addhead(&st->regiontypes, art);
233
234 /* regions: navigation window */
235 art = MEM_new_zeroed<ARegionType>("spacetype project region");
236 art->regionid = RGN_TYPE_UI;
243
244 BLI_addhead(&st->regiontypes, art);
245
246 /* regions: execution window */
247 art = MEM_new_zeroed<ARegionType>("spacetype project region");
249 art->prefsizey = HEADERY;
256
257 BLI_addhead(&st->regiontypes, art);
258
259 BKE_spacetype_register(std::move(st));
260}
261
262} // namespace blender
#define HEADERY
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define UI_NAVIGATION_REGION_WIDTH
BMesh Iterators.
void WM_operatortype_append(void(*opfunc)(wmOperatorType *))
char * STRNCPY(char(&dst)[N], const char *src)
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:98
void PROJECT_OT_open(wmOperatorType *ot)
static void project_init(wmWindowManager *, ScrArea *)
void PROJECT_OT_splash_image_create(wmOperatorType *ot)
void PROJECT_OT_variable_remove(wmOperatorType *ot)
static void project_header_region_draw(const bContext *C, ARegion *region)
void PROJECT_OT_close(wmOperatorType *ot)
void ED_spacetype_project()
static void project_main_region_layout(const bContext *C, ARegion *region)
void PROJECT_OT_config_save(wmOperatorType *ot)
static void project_main_region_listener(const wmRegionListenerParams *)
static bool project_execute_region_poll(const RegionPollParams *params)
static void project_execute_region_listener(const wmRegionListenerParams *)
static void project_main_region_init(wmWindowManager *wm, ARegion *region)
static void project_execute_region_init(wmWindowManager *wm, ARegion *region)
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void PROJECT_OT_asset_library_add(wmOperatorType *ot)
static void project_keymap(wmKeyConfig *)
void ED_region_panels(const bContext *C, ARegion *region)
Definition area.cc:3999
static SpaceLink * project_duplicate(SpaceLink *sl)
static void project_main_region_draw(const bContext *C, ARegion *region)
void PROJECT_OT_new(wmOperatorType *ot)
ARegion * BKE_area_region_new()
Definition screen.cc:522
static SpaceLink * project_create(const ScrArea *, const Scene *)
static void project_navigation_region_init(wmWindowManager *wm, ARegion *region)
static void project_header_region_init(wmWindowManager *, ARegion *region)
@ ED_KEYMAP_UI
Definition ED_screen.hh:852
@ ED_KEYMAP_NAVBAR
Definition ED_screen.hh:861
@ ED_KEYMAP_HEADER
Definition ED_screen.hh:858
@ ED_KEYMAP_VIEW2D
Definition ED_screen.hh:855
ARegion * BKE_area_find_region_type(const ScrArea *area, int region_type)
Definition screen.cc:1024
@ V2D_SCROLL_VERTICAL_HIDE
void PROJECT_OT_splash_image_clear(wmOperatorType *ot)
void PROJECT_OT_variable_move(wmOperatorType *ot)
void BLI_addtail(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
Definition listbase.cc:118
static void project_navigation_region_draw(const bContext *C, ARegion *region)
void BKE_spacetype_register(std::unique_ptr< SpaceType > st)
Definition screen.cc:379
void PROJECT_OT_asset_library_remove(wmOperatorType *ot)
void ED_region_header_init(ARegion *region)
Definition area.cc:4406
static void project_navigation_region_listener(const wmRegionListenerParams *)
static void project_space_blend_write(BlendWriter *writer, SpaceLink *sl)
static void project_header_region_listener(const wmRegionListenerParams *)
void ED_region_panels_layout(const bContext *C, ARegion *region)
Definition area.cc:3835
@ RGN_FLAG_NO_USER_RESIZE
void PROJECT_OT_variable_add(wmOperatorType *ot)
void ED_region_header(const bContext *C, ARegion *region)
Definition area.cc:4391
static void project_free(SpaceLink *)
void ED_region_panels_draw(const bContext *C, ARegion *region)
Definition area.cc:3916
void ED_region_panels_init(wmWindowManager *wm, ARegion *region)
Definition area.cc:4006
static void project_operatortypes()
ARegionTypeFlag flag
void(*) draw(const bContext *C, ARegion *region)
void(*) listener(const wmRegionListenerParams *params)
void(*) layout(const bContext *C, ARegion *region)
bool(*) poll(const RegionPollParams *params)
void(*) init(wmWindowManager *wm, ARegion *region)
bke::ARegionRuntime * runtime
eRegion_Alignment alignment
eRegion_Type regiontype
void write_struct_cast(const void *data, BlendStructWriterTypedFn< T > fn=nullptr)
ListBaseT< ARegion > regionbase
eView2D_KeepZoom keepzoom
eView2D_Scroll scroll