49 for (
int i = 0; i < 3; i++) {
50 if (
fabsf(rgb[i]) < 5e-5f) {
53 else if (
fabsf(1.0f - rgb[i]) < 5e-5f) {
63 switch (
U.color_picker_type) {
75 switch (
U.color_picker_type) {
87 switch (
U.color_picker_type) {
114 if (color_components_count == 4) {
150 const float rgb_scene_linear[3])
153 if (cpicker->
is_init ==
false) {
161 float rgb_perceptual[3];
167 if (cpicker->
is_init ==
false) {
180 float rgb_perceptual[3];
193 const float rgba_scene_linear[4])
198 if (bt->custom_data != cpicker) {
211 uchar rgba_hex_uchar[4];
230 memcpy(bt->poin,
col, col_len + 1);
244 float rgba_scene_linear[4];
268 float rgba_scene_linear[4];
307 hex_to_rgba(hexcol, rgba, rgba + 1, rgba + 2, rgba + 3);
360#define PICKER_TOTAL_W (180.0f * UI_SCALE_FAC)
361#define PICKER_BAR ((8.0f * UI_SCALE_FAC) + (6 * U.pixelsize))
362#define PICKER_SPACE (8.0f * UI_SCALE_FAC)
363#define PICKER_W (PICKER_TOTAL_W - PICKER_BAR - PICKER_SPACE)
364#define PICKER_H PICKER_W
484 float rgba_scene_linear[4],
488 static char colormode = 1;
491 static char hexcol[128];
492 float softmin, softmax, hardmin, hardmax, step, precision;
513 switch (
U.color_picker_type) {
546 TIP_(
"Red, Green, Blue"));
563 TIP_(
"Hue, Saturation, Value"));
730 rgba_scene_linear[3] = 1.0f;
737 uchar rgba_hex_uchar[4];
757 const int label_width = picker_width * 0.15f;
758 const int eyedropper_offset = show_picker ?
UI_UNIT_X * 1.25f : 0;
759 const int text_width = picker_width - label_width - eyedropper_offset;
787 const bool *has_alpha =
static_cast<bool *
>(has_alpha_ptr);
790 "Hex triplet for color with alpha (#RRGGBBAA).",
798 "Hex triplet for color (#RRGGBB).",
808 bt, bt_tooltip_func,
static_cast<void *
>(&cpicker->
has_alpha),
nullptr);
816 "UI_OT_eyedropper_color",
853 float rgba_perceptual[4];
861 hsv_perceptual[2] =
clamp_f(hsv_perceptual[2] + add, 0.0f, 1.0f);
864 float rgba_scene_linear[4];
865 rgba_scene_linear[3] = rgba_perceptual[3];
910 ColorPicker *cpicker = MEM_cnew<ColorPicker>(__func__);
void BLI_addhead(struct ListBase *listbase, void *vlink) ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
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])
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])
#define SNPRINTF(dst, format,...)
#define SNPRINTF_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_IFACE_(context, msgid)
#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])
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)
void UI_but_flag_disable(uiBut *but, int flag)
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)
@ UI_BLOCK_MOVEMOUSE_QUIT
uiBut * uiDefButC(uiBlock *block, int type, int retval, blender::StringRef str, int x, int y, short width, short height, char *poin, float min, float max, const char *tip)
uiBut * uiDefBut(uiBlock *block, int type, int retval, blender::StringRef str, int x, int y, short width, short height, void *poin, float min, float max, const char *tip)
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)
uiBlock * UI_block_begin(const bContext *C, ARegion *region, std::string name, eUIEmbossType emboss)
void UI_but_number_slider_precision_set(uiBut *but, float precision)
uiBut * uiDefIconButO(uiBlock *block, int type, const char *opname, wmOperatorCallContext opcontext, int icon, int x, int y, short width, short height, const char *tip)
uiBut * uiDefButF(uiBlock *block, int type, int retval, blender::StringRef str, int x, int y, short width, short height, float *poin, float min, float max, const char *tip)
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 * uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, PointerRNA *ptr, PropertyRNA *prop, int index, float min, float max, const char *tip)
void UI_block_align_end(uiBlock *block)
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)
double ui_but_value_get(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_colorpicker_hide_reveal(uiBlock *block, ePickerType colormode)
static void ui_colorpicker_square(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, eButGradientType type, ColorPicker *cpicker)
ColorPicker * ui_block_colorpicker_create(uiBlock *block)
void ui_perceptual_to_scene_linear_space(uiBut *but, float rgb[3])
static void ui_colorpicker_rgba_update_cb(bContext *, void *bt1, void *)
void ui_color_picker_hsv_to_rgb(const float r_cp[3], float rgb[3])
static void ui_colorpicker_hex_rna_cb(bContext *, void *bt1, void *bt2)
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])
void ui_scene_linear_to_perceptual_space(uiBut *but, float rgb[3])
static void ui_color_picker_update_hsv(ColorPicker *cpicker, uiBut *from_but, const float rgb_scene_linear[3])
void ui_but_hsv_set(uiBut *but)
static void ui_block_colorpicker(uiBlock *block, uiBut *from_but, float rgba_scene_linear[4], bool show_picker)
static void ui_colorpicker_create_mode_cb(bContext *, void *bt1, void *)
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])
bool ui_but_color_has_alpha(uiBut *but)
static void ui_colorpicker_hsv_update_cb(bContext *, void *bt1, void *bt2)
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_update_color_picker_buts_rgba(uiBut *from_but, uiBlock *block, ColorPicker *cpicker, const float rgba_scene_linear[4])
void RNA_property_float_get_array(PointerRNA *ptr, PropertyRNA *prop, float *values)
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)
int RNA_property_array_length(PointerRNA *ptr, PropertyRNA *prop)
PropertySubType RNA_property_subtype(PropertyRNA *prop)
float hsv_perceptual_init[3]
float hsv_scene_linear[3]
bool is_color_gamma_picker
ColorPickerData color_pickers
uiPopupBlockHandle * handle
int(* block_event_func)(const bContext *C, uiBlock *, const wmEvent *)
eButGradientType gradient_type