From 3c2126c6f11d4f1d912afb1ccfdab213255f39af Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 18 Jan 2019 12:07:04 +1100 Subject: Fix eye-dropper causing undo push w/o any changes Happened when accessing the eyedropper from a popup. --- source/blender/editors/interface/interface_intern.h | 7 +++++-- .../editors/interface/interface_region_color_picker.c | 13 +++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'source/blender') diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index 1c361be1b3d..c5315518ec7 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -339,8 +339,11 @@ typedef struct uiButTab { typedef struct ColorPicker { struct ColorPicker *next, *prev; - float color_data[3]; /* colr data may be HSV or HSL for now */ - int representation; /* store hsv/hsl value */ + /** Color data, may be HSV or HSL. */ + float color_data[3]; + /** Initial color data (detect changes). */ + float color_data_init[3]; + bool is_init; } ColorPicker; typedef struct ColorPickerData { diff --git a/source/blender/editors/interface/interface_region_color_picker.c b/source/blender/editors/interface/interface_region_color_picker.c index e91b775b261..59a723c7b90 100644 --- a/source/blender/editors/interface/interface_region_color_picker.c +++ b/source/blender/editors/interface/interface_region_color_picker.c @@ -301,8 +301,13 @@ static void ui_popup_close_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg)) uiBut *but = (uiBut *)bt1; uiPopupBlockHandle *popup = but->block->handle; - if (popup) - popup->menuretval = UI_RETURN_OK; + if (popup) { + ColorPicker *cpicker = but->custom_data; + BLI_assert(cpicker->is_init); + popup->menuretval = ( + equals_v3v3(cpicker->color_data, cpicker->color_data_init) ? + UI_RETURN_CANCEL : UI_RETURN_OK); + } } static void ui_colorpicker_hide_reveal(uiBlock *block, short colormode) @@ -420,6 +425,10 @@ static void ui_block_colorpicker( copy_v3_v3(rgb_perceptual, rgba); ui_scene_linear_to_color_picker_space(from_but, rgb_perceptual); ui_rgb_to_color_picker_v(rgb_perceptual, hsv); + if (cpicker->is_init == false) { + copy_v3_v3(cpicker->color_data_init, cpicker->color_data); + cpicker->is_init = true; + } /* when the softmax isn't defined in the RNA, * using very large numbers causes sRGB/linear round trip to fail. */ -- cgit v1.2.3