~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to source/blender/editors/space_node/node_view.c

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2014-02-19 11:24:23 UTC
  • mfrom: (14.2.23 sid)
  • Revision ID: package-import@ubuntu.com-20140219112423-rkmaz2m7ha06d4tk
Tags: 2.69-3ubuntu1
* Merge with Debian; remaining changes:
  - Configure without OpenImageIO on armhf, as it is not available on
    Ubuntu.

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
 
67
67
/* **************** View All Operator ************** */
68
68
 
69
 
int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar, const int node_flag)
 
69
int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *ar,
 
70
                         const int node_flag, const int smooth_viewtx)
70
71
{
71
72
        bNode *node;
72
73
        rctf cur_new;
125
126
                        BLI_rctf_scale(&cur_new, 1.1f);
126
127
                }
127
128
 
128
 
                UI_view2d_smooth_view(C, ar, &cur_new);
 
129
                UI_view2d_smooth_view(C, ar, &cur_new, smooth_viewtx);
129
130
        }
130
131
 
131
132
        return (tot != 0);
132
133
}
133
134
 
134
 
static int node_view_all_exec(bContext *C, wmOperator *UNUSED(op))
 
135
static int node_view_all_exec(bContext *C, wmOperator *op)
135
136
{
136
137
        ARegion *ar = CTX_wm_region(C);
137
138
        SpaceNode *snode = CTX_wm_space_node(C);
 
139
        const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
138
140
 
139
141
        /* is this really needed? */
140
142
        snode->xof = 0;
141
143
        snode->yof = 0;
142
144
 
143
 
        if (space_node_view_flag(C, snode, ar, 0)) {
 
145
        if (space_node_view_flag(C, snode, ar, 0, smooth_viewtx)) {
144
146
                return OPERATOR_FINISHED;
145
147
        }
146
148
        else {
163
165
        ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
164
166
}
165
167
 
166
 
static int node_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
 
168
static int node_view_selected_exec(bContext *C, wmOperator *op)
167
169
{
168
170
        ARegion *ar = CTX_wm_region(C);
169
171
        SpaceNode *snode = CTX_wm_space_node(C);
 
172
        const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
170
173
 
171
 
        if (space_node_view_flag(C, snode, ar, NODE_SELECT)) {
 
174
        if (space_node_view_flag(C, snode, ar, NODE_SELECT, smooth_viewtx)) {
172
175
                return OPERATOR_FINISHED;
173
176
        }
174
177
        else {
295
298
        ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER;
296
299
}
297
300
 
298
 
static int backimage_zoom(bContext *C, wmOperator *op)
 
301
static int backimage_zoom_exec(bContext *C, wmOperator *op)
299
302
{
300
303
        SpaceNode *snode = CTX_wm_space_node(C);
301
304
        ARegion *ar = CTX_wm_region(C);
317
320
        ot->description = "Zoom in/out the background image";
318
321
 
319
322
        /* api callbacks */
320
 
        ot->exec = backimage_zoom;
 
323
        ot->exec = backimage_zoom_exec;
321
324
        ot->poll = composite_node_active;
322
325
 
323
326
        /* flags */
327
330
        RNA_def_float(ot->srna, "factor", 1.2f, 0.0f, 10.0f, "Factor", "", 0.0f, 10.0f);
328
331
}
329
332
 
 
333
static int backimage_fit_exec(bContext *C, wmOperator *UNUSED(op))
 
334
{
 
335
        SpaceNode *snode = CTX_wm_space_node(C);
 
336
        ARegion *ar = CTX_wm_region(C);
 
337
 
 
338
        Image *ima;
 
339
        ImBuf *ibuf;
 
340
 
 
341
        const float pad = 32.0f;
 
342
 
 
343
        void *lock;
 
344
 
 
345
        float facx, facy;
 
346
 
 
347
        ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
 
348
        ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
 
349
 
 
350
        if (ibuf == NULL) {
 
351
                BKE_image_release_ibuf(ima, ibuf, lock);
 
352
                return OPERATOR_CANCELLED;
 
353
        }
 
354
 
 
355
        facx = 1.0f * (ar->sizex - pad) / (ibuf->x * snode->zoom);
 
356
        facy = 1.0f * (ar->sizey - pad) / (ibuf->y * snode->zoom);
 
357
 
 
358
        BKE_image_release_ibuf(ima, ibuf, lock);
 
359
 
 
360
        snode->zoom *= min_ff(facx, facy);
 
361
 
 
362
        snode->xof = 0;
 
363
        snode->yof = 0;
 
364
 
 
365
        ED_region_tag_redraw(ar);
 
366
 
 
367
        return OPERATOR_FINISHED;
 
368
}
 
369
 
 
370
void NODE_OT_backimage_fit(wmOperatorType *ot)
 
371
{
 
372
 
 
373
        /* identifiers */
 
374
        ot->name = "Background Image Fit";
 
375
        ot->idname = "NODE_OT_backimage_fit";
 
376
        ot->description = "Fit the background image to the view";
 
377
 
 
378
        /* api callbacks */
 
379
        ot->exec = backimage_fit_exec;
 
380
        ot->poll = composite_node_active;
 
381
 
 
382
        /* flags */
 
383
        ot->flag = OPTYPE_BLOCKING;
 
384
 
 
385
}
 
386
 
330
387
/******************** sample backdrop operator ********************/
331
388
 
332
389
typedef struct ImageSampleInfo {