Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_region_color_picker.c
| Show First 20 Lines • Show All 177 Lines • ▼ Show 20 Lines | |||||
| /* Updates all buttons who share the same color picker as the one passed | /* Updates all buttons who share the same color picker as the one passed | ||||
| * also used by small picker, be careful with name checks below... */ | * also used by small picker, be careful with name checks below... */ | ||||
| static void ui_update_color_picker_buts_rgb(uiBut *from_but, | static void ui_update_color_picker_buts_rgb(uiBut *from_but, | ||||
| uiBlock *block, | uiBlock *block, | ||||
| ColorPicker *cpicker, | ColorPicker *cpicker, | ||||
| const float rgb[3]) | const float rgb[3]) | ||||
| { | { | ||||
| uiBut *bt; | |||||
| float *hsv = cpicker->color_data; | float *hsv = cpicker->color_data; | ||||
| /* Convert from RGB to HSV in perceptually linear space. */ | /* Convert from RGB to HSV in perceptually linear space. */ | ||||
| float tmp[3]; | float tmp[3]; | ||||
| copy_v3_v3(tmp, rgb); | copy_v3_v3(tmp, rgb); | ||||
| if (from_but) { | if (from_but) { | ||||
| ui_scene_linear_to_color_picker_space(from_but, tmp); | ui_scene_linear_to_color_picker_space(from_but, tmp); | ||||
| } | } | ||||
| ui_rgb_to_color_picker_compat_v(tmp, hsv); | ui_rgb_to_color_picker_compat_v(tmp, hsv); | ||||
| /* this updates button strings, | /* this updates button strings, | ||||
| * is hackish... but button pointers are on stack of caller function */ | * is hackish... but button pointers are on stack of caller function */ | ||||
| for (bt = block->buttons.first; bt; bt = bt->next) { | LISTBASE_FOREACH (uiBut *, bt, &block->buttons) { | ||||
| if (bt->custom_data != cpicker) { | if (bt->custom_data != cpicker) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| if (bt->rnaprop) { | if (bt->rnaprop) { | ||||
| ui_but_v3_set(bt, rgb); | ui_but_v3_set(bt, rgb); | ||||
| /* original button that created the color picker already does undo | /* original button that created the color picker already does undo | ||||
| ▲ Show 20 Lines • Show All 636 Lines • ▼ Show 20 Lines | static int ui_colorpicker_small_wheel_cb(const bContext *UNUSED(C), | ||||
| if (event->type == WHEELUPMOUSE) { | if (event->type == WHEELUPMOUSE) { | ||||
| add = 0.05f; | add = 0.05f; | ||||
| } | } | ||||
| else if (event->type == WHEELDOWNMOUSE) { | else if (event->type == WHEELDOWNMOUSE) { | ||||
| add = -0.05f; | add = -0.05f; | ||||
| } | } | ||||
| if (add != 0.0f) { | if (add != 0.0f) { | ||||
| uiBut *but; | LISTBASE_FOREACH (uiBut *, but, &block->buttons) { | ||||
| for (but = block->buttons.first; but; but = but->next) { | |||||
| if (but->type == UI_BTYPE_HSVCUBE && but->active == NULL) { | if (but->type == UI_BTYPE_HSVCUBE && but->active == NULL) { | ||||
| uiPopupBlockHandle *popup = block->handle; | uiPopupBlockHandle *popup = block->handle; | ||||
| float rgb[3]; | float rgb[3]; | ||||
| ColorPicker *cpicker = but->custom_data; | ColorPicker *cpicker = but->custom_data; | ||||
| float *hsv = cpicker->color_data; | float *hsv = cpicker->color_data; | ||||
| ui_but_v3_get(but, rgb); | ui_but_v3_get(but, rgb); | ||||
| ui_scene_linear_to_color_picker_space(but, rgb); | ui_scene_linear_to_color_picker_space(but, rgb); | ||||
| ▲ Show 20 Lines • Show All 65 Lines • Show Last 20 Lines | |||||