From 23612a8598bc4cb3ed3a21be6a9c181b8866112b Mon Sep 17 00:00:00 2001 From: Antony Riakiotakis Date: Tue, 15 Oct 2013 13:45:27 +0000 Subject: Final fix for #36905. Enforce redraw of window once before sampling. Thanks to Brecht for the solution! --- source/blender/editors/sculpt_paint/paint_image.c | 30 ++++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/source/blender/editors/sculpt_paint/paint_image.c b/source/blender/editors/sculpt_paint/paint_image.c index a5d4ff98b4b..f3f12464528 100644 --- a/source/blender/editors/sculpt_paint/paint_image.c +++ b/source/blender/editors/sculpt_paint/paint_image.c @@ -936,11 +936,23 @@ static int sample_color_exec(bContext *C, wmOperator *op) Paint *paint = BKE_paint_get_active_from_context(C); Brush *brush = BKE_paint_brush(paint); ARegion *ar = CTX_wm_region(C); + wmWindow *win = CTX_wm_window(C); + bool show_cursor = ((paint->flags & PAINT_SHOW_BRUSH) != 0); int location[2]; + paint->flags &= ~PAINT_SHOW_BRUSH; + + /* force redraw without cursor */ + WM_paint_cursor_tag_redraw(win, ar); + WM_redraw_windows(C); + RNA_int_get_array(op->ptr, "location", location); paint_sample_color(C, ar, location[0], location[1]); + if(show_cursor) { + paint->flags |= PAINT_SHOW_BRUSH; + } + WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush); return OPERATOR_FINISHED; @@ -950,14 +962,20 @@ static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event { Paint *paint = BKE_paint_get_active_from_context(C); SampleColorData *data = MEM_mallocN(sizeof(SampleColorData), "sample color custom data"); + ARegion *ar = CTX_wm_region(C); + wmWindow *win = CTX_wm_window(C); data->event_type = event->type; data->show_cursor = ((paint->flags & PAINT_SHOW_BRUSH) != 0); op->customdata = data; paint->flags &= ~PAINT_SHOW_BRUSH; + /* force redraw without cursor */ + WM_paint_cursor_tag_redraw(win, ar); + WM_redraw_windows(C); + RNA_int_set_array(op->ptr, "location", event->mval); - sample_color_exec(C, op); + paint_sample_color(C, ar, event->mval[0], event->mval[1]); WM_event_add_modal_handler(C, op); @@ -967,10 +985,10 @@ static int sample_color_invoke(bContext *C, wmOperator *op, const wmEvent *event static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event) { SampleColorData *data = op->customdata; + Paint *paint = BKE_paint_get_active_from_context(C); + Brush *brush = BKE_paint_brush(paint); if ((event->type == data->event_type) && (event->val == KM_RELEASE)) { - Paint *paint = BKE_paint_get_active_from_context(C); - if(data->show_cursor) { paint->flags |= PAINT_SHOW_BRUSH; } @@ -981,9 +999,13 @@ static int sample_color_modal(bContext *C, wmOperator *op, const wmEvent *event) switch (event->type) { case MOUSEMOVE: + { + ARegion *ar = CTX_wm_region(C); RNA_int_set_array(op->ptr, "location", event->mval); - sample_color_exec(C, op); + paint_sample_color(C, ar, event->mval[0], event->mval[1]); + WM_event_add_notifier(C, NC_BRUSH | NA_EDITED, brush); break; + } } return OPERATOR_RUNNING_MODAL; -- cgit v1.2.3