82 const float old_aspect = oldwidth / oldheight;
88 bool has_frame =
false;
91 if ((node->flag & node_flag) == node_flag) {
108 const float new_aspect = width / height;
112 if ((tot == 1) && (has_frame ==
false) && ((oldwidth * oldheight) > (width * height))) {
117 if (old_aspect < new_aspect) {
118 const float height_new = width / old_aspect;
119 cur_new.
ymin = cur_new.
ymin - height_new / 2.0f;
120 cur_new.
ymax = cur_new.
ymax + height_new / 2.0f;
123 const float width_new = height * old_aspect;
124 cur_new.
xmin = cur_new.
xmin - width_new / 2.0f;
125 cur_new.
xmax = cur_new.
xmax + width_new / 2.0f;
189 ot->
name =
"Frame Selected";
190 ot->
idname =
"NODE_OT_view_selected";
191 ot->
description =
"Resize view so you can see selected nodes";
220 switch (event->
type) {
223 snode->
xof -= (nvm->
mvalo.x -
event->mval[0]);
224 snode->
yof -= (nvm->
mvalo.y -
event->mval[1]);
225 nvm->
mvalo.x =
event->mval[0];
226 nvm->
mvalo.y =
event->mval[1];
271 const float pad = 32.0f;
278 if (ibuf ==
nullptr) {
283 nvm = MEM_cnew<NodeViewMove>(__func__);
285 nvm->
mvalo.x =
event->mval[0];
286 nvm->
mvalo.y =
event->mval[1];
288 nvm->
xmin = -(region->winx / 2) - (ibuf->
x * (0.5f * snode->
zoom)) +
pad;
289 nvm->
xmax = (region->winx / 2) + (ibuf->
x * (0.5f * snode->
zoom)) -
pad;
290 nvm->
ymin = -(region->winy / 2) - (ibuf->
y * (0.5f * snode->
zoom)) +
pad;
291 nvm->
ymax = (region->winy / 2) + (ibuf->
y * (0.5f * snode->
zoom)) -
pad;
313 ot->
name =
"Background Image Move";
315 ot->
idname =
"NODE_OT_backimage_move";
351 ot->
name =
"Background Image Zoom";
352 ot->
idname =
"NODE_OT_backimage_zoom";
381 const float pad = 32.0f;
390 if ((ibuf ==
nullptr) || (ibuf->
x == 0) || (ibuf->
y == 0)) {
395 facx = 1.0f * (region->sizex -
pad) / (ibuf->
x * snode->
zoom);
396 facy = 1.0f * (region->sizey -
pad) / (ibuf->
y * snode->
zoom);
416 ot->
name =
"Background Image Fit";
417 ot->
idname =
"NODE_OT_backimage_fit";
485 float bufx = ibuf->
x * snode->
zoom;
486 float bufy = ibuf->
y * snode->
zoom;
487 fpos[0] = (bufx > 0.0f ? (
float(mval[0]) - 0.5f * region->winx - snode->
xof) / bufx + 0.5f :
489 fpos[1] = (bufy > 0.0f ? (
float(mval[1]) - 0.5f * region->winy - snode->
yof) / bufy + 0.5f :
502 float fx, fy, bufx, bufy;
519 bufx = ibuf->
x * snode->
zoom;
520 bufy = ibuf->
y * snode->
zoom;
521 fx = (bufx > 0.0f ? (
float(mval[0]) - 0.5f * region->winx - snode->
xof) / bufx + 0.5f : 0.0f);
522 fy = (bufy > 0.0f ? (
float(mval[1]) - 0.5f * region->winy - snode->
yof) / bufy + 0.5f : 0.0f);
524 if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
527 int x =
int(fx * ibuf->
x), y =
int(fy * ibuf->
y);
562 float fx, fy, bufx, bufy;
576 bufx = ibuf->
x * snode->
zoom;
577 bufy = ibuf->
y * snode->
zoom;
578 fx = (bufx > 0.0f ? (
float(event->
mval[0]) - 0.5f * region->winx - snode->
xof) / bufx + 0.5f :
580 fy = (bufy > 0.0f ? (
float(event->
mval[1]) - 0.5f * region->winy - snode->
yof) / bufy + 0.5f :
583 if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
586 int x =
int(fx * ibuf->
x), y =
int(fy * ibuf->
y);
599 info->
col[0] = cp[0];
600 info->
col[1] = cp[1];
601 info->
col[2] = cp[2];
602 info->
col[3] = cp[3];
618 info->
colf[0] = fp[0];
619 info->
colf[1] = fp[1];
620 info->
colf[2] = fp[2];
621 info->
colf[3] = fp[3];
664 info = MEM_cnew<ImageSampleInfo>(
"ImageSampleInfo");
665 info->
art = region->type;
679 switch (event->
type) {
703 ot->
name =
"Backimage Sample";
704 ot->
idname =
"NODE_OT_backimage_sample";
SpaceNode * CTX_wm_space_node(const bContext *C)
ScrArea * CTX_wm_area(const bContext *C)
Scene * CTX_data_scene(const bContext *C)
Main * CTX_data_main(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
ImBuf * BKE_image_acquire_ibuf(Image *ima, ImageUser *iuser, void **r_lock)
Image * BKE_image_ensure_viewer(Main *bmain, int type, const char *name)
void BKE_image_release_ibuf(Image *ima, ImBuf *ibuf, void *lock)
MINLINE float min_ff(float a, float b)
void rgb_uchar_to_float(float r_col[3], const unsigned char col_ub[3])
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE void copy_v3_v3(float r[3], const float a[3])
void BLI_rctf_union(struct rctf *rct_a, const struct rctf *rct_b)
void BLI_rctf_scale(rctf *rect, float scale)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
void BLI_rctf_resize(struct rctf *rect, float x, float y)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
void BLI_rctf_init_minmax(struct rctf *rect)
void ED_image_draw_info(Scene *scene, ARegion *region, bool color_manage, bool use_default_view, int channels, int x, int y, const unsigned char cp[4], const float fp[4], const float linearcol[4])
void ED_node_sample_set(const float col[4])
bool ED_node_is_compositor(const SpaceNode *snode)
void ED_area_tag_redraw(ScrArea *area)
bool ED_operator_node_active(bContext *C)
void ED_region_tag_redraw(ARegion *region)
void * ED_region_draw_cb_activate(ARegionType *art, void(*draw)(const bContext *, ARegion *, void *), void *customdata, int type)
bool ED_region_draw_cb_exit(ARegionType *art, void *handle)
#define REGION_DRAW_POST_PIXEL
void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], ColorSpace *colorspace)
void IMB_colormanagement_colorspace_to_scene_linear_v4(float pixel[4], bool predivide, ColorSpace *colorspace)
void IMB_rect_from_float(ImBuf *ibuf)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
void UI_view2d_smooth_view(const bContext *C, ARegion *region, const rctf *cur, int smooth_viewtx)
#define ND_SPACE_NODE_VIEW
int pad[32 - sizeof(int)]
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
void MEM_freeN(void *vmemh)
static bool space_node_composite_active_view_poll(bContext *C)
static int backimage_zoom_exec(bContext *C, wmOperator *op)
static int node_view_selected_exec(bContext *C, wmOperator *op)
bool space_node_view_flag(bContext &C, SpaceNode &snode, ARegion ®ion, int node_flag, int smooth_viewtx)
void NODE_OT_backimage_sample(wmOperatorType *ot)
static int sample_modal(bContext *C, wmOperator *op, const wmEvent *event)
void NODE_OT_backimage_zoom(wmOperatorType *ot)
void NODE_OT_backimage_move(wmOperatorType *ot)
static void sample_exit(bContext *C, wmOperator *op)
static int node_view_all_exec(bContext *C, wmOperator *op)
static void sample_cancel(bContext *C, wmOperator *op)
static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, const wmEvent *event)
void NODE_OT_view_selected(wmOperatorType *ot)
static void sample_draw(const bContext *C, ARegion *region, void *arg_info)
static bool space_node_active_view_poll(bContext *C)
static void snode_bg_viewmove_cancel(bContext *, wmOperator *op)
void NODE_OT_view_all(wmOperatorType *ot)
bool node_or_socket_isect_event(const bContext &C, const wmEvent &event)
static int sample_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int backimage_fit_exec(bContext *C, wmOperator *)
bool composite_node_active(bContext *C)
static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *event)
void NODE_OT_backimage_fit(wmOperatorType *ot)
bool ED_space_node_get_position(Main *bmain, SpaceNode *snode, ARegion *region, const int mval[2], float fpos[2])
bool ED_space_node_color_sample(Main *bmain, SpaceNode *snode, ARegion *region, const int mval[2], float r_col[3])
float RNA_float_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, const float default_value, const float hardmin, const float hardmax, const char *ui_name, const char *ui_description, const float softmin, const float softmax)
ImBufFloatBuffer float_buffer
ImBufByteBuffer byte_buffer
struct bNodeTree * edittree
bool(* poll)(bContext *C) ATTR_WARN_UNUSED_RESULT
int(* modal)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* invoke)(bContext *C, wmOperator *op, const wmEvent *event) ATTR_WARN_UNUSED_RESULT
int(* exec)(bContext *C, wmOperator *op) ATTR_WARN_UNUSED_RESULT
void(* cancel)(bContext *C, wmOperator *op)
void WM_main_add_notifier(uint type, void *reference)
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
int WM_operator_smooth_viewtx_get(const wmOperator *op)