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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 *****
33 #include "MEM_guardedalloc.h"
35 #include "BLI_blenlib.h"
39 #include "BKE_context.h"
40 #include "BKE_colortools.h"
41 #include "BKE_screen.h"
42 #include "BKE_utildefines.h"
44 #include "ED_screen.h"
51 #include "UI_resources.h"
54 #include "info_intern.h" // own include
56 /* ******************** default callbacks for info space ***************** */
58 static SpaceLink *info_new(const bContext *C)
63 sinfo= MEM_callocN(sizeof(SpaceInfo), "initinfo");
64 sinfo->spacetype= SPACE_INFO;
67 ar= MEM_callocN(sizeof(ARegion), "header for info");
69 BLI_addtail(&sinfo->regionbase, ar);
70 ar->regiontype= RGN_TYPE_HEADER;
71 ar->alignment= RGN_ALIGN_BOTTOM;
74 ar= MEM_callocN(sizeof(ARegion), "main area for info");
76 BLI_addtail(&sinfo->regionbase, ar);
77 ar->regiontype= RGN_TYPE_WINDOW;
79 return (SpaceLink *)sinfo;
82 /* not spacelink itself */
83 static void info_free(SpaceLink *sl)
85 // SpaceInfo *sinfo= (SpaceInfo*) sl;
90 /* spacetype; init callback */
91 static void info_init(struct wmWindowManager *wm, ScrArea *sa)
96 static SpaceLink *info_duplicate(SpaceLink *sl)
98 SpaceInfo *sinfon= MEM_dupallocN(sl);
100 /* clear or remove stuff from old */
102 return (SpaceLink *)sinfon;
107 /* add handlers, stuff you only do once or on area/region changes */
108 static void info_main_area_init(wmWindowManager *wm, ARegion *ar)
112 static void info_main_area_draw(const bContext *C, ARegion *ar)
115 /* clear and setup matrix */
116 UI_ThemeClearColor(TH_BACK);
117 glClear(GL_COLOR_BUFFER_BIT);
120 void info_operatortypes(void)
122 WM_operatortype_append(FILE_OT_pack_all);
123 WM_operatortype_append(FILE_OT_unpack_all);
124 WM_operatortype_append(FILE_OT_make_paths_relative);
125 WM_operatortype_append(FILE_OT_make_paths_absolute);
126 WM_operatortype_append(FILE_OT_report_missing_files);
127 WM_operatortype_append(FILE_OT_find_missing_files);
130 void info_keymap(struct wmKeyConfig *keyconf)
135 /* add handlers, stuff you only do once or on area/region changes */
136 static void info_header_area_init(wmWindowManager *wm, ARegion *ar)
138 ED_region_header_init(ar);
141 static void info_header_area_draw(const bContext *C, ARegion *ar)
143 ED_region_header(C, ar);
146 static void info_main_area_listener(ARegion *ar, wmNotifier *wmn)
148 /* context changes */
151 static void info_header_listener(ARegion *ar, wmNotifier *wmn)
153 /* context changes */
154 switch(wmn->category) {
156 if(ELEM(wmn->data, ND_SCREENCAST, ND_ANIMPLAY))
157 ED_region_tag_redraw(ar);
160 if(wmn->data==ND_RENDER_RESULT)
161 ED_region_tag_redraw(ar);
164 if(wmn->data == ND_SPACE_INFO)
165 ED_region_tag_redraw(ar);
168 if(wmn->action == NA_RENAME)
169 ED_region_tag_redraw(ar);
174 /* only called once, from space/spacetypes.c */
175 void ED_spacetype_info(void)
177 SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype info");
180 st->spaceid= SPACE_INFO;
181 strncpy(st->name, "Info", BKE_ST_MAXNAME);
186 st->duplicate= info_duplicate;
187 st->operatortypes= info_operatortypes;
188 st->keymap= info_keymap;
190 /* regions: main window */
191 art= MEM_callocN(sizeof(ARegionType), "spacetype info region");
192 art->regionid = RGN_TYPE_WINDOW;
193 art->init= info_main_area_init;
194 art->draw= info_main_area_draw;
195 art->listener= info_main_area_listener;
196 art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
198 BLI_addhead(&st->regiontypes, art);
200 /* regions: header */
201 art= MEM_callocN(sizeof(ARegionType), "spacetype info region");
202 art->regionid = RGN_TYPE_HEADER;
203 art->prefsizey= HEADERY;
205 art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER;
206 art->listener= info_header_listener;
207 art->init= info_header_area_init;
208 art->draw= info_header_area_draw;
210 BLI_addhead(&st->regiontypes, art);
213 BKE_spacetype_register(st);