me-main #1

Merged
Nate Rupsis merged 123 commits from me-main into main 2023-02-13 18:39:11 +01:00
Showing only changes of commit 218a909dec - Show all commits

View File

@ -49,12 +49,17 @@
#include "eyedropper_intern.hh" #include "eyedropper_intern.hh"
#include "interface_intern.hh" #include "interface_intern.hh"
typedef enum eGP_EyeMode {
GP_EYE_MATERIAL = 0,
GP_EYE_PALETTE = 1,
} eGP_EyeMode;
struct EyedropperGPencil { struct EyedropperGPencil {
struct ColorManagedDisplay *display; struct ColorManagedDisplay *display;
/** color under cursor RGB */ /** color under cursor RGB */
float color[3]; float color[3];
/** Mode */ /** Mode */
int mode; eGP_EyeMode mode;
}; };
/* Helper: Draw status message while the user is running the operator */ /* Helper: Draw status message while the user is running the operator */
@ -79,7 +84,7 @@ static bool eyedropper_gpencil_init(bContext *C, wmOperator *op)
display_device = scene->display_settings.display_device; display_device = scene->display_settings.display_device;
eye->display = IMB_colormanagement_display_get_named(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; return true;
} }
@ -228,10 +233,10 @@ static void eyedropper_gpencil_color_set(bContext *C, const wmEvent *event, Eyed
float col_conv[4]; 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 * space, and this conversion is needed to undo the conversion to linear performed by
* eyedropper_color_sample_fl. */ * eyedropper_color_sample_fl. */
if (eye->display) { if ((eye->display) && (eye->mode == GP_EYE_PALETTE)) {
copy_v3_v3(col_conv, eye->color); copy_v3_v3(col_conv, eye->color);
IMB_colormanagement_scene_linear_to_display_v3(col_conv, eye->display); IMB_colormanagement_scene_linear_to_display_v3(col_conv, eye->display);
} }
@ -240,7 +245,7 @@ static void eyedropper_gpencil_color_set(bContext *C, const wmEvent *event, Eyed
} }
/* Add material or Palette color. */ /* 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); eyedropper_add_material(C, col_conv, only_stroke, only_fill, both);
} }
else { else {
@ -348,8 +353,8 @@ static bool eyedropper_gpencil_poll(bContext *C)
void UI_OT_eyedropper_gpencil_color(wmOperatorType *ot) void UI_OT_eyedropper_gpencil_color(wmOperatorType *ot)
{ {
static const EnumPropertyItem items_mode[] = { static const EnumPropertyItem items_mode[] = {
{0, "MATERIAL", 0, "Material", ""}, {GP_EYE_MATERIAL, "MATERIAL", 0, "Material", ""},
{1, "PALETTE", 0, "Palette", ""}, {GP_EYE_PALETTE, "PALETTE", 0, "Palette", ""},
{0, nullptr, 0, nullptr, nullptr}, {0, nullptr, 0, nullptr, nullptr},
}; };
@ -369,5 +374,5 @@ void UI_OT_eyedropper_gpencil_color(wmOperatorType *ot)
ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING; ot->flag = OPTYPE_UNDO | OPTYPE_BLOCKING;
/* properties */ /* 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", "");
} }