4 * ***** BEGIN GPL LICENSE BLOCK *****
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * The Original Code is Copyright (C) Blender Foundation, 2008
22 * ***** END GPL/BL DUAL LICENSE BLOCK *****
27 #include "MEM_guardedalloc.h"
28 #include "BLI_blenlib.h"
30 #include "DNA_object_types.h"
31 #include "DNA_scene_types.h"
32 #include "DNA_windowmanager_types.h"
34 #include "BKE_context.h"
35 #include "BKE_screen.h"
37 #include "UI_interface.h"
38 #include "UI_view2d.h"
42 #include "ED_anim_api.h"
43 #include "ED_armature.h"
45 #include "ED_gpencil.h"
46 #include "ED_markers.h"
48 #include "ED_object.h"
49 #include "ED_physics.h"
50 #include "ED_render.h"
51 #include "ED_screen.h"
52 #include "ED_sculpt.h"
53 #include "ED_space_api.h"
55 #include "ED_uvedit.h"
58 /* only call once on startup, storage is global in BKE kernel listbase */
59 void ED_spacetypes_init(void)
61 const ListBase *spacetypes;
64 /* create space types */
65 ED_spacetype_outliner();
67 ED_spacetype_view3d();
71 ED_spacetype_buttons();
75 ED_spacetype_action();
77 ED_spacetype_script();
79 ED_spacetype_sequencer();
81 ED_spacetype_console();
82 ED_spacetype_userpref();
85 /* register operator types for screen and all spaces */
86 ED_operatortypes_screen();
87 ED_operatortypes_anim();
88 ED_operatortypes_animchannels();
89 ED_operatortypes_gpencil();
90 ED_operatortypes_object();
91 ED_operatortypes_mesh();
92 ED_operatortypes_sculpt();
93 ED_operatortypes_uvedit();
94 ED_operatortypes_paint();
95 ED_operatortypes_physics();
96 ED_operatortypes_curve();
97 ED_operatortypes_armature();
98 ED_operatortypes_marker();
99 ED_operatortypes_metaball();
100 ED_operatortypes_sound();
101 ED_operatortypes_render();
103 ui_view2d_operatortypes();
105 spacetypes = BKE_spacetypes_list();
106 for(type=spacetypes->first; type; type=type->next)
107 type->operatortypes();
110 /* Macros's must go last since they reference other operators
111 * maybe we'll need to have them go after python operators too? */
112 ED_operatormacros_mesh();
113 ED_operatormacros_object();
117 /* keymap definitions are registered only once per WM initialize, usually on file read,
118 using the keymap the actual areas/regions add the handlers */
119 void ED_spacetypes_keymap(wmKeyConfig *keyconf)
121 const ListBase *spacetypes;
125 ED_keymap_screen(keyconf);
126 ED_keymap_anim(keyconf);
127 ED_keymap_animchannels(keyconf);
128 ED_keymap_gpencil(keyconf);
129 ED_keymap_object(keyconf);
130 ED_keymap_mesh(keyconf);
131 ED_keymap_uvedit(keyconf);
132 ED_keymap_curve(keyconf);
133 ED_keymap_armature(keyconf);
134 ED_keymap_physics(keyconf);
135 ED_keymap_metaball(keyconf);
136 ED_keymap_paint(keyconf);
137 ED_marker_keymap(keyconf);
139 UI_view2d_keymap(keyconf);
141 spacetypes = BKE_spacetypes_list();
142 for(stype=spacetypes->first; stype; stype=stype->next) {
144 stype->keymap(keyconf);
145 for(atype=stype->regiontypes.first; atype; atype=atype->next) {
147 atype->keymap(keyconf);
152 /* ********************** custom drawcall api ***************** */
155 #define REGION_DRAW_PRE 1
156 #define REGION_DRAW_POST 0
158 typedef struct RegionDrawCB {
159 struct RegionDrawCB *next, *prev;
161 void (*draw)(const struct bContext *, struct ARegion *, void *);
168 void *ED_region_draw_cb_activate(ARegionType *art,
169 void (*draw)(const struct bContext *, struct ARegion *, void *),
170 void *customdata, int type)
172 RegionDrawCB *rdc= MEM_callocN(sizeof(RegionDrawCB), "RegionDrawCB");
174 BLI_addtail(&art->drawcalls, rdc);
176 rdc->customdata= customdata;
182 void ED_region_draw_cb_exit(ARegionType *art, void *handle)
186 for(rdc= art->drawcalls.first; rdc; rdc= rdc->next) {
187 if(rdc==(RegionDrawCB *)handle) {
188 BLI_remlink(&art->drawcalls, rdc);
195 void ED_region_draw_cb_draw(const bContext *C, ARegion *ar, int type)
199 for(rdc= ar->type->drawcalls.first; rdc; rdc= rdc->next) {
201 rdc->draw(C, ar, rdc->customdata);
207 /* ********************* space template *********************** */
209 /* allocate and init some vars */
210 static SpaceLink *xxx_new(const bContext *C)
215 /* not spacelink itself */
216 static void xxx_free(SpaceLink *sl)
221 /* spacetype; init callback for usage, should be redoable */
222 static void xxx_init(wmWindowManager *wm, ScrArea *sa)
225 /* link area to SpaceXXX struct */
227 /* define how many regions, the order and types */
229 /* add types to regions */
232 static SpaceLink *xxx_duplicate(SpaceLink *sl)
238 static void xxx_operatortypes(void)
240 /* register operator types for this space */
243 static void xxx_keymap(wmKeyConfig *keyconf)
245 /* add default items to keymap */
248 /* only called once, from screen/spacetypes.c */
249 void ED_spacetype_xxx(void)
253 st.spaceid= SPACE_VIEW3D;
258 st.duplicate= xxx_duplicate;
259 st.operatortypes= xxx_operatortypes;
260 st.keymap= xxx_keymap;
262 BKE_spacetype_register(&st);
265 /* ****************************** end template *********************** */