~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to source/blender/makesrna/intern/rna_screen.c

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
        {RGN_TYPE_TOOLS, "TOOLS", 0, "Tools", ""},
46
46
        {RGN_TYPE_TOOL_PROPS, "TOOL_PROPS", 0, "Tool Properties", ""},
47
47
        {RGN_TYPE_PREVIEW, "PREVIEW", 0, "Preview", ""},
48
 
        {0, NULL, 0, NULL, NULL}};
 
48
        {0, NULL, 0, NULL, NULL}
 
49
};
49
50
 
50
51
#include "ED_screen.h"
51
52
 
56
57
 
57
58
#include "BKE_global.h"
58
59
 
 
60
#include "UI_view2d.h"
 
61
 
59
62
static void rna_Screen_scene_set(PointerRNA *ptr, PointerRNA value)
60
63
{
61
 
        bScreen *sc = (bScreen*)ptr->data;
 
64
        bScreen *sc = (bScreen *)ptr->data;
62
65
 
63
66
        if (value.data == NULL)
64
67
                return;
68
71
 
69
72
static void rna_Screen_scene_update(bContext *C, PointerRNA *ptr)
70
73
{
71
 
        bScreen *sc = (bScreen*)ptr->data;
 
74
        bScreen *sc = (bScreen *)ptr->data;
72
75
 
73
76
        /* exception: must use context so notifier gets to the right window  */
74
77
        if (sc->newscene) {
75
78
                ED_screen_set_scene(C, sc, sc->newscene);
76
 
                WM_event_add_notifier(C, NC_SCENE|ND_SCENEBROWSE, sc->newscene);
 
79
                WM_event_add_notifier(C, NC_SCENE | ND_SCENEBROWSE, sc->newscene);
77
80
 
78
81
                if (G.debug & G_DEBUG)
79
82
                        printf("scene set %p\n", sc->newscene);
93
96
 
94
97
static int rna_Screen_is_animation_playing_get(PointerRNA *ptr)
95
98
{
96
 
        bScreen *sc = (bScreen*)ptr->data;
97
 
        return (sc->animtimer != NULL);
 
99
        return (ED_screen_animation_playing(G.main->wm.first) != NULL);
98
100
}
99
101
 
100
102
static int rna_Screen_fullscreen_get(PointerRNA *ptr)
101
103
{
102
 
        bScreen *sc = (bScreen*)ptr->data;
 
104
        bScreen *sc = (bScreen *)ptr->data;
103
105
        return (sc->full != 0);
104
106
}
105
107
 
106
108
static void rna_Area_type_set(PointerRNA *ptr, int value)
107
109
{
108
 
        ScrArea *sa = (ScrArea*)ptr->data;
 
110
        ScrArea *sa = (ScrArea *)ptr->data;
109
111
        sa->butspacetype = value;
110
112
}
111
113
 
112
114
static void rna_Area_type_update(bContext *C, PointerRNA *ptr)
113
115
{
114
 
        ScrArea *sa = (ScrArea*)ptr->data;
115
 
 
116
 
        ED_area_newspace(C, sa, sa->butspacetype); /* XXX - this uses the window */
117
 
        ED_area_tag_redraw(sa);
 
116
        wmWindowManager *wm = CTX_wm_manager(C);
 
117
        wmWindow *win;
 
118
        bScreen *sc = (bScreen *)ptr->id.data;
 
119
        ScrArea *sa = (ScrArea *)ptr->data;
 
120
 
 
121
        /* XXX this call still use context, so we trick it to work in the right context */
 
122
        for (win = wm->windows.first; win; win = win->next) {
 
123
                if (sc == win->screen) {
 
124
                        wmWindow *prevwin = CTX_wm_window(C);
 
125
                        ScrArea *prevsa = CTX_wm_area(C);
 
126
                        ARegion *prevar = CTX_wm_region(C);
 
127
 
 
128
                        CTX_wm_window_set(C, win);
 
129
                        CTX_wm_area_set(C, sa);
 
130
                        CTX_wm_region_set(C, NULL);
 
131
 
 
132
                        ED_area_newspace(C, sa, sa->butspacetype);
 
133
                        ED_area_tag_redraw(sa);
 
134
 
 
135
                        CTX_wm_window_set(C, prevwin);
 
136
                        CTX_wm_area_set(C, prevsa);
 
137
                        CTX_wm_region_set(C, prevar);
 
138
                        break;
 
139
                }
 
140
        }
 
141
}
 
142
 
 
143
static void rna_View2D_region_to_view(struct View2D *v2d, int x, int y, float result[2])
 
144
{
 
145
        UI_view2d_region_to_view(v2d, x, y, &result[0], &result[1]);
 
146
}
 
147
 
 
148
static void rna_View2D_view_to_region(struct View2D *v2d, float x, float y, int clip, int result[2])
 
149
{
 
150
        if (clip)
 
151
                UI_view2d_view_to_region(v2d, x, y, &result[0], &result[1]);
 
152
        else
 
153
                UI_view2d_to_region_no_clip(v2d, x, y, &result[0], &result[1]);
118
154
}
119
155
 
120
156
#else
172
208
        RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
173
209
        RNA_def_property_update(prop, 0, "rna_Area_type_update");
174
210
 
 
211
        prop = RNA_def_property(srna, "x", PROP_INT, PROP_NONE);
 
212
        RNA_def_property_int_sdna(prop, NULL, "totrct.xmin");
 
213
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
214
        RNA_def_property_ui_text(prop, "X Position", "The window relative vertical location of the area");
 
215
 
 
216
        prop = RNA_def_property(srna, "y", PROP_INT, PROP_NONE);
 
217
        RNA_def_property_int_sdna(prop, NULL, "totrct.ymin");
 
218
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
219
        RNA_def_property_ui_text(prop, "Y Position", "The window relative horizontal location of the area");
 
220
 
175
221
        prop = RNA_def_property(srna, "width", PROP_INT, PROP_UNSIGNED);
176
222
        RNA_def_property_int_sdna(prop, NULL, "winx");
177
223
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
189
235
        RNA_def_string(func, "text", NULL, 0, "Text", "New string for the header, no argument clears the text");
190
236
}
191
237
 
 
238
static void rna_def_view2d_api(StructRNA *srna)
 
239
{
 
240
        FunctionRNA *func;
 
241
        PropertyRNA *parm;
 
242
        
 
243
        static const float view_default[2] = {0.0f, 0.0f};
 
244
        static const int region_default[2] = {0.0f, 0.0f};
 
245
        
 
246
        func = RNA_def_function(srna, "region_to_view", "rna_View2D_region_to_view");
 
247
        RNA_def_function_ui_description(func, "Transform region coordinates to 2D view");
 
248
        parm = RNA_def_int(func, "x", 0, INT_MIN, INT_MAX, "x", "Region x coordinate", -10000, 10000);
 
249
        RNA_def_property_flag(parm, PROP_REQUIRED);
 
250
        parm = RNA_def_int(func, "y", 0, INT_MIN, INT_MAX, "y", "Region y coordinate", -10000, 10000);
 
251
        RNA_def_property_flag(parm, PROP_REQUIRED);
 
252
        parm = RNA_def_float_array(func, "result", 2, view_default, -FLT_MAX, FLT_MAX, "Result", "View coordinates", -10000.0f, 10000.0f);
 
253
        RNA_def_property_flag(parm, PROP_THICK_WRAP);
 
254
        RNA_def_function_output(func, parm);
 
255
 
 
256
        func = RNA_def_function(srna, "view_to_region", "rna_View2D_view_to_region");
 
257
        RNA_def_function_ui_description(func, "Transform 2D view coordinates to region");
 
258
        parm = RNA_def_float(func, "x", 0.0f, -FLT_MAX, FLT_MAX, "x", "2D View x coordinate", -10000.0f, 10000.0f);
 
259
        RNA_def_property_flag(parm, PROP_REQUIRED);
 
260
        parm = RNA_def_float(func, "y", 0.0f, -FLT_MAX, FLT_MAX, "y", "2D View y coordinate", -10000.0f, 10000.0f);
 
261
        RNA_def_property_flag(parm, PROP_REQUIRED);
 
262
        RNA_def_boolean(func, "clip", 1, "Clip", "Clip coordinates to the visible region");
 
263
        parm = RNA_def_int_array(func, "result", 2, region_default, INT_MIN, INT_MAX, "Result", "Region coordinates", -10000, 10000);
 
264
        RNA_def_property_flag(parm, PROP_THICK_WRAP);
 
265
        RNA_def_function_output(func, parm);
 
266
}
 
267
 
 
268
static void rna_def_view2d(BlenderRNA *brna)
 
269
{
 
270
        StructRNA *srna;
 
271
        /* PropertyRNA *prop; */
 
272
 
 
273
        srna = RNA_def_struct(brna, "View2D", NULL);
 
274
        RNA_def_struct_ui_text(srna, "View2D", "Scroll and zoom for a 2D region");
 
275
        RNA_def_struct_sdna(srna, "View2D");
 
276
        
 
277
        /* TODO more View2D properties could be exposed here (read-only) */
 
278
        
 
279
        rna_def_view2d_api(srna);
 
280
}
 
281
 
192
282
static void rna_def_region(BlenderRNA *brna)
193
283
{
194
284
        StructRNA *srna;
209
299
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
210
300
        RNA_def_property_ui_text(prop, "Region Type", "Type of this region");
211
301
 
 
302
        prop = RNA_def_property(srna, "x", PROP_INT, PROP_NONE);
 
303
        RNA_def_property_int_sdna(prop, NULL, "winrct.xmin");
 
304
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
305
        RNA_def_property_ui_text(prop, "X Position", "The window relative vertical location of the region");
 
306
 
 
307
        prop = RNA_def_property(srna, "y", PROP_INT, PROP_NONE);
 
308
        RNA_def_property_int_sdna(prop, NULL, "winrct.ymin");
 
309
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
310
        RNA_def_property_ui_text(prop, "Y Position", "The window relative horizontal location of the region");
 
311
 
212
312
        prop = RNA_def_property(srna, "width", PROP_INT, PROP_UNSIGNED);
213
313
        RNA_def_property_int_sdna(prop, NULL, "winx");
214
314
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
219
319
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
220
320
        RNA_def_property_ui_text(prop, "Height", "Region height");
221
321
 
 
322
        prop = RNA_def_property(srna, "view2d", PROP_POINTER, PROP_NONE);
 
323
        RNA_def_property_pointer_sdna(prop, NULL, "v2d");
 
324
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
325
        RNA_def_property_flag(prop, PROP_NEVER_NULL);
 
326
        RNA_def_property_ui_text(prop, "View2D", "2D view of the region");
 
327
 
222
328
        RNA_def_function(srna, "tag_redraw", "ED_region_tag_redraw");
223
329
}
224
330
 
234
340
 
235
341
        /* pointers */
236
342
        prop = RNA_def_property(srna, "scene", PROP_POINTER, PROP_NONE);
237
 
        RNA_def_property_flag(prop, PROP_EDITABLE|PROP_NEVER_NULL);
 
343
        RNA_def_property_flag(prop, PROP_EDITABLE | PROP_NEVER_NULL);
238
344
        RNA_def_property_pointer_funcs(prop, NULL, "rna_Screen_scene_set", NULL, NULL);
239
345
        RNA_def_property_ui_text(prop, "Scene", "Active scene to be edited in the screen");
240
346
        RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
255
361
        prop = RNA_def_property(srna, "show_fullscreen", PROP_BOOLEAN, PROP_NONE);
256
362
        RNA_def_property_clear_flag(prop, PROP_EDITABLE);
257
363
        RNA_def_property_boolean_funcs(prop, "rna_Screen_fullscreen_get", NULL);
258
 
        RNA_def_property_ui_text(prop, "Fullscreen", "An area is maximised, filling this screen");
 
364
        RNA_def_property_ui_text(prop, "Fullscreen", "An area is maximized, filling this screen");
259
365
 
260
366
        /* Define Anim Playback Areas */
261
367
        prop = RNA_def_property(srna, "use_play_top_left_3d_editor", PROP_BOOLEAN, PROP_NONE);
262
368
        RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_REGION);
263
369
        RNA_def_property_ui_text(prop, "Top-Left 3D Editor", "");
264
 
        RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
 
370
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
265
371
 
266
372
        prop = RNA_def_property(srna, "use_play_3d_editors", PROP_BOOLEAN, PROP_NONE);
267
373
        RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_ALL_3D_WIN);
