~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/blender/editors/space_info/space_info.c

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * $Id: space_info.c 29935 2010-07-04 15:35:23Z elubie $
3
 
 *
 
1
/*
4
2
 * ***** BEGIN GPL LICENSE BLOCK *****
5
3
 *
6
4
 * This program is free software; you can redistribute it and/or
26
24
 * ***** END GPL LICENSE BLOCK *****
27
25
 */
28
26
 
 
27
/** \file blender/editors/space_info/space_info.c
 
28
 *  \ingroup spinfo
 
29
 */
 
30
 
 
31
 
29
32
#include <string.h>
30
33
#include <stdio.h>
31
34
 
32
 
 
33
35
#include "MEM_guardedalloc.h"
34
36
 
35
37
#include "BLI_blenlib.h"
36
38
#include "BLI_math.h"
37
39
#include "BLI_rand.h"
 
40
#include "BLI_utildefines.h"
 
41
 
 
42
#include "BLF_translation.h"
38
43
 
39
44
#include "BKE_context.h"
40
 
#include "BKE_colortools.h"
41
45
#include "BKE_global.h"
42
46
#include "BKE_screen.h"
43
 
#include "BKE_utildefines.h"
44
47
 
 
48
#include "ED_space_api.h"
45
49
#include "ED_screen.h"
46
50
 
47
51
#include "BIF_gl.h"
51
55
 
52
56
#include "UI_resources.h"
53
57
#include "UI_interface.h"
 
58
#include "UI_view2d.h"
54
59
 
55
 
#include "info_intern.h"        // own include
 
60
#include "info_intern.h"  /* own include */
56
61
 
57
62
/* ******************** default callbacks for info space ***************** */
58
63
 
59
 
static SpaceLink *info_new(const bContext *C)
 
64
static SpaceLink *info_new(const bContext *UNUSED(C))
60
65
{
61
66
        ARegion *ar;
62
67
        SpaceInfo *sinfo;
63
68
        
64
 
        sinfo= MEM_callocN(sizeof(SpaceInfo), "initinfo");
65
 
        sinfo->spacetype= SPACE_INFO;
66
 
        
 
69
        sinfo = MEM_callocN(sizeof(SpaceInfo), "initinfo");
 
70
        sinfo->spacetype = SPACE_INFO;
 
71
 
 
72
        sinfo->rpt_mask = INFO_RPT_OP;
 
73
 
67
74
        /* header */
68
 
        ar= MEM_callocN(sizeof(ARegion), "header for info");
 
75
        ar = MEM_callocN(sizeof(ARegion), "header for info");
69
76
        
70
77
        BLI_addtail(&sinfo->regionbase, ar);
71
 
        ar->regiontype= RGN_TYPE_HEADER;
72
 
        ar->alignment= RGN_ALIGN_BOTTOM;
 
78
        ar->regiontype = RGN_TYPE_HEADER;
 
79
        ar->alignment = RGN_ALIGN_BOTTOM;
73
80
        
74
81
        /* main area */
75
 
        ar= MEM_callocN(sizeof(ARegion), "main area for info");
 
82
        ar = MEM_callocN(sizeof(ARegion), "main area for info");
76
83
        
77
84
        BLI_addtail(&sinfo->regionbase, ar);
78
 
        ar->regiontype= RGN_TYPE_WINDOW;
 
85
        ar->regiontype = RGN_TYPE_WINDOW;
 
86
        
 
87
        /* keep in sync with console */
 
88
        ar->v2d.scroll |= (V2D_SCROLL_RIGHT);
 
89
        ar->v2d.align |= V2D_ALIGN_NO_NEG_X | V2D_ALIGN_NO_NEG_Y; /* align bottom left */
 
90
        ar->v2d.keepofs |= V2D_LOCKOFS_X;
 
91
        ar->v2d.keepzoom = (V2D_LOCKZOOM_X | V2D_LOCKZOOM_Y | V2D_LIMITZOOM | V2D_KEEPASPECT);
 
92
        ar->v2d.keeptot = V2D_KEEPTOT_BOUNDS;
 
93
        ar->v2d.minzoom = ar->v2d.maxzoom = 1.0f;
 
94
 
 
95
        /* for now, aspect ratio should be maintained, and zoom is clamped within sane default limits */
 
96
        //ar->v2d.keepzoom= (V2D_KEEPASPECT|V2D_LIMITZOOM);
79
97
        
80
98
        return (SpaceLink *)sinfo;
81
99
}
82
100
 
83
101
/* not spacelink itself */
84
 
