Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Eisel <julian@blender.org>2020-03-26 23:03:42 +0300
committerJulian Eisel <julian@blender.org>2020-03-26 23:18:45 +0300
commitc94b6209861ca7cc3985b53474feed7d94c0221a (patch)
tree752054f0dca1338cda5cf8ad4f6d18573fcca3b9 /source/blender/editors/space_node/node_view.c
parent357ed79cb93f9d655501a828c6cddd68282de62d (diff)
parentafb1a64ccb81b7ed792f64151986f40f53af8da5 (diff)
Merge branch 'master' into wm-drag-drop-rewrite
Diffstat (limited to 'source/blender/editors/space_node/node_view.c')
-rw-r--r--source/blender/editors/space_node/node_view.c82
1 files changed, 42 insertions, 40 deletions
diff --git a/source/blender/editors/space_node/node_view.c b/source/blender/editors/space_node/node_view.c
index f12d972f30c..9283b073e86 100644
--- a/source/blender/editors/space_node/node_view.c
+++ b/source/blender/editors/space_node/node_view.c
@@ -23,9 +23,9 @@
#include "DNA_node_types.h"
+#include "BLI_math.h"
#include "BLI_rect.h"
#include "BLI_utildefines.h"
-#include "BLI_math.h"
#include "BKE_context.h"
#include "BKE_image.h"
@@ -33,10 +33,10 @@
#include "BKE_node.h"
#include "BKE_screen.h"
+#include "ED_image.h"
#include "ED_node.h" /* own include */
#include "ED_screen.h"
#include "ED_space_api.h"
-#include "ED_image.h"
#include "RNA_access.h"
#include "RNA_define.h"
@@ -52,13 +52,13 @@
#include "IMB_imbuf.h"
#include "IMB_imbuf_types.h"
-#include "node_intern.h" /* own include */
#include "NOD_composite.h"
+#include "node_intern.h" /* own include */
/* **************** View All Operator ************** */
int space_node_view_flag(
- bContext *C, SpaceNode *snode, ARegion *ar, const int node_flag, const int smooth_viewtx)
+ bContext *C, SpaceNode *snode, ARegion *region, const int node_flag, const int smooth_viewtx)
{
bNode *node;
rctf cur_new;
@@ -67,8 +67,8 @@ int space_node_view_flag(
int tot = 0;
bool has_frame = false;
- oldwidth = BLI_rctf_size_x(&ar->v2d.cur);
- oldheight = BLI_rctf_size_y(&ar->v2d.cur);
+ oldwidth = BLI_rctf_size_x(&region->v2d.cur);
+ oldheight = BLI_rctf_size_y(&region->v2d.cur);
oldasp = oldwidth / oldheight;
@@ -114,7 +114,7 @@ int space_node_view_flag(
BLI_rctf_scale(&cur_new, 1.1f);
}
- UI_view2d_smooth_view(C, ar, &cur_new, smooth_viewtx);
+ UI_view2d_smooth_view(C, region, &cur_new, smooth_viewtx);
}
return (tot != 0);
@@ -122,7 +122,7 @@ int space_node_view_flag(
static int node_view_all_exec(bContext *C, wmOperator *op)
{
- ARegion *ar = CTX_wm_region(C);
+ ARegion *region = CTX_wm_region(C);
SpaceNode *snode = CTX_wm_space_node(C);
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
@@ -130,7 +130,7 @@ static int node_view_all_exec(bContext *C, wmOperator *op)
snode->xof = 0;
snode->yof = 0;
- if (space_node_view_flag(C, snode, ar, 0, smooth_viewtx)) {
+ if (space_node_view_flag(C, snode, region, 0, smooth_viewtx)) {
return OPERATOR_FINISHED;
}
else {
@@ -155,11 +155,11 @@ void NODE_OT_view_all(wmOperatorType *ot)
static int node_view_selected_exec(bContext *C, wmOperator *op)
{
- ARegion *ar = CTX_wm_region(C);
+ ARegion *region = CTX_wm_region(C);
SpaceNode *snode = CTX_wm_space_node(C);
const int smooth_viewtx = WM_operator_smooth_viewtx_get(op);
- if (space_node_view_flag(C, snode, ar, NODE_SELECT, smooth_viewtx)) {
+ if (space_node_view_flag(C, snode, region, NODE_SELECT, smooth_viewtx)) {
return OPERATOR_FINISHED;
}
else {
@@ -170,7 +170,7 @@ static int node_view_selected_exec(bContext *C, wmOperator *op)
void NODE_OT_view_selected(wmOperatorType *ot)
{
/* identifiers */
- ot->name = "View Selected";
+ ot->name = "Frame Selected";
ot->idname = "NODE_OT_view_selected";
ot->description = "Resize view so you can see selected nodes";
@@ -192,7 +192,7 @@ typedef struct NodeViewMove {
static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, const wmEvent *event)
{
SpaceNode *snode = CTX_wm_space_node(C);
- ARegion *ar = CTX_wm_region(C);
+ ARegion *region = CTX_wm_region(C);
NodeViewMove *nvm = op->customdata;
switch (event->type) {
@@ -207,7 +207,7 @@ static int snode_bg_viewmove_modal(bContext *C, wmOperator *op, const wmEvent *e
CLAMP(snode->xof, nvm->xmin, nvm->xmax);
CLAMP(snode->yof, nvm->ymin, nvm->ymax);
- ED_region_tag_redraw(ar);
+ ED_region_tag_redraw(region);
WM_main_add_notifier(NC_NODE | ND_DISPLAY, NULL);
break;
@@ -230,7 +230,7 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *
{
Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
- ARegion *ar = CTX_wm_region(C);
+ ARegion *region = CTX_wm_region(C);
NodeViewMove *nvm;
Image *ima;
ImBuf *ibuf;
@@ -238,7 +238,7 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *
void *lock;
- ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
+ ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (ibuf == NULL) {
@@ -251,10 +251,10 @@ static int snode_bg_viewmove_invoke(bContext *C, wmOperator *op, const wmEvent *
nvm->mvalo[0] = event->mval[0];
nvm->mvalo[1] = event->mval[1];
- nvm->xmin = -(ar->winx / 2) - (ibuf->x * (0.5f * snode->zoom)) + pad;
- nvm->xmax = (ar->winx / 2) + (ibuf->x * (0.5f * snode->zoom)) - pad;
- nvm->ymin = -(ar->winy / 2) - (ibuf->y * (0.5f * snode->zoom)) + pad;
- nvm->ymax = (ar->winy / 2) + (ibuf->y * (0.5f * snode->zoom)) - pad;
+ nvm->xmin = -(region->winx / 2) - (ibuf->x * (0.5f * snode->zoom)) + pad;
+ nvm->xmax = (region->winx / 2) + (ibuf->x * (0.5f * snode->zoom)) - pad;
+ nvm->ymin = -(region->winy / 2) - (ibuf->y * (0.5f * snode->zoom)) + pad;
+ nvm->ymax = (region->winy / 2) + (ibuf->y * (0.5f * snode->zoom)) - pad;
BKE_image_release_ibuf(ima, ibuf, lock);
@@ -290,11 +290,11 @@ void NODE_OT_backimage_move(wmOperatorType *ot)
static int backimage_zoom_exec(bContext *C, wmOperator *op)
{
SpaceNode *snode = CTX_wm_space_node(C);
- ARegion *ar = CTX_wm_region(C);
+ ARegion *region = CTX_wm_region(C);
float fac = RNA_float_get(op->ptr, "factor");
snode->zoom *= fac;
- ED_region_tag_redraw(ar);
+ ED_region_tag_redraw(region);
WM_main_add_notifier(NC_NODE | ND_DISPLAY, NULL);
return OPERATOR_FINISHED;
@@ -323,7 +323,7 @@ static int backimage_fit_exec(bContext *C, wmOperator *UNUSED(op))
{
Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
- ARegion *ar = CTX_wm_region(C);
+ ARegion *region = CTX_wm_region(C);
Image *ima;
ImBuf *ibuf;
@@ -334,7 +334,7 @@ static int backimage_fit_exec(bContext *C, wmOperator *UNUSED(op))
float facx, facy;
- ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
+ ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if ((ibuf == NULL) || (ibuf->x == 0) || (ibuf->y == 0)) {
@@ -342,8 +342,8 @@ static int backimage_fit_exec(bContext *C, wmOperator *UNUSED(op))
return OPERATOR_CANCELLED;
}
- facx = 1.0f * (ar->sizex - pad) / (ibuf->x * snode->zoom);
- facy = 1.0f * (ar->sizey - pad) / (ibuf->y * snode->zoom);
+ facx = 1.0f * (region->sizex - pad) / (ibuf->x * snode->zoom);
+ facy = 1.0f * (region->sizey - pad) / (ibuf->y * snode->zoom);
BKE_image_release_ibuf(ima, ibuf, lock);
@@ -352,7 +352,7 @@ static int backimage_fit_exec(bContext *C, wmOperator *UNUSED(op))
snode->xof = 0;
snode->yof = 0;
- ED_region_tag_redraw(ar);
+ ED_region_tag_redraw(region);
WM_main_add_notifier(NC_NODE | ND_DISPLAY, NULL);
return OPERATOR_FINISHED;
@@ -396,14 +396,14 @@ typedef struct ImageSampleInfo {
int color_manage;
} ImageSampleInfo;
-static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
+static void sample_draw(const bContext *C, ARegion *region, void *arg_info)
{
Scene *scene = CTX_data_scene(C);
ImageSampleInfo *info = arg_info;
if (info->draw) {
ED_image_draw_info(scene,
- ar,
+ region,
info->color_manage,
false,
info->channels,
@@ -421,7 +421,7 @@ static void sample_draw(const bContext *C, ARegion *ar, void *arg_info)
* And here we've got recursion in the comments tips...
*/
bool ED_space_node_color_sample(
- Main *bmain, SpaceNode *snode, ARegion *ar, int mval[2], float r_col[3])
+ Main *bmain, SpaceNode *snode, ARegion *region, int mval[2], float r_col[3])
{
void *lock;
Image *ima;
@@ -436,7 +436,7 @@ bool ED_space_node_color_sample(
return false;
}
- ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
+ ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (!ibuf) {
return false;
@@ -445,8 +445,8 @@ bool ED_space_node_color_sample(
/* map the mouse coords to the backdrop image space */
bufx = ibuf->x * snode->zoom;
bufy = ibuf->y * snode->zoom;
- fx = (bufx > 0.0f ? ((float)mval[0] - 0.5f * ar->winx - snode->xof) / bufx + 0.5f : 0.0f);
- fy = (bufy > 0.0f ? ((float)mval[1] - 0.5f * ar->winy - snode->yof) / bufy + 0.5f : 0.0f);
+ fx = (bufx > 0.0f ? ((float)mval[0] - 0.5f * region->winx - snode->xof) / bufx + 0.5f : 0.0f);
+ fy = (bufy > 0.0f ? ((float)mval[1] - 0.5f * region->winy - snode->yof) / bufy + 0.5f : 0.0f);
if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
const float *fp;
@@ -479,14 +479,14 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
{
Main *bmain = CTX_data_main(C);
SpaceNode *snode = CTX_wm_space_node(C);
- ARegion *ar = CTX_wm_region(C);
+ ARegion *region = CTX_wm_region(C);
ImageSampleInfo *info = op->customdata;
void *lock;
Image *ima;
ImBuf *ibuf;
float fx, fy, bufx, bufy;
- ima = BKE_image_verify_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
+ ima = BKE_image_ensure_viewer(bmain, IMA_TYPE_COMPOSITE, "Viewer Node");
ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
if (!ibuf) {
info->draw = 0;
@@ -500,8 +500,10 @@ static void sample_apply(bContext *C, wmOperator *op, const wmEvent *event)
/* map the mouse coords to the backdrop image space */
bufx = ibuf->x * snode->zoom;
bufy = ibuf->y * snode->zoom;
- fx = (bufx > 0.0f ? ((float)event->mval[0] - 0.5f * ar->winx - snode->xof) / bufx + 0.5f : 0.0f);
- fy = (bufy > 0.0f ? ((float)event->mval[1] - 0.5f * ar->winy - snode->yof) / bufy + 0.5f : 0.0f);
+ fx = (bufx > 0.0f ? ((float)event->mval[0] - 0.5f * region->winx - snode->xof) / bufx + 0.5f :
+ 0.0f);
+ fy = (bufy > 0.0f ? ((float)event->mval[1] - 0.5f * region->winy - snode->yof) / bufy + 0.5f :
+ 0.0f);
if (fx >= 0.0f && fy >= 0.0f && fx < 1.0f && fy < 1.0f) {
const float *fp;
@@ -583,7 +585,7 @@ static void sample_exit(bContext *C, wmOperator *op)
static int sample_invoke(bContext *C, wmOperator *op, const wmEvent *event)
{
SpaceNode *snode = CTX_wm_space_node(C);
- ARegion *ar = CTX_wm_region(C);
+ ARegion *region = CTX_wm_region(C);
ImageSampleInfo *info;
if (!ED_node_is_compositor(snode) || !(snode->flag & SNODE_BACKDRAW)) {
@@ -591,9 +593,9 @@ static int sample_invoke(bContext *C, wmOperator *op, const wmEvent *event)
}
info = MEM_callocN(sizeof(ImageSampleInfo), "ImageSampleInfo");
- info->art = ar->type;
+ info->art = region->type;
info->draw_handle = ED_region_draw_cb_activate(
- ar->type, sample_draw, info, REGION_DRAW_POST_PIXEL);
+ region->type, sample_draw, info, REGION_DRAW_POST_PIXEL);
op->customdata = info;
sample_apply(C, op, event);