50 for (
int i = 0;
i < 3;
i++) {
51 if (
fabsf(rgb[
i]) < 5e-5f) {
54 else if (
fabsf(1.0f - rgb[
i]) < 5e-5f) {
64 switch (
U.color_picker_type) {
76 switch (
U.color_picker_type) {
88 switch (
U.color_picker_type) {
115 if (color_components_count == 4) {
151 const float rgb_scene_linear[3])
154 if (cpicker->
is_init ==
false) {
162 float rgb_perceptual[3];
168 if (cpicker->
is_init ==
false) {
181 float rgb_perceptual[3];
194 const float rgba_scene_linear[4])
198 for (
const std::unique_ptr<uiBut> &bt : block->
buttons) {
199 if (bt->custom_data != cpicker) {
212 uchar rgba_hex_uchar[4];
231 memcpy(bt->poin,
col, col_len + 1);
245 float rgba_scene_linear[4];
250 &
ptr, prop, rgba_scene_linear,
ARRAY_SIZE(rgba_scene_linear));
270 float rgba_scene_linear[4];
277 &color_ptr, color_prop, rgba_scene_linear,
ARRAY_SIZE(rgba_scene_linear));
310 hex_to_rgba(hexcol, rgba, rgba + 1, rgba + 2, rgba + 3);
342 for (
const std::unique_ptr<uiBut> &bt : block->
buttons) {
363#define PICKER_TOTAL_W (180.0f * UI_SCALE_FAC)
364#define PICKER_BAR ((8.0f * UI_SCALE_FAC) + (6 * U.pixelsize))
365#define PICKER_SPACE (8.0f * UI_SCALE_FAC)
366#define PICKER_W (PICKER_TOTAL_W - PICKER_BAR - PICKER_SPACE)
367#define PICKER_H PICKER_W
487 float rgba_scene_linear[4],
491 static char colormode = 1;
494 static char hexcol[128];
495 float softmin, softmax, hardmin, hardmax,
step, precision;
516 switch (
U.color_picker_type) {
549 TIP_(
"Red, Green, Blue"));
566 TIP_(
"Hue, Saturation, Value"));
733 rgba_scene_linear[3] = 1.0f;
740 uchar rgba_hex_uchar[4];
760 const int label_width = picker_width * 0.15f;
761 const int eyedropper_offset = show_picker ?
UI_UNIT_X * 1.25f : 0;
762 const int text_width = picker_width - label_width - eyedropper_offset;
790 const bool *has_alpha =
static_cast<bool *
>(has_alpha_ptr);
793 "Hex triplet for color with alpha (#RRGGBBAA).",
801 "Hex triplet for color (#RRGGBB).",
811 bt, bt_tooltip_func,
static_cast<void *
>(&cpicker->
has_alpha),
nullptr);
819 "UI_OT_eyedropper_color",
841 switch (event->
type) {
856 for (
const std::unique_ptr<uiBut> &but : block->
buttons) {
863 float rgba_perceptual[4];
871 hsv_perceptual[2] =
clamp_f(hsv_perceptual[2] +
add, 0.0f, 1.0f);
874 float rgba_scene_linear[4];
875 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])
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)
@ UI_BLOCK_THEME_STYLE_POPUP
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)
uiBut * uiDefButR_prop(uiBlock *block, int 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)
uiBlock * UI_block_begin(const bContext *C, ARegion *region, std::string name, blender::ui::EmbossType emboss)
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, std::optional< blender::StringRef > 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)
void UI_but_number_slider_precision_set(uiBut *but, float precision)
uiBut * uiDefIconButO(uiBlock *block, int type, blender::StringRefNull opname, wmOperatorCallContext opcontext, int icon, int x, int y, short width, short height, std::optional< blender::StringRef > tip)
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, std::optional< blender::StringRef > 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_MOVEMOUSE_QUIT
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, 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)
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 * 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_perceptual_init[3]
float hsv_scene_linear[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)