static void info_free(SpaceLink *sl)
 
102
static void info_free(SpaceLink *UNUSED(sl))
85
103
{       
86
104
//      SpaceInfo *sinfo= (SpaceInfo*) sl;
87
105
        
89
107
 
90
108
 
91
109
/* spacetype; init callback */
92
 
static void info_init(struct wmWindowManager *wm, ScrArea *sa)
 
110
static void info_init(struct wmWindowManager *UNUSED(wm), ScrArea *UNUSED(sa))
93
111
{
94
112
 
95
113
}
96
114
 
97
115
static SpaceLink *info_duplicate(SpaceLink *sl)
98
116
{
99
 
        SpaceInfo *sinfon= MEM_dupallocN(sl);
 
117
        SpaceInfo *sinfon = MEM_dupallocN(sl);
100
118
        
101
119
        /* clear or remove stuff from old */
102
120
        
108
126
/* add handlers, stuff you only do once or on area/region changes */
109
127
static void info_main_area_init(wmWindowManager *wm, ARegion *ar)
110
128
{
 
129
        wmKeyMap *keymap;
 
130
 
 
131
        UI_view2d_region_reinit(&ar->v2d, V2D_COMMONVIEW_CUSTOM, ar->winx, ar->winy);
 
132
 
 
133
        /* own keymap */
 
134
        keymap = WM_keymap_find(wm->defaultconf, "Info", SPACE_INFO, 0);
 
135
        WM_event_add_keymap_handler(&ar->handlers, keymap);
 
136
}
 
137
 
 
138
static void info_textview_update_rect(const bContext *C, ARegion *ar)
 
139
{
 
140
        SpaceInfo *sinfo = CTX_wm_space_info(C);
 
141
        View2D *v2d = &ar->v2d;
 
142
 
 
143
        UI_view2d_totRect_set(v2d, ar->winx - 1, info_textview_height(sinfo, ar, CTX_wm_reports(C)));
111
144
}
112
145
 
113
146
static void info_main_area_draw(const bContext *C, ARegion *ar)
114
147
{
115
 
        
 
148
        /* draw entirely, view changes should be handled here */
 
149
        SpaceInfo *sinfo = CTX_wm_space_info(C);
 
150
        View2D *v2d = &ar->v2d;
 
151
        View2DScrollers *scrollers;
 
152
 
116
153
        /* clear and setup matrix */
117
154
        UI_ThemeClearColor(TH_BACK);
118
155
        glClear(GL_COLOR_BUFFER_BIT);
 
156
 
 
157
        /* quick way to avoid drawing if not bug enough */
 
158
        if (ar->winy < 16)
 
159
                return;
 
160
                
 
161
        info_textview_update_rect(C, ar);
 
162
 
 
163
        /* worlks best with no view2d matrix set */
 
164
        UI_view2d_view_ortho(v2d);
 
165
 
 
166
        info_textview_main(sinfo, ar, CTX_wm_reports(C));
 
167
 
 
168
        /* reset view matrix */
 
169
        UI_view2d_view_restore(C);
 
170
        
 
171
        /* scrollers */
 
172
        scrollers = UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_GRID_CLAMP);
 
173
        UI_view2d_scrollers_draw(C, v2d, scrollers);
 
174
        UI_view2d_scrollers_free(scrollers);
119
175
}
120
176
 
121
 
void info_operatortypes(void)
 
177
static void info_operatortypes(void)
122
178
{
123
179
        WM_operatortype_append(FILE_OT_pack_all);
124
180
        WM_operatortype_append(FILE_OT_unpack_all);
126
182
        WM_operatortype_append(FILE_OT_make_paths_absolute);
127
183
        WM_operatortype_append(FILE_OT_report_missing_files);
128
184
        WM_operatortype_append(FILE_OT_find_missing_files);
129
 
        
130
185
        WM_operatortype_append(INFO_OT_reports_display_update);
 
186
 
 
187
        /* info_report.c */
 
188
        WM_operatortype_append(INFO_OT_select_pick);
 
189
        WM_operatortype_append(INFO_OT_select_all_toggle);
 
190
        WM_operatortype_append(INFO_OT_select_border);
 
191
 
 
192
        WM_operatortype_append(INFO_OT_report_replay);
 
193
        WM_operatortype_append(INFO_OT_report_delete);
 
194
        WM_operatortype_append(INFO_OT_report_copy);
131
195
}
132
196
 
133
 
void info_keymap(struct wmKeyConfig *keyconf)
 
197
static void info_keymap(struct wmKeyConfig *keyconf)
134
198
{
135
 
        wmKeyMap *keymap= WM_keymap_find(keyconf, "Window", 0, 0);
136
 
        
137
 
        WM_keymap_verify_item(keymap, "INFO_OT_reports_display_update", TIMER, KM_ANY, KM_ANY, 0);
 
199
        wmKeyMap *keymap = WM_keymap_find(keyconf, "Window", 0, 0);
 
200
        
 
201
        WM_keymap_verify_item(keymap, "INFO_OT_reports_display_update", TIMERREPORT, KM_ANY, KM_ANY, 0);
 
202
 
 
203
        /* info space */
 
204
        keymap = WM_keymap_find(keyconf, "Info", SPACE_INFO, 0);
 
205
        
 
206
        
 
207
        /* report selection */
 
208
        WM_keymap_add_item(keymap, "INFO_OT_select_pick", SELECTMOUSE, KM_PRESS, 0, 0);
 
209
        WM_keymap_add_item(keymap, "INFO_OT_select_all_toggle", AKEY, KM_PRESS, 0, 0);
 
210
        WM_keymap_add_item(keymap, "INFO_OT_select_border", BKEY, KM_PRESS, 0, 0);
 
211
 
 
212
        WM_keymap_add_item(keymap, "INFO_OT_report_replay", RKEY, KM_PRESS, 0, 0);
 
213
        WM_keymap_add_item(keymap, "INFO_OT_report_delete", XKEY, KM_PRESS, 0, 0);
 
214
        WM_keymap_add_item(keymap, "INFO_OT_report_delete", DELKEY, KM_PRESS, 0, 0);
 
215
        WM_keymap_add_item(keymap, "INFO_OT_report_copy", CKEY, KM_PRESS, KM_CTRL, 0);
138
216
}
139
217
 
140
218
/* add handlers, stuff you only do once or on area/region changes */
141
 
static void info_header_area_init(wmWindowManager *wm, ARegion *ar)
 
219
static void info_header_area_init(wmWindowManager *UNUSED(wm), ARegion *ar)
142
220
{
143
221
        ED_region_header_init(ar);
144
222
}
150
228
 
151
229
static void info_main_area_listener(ARegion *ar, wmNotifier *wmn)
152
230
{
 
231
        // SpaceInfo *sinfo= sa->spacedata.first;
 
232
 
153
233
        /* context changes */
 
234
        switch (wmn->category) {
 
235
                case NC_SPACE:
 
236
                        if (wmn->data == ND_SPACE_INFO_REPORT) {
 
237
                                /* redraw also but only for report view, could do less redraws by checking the type */
 
238
                                ED_region_tag_redraw(ar);
 
239
                        }
 
240
                        break;
 
241
        }
154
242
}
155
243
 
156
244
static void info_header_listener(ARegion *ar, wmNotifier *wmn)
157
245
{
158
246
        /* context changes */
159
 
        switch(wmn->category) {
 
247
        switch (wmn->category) {
160
248
                case NC_SCREEN:
161
 
                        if(ELEM(wmn->data, ND_SCREENCAST, ND_ANIMPLAY))
 
249
                        if (ELEM(wmn->data, ND_SCREENCAST, ND_ANIMPLAY))
162
250
                                ED_region_tag_redraw(ar);
163
251
                        break;
164
252
                case NC_WM:     
165
 
                        if(wmn->data == ND_JOB)
 
253
                        if (wmn->data == ND_JOB)
166
254
                                ED_region_tag_redraw(ar);
167
255
                        break;
168
256
                case NC_SCENE:
169
 
                        if(wmn->data==ND_RENDER_RESULT)
 
257
                        if (wmn->data == ND_RENDER_RESULT)
170
258
                                ED_region_tag_redraw(ar);
171
259
                        break;
172
260
                case NC_SPACE:  
173
 
                        if(wmn->data == ND_SPACE_INFO)
 
261
                        if (wmn->data == ND_SPACE_INFO)
174
262
                                ED_region_tag_redraw(ar);
175
263
                        break;
176
264
                case NC_ID:
177
 
                        if(wmn->action == NA_RENAME)
 
265
                        if (wmn->action == NA_RENAME)
178
266
                                ED_region_tag_redraw(ar);
179
267
        }
180
268
        
181
269
}
182
270
 
183
 
static void recent_files_menu(const bContext *C, Menu *menu)
 
271
static void recent_files_menu_draw(const bContext *UNUSED(C), Menu *menu)
184
272
{
185
273
        struct RecentFile *recent;
186
 
        uiLayout *layout= menu->layout;
 
274
        uiLayout *layout = menu->layout;
187
275
        uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN);
188
276
        if (G.recent_files.first) {
189
 
                for(recent = G.recent_files.first; (recent); recent = recent->next) {
 
277
                for (recent = G.recent_files.first; (recent); recent = recent->next) {
190
278
                        uiItemStringO(layout, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath);
191
279
                }
192
 
        } else {
193
 
                uiItemL(layout, "No Recent Files", 0);
 
280
        }
 
281
        else {
 
282
                uiItemL(layout, IFACE_("No Recent Files"), ICON_NONE);
194
283
        }
195
284
}
196
285
 
197
 
void recent_files_menu_register()
 
286
static void recent_files_menu_register(void)
198
287
{
199
288
        MenuType *mt;
200
289
 
201
 
        mt= MEM_callocN(sizeof(MenuType), "spacetype info menu recent files");
 
290
        mt = MEM_callocN(sizeof(MenuType), "spacetype info menu recent files");
202
291
        strcpy(mt->idname, "INFO_MT_file_open_recent");
203
 
        strcpy(mt->label, "Open Recent...");
204
 
        mt->draw= recent_files_menu;
 
292
        strcpy(mt->label, N_("Open Recent..."));
 
293
        mt->draw = recent_files_menu_draw;
205
294
        WM_menutype_add(mt);
206
295
}
207
296
 
208
297
/* only called once, from space/spacetypes.c */
209
298
void ED_spacetype_info(void)
210
299
{
211
 
        SpaceType *st= MEM_callocN(sizeof(SpaceType), "spacetype info");
 
300
        SpaceType *st = MEM_callocN(sizeof(SpaceType), "spacetype info");
212
301
        ARegionType *art;
213
302
        
214
 
        st->spaceid= SPACE_INFO;
 
303
        st->spaceid = SPACE_INFO;
215
304
        strncpy(st->name, "Info", BKE_ST_MAXNAME);
216
305
        
217
 
        st->new= info_new;
218
 
        st->free= info_free;
219
 
        st->init= info_init;
220
 
        st->duplicate= info_duplicate;
221
 
        st->operatortypes= info_operatortypes;
222
 
        st->keymap= info_keymap;
 
306
        st->new = info_new;
 
307
        st->free = info_free;
 
308
        st->init = info_init;
 
309
        st->duplicate = info_duplicate;
 
310
        st->operatortypes = info_operatortypes;
 
311
        st->keymap = info_keymap;
223
312
        
224
313
        /* regions: main window */
225
 
        art= MEM_callocN(sizeof(ARegionType), "spacetype info region");
 
314
        art = MEM_callocN(sizeof(ARegionType), "spacetype info region");
226
315
        art->regionid = RGN_TYPE_WINDOW;
227
 
        art->init= info_main_area_init;
228
 
        art->draw= info_main_area_draw;
229
 
        art->listener= info_main_area_listener;
230
 
        art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D;
 
316
        art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D;
 
317
 
 
318
        art->init = info_main_area_init;
 
319
        art->draw = info_main_area_draw;
 
320
        art->listener = info_main_area_listener;
231
321
 
232
322
        BLI_addhead(&st->regiontypes, art);
233
323
        
234
324
        /* regions: header */
235
 
        art= MEM_callocN(sizeof(ARegionType), "spacetype info region");
 
325
        art = MEM_callocN(sizeof(ARegionType), "spacetype info region");
236
326
        art->regionid = RGN_TYPE_HEADER;
237
 
        art->prefsizey= HEADERY;
 
327
        art->prefsizey = HEADERY;
238
328
        
239
 
        art->keymapflag= ED_KEYMAP_UI|ED_KEYMAP_VIEW2D|ED_KEYMAP_FRAMES|ED_KEYMAP_HEADER;
240
 
        art->listener= info_header_listener;
241
 
        art->init= info_header_area_init;
242
 
        art->draw= info_header_area_draw;
 
329
        art->keymapflag = ED_KEYMAP_UI | ED_KEYMAP_VIEW2D | ED_KEYMAP_FRAMES | ED_KEYMAP_HEADER;
 
330
        art->listener = info_header_listener;
 
331
        art->init = info_header_area_init;
 
332
        art->draw = info_header_area_draw;
243
333
        
244
334
        BLI_addhead(&st->regiontypes, art);
245
335
        
247
337
 
248
338
        BKE_spacetype_register(st);
249
339
}
250