67
67
/* **************** View All Operator ************** */
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)
125
126
BLI_rctf_scale(&cur_new, 1.1f);
128
UI_view2d_smooth_view(C, ar, &cur_new);
129
UI_view2d_smooth_view(C, ar, &cur_new, smooth_viewtx);
131
132
return (tot != 0);
134
static int node_view_all_exec(bContext *C, wmOperator *UNUSED(op))
135
static int node_view_all_exec(bContext *C, wmOperator *op)
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);
139
141
/* is this really needed? */
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;
163
165
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
166
static int node_view_selected_exec(bContext *C, wmOperator *UNUSED(op))
168
static int node_view_selected_exec(bContext *C, wmOperator *op)
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);
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;
295
298
ot->flag = OPTYPE_BLOCKING | OPTYPE_GRAB_POINTER;
298
static int backimage_zoom(bContext *C, wmOperator *op)
301
static int backimage_zoom_exec(bContext *C, wmOperator *op)
300
303
SpaceNode *snode = CTX_wm_space_node(C);
301
304
ARegion *ar = CTX_wm_region(C);
327
330
RNA_def_float(ot->srna, "factor", 1.2f, 0.0f, 10.0f, "Factor", "", 0.0f, 10.0f);
333
static int backimage_fit_exec(bContext *C, wmOperator *UNUSED(op))
335
SpaceNode *snode = CTX_wm_space_node(C);
336
ARegion *ar = CTX_wm_region(C);
341
const float pad = 32.0f;
347
ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
348
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
351
BKE_image_release_ibuf(ima, ibuf, lock);
352
return OPERATOR_CANCELLED;
355
facx = 1.0f * (ar->sizex - pad) / (ibuf->x * snode->zoom);
356
facy = 1.0f * (ar->sizey - pad) / (ibuf->y * snode->zoom);
358
BKE_image_release_ibuf(ima, ibuf, lock);
360
snode->zoom *= min_ff(facx, facy);
365
ED_region_tag_redraw(ar);
367
return OPERATOR_FINISHED;
370
void NODE_OT_backimage_fit(wmOperatorType *ot)
374
ot->name = "Background Image Fit";
375
ot->idname = "NODE_OT_backimage_fit";
376
ot->description = "Fit the background image to the view";
379
ot->exec = backimage_fit_exec;
380
ot->poll = composite_node_active;
383
ot->flag = OPTYPE_BLOCKING;
330
387
/******************** sample backdrop operator ********************/
332
389
typedef struct ImageSampleInfo {