69 bool has_frame =
false;
74 oldasp = oldwidth / oldheight;
80 if ((
node->flag & node_flag) == node_flag) {
98 if ((tot == 1) && (has_frame ==
false) && ((oldwidth * oldheight) > (
width *
height))) {
104 const float height_new =
width / oldasp;
105 cur_new.
ymin = cur_new.
ymin - height_new / 2.0f;
106 cur_new.
ymax = cur_new.
ymax + height_new / 2.0f;
109 const float width_new =
height * oldasp;
110 cur_new.
xmin = cur_new.
xmin - width_new / 2.0f;
111 cur_new.
xmax = cur_new.
xmax + width_new / 2.0f;
176 ot->
name =
"Frame Selected";
177 ot->
idname =
"NODE_OT_view_selected";
178 ot->
description =
"Resize view so you can see selected nodes";
205 switch (event->
type) {
208 snode->
xof -= (nvm->
mvalo[0] -
event->mval[0]);
209 snode->
yof -= (nvm->
mvalo[1] -
event->mval[1]);
210 nvm->
mvalo[0] =
event->mval[0];
211 nvm->
mvalo[1] =
event->mval[1];
245 const float pad = 32.0f;
259 nvm->
mvalo[0] =
event->mval[0];
260 nvm->
mvalo[1] =
event->mval[1];
262 nvm->
xmin = -(region->
winx / 2) - (ibuf->
x * (0.5f * snode->
zoom)) + pad;
263 nvm->
xmax = (region->
winx / 2) + (ibuf->
x * (0.5f * snode->
zoom)) - pad;
264 nvm->
ymin = -(region->
winy / 2) - (ibuf->
y * (0.5f * snode->
zoom)) + pad;
265 nvm->
ymax = (region->
winy / 2) + (ibuf->
y * (0.5f * snode->
zoom)) - pad;
284 ot->
name =
"Background Image Move";
286 ot->
idname =
"NODE_OT_backimage_move";
322 ot->
name =
"Background Image Zoom";
323 ot->
idname =
"NODE_OT_backimage_zoom";
352 const float pad = 32.0f;
361 if ((ibuf ==
NULL) || (ibuf->
x == 0) || (ibuf->
y == 0)) {
366 facx = 1.0f * (region->
sizex - pad) / (ibuf->
x * snode->
zoom);
367 facy = 1.0f * (region->
sizey - pad) / (ibuf->
y * snode->
zoom);
387 ot->
name =
"Background Image Fit";
388 ot->
idname =
"NODE_OT_backimage_fit";
463 float bufx = ibuf->
x * snode->
zoom;
464 float bufy = ibuf->
y * snode->
zoom;
465 fpos[0] = (bufx > 0.0f ? ((
float)mval[0] - 0.5f * ar->
winx - snode->
xof) / bufx + 0.5f : 0.0f);
466 fpos[1] = (bufy > 0.0f ? ((
float)mval[1] - 0.5f * ar->
winy - snode->
yof) / bufy + 0.5f : 0.0f);
481 float fx, fy, bufx, bufy;
498 bufx = ibuf->
x * snode->
zoom;
499 bufy = ibuf->
y * snode->
zoom;
500 fx = (bufx > 0.0f ? ((
float)mval[0] - 0.5f * region->
winx - snode->
xof) / bufx + 0.5f : 0.0f);
501 fy = (bufy > 0.0f ? ((
float)mval[1] - 0.5f * region->
winy - snode->
yof) / bufy + 0.5f : 0.0f);
503 if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
506 int x = (int)(fx * ibuf->
x),
y = (int)(fy * ibuf->
y);
517 else if (ibuf->
rect) {
539 float fx, fy, bufx, bufy;
553 bufx = ibuf->
x * snode->
zoom;
554 bufy = ibuf->
y * snode->
zoom;
555 fx = (bufx > 0.0f ? ((
float)event->
mval[0] - 0.5f * region->
winx - snode->
xof) / bufx + 0.5f :
557 fy = (bufy > 0.0f ? ((
float)event->
mval[1] - 0.5f * region->
winy - snode->
yof) / bufy + 0.5f :
560 if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
563 int x = (int)(fx * ibuf->
x),
y = (int)(fy * ibuf->
y);
579 info->
col[0] = cp[0];
580 info->
col[1] = cp[1];
581 info->
col[2] = cp[2];
582 info->
col[3] = cp[3];
598 info->
colf[0] = fp[0];
599 info->
colf[1] = fp[1];
600 info->
colf[2] = fp[2];
601 info->
colf[3] = fp[3];
607 info->
z = ibuf->
zbuf[
y * ibuf->
x +
x];
612 info->
zfp = &info->
zf;
662 switch (event->
type) {
686 ot->
name =
"Backimage Sample";
687 ot->
idname =
"NODE_OT_backimage_sample";
typedef float(TangentPoint)[2]
struct ScrArea * CTX_wm_area(const bContext *C)
struct Scene * CTX_data_scene(const bContext *C)
struct SpaceNode * CTX_wm_space_node(const bContext *C)
struct ARegion * CTX_wm_region(const bContext *C)
struct Main * CTX_data_main(const bContext *C)
void BKE_image_release_ibuf(struct Image *ima, struct ImBuf *ibuf, void *lock)
struct ImBuf * BKE_image_acquire_ibuf(struct Image *ima, struct ImageUser *iuser, void **r_lock)
struct Image * BKE_image_ensure_viewer(struct Main *bmain, int type, const char *name)
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_scale(rctf *rect, const 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_union(struct rctf *rct1, const struct rctf *rct2)
void BLI_rctf_init_minmax(struct rctf *rect)
void ED_image_draw_info(struct Scene *scene, struct 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], const int *zp, const float *zpf)
bool ED_node_is_compositor(struct SpaceNode *snode)
void ED_node_sample_set(const float col[4])
void ED_area_tag_redraw(ScrArea *area)
bool ED_operator_node_active(struct bContext *C)
void ED_region_tag_redraw(struct ARegion *region)
void * ED_region_draw_cb_activate(struct ARegionType *art, void(*draw)(const struct bContext *, struct ARegion *, void *), void *customdata, int type)
#define REGION_DRAW_POST_PIXEL
void ED_region_draw_cb_exit(struct ARegionType *, void *)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
void IMB_colormanagement_colorspace_to_scene_linear_v4(float pixel[4], bool predivide, struct ColorSpace *colorspace)
void IMB_colormanagement_colorspace_to_scene_linear_v3(float pixel[3], struct ColorSpace *colorspace)
void IMB_rect_from_float(struct ImBuf *ibuf)
Contains defines and structs used throughout the imbuf module.
Read Guarded memory(de)allocation.
Group RGB to Bright Vector Camera CLAMP
void UI_view2d_smooth_view(struct bContext *C, struct ARegion *region, const struct rctf *cur, const int smooth_viewtx)
#define ND_SPACE_NODE_VIEW
void(* MEM_freeN)(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
bool composite_node_active(bContext *C)
struct ImageSampleInfo ImageSampleInfo
static int backimage_zoom_exec(bContext *C, wmOperator *op)
static int backimage_fit_exec(bContext *C, wmOperator *UNUSED(op))
static void sample_exit(bContext *C, wmOperator *op)
static void sample_draw(const bContext *C, ARegion *region, void *arg_info)
void NODE_OT_backimage_move(wmOperatorType *ot)
struct NodeViewMove NodeViewMove
bool ED_space_node_get_position(Main *bmain, SpaceNode *snode, struct ARegion *ar, const int mval[2], float fpos[2])
void NODE_OT_view_selected(wmOperatorType *ot)
bool ED_space_node_color_sample(Main *bmain, SpaceNode *snode, ARegion *region, const int mval[2], float r_col[3])
static int node_view_all_exec(bContext *C, wmOperator *op)
void NODE_OT_backimage_sample(wmOperatorType *ot)
static void snode_bg_viewmove_cancel(bContext *UNUSED(C), wmOperator *op)
void NODE_OT_backimage_zoom(wmOperatorType *ot)
int space_node_view_flag(bContext *C, SpaceNode *snode, ARegion *region, const int node_flag, const int smooth_viewtx)
void NODE_OT_backimage_fit(wmOperatorType *ot)
static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static int sample_invoke(bContext *C, wmOperator *op, const wmEvent *event)
static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
static int node_view_selected_exec(bContext *C, wmOperator *op)
static int sample_modal(bContext *C, wmOperator *op, const wmEvent *event)
void NODE_OT_view_all(wmOperatorType *ot)
static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, const wmEvent *event)
static void sample_cancel(bContext *C, wmOperator *op)
float RNA_float_get(PointerRNA *ptr, const char *name)
PropertyRNA * RNA_def_float(StructOrFunctionRNA *cont_, const char *identifier, float default_value, float hardmin, float hardmax, const char *ui_name, const char *ui_description, float softmin, float softmax)
struct ARegionType * type
struct ColorSpace * rect_colorspace
struct bNodeTree * edittree
int(* invoke)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
int(* modal)(struct bContext *, struct wmOperator *, const struct wmEvent *) ATTR_WARN_UNUSED_RESULT
bool(* poll)(struct bContext *) ATTR_WARN_UNUSED_RESULT
void(* cancel)(struct bContext *, struct wmOperator *)
int(* exec)(struct bContext *, struct wmOperator *) ATTR_WARN_UNUSED_RESULT
wmEventHandler_Op * WM_event_add_modal_handler(bContext *C, wmOperator *op)
void WM_main_add_notifier(unsigned int type, void *reference)
int WM_operator_smooth_viewtx_get(const wmOperator *op)