268
374
        RNA_def_property_ui_text(prop, "All 3D View Editors", "");
269
 
        RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
 
375
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
270
376
 
271
377
        prop = RNA_def_property(srna, "use_play_animation_editors", PROP_BOOLEAN, PROP_NONE);
272
378
        RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_ALL_ANIM_WIN);
273
379
        RNA_def_property_ui_text(prop, "Animation Editors", "");
274
 
        RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
 
380
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
275
381
 
276
382
        prop = RNA_def_property(srna, "use_play_properties_editors", PROP_BOOLEAN, PROP_NONE);
277
383
        RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_ALL_BUTS_WIN);
278
384
        RNA_def_property_ui_text(prop, "Property Editors", "");
279
 
        RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
 
385
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
280
386
 
281
387
        prop = RNA_def_property(srna, "use_play_image_editors", PROP_BOOLEAN, PROP_NONE);
282
388
        RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_ALL_IMAGE_WIN);
283
389
        RNA_def_property_ui_text(prop, "Image Editors", "");
284
 
        RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
 
390
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
285
391
 
286
392
        prop = RNA_def_property(srna, "use_play_sequence_editors", PROP_BOOLEAN, PROP_NONE);
287
393
        RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_SEQ);
288
394
        RNA_def_property_ui_text(prop, "Sequencer Editors", "");
289
 
        RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
 
395
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
290
396
 
291
397
        prop = RNA_def_property(srna, "use_play_node_editors", PROP_BOOLEAN, PROP_NONE);
292
398
        RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_NODES);
293
399
        RNA_def_property_ui_text(prop, "Node Editors", "");
294
 
        RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
 
400
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
295
401
 
296
402
        prop = RNA_def_property(srna, "use_play_clip_editors", PROP_BOOLEAN, PROP_NONE);
297
403
        RNA_def_property_boolean_sdna(prop, NULL, "redraws_flag", TIME_CLIPS);
298
404
        RNA_def_property_ui_text(prop, "Clip Editors", "");
299
 
        RNA_def_property_update(prop, NC_SPACE|ND_SPACE_TIME, "rna_Screen_redraw_update");
 
405
        RNA_def_property_update(prop, NC_SPACE | ND_SPACE_TIME, "rna_Screen_redraw_update");
300
406
}
301
407
 
302
408
void RNA_def_screen(BlenderRNA *brna)
304
410
        rna_def_screen(brna);
305
411
        rna_def_area(brna);
306
412
        rna_def_region(brna);
 
413
        rna_def_view2d(brna);
307
414
}
308
415
 
309
416
#endif