[Bf-blender-cvs] [3c2126c6f11] master: Fix eye-dropper causing undo push w/o any changes

Campbell Barton noreply at git.blender.org
Fri Jan 18 02:12:01 CET 2019


Commit: 3c2126c6f11d4f1d912afb1ccfdab213255f39af
Author: Campbell Barton
Date:   Fri Jan 18 12:07:04 2019 +1100
Branches: master
https://developer.blender.org/rB3c2126c6f11d4f1d912afb1ccfdab213255f39af

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

Happened when accessing the eyedropper from a popup.

===================================================================

M	source/blender/editors/interface/interface_intern.h
M	source/blender/editors/interface/interface_region_color_picker.c

===================================================================

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



More information about the Bf-blender-cvs mailing list