sampling the node backdrop now draws a line in the curve (as it did in 2.4x).

This commit is contained in:
Campbell Barton 2012-06-21 14:12:14 +00:00
parent b4440696a5
commit c896a99213
4 changed files with 21 additions and 11 deletions

@ -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_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_set_active(struct Main *bmain, struct bNodeTree *ntree, struct bNode *node);
void ED_node_sample_set(const float col[4]);
/* node ops.c */ /* node ops.c */
void ED_operatormacros_node(void); void ED_operatormacros_node(void);

@ -1423,8 +1423,6 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, rcti *rect
#endif #endif
/* sample option */ /* sample option */
/* XXX 2.48 */
#if 0
if (cumap->flag & CUMA_DRAW_SAMPLE) { if (cumap->flag & CUMA_DRAW_SAMPLE) {
if (cumap->cur == 3) { if (cumap->cur == 3) {
float lum = cumap->sample[0] * 0.35f + cumap->sample[1] * 0.45f + cumap->sample[2] * 0.2f; 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(); glEnd();
} }
} }
#endif
/* the curve */ /* the curve */
glColor3ubv((unsigned char *)wcol->item); glColor3ubv((unsigned char *)wcol->item);

@ -340,25 +340,30 @@ static void node_buts_curvevec(uiLayout *layout, bContext *UNUSED(C), PointerRNA
uiTemplateCurveMapping(layout, ptr, "mapping", 'v', 0, 0); uiTemplateCurveMapping(layout, ptr, "mapping", 'v', 0, 0);
} }
static float *_sample_col = NULL; // bad bad, 2.5 will do better? static float _sample_col[4]; // bad bad, 2.5 will do better?
#if 0 #define SAMPLE_FLT_ISNONE FLT_MAX
static void node_curvemap_sample(float *col) 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) static void node_buts_curvecol(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr)
{ {
bNode *node = ptr->data; bNode *node = ptr->data;
CurveMapping *cumap = node->storage; CurveMapping *cumap = node->storage;
if (_sample_col) { if (_sample_col[0] != SAMPLE_FLT_ISNONE) {
cumap->flag |= CUMA_DRAW_SAMPLE; cumap->flag |= CUMA_DRAW_SAMPLE;
copy_v3_v3(cumap->sample, _sample_col); copy_v3_v3(cumap->sample, _sample_col);
} }
else else {
cumap->flag &= ~CUMA_DRAW_SAMPLE; cumap->flag &= ~CUMA_DRAW_SAMPLE;
}
uiTemplateCurveMapping(layout, ptr, "mapping", 'c', 0, 0); uiTemplateCurveMapping(layout, ptr, "mapping", 'c', 0, 0);
} }

@ -1745,9 +1745,13 @@ static void sample_apply(bContext *C, wmOperator *op, wmEvent *event)
info->colf[2] = fp[2]; info->colf[2] = fp[2];
info->colf[3] = fp[3]; info->colf[3] = fp[3];
} }
ED_node_sample_set(info->colf);
} }
else else {
info->draw = 0; info->draw = 0;
ED_node_sample_set(NULL);
}
BKE_image_release_ibuf(ima, lock); BKE_image_release_ibuf(ima, lock);
@ -1758,6 +1762,7 @@ static void sample_exit(bContext *C, wmOperator *op)
{ {
ImageSampleInfo *info = op->customdata; ImageSampleInfo *info = op->customdata;
ED_node_sample_set(NULL);
ED_region_draw_cb_exit(info->art, info->draw_handle); ED_region_draw_cb_exit(info->art, info->draw_handle);
ED_area_tag_redraw(CTX_wm_area(C)); ED_area_tag_redraw(CTX_wm_area(C));
MEM_freeN(info); MEM_freeN(info);