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) 2008 Blender Foundation.
21 * All rights reserved.
24 * Contributor(s): Blender Foundation
26 * ***** END GPL LICENSE BLOCK *****
32 #include "DNA_color_types.h"
33 #include "DNA_object_types.h"
34 #include "DNA_outliner_types.h"
35 #include "DNA_space_types.h"
36 #include "DNA_scene_types.h"
37 #include "DNA_screen_types.h"
38 #include "DNA_space_types.h"
39 #include "DNA_texture_types.h"
40 #include "DNA_vec_types.h"
41 #include "DNA_windowmanager_types.h"
43 #include "MEM_guardedalloc.h"
45 #include "BLI_blenlib.h"
46 #include "BLI_arithb.h"
49 #include "BKE_colortools.h"
50 #include "BKE_context.h"
51 #include "BKE_screen.h"
52 #include "BKE_texture.h"
53 #include "BKE_utildefines.h"
55 #include "ED_space_api.h"
56 #include "ED_screen.h"
62 #include "BIF_glutil.h"
64 #include "UI_interface.h"
65 #include "UI_resources.h"
66 #include "UI_view2d.h"
68 #include "RNA_access.h"
69 #include "RNA_types.h"
71 #include "outliner_intern.h"
73 static void outliner_main_area_init(wmWindowManager *wm, ARegion *ar)
77 UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_LIST, ar->winx, ar->winy);
80 keymap= WM_keymap_find(wm, "Outliner", SPACE_OUTLINER, 0);
81 WM_event_add_keymap_handler_bb(&ar->handlers, keymap, &ar->v2d.mask, &ar->winrct);
84 static void outliner_main_area_draw(const bContext *C, ARegion *ar)
86 View2D *v2d= &ar->v2d;
87 View2DScrollers *scrollers;
91 UI_GetThemeColor3fv(TH_BACK, col);
92 glClearColor(col[0], col[1], col[2], 0.0);
93 glClear(GL_COLOR_BUFFER_BIT);
97 /* reset view matrix */
98 UI_view2d_view_restore(C);
101 scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
102 UI_view2d_scrollers_draw(C, v2d, scrollers);
103 UI_view2d_scrollers_free(scrollers);
107 static void outliner_main_area_free(ARegion *ar)
112 static void outliner_main_area_listener(ARegion *ar, wmNotifier *wmn)
114 /* context changes */
115 switch(wmn->category) {
123 case ND_RENDER_OPTIONS:
124 ED_region_tag_redraw(ar);
133 ED_region_tag_redraw(ar);
137 /* all actions now, todo: check outliner view mode? */
138 ED_region_tag_redraw(ar);
141 if(wmn->data == ND_SPACE_OUTLINER)
142 ED_region_tag_redraw(ar);
149 /* ************************ header outliner area region *********************** */
153 /* add handlers, stuff you only do once or on area/region changes */
154 static void outliner_header_area_init(wmWindowManager *wm, ARegion *ar)
157 ED_region_header_init(ar);
159 UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_HEADER, ar->winx, ar->winy);
163 static void outliner_header_area_draw(const bContext *C, ARegion *ar)
166 ED_region_header(C, ar);
170 if(ED_screen_area_active(C))
171 UI_GetThemeColor3fv(TH_HEADER, col);
173 UI_GetThemeColor3fv(TH_HEADERDESEL, col);
175 glClearColor(col[0], col[1], col[2], 0.0);
176 glClear(GL_COLOR_BUFFER_BIT);
178 /* set view2d view matrix for scrolling (without scrollers) */
179 UI_view2d_view_ortho(C, &ar->v2d);
181 outliner_header_buttons(C, ar);
185 static void outliner_header_area_free(ARegion *ar)
189 static void outliner_header_area_listener(ARegion *ar, wmNotifier *wmn)
191 /* context changes */
192 switch(wmn->category) {
194 if(wmn->data == ND_KEYINGSET)
195 ED_region_tag_redraw(ar);
198 if(wmn->data == ND_SPACE_OUTLINER)
199 ED_region_tag_redraw(ar);
204 /* ******************** default callbacks for outliner space ***************** */
206 static SpaceLink *outliner_new(const bContext *C)
209 SpaceOops *soutliner;
211 soutliner= MEM_callocN(sizeof(SpaceOops), "initoutliner");
212 soutliner->spacetype= SPACE_OUTLINER;
215 ar= MEM_callocN(sizeof(ARegion), "header for outliner");
217 BLI_addtail(&soutliner->regionbase, ar);
218 ar->regiontype= RGN_TYPE_HEADER;
219 ar->alignment= RGN_ALIGN_BOTTOM;
222 ar= MEM_callocN(sizeof(ARegion), "main area for outliner");
224 BLI_addtail(&soutliner->regionbase, ar);
225 ar->regiontype= RGN_TYPE_WINDOW;
227 ar->v2d.scroll = (V2D_SCROLL_RIGHT|V2D_SCROLL_BOTTOM_O);
228 ar->v2d.align = (V2D_ALIGN_NO_NEG_X|V2D_ALIGN_NO_POS_Y);
229 ar->v2d.keepzoom = (V2D_LOCKZOOM_X|V2D_LOCKZOOM_Y|V2D_LIMITZOOM|V2D_KEEPASPECT);
230 ar->v2d.keeptot= V2D_KEEPTOT_STRICT;
231 ar->v2d.minzoom= ar->v2d.maxzoom= 1.0f;
233 return (SpaceLink*)soutliner;
236 /* not spacelink itself */
237 static void outliner_free(SpaceLink *sl)
239 SpaceOops *soutliner= (SpaceOops*)sl;
241 outliner_free_tree(&soutliner->tree);
242 if(soutliner->treestore) {
243 if(soutliner->treestore->data) MEM_freeN(soutliner->treestore->data);
244 MEM_freeN(soutliner->treestore);
249 /* spacetype; init callback */
250 static void outliner_init(wmWindowManager *wm, ScrArea *sa)
255 static SpaceLink *outliner_duplicate(SpaceLink *sl)
257 SpaceOops *soutliner= (SpaceOops *)sl;
258 SpaceOops *soutlinern= MEM_dupallocN(soutliner);
260 soutlinern->tree.first= soutlinern->tree.last= NULL;
261 soutlinern->treestore= NULL;
263 return (SpaceLink *)soutlinern;
266 /* only called once, from space_api/spacetypes.c */
267 void ED_spacetype_outliner(void)
269 SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype time");
272 st->spaceid= SPACE_OUTLINER;
273 strncpy(st->name, "Outliner", BKE_ST_MAXNAME);
275 st->new= outliner_new;
276 st->free= outliner_free;
277 st->init= outliner_init;
278 st->duplicate= outliner_duplicate;
279 st->operatortypes= outliner_operatortypes;
280 st->keymap= outliner_keymap;
282 /* regions: main window */
283 art= MEM_callocN(sizeof(ARegionType), "spacetype time region");
284 art->regionid = RGN_TYPE_WINDOW;
285 art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
287 art->init= outliner_main_area_init;
288 art->draw= outliner_main_area_draw;
289 art->free= outliner_main_area_free;
290 art->listener= outliner_main_area_listener;
291 BLI_addhead(&st->regiontypes, art);
293 /* regions: header */
294 art= MEM_callocN(sizeof(ARegionType), "spacetype time region");
295 art->regionid = RGN_TYPE_HEADER;
296 art->minsizey= HEADERY;
297 art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
299 art->init= outliner_header_area_init;
300 art->draw= outliner_header_area_draw;
301 art->free= outliner_header_area_free;
302 art->listener= outliner_header_area_listener;
303 BLI_addhead(&st->regiontypes, art);
305 BKE_spacetype_register(st);