mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
GPencil: Fix unreported Eyedropper color difference in Materials
The color selected was converted wrongly for materials. The undo of the conversion must be done only for palettes. Also, some code cleanup done.
This commit is contained in:
parent
06c974bca6
commit
bb32f316f6
1 changed files with 13 additions and 8 deletions
|
|
@ -65,12 +65,17 @@
|
|||
#include "interface_eyedropper_intern.h"
|
||||
#include "interface_intern.h"
|
||||
|
||||
typedef enum eGP_EyeMode {
|
||||
GP_EYE_MATERIAL = 0,
|
||||
GP_EYE_PALETTE = 1,
|
||||
} eGP_EyeMode;
|
||||
|
||||
typedef struct EyedropperGPencil {
|
||||
struct ColorManagedDisplay *display;
|
||||
/** color under cursor RGB */
|
||||
float color[3];
|
||||
/** Mode */
|
||||
int mode;
|
||||
eGP_EyeMode mode;
|
||||
} EyedropperGPencil;
|
||||
|
||||
/* Helper: Draw status message while the user is running the operator */
|
||||
|
|
@ -95,7 +100,7 @@ static bool eyedropper_gpencil_init(bContext *C, wmOperator *op)
|
|||
display_device = scene->display_settings.display_device;
|
||||
eye->display = IMB_colormanagement_display_get_named(display_device);
|
||||
|
||||
eye->mode = RNA_enum_get(op->ptr, "mode");
|
||||
eye->mode = (eGP_EyeMode)RNA_enum_get(op->ptr, "mode");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -244,10 +249,10 @@ static void eyedropper_gpencil_color_set(bContext *C, const wmEvent *event, Eyed
|
|||
|
||||
float col_conv[4];
|
||||
|
||||
/* Convert from linear rgb space to display space because grease pencil colors are in display
|
||||
/* Convert from linear rgb space to display space because palette colors are in display
|
||||
* space, and this conversion is needed to undo the conversion to linear performed by
|
||||
* eyedropper_color_sample_fl. */
|
||||
if (eye->display) {
|
||||
if ((eye->display) && (eye->mode == GP_EYE_PALETTE)) {
|
||||
copy_v3_v3(col_conv, eye->color);
|
||||
IMB_colormanagement_scene_linear_to_display_v3(col_conv, eye->display);
|
||||
}
|
||||
|
|
@ -256,7 +261,7 @@ static void eyedropper_gpencil_color_set(bContext *C, const wmEvent *event, Eyed
|
|||
}
|
||||
|
||||
/* Add material or Palette color*/
|
||||
if (eye->mode == 0) {
|
||||
if (eye->mode == GP_EYE_MATERIAL) {
|
||||
eyedropper_add_material(C, col_conv, only_stroke, only_fill, both);
|
||||
}
|
||||
else {
|
||||
|
|
@ -364,8 +369,8 @@ static bool eyedropper_gpencil_poll(bContext *C)
|
|||
void UI_OT_eyedropper_gpencil_color(wmOperatorType *ot)
|
||||
{
|
||||
static const EnumPropertyItem items_mode[] = {
|
||||
{0, "MATERIAL", 0, "Material", ""},
|
||||
{1, "PALETTE", 0, "Palette", ""},
|
||||
{GP_EYE_MATERIAL, "MATERIAL", 0, "Material", ""},
|
||||
{GP_EYE_PALETTE, "PALETTE", 0, "Palette", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
|
|
@ -385,5 +390,5 @@ void UI_OT_eyedropper_gpencil_color(wmOperatorType *ot)
|
|||
ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING;
|
||||
|
||||
/* properties */
|
||||
ot->prop = RNA_def_enum(ot->srna, "mode", items_mode, 0, "Mode", "");
|
||||
ot->prop = RNA_def_enum(ot->srna, "mode", items_mode, GP_EYE_MATERIAL, "Mode", "");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue