Fix eye-dropper causing undo push w/o any changes

Happened when accessing the eyedropper from a popup.
This commit is contained in:
Campbell Barton 2019-01-18 12:07:04 +11:00
parent a3f312dcd1
commit 3c2126c6f1
Notes: blender-bot 2023-02-14 06:47:29 +01:00
Referenced by issue #60609, Color picker undo adds step when cursor exist
2 changed files with 16 additions and 4 deletions

View File

@ -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 {

View File

@ -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. */