54 for (
int i = 0; i < 3; i++) {
58 else if (
fabsf(1.0f -
rgb[i]) < 5e-5f) {
68 switch (
U.color_picker_type) {
80 switch (
U.color_picker_type) {
92 switch (
U.color_picker_type) {
140 const float rgb_scene_linear[3])
143 if (cpicker->
is_init ==
false) {
151 float rgb_perceptual[3];
157 if (cpicker->
is_init ==
false) {
170 float rgb_perceptual[3];
184 const float rgb_scene_linear[3])
191 if (bt->custom_data != cpicker) {
202 else if (
STREQ(bt->str,
"Hex: ")) {
204 uchar rgb_hex_uchar[3];
218 strcpy(bt->poin,
col);
220 else if (bt->str[1] ==
' ') {
221 if (bt->str[0] ==
'R') {
224 else if (bt->str[0] ==
'G') {
227 else if (bt->str[0] ==
'B') {
230 else if (bt->str[0] ==
'H') {
233 else if (bt->str[0] ==
'S') {
236 else if (bt->str[0] ==
'V') {
239 else if (bt->str[0] ==
'L') {
254 float rgb_scene_linear[4];
271 float rgb_scene_linear[3];
287 char *hexcol = (
char *)hexcl;
324 (bt->rnaindex != 3)) {
346 #define PICKER_H (7.5f * U.widget_unit)
347 #define PICKER_W (7.5f * U.widget_unit)
348 #define PICKER_SPACE (0.3f * U.widget_unit)
349 #define PICKER_BAR (0.7f * U.widget_unit)
351 #define PICKER_TOTAL_W (PICKER_W + PICKER_SPACE + PICKER_BAR)
481 float rgba_scene_linear[4],
485 static char colormode = 1;
488 static char hexcol[128];
489 float softmin, softmax, hardmin, hardmax, step, precision;
499 rgba_scene_linear[3] = FLT_MAX;
509 if (softmax == FLT_MAX) {
513 switch (
U.color_picker_type) {
595 "UI_OT_eyedropper_color",
749 if (rgba_scene_linear[3] != FLT_MAX) {
770 rgba_scene_linear[3] = 1.0f;
775 uchar rgb_hex_uchar[3];
801 TIP_(
"Hex triplet for color (#RRGGBB)"));
808 IFACE_(
"(Gamma Corrected)"),
843 float rgb_perceptual[3];
848 hsv_perceptual[2] =
clamp_f(hsv_perceptual[2] +
add, 0.0f, 1.0f);
850 float rgb_scene_linear[3];
871 bool show_picker =
true;
905 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 hsl_to_rgb_v(const float hsl[3], float r_rgb[3])
void hex_to_rgb(const char *hexcol, float *r_r, float *r_g, float *r_b)
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])
void rgb_float_to_uchar(unsigned char r_col[3], const float col_f[3])
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE bool equals_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
size_t BLI_snprintf(char *__restrict dst, size_t maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
#define UNPACK3_EX(pre, a, post)
#define SET_FLAG_FROM_TEST(value, test, flag)
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei width
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_flag_disable(uiBut *but, int flag)
uiBut * uiDefButC(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, char *poin, float min, float max, float a1, float a2, const char *tip)
void UI_block_theme_style_set(uiBlock *block, char theme_style)
uiBut * uiDefBut(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, void *poin, float min, float max, float a1, float a2, const char *tip)
uiBut * uiDefButF(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, float *poin, float min, float max, float a1, float a2, const char *tip)
void UI_block_bounds_set_normal(struct uiBlock *block, int addval)
@ UI_BLOCK_THEME_STYLE_POPUP
void UI_but_drawflag_disable(uiBut *but, int flag)
void UI_but_func_set(uiBut *but, uiButHandleFunc func, void *arg1, void *arg2)
uiBut * uiDefButR_prop(uiBlock *block, int type, int retval, const char *str, int x, int y, short width, short height, struct PointerRNA *ptr, struct PropertyRNA *prop, int index, float min, float max, float a1, float a2, const char *tip)
void UI_block_align_begin(uiBlock *block)
uiBlock * UI_block_begin(const struct bContext *C, struct ARegion *region, const char *name, eUIEmbossType emboss)
uiBut * uiDefIconButO(uiBlock *block, int type, const char *opname, wmOperatorCallContext opcontext, int icon, int x, int y, short width, short height, const char *tip)
@ UI_BLOCK_MOVEMOUSE_QUIT
void UI_block_align_end(uiBlock *block)
void ui_but_update(uiBut *but)
double ui_but_value_get(uiBut *but)
void ui_but_value_set(uiBut *but, double value)
void ui_but_v3_set(uiBut *but, const float vec[3])
void ui_but_v3_get(uiBut *but, 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)
uiBlock * ui_block_func_COLOR(bContext *C, uiPopupBlockHandle *handle, void *arg_but)
void ui_perceptual_to_scene_linear_space(uiBut *but, float rgb[3])
void ui_color_picker_hsv_to_rgb(const float r_cp[3], float rgb[3])
static void ui_colorpicker_rgba_update_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg))
static void ui_update_color_picker_buts_rgb(uiBut *from_but, uiBlock *block, ColorPicker *cpicker, const float rgb_scene_linear[3])
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])
static void ui_popup_close_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg))
static void ui_colorpicker_hsv_update_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg))
void ui_but_hsv_set(uiBut *but)
static int ui_colorpicker_small_wheel_cb(const bContext *UNUSED(C), uiBlock *block, const wmEvent *event)
static void ui_colorpicker_create_mode_cb(bContext *UNUSED(C), void *bt1, void *UNUSED(arg))
ColorPicker * ui_block_colorpicker_create(struct uiBlock *block)
static void ui_block_colorpicker(uiBlock *block, uiBut *from_but, float rgba_scene_linear[4], bool show_picker)
void ui_color_picker_rgb_to_hsv_compat(const float rgb[3], float r_cp[3])
static void ui_colorpicker_hex_rna_cb(bContext *UNUSED(C), void *bt1, void *hexcl)
bool ui_but_is_color_gamma(uiBut *but)
bool add(void *owner, const AttributeIDRef &attribute_id, eAttrDomain domain, eCustomDataType data_type, const AttributeInit &initializer)
static const pxr::TfToken rgb("rgb", pxr::TfToken::Immortal)
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)
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 struct bContext *C, struct uiBlock *, const struct wmEvent *)
eButGradientType gradient_type
struct PropertyRNA * rnaprop
struct PointerRNA rnapoin