59 for (
int i = 0;
i < 3;
i++) {
60 if (
fabsf(rgb[
i]) < 5e-5f) {
63 else if (
fabsf(1.0f - rgb[
i]) < 5e-5f) {
73 switch (
U.color_picker_type) {
85 switch (
U.color_picker_type) {
97 switch (
U.color_picker_type) {
124 if (color_components_count == 4) {
170 const bool is_editing_sliders,
171 const float rgb_scene_linear[3])
178 if (cpicker->
is_init ==
false ||
187 if (cpicker->
is_init ==
false) {
198 if (cpicker->
is_init ==
false) {
212 float rgb_perceptual_slider[3];
213 copy_v3_v3(rgb_perceptual_slider, rgb_scene_linear);
216 if (cpicker->
is_init ==
false) {
229 float rgb_perceptual_slider[3];
241 const bool is_editing_sliders,
242 const float rgba_scene_linear[4])
247 for (
const std::unique_ptr<uiBut> &bt : block->
buttons) {
248 if (bt->custom_data != cpicker) {
261 uchar rgba_hex_uchar[4];
281 memcpy(bt->poin,
col, col_len + 1);
290 uiBut *picker_but =
static_cast<uiBut *
>(picker_bt1);
295 uiBut *prop_but =
static_cast<uiBut *
>(prop_bt1);
300 float rgba_scene_linear[4];
304 &
ptr, prop, rgba_scene_linear,
ARRAY_SIZE(rgba_scene_linear));
324 float rgba_scene_linear[4];
331 &
ptr, prop, rgba_scene_linear,
ARRAY_SIZE(rgba_scene_linear));
354 float rgba_scene_linear[4];
361 &
ptr, prop, rgba_scene_linear,
ARRAY_SIZE(rgba_scene_linear));
382 float rgba_scene_linear[4];
389 &
ptr, prop, rgba_scene_linear,
ARRAY_SIZE(rgba_scene_linear));
424 hex_to_rgba(hexcol, rgba, rgba + 1, rgba + 2, rgba + 3);
462 for (
const std::unique_ptr<uiBut> &bt : block->
buttons) {
490 uiBut *picker_but =
static_cast<uiBut *
>(picker_bt1);
494 uiBut *prop_but =
static_cast<uiBut *
>(prop_bt1);
498 float rgba_scene_linear[4];
502 &
ptr, prop, rgba_scene_linear,
ARRAY_SIZE(rgba_scene_linear));
508#define PICKER_TOTAL_W (180.0f * UI_SCALE_FAC)
509#define PICKER_BAR ((8.0f * UI_SCALE_FAC) + (6 * U.pixelsize))
510#define PICKER_SPACE (8.0f * UI_SCALE_FAC)
511#define PICKER_W (PICKER_TOTAL_W - PICKER_BAR - PICKER_SPACE)
512#define PICKER_H PICKER_W
633 float rgba_scene_linear[4],
639 float softmin, softmax, hardmin, hardmax,
step, precision;
660 switch (
U.color_picker_type) {
687 std::string(
static_cast<const char *
>(space)),
707 TIP_(
"Scene linear values in the working color space"));
729 TIP_(
"Perceptually uniform values, matching the color picker"));
777 TIP_(
"Hue, Saturation, Value"));
785 const int slider_yco = yco - 1.1f *
UI_UNIT_Y;
791 const auto add_rgb_perceptual_slider =
792 [&](
const char *
str,
const char *tip,
const int index,
const int y) {
814 add_rgb_perceptual_slider(
IFACE_(
"Red:"),
TIP_(
"Red"), 0, yco);
819 const auto add_hsv_perceptual_slider =
820 [&](
const char *
str,
const char *tip,
const int index,
const int y,
const bool linear) {
850 add_hsv_perceptual_slider(
IFACE_(
"Saturation:"),
856 add_hsv_perceptual_slider(
IFACE_(
"Lightness:"),
863 add_hsv_perceptual_slider(
IFACE_(
"Value:"),
878 const auto add_rgb_perceptual_slider =
879 [&](
const char *
str,
const char *tip,
const int index,
const int y) {
901 add_rgb_perceptual_slider(
IFACE_(
"Red:"),
TIP_(
"Red"), 0, yco);
906 add_hsv_perceptual_slider(
IFACE_(
"Hue:"),
TIP_(
"Hue"), 0, yco,
false);
907 add_hsv_perceptual_slider(
910 add_hsv_perceptual_slider(
914 add_hsv_perceptual_slider(
940 rgba_scene_linear[3] = 1.0f;
947 uchar rgba_hex_uchar[4];
967 const int label_width = picker_width * 0.15f;
968 const int eyedropper_offset = show_picker ?
UI_UNIT_X * 1.25f : 0;
969 const int text_width = picker_width - label_width - eyedropper_offset;
996 const auto bt_tooltip_func =
998 const bool *has_alpha =
static_cast<bool *
>(has_alpha_ptr);
1001 "Hex triplet for color with alpha (#RRGGBBAA).",
1009 "Hex triplet for color (#RRGGBB).",
1019 bt, bt_tooltip_func,
static_cast<void *
>(&cpicker->
has_alpha),
nullptr);
1027 "UI_OT_eyedropper_color",
1048 float(event->
xy[0]),
1049 float(event->
xy[1]));
1060 switch (event->
type) {
1075 for (
const std::unique_ptr<uiBut> &but : block->
buttons) {
1081 float rgba_perceptual[4];
1089 hsv_perceptual[2] =
clamp_f(hsv_perceptual[2] +
add, 0.0f, 1.0f);
1092 float rgba_scene_linear[4];
1093 rgba_scene_linear[3] = rgba_perceptual[3];
void BLI_addhead(ListBase *listbase, void *vlink) ATTR_NONNULL(1)
MINLINE float clamp_f(float value, float min, float max)
void hsv_to_rgb_v(const float hsv[3], float r_rgb[3])
void rgb_to_hsv_v(const float rgb[3], float r_hsv[3])
void rgb_to_hsv_compat_v(const float rgb[3], float r_hsv[3])
void hex_to_rgba(const char *hexcol, float *r_r, float *r_g, float *r_b, float *r_a)
void hsl_to_rgb_v(const float hsl[3], float r_rgb[3])
MINLINE void rgba_float_to_uchar(unsigned char r_col[4], const float col_f[4])
void rgb_to_hsl_v(const float rgb[3], float r_hsl[3])
void rgb_to_hsl_compat_v(const float rgb[3], float r_hsl[3])
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE bool equals_v3v3(const float v1[3], const float v2[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void zero_v4(float r[4])
bool BLI_rcti_isect_pt(const struct rcti *rect, int x, int y)
#define SNPRINTF_UTF8(dst, format,...)
#define SNPRINTF_UTF8_RLEN(dst, format,...)
#define UNPACK3_EX(pre, a, post)
#define UNPACK4_EX(pre, a, post)
#define SET_FLAG_FROM_TEST(value, test, flag)
#define CTX_TIP_(context, msgid)
#define BLT_I18NCONTEXT_COLOR
BLI_INLINE void IMB_colormanagement_srgb_to_scene_linear_v3(float scene_linear[3], const float srgb[3])
void IMB_colormanagement_color_picking_to_scene_linear_v3(float scene_linear[3], const float color_picking[3])
@ COLOR_ROLE_SCENE_LINEAR
@ COLOR_ROLE_COLOR_PICKING
const char * IMB_colormanagement_role_colorspace_name_get(int role)
void IMB_colormanagement_scene_linear_to_color_picking_v3(float color_picking[3], const float scene_linear[3])
BLI_INLINE void IMB_colormanagement_scene_linear_to_srgb_v3(float srgb[3], const float scene_linear[3])
Read Guarded memory(de)allocation.
void UI_but_func_set(uiBut *but, std::function< void(bContext &)> func)
uiBut * uiDefButF(uiBlock *block, ButType type, int retval, blender::StringRef str, int x, int y, short width, short height, float *poin, float min, float max, std::optional< blender::StringRef > tip)
void UI_but_flag_disable(uiBut *but, int flag)
@ UI_BLOCK_MOVEMOUSE_QUIT
void UI_block_theme_style_set(uiBlock *block, char theme_style)
void UI_but_func_tooltip_custom_set(uiBut *but, uiButToolTipCustomFunc func, void *arg, uiFreeArgFunc free_arg)
uiBlock * UI_block_begin(const bContext *C, ARegion *region, std::string name, blender::ui::EmbossType emboss)
void UI_block_bounds_set_normal(uiBlock *block, int addval)
void UI_tooltip_text_field_add(uiTooltipData &data, std::string text, std::string suffix, const uiTooltipStyle style, const uiTooltipColorID color_id, const bool is_pad=false)
uiBut * uiDefIconButO(uiBlock *block, ButType type, blender::StringRefNull opname, blender::wm::OpCallContext opcontext, int icon, int x, int y, short width, short height, std::optional< blender::StringRef > tip)
uiBut * uiDefButR_prop(uiBlock *block, ButType type, int retval, std::optional< blender::StringRef > str, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, std::optional< blender::StringRef > tip)
void UI_but_number_slider_precision_set(uiBut *but, float precision)
void UI_but_number_slider_step_size_set(uiBut *but, float step_size)
void UI_but_drawflag_disable(uiBut *but, int flag)
void UI_block_align_begin(uiBlock *block)
@ UI_BLOCK_THEME_STYLE_POPUP
uiBut * uiDefButC(uiBlock *block, ButType type, int retval, blender::StringRef str, int x, int y, short width, short height, char *poin, float min, float max, std::optional< blender::StringRef > tip)
uiBut * uiDefBut(uiBlock *block, uiButTypeWithPointerType but_and_ptr_type, int retval, blender::StringRef str, int x, int y, short width, short height, void *poin, float min, float max, std::optional< blender::StringRef > tip)
void UI_block_align_end(uiBlock *block)
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
void ui_but_v4_get(uiBut *but, float vec[4])
void ui_but_v4_set(uiBut *but, const float vec[4])
void ui_but_update(uiBut *but)
void ui_but_string_get(uiBut *but, char *str, const size_t str_maxncpy)
void ui_but_v3_set(uiBut *but, const float vec[3])
static void ui_color_picker_rgb_round(float rgb[3])
static void ui_block_colorpicker(const bContext *, uiBlock *block, uiBut *from_but, float rgba_scene_linear[4], bool show_picker)
static void ui_colorpicker_square(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, eButGradientType type, ColorPicker *cpicker)
ColorPicker * ui_block_colorpicker_create(uiBlock *block)
void ui_color_picker_hsv_to_rgb(const float r_cp[3], float rgb[3])
static void ui_colorpicker_rgb_perceptual_slider_update_cb(bContext *, void *bt1, void *bt2)
static void ui_colorpicker_hex_rna_cb(bContext *, void *bt1, void *bt2)
static void ui_update_color_picker_buts_rgba(uiBlock *block, ColorPicker *cpicker, const bool is_editing_sliders, const float rgba_scene_linear[4])
static void ui_scene_linear_to_perceptual_space(const bool is_gamma, float rgb[3])
static void ui_colorpicker_hide_reveal(uiBlock *block)
static void ui_colorpicker_circle(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, ColorPicker *cpicker)
void ui_color_picker_rgb_to_hsv(const float rgb[3], float r_cp[3])
static char g_color_picker_space
static void ui_perceptual_to_scene_linear_space(const bool is_gamma, float rgb[3])
@ PICKER_SPACE_PERCEPTUAL
void ui_but_hsv_set(uiBut *but)
static char g_color_picker_type
static void ui_colorpicker_hsv_perceptual_slider_update_cb(bContext *, void *bt1, void *bt2)
uiBlock * ui_block_func_COLOR(bContext *C, uiPopupBlockHandle *handle, void *arg_but)
void ui_color_picker_rgb_to_hsv_compat(const float rgb[3], float r_cp[3])
static void ui_colorpicker_update_type_space_cb(bContext *, void *picker_bt1, void *prop_bt1)
static void ui_colorpicker_rgba_update_cb(bContext *, void *picker_bt1, void *prop_bt1)
bool ui_but_color_has_alpha(uiBut *but)
static void ui_color_picker_update_from_rgb_linear(ColorPicker *cpicker, const bool is_gamma, const bool is_editing_sliders, const float rgb_scene_linear[3])
bool ui_but_is_color_gamma(uiBut *but)
static int ui_colorpicker_wheel_cb(const bContext *, uiBlock *block, const wmEvent *event)
static void ui_popup_close_cb(bContext *, void *bt1, void *)
static void ui_colorpicker_hsv_linear_slider_update_cb(bContext *, void *bt1, void *bt2)
void * MEM_callocN(size_t len, const char *str)
static void add(blender::Map< std::string, std::string > &messages, Message &msg)
void RNA_property_float_ui_range(PointerRNA *ptr, PropertyRNA *prop, float *softmin, float *softmax, float *step, float *precision)
void RNA_property_float_range(PointerRNA *ptr, PropertyRNA *prop, float *hardmin, float *hardmax)
void RNA_property_float_get_array_at_most(PointerRNA *ptr, PropertyRNA *prop, float *values, int values_num)
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
PropertySubType RNA_property_subtype(PropertyRNA *prop)
float hsv_linear_slider[3]
float hsv_perceptual_init[3]
float rgb_perceptual_slider[3]
float hsv_perceptual_slider[3]
blender::Vector< std::unique_ptr< uiBut > > buttons
bool is_color_gamma_picker
ColorPickerData color_pickers
uiPopupBlockHandle * handle
int(* block_event_func)(const bContext *C, uiBlock *, const wmEvent *)
eButGradientType gradient_type
int WM_event_absolute_delta_y(const wmEvent *event)
#define ISMOUSE_WHEEL(event_type)