From c896a9921371a01b95046dd3522a7758a4e9a878 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 21 Jun 2012 14:12:14 +0000 Subject: [PATCH] sampling the node backdrop now draws a line in the curve (as it did in 2.4x). --- source/blender/editors/include/ED_node.h | 3 +++ .../editors/interface/interface_draw.c | 3 --- source/blender/editors/space_node/drawnode.c | 19 ++++++++++++------- source/blender/editors/space_node/node_edit.c | 7 ++++++- 4 files changed, 21 insertions(+), 11 deletions(-) diff --git a/source/blender/editors/include/ED_node.h b/source/blender/editors/include/ED_node.h index 66e65d114cb..0979e3ec92b 100644 --- a/source/blender/editors/include/ED_node.h +++ b/source/blender/editors/include/ED_node.h @@ -61,6 +61,9 @@ void ED_node_link_insert(struct ScrArea *sa); void ED_node_post_apply_transform(struct bContext *C, struct bNodeTree *ntree); void ED_node_set_active(struct Main *bmain, struct bNodeTree *ntree, struct bNode *node); + +void ED_node_sample_set(const float col[4]); + /* node ops.c */ void ED_operatormacros_node(void); diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 0007facdf8f..b797b5377e3 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -1423,8 +1423,6 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect #endif /* sample option */ - /* XXX 2.48 */ -#if 0 if (cumap->flag & CUMA_DRAW_SAMPLE) { if (cumap->cur == 3) { float lum = cumap->sample[0] * 0.35f + cumap->sample[1] * 0.45f + cumap->sample[2] * 0.2f; @@ -1449,7 +1447,6 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect glEnd(); } } -#endif /* the curve */ glColor3ubv((unsigned char *)wcol->item); diff --git a/source/blender/editors/space_node/drawnode.c b/source/blender/editors/space_node/drawnode.c index 8a643891531..78de45dd219 100644 --- a/source/blender/editors/space_node/drawnode.c +++ b/source/blender/editors/space_node/drawnode.c @@ -340,25 +340,30 @@ static void node_buts_curvevec(uiLayout *layout, bContext *UNUSED(C), PointerRNA uiTemplateCurveMapping(layout, ptr, "mapping", 'v', 0, 0); } -static float *_sample_col = NULL; // bad bad, 2.5 will do better? -#if 0 -static void node_curvemap_sample(float *col) +static float _sample_col[4]; // bad bad, 2.5 will do better? +#define SAMPLE_FLT_ISNONE FLT_MAX +void ED_node_sample_set(const float col[4]) { - _sample_col = col; + if (col) { + copy_v4_v4(_sample_col, col); + } + else { + copy_v4_fl(_sample_col, SAMPLE_FLT_ISNONE); + } } -#endif static void node_buts_curvecol(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { bNode *node = ptr->data; CurveMapping *cumap = node->storage; - if (_sample_col) { + if (_sample_col[0] != SAMPLE_FLT_ISNONE) { cumap->flag |= CUMA_DRAW_SAMPLE; copy_v3_v3(cumap->sample, _sample_col); } - else + else { cumap->flag &= ~CUMA_DRAW_SAMPLE; + } uiTemplateCurveMapping(layout, ptr, "mapping", 'c', 0, 0); } diff --git a/source/blender/editors/space_node/node_edit.c b/source/blender/editors/space_node/node_edit.c index 47005dee63b..fc7bf473f8f 100644 --- a/source/blender/editors/space_node/node_edit.c +++ b/source/blender/editors/space_node/node_edit.c @@ -1745,9 +1745,13 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event) info->colf[2] = fp[2]; info->colf[3] = fp[3]; } + + ED_node_sample_set(info->colf); } - else + else { info->draw = 0; + ED_node_sample_set(NULL); + } BKE_image_release_ibuf(ima, lock); @@ -1758,6 +1762,7 @@ static void sample_exit(bContext *C, wmOperator *op) { ImageSampleInfo *info = op->customdata; + ED_node_sample_set(NULL); ED_region_draw_cb_exit(info->art, info->draw_handle); ED_area_tag_redraw(CTX_wm_area(C)); MEM_freeN(info);