~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/blender/editors/space_time/time_ops.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: time_ops.c 27676 2010-03-23 14:09:09Z campbellbarton $
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_time/time_ops.c
 
28
 *  \ingroup sptime
 
29
 */
 
30
 
 
31
 
29
32
#include <stdlib.h>
30
33
#include <math.h>
31
34
 
32
 
#include "MEM_guardedalloc.h"
33
 
 
34
35
#include "DNA_scene_types.h"
35
36
 
36
37
#include "BLI_blenlib.h"
 
38
#include "BLI_utildefines.h"
37
39
 
38
40
#include "BKE_context.h"
39
 
#include "BKE_utildefines.h"
40
 
 
41
41
 
42
42
#include "ED_screen.h"
43
43
 
44
 
 
45
44
#include "WM_api.h"
46
45
#include "WM_types.h"
47
46
 
 
47
#include "time_intern.h"
48
48
 
49
49
/* ****************** Start/End Frame Operators *******************************/
50
 
 
51
 
static int time_set_sfra_exec (bContext *C, wmOperator *op)
 
50
static int time_set_sfra_exec (bContext *C, wmOperator *UNUSED(op))
52
51
{
53
52
        Scene *scene= CTX_data_scene(C);
54
 
        int frame= CFRA;
55
 
        
 
53
        int frame;
 
54
 
56
55
        if (scene == NULL)
57
56
                return OPERATOR_CANCELLED;
58
 
                
59
 
        /* if 'end frame' (Preview Range or Actual) is less than 'frame', 
60
 
         * clamp 'frame' to 'end frame'
61
 
         */
62
 
        if (PEFRA < frame) frame= PEFRA;
63
 
                
 
57
 
 
58
        frame= CFRA;
 
59
 
64
60
        /* if Preview Range is defined, set the 'start' frame for that */
65
61
        if (PRVRANGEON)
66
62
                scene->r.psfra= frame;
67
63
        else
68
64
                scene->r.sfra= frame;
69
65
        
 
66
        if (PEFRA < frame) {
 
67
                if (PRVRANGEON)
 
68
                        scene->r.pefra= frame;
 
69
                else
 
70
                        scene->r.efra= frame;
 
71
        }
 
72
        
70
73
        WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
71
74
        
72
75
        return OPERATOR_FINISHED;
73
76
}
74
77
 
75
 
void TIME_OT_start_frame_set (wmOperatorType *ot)
 
78
static void TIME_OT_start_frame_set (wmOperatorType *ot)
76
79
{
77
80
        /* identifiers */
78
 
        ot->name= "Set Start Frame";
79
 
        ot->idname= "TIME_OT_start_frame_set";
80
 
        ot->description="Set the start frame";
 
81
        ot->name = "Set Start Frame";
 
82
        ot->idname = "TIME_OT_start_frame_set";
 
83
        ot->description = "Set the start frame";
81
84
        
82
85
        /* api callbacks */
83
 
        ot->exec= time_set_sfra_exec;
84
 
        ot->poll= ED_operator_timeline_active;
 
86
        ot->exec = time_set_sfra_exec;
 
87
        ot->poll = ED_operator_timeline_active;
85
88
        
86
89
        /* flags */
87
 
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 
90
        ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
88
91
}       
89
92
 
90
93
 
91
 
static int time_set_efra_exec (bContext *C, wmOperator *op)
 
94
static int time_set_efra_exec (bContext *C, wmOperator *UNUSED(op))
92
95
{
93
96
        Scene *scene= CTX_data_scene(C);
94
 
        int frame= CFRA;
95
 
        
 
97
        int frame;
 
98
 
96
99
        if (scene == NULL)
97
100
                return OPERATOR_CANCELLED;
98
 
                
99
 
        /* if 'start frame' (Preview Range or Actual) is greater than 'frame', 
100
 
         * clamp 'frame' to 'end frame'
101
 
         */
102
 
        if (PSFRA > frame) frame= PSFRA;
103
 
                
 
101
 
 
102
        frame= CFRA;
 
103
 
104
104
        /* if Preview Range is defined, set the 'end' frame for that */
105
105
        if (PRVRANGEON)
106
106
                scene->r.pefra= frame;
107
107
        else
108
108
                scene->r.efra= frame;
 
109
 
 
110
        if (PSFRA > frame) {
 
111
                if (PRVRANGEON)
 
112
                        scene->r.psfra= frame;
 
113
                else
 
114
                        scene->r.sfra= frame;
 
115
        }
109
116
        
110
117
        WM_event_add_notifier(C, NC_SCENE|ND_FRAME, scene);
111
118
        
112
119
        return OPERATOR_FINISHED;
113
120
}
114
121
 
115
 
void TIME_OT_end_frame_set (wmOperatorType *ot)
 
122
static void TIME_OT_end_frame_set (wmOperatorType *ot)
116
123
{
117
124
        /* identifiers */
118
 
        ot->name= "Set End Frame";
119
 
        ot->idname= "TIME_OT_end_frame_set";
120
 
        ot->description="Set the end frame";
 
125
        ot->name = "Set End Frame";
 
126
        ot->idname = "TIME_OT_end_frame_set";
 
127
        ot->description = "Set the end frame";
121
128
        
122
129
        /* api callbacks */
123
 
        ot->exec= time_set_efra_exec;
124
 
        ot->poll= ED_operator_timeline_active;
 
130
        ot->exec = time_set_efra_exec;
 
131
        ot->poll = ED_operator_timeline_active;
125
132
        
126
133
        /* flags */
127
 
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 
134
        ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
128
135
}
129
136
 
130
137
/* ************************ View All Operator *******************************/
131
138
 
132
 
static int time_view_all_exec (bContext *C, wmOperator *op)
 
139
static int time_view_all_exec (bContext *C, wmOperator *UNUSED(op))
133
140
{
134
141
        Scene *scene= CTX_data_scene(C);
135
142
        ARegion *ar= CTX_wm_region(C);
136
143
        View2D *v2d= (ar) ? &ar->v2d : NULL;
137
144
        float extra;
138
145
        
139
 
        if ELEM(NULL, scene, ar)
 
146
        if (ELEM(NULL, scene, ar))
140
147
                return OPERATOR_CANCELLED;
141
148
                
142
149
        /* set extents of view to start/end frames (Preview Range too) */
143
 
        v2d->cur.xmin= (float)PSFRA;
144
 
        v2d->cur.xmax= (float)PEFRA;
 
150
        v2d->cur.xmin = (float)PSFRA;
 
151
        v2d->cur.xmax = (float)PEFRA;
145
152
        
146
153
        /* we need an extra "buffer" factor on either side so that the endpoints are visible */
147
154
        extra= 0.01f * (v2d->cur.xmax - v2d->cur.xmin);
154
161
        return OPERATOR_FINISHED;
155
162
}
156
163
 
157
 
void TIME_OT_view_all (wmOperatorType *ot)
 
164
static void TIME_OT_view_all (wmOperatorType *ot)
158
165
{
159
166
        /* identifiers */
160
 
        ot->name= "View All";
161
 
        ot->idname= "TIME_OT_view_all";
162
 
        ot->description= "Show the entire playable frame range";
 
167
        ot->name = "View All";
 
168
        ot->idname = "TIME_OT_view_all";
 
169
        ot->description = "Show the entire playable frame range";
163
170
        
164
171
        /* api callbacks */
165
 
        ot->exec= time_view_all_exec;
166
 
        ot->poll= ED_operator_timeline_active;
 
172
        ot->exec = time_view_all_exec;
 
173
        ot->poll = ED_operator_timeline_active;
167
174
        
168
175
        /* flags */
169
 
        ot->flag= OPTYPE_REGISTER|OPTYPE_UNDO;
 
176
        ot->flag = OPTYPE_REGISTER|OPTYPE_UNDO;
170
177
}
171
178
 
172
179
/* ************************** registration **********************************/
180
187
 
181
188
void time_keymap(wmKeyConfig *keyconf)
182
189
{
183
 
        wmKeyMap *keymap= WM_keymap_find(keyconf, "Timeline", SPACE_TIME, 0);
 
190
        wmKeyMap *keymap = WM_keymap_find(keyconf, "Timeline", SPACE_TIME, 0);
184
191
        
185
192
        WM_keymap_add_item(keymap, "TIME_OT_start_frame_set", SKEY, KM_PRESS, 0, 0);
186
193
        WM_keymap_add_item(keymap, "TIME_OT_end_frame_set", EKEY, KM_PRESS, 0, 0);