Draw an indicator to denote overbright colors in ColorPicker

This makes it faster to distinguish overbright colors from
"standard" colors.
This commit is contained in:
Hugo Locurcio
2019-09-27 01:07:41 +02:00
parent b2569d5fa8
commit 70c4e96623
6 changed files with 24 additions and 4 deletions

View File

@ -396,11 +396,18 @@ void ColorPicker::_update_text_value() {
}
void ColorPicker::_sample_draw() {
Rect2 r = Rect2(Point2(), Size2(uv_edit->get_size().width, sample->get_size().height * 0.95));
const Rect2 r = Rect2(Point2(), Size2(uv_edit->get_size().width, sample->get_size().height * 0.95));
if (color.a < 1.0) {
sample->draw_texture_rect(get_icon("preset_bg", "ColorPicker"), r, true);
}
sample->draw_rect(r, color);
if (color.r > 1 || color.g > 1 || color.b > 1) {
// Draw an indicator to denote that the color is "overbright" and can't be displayed accurately in the preview
sample->draw_texture(get_icon("overbright_indicator", "ColorPicker"), Point2());
}
}
void ColorPicker::_hsv_draw(int p_which, Control *c) {
@ -894,10 +901,15 @@ void ColorPickerButton::_notification(int p_what) {
switch (p_what) {
case NOTIFICATION_DRAW: {
Ref<StyleBox> normal = get_stylebox("normal");
Rect2 r = Rect2(normal->get_offset(), get_size() - normal->get_minimum_size());
const Ref<StyleBox> normal = get_stylebox("normal");
const Rect2 r = Rect2(normal->get_offset(), get_size() - normal->get_minimum_size());
draw_texture_rect(Control::get_icon("bg", "ColorPickerButton"), r, true);
draw_rect(r, color);
if (color.r > 1 || color.g > 1 || color.b > 1) {
// Draw an indicator to denote that the color is "overbright" and can't be displayed accurately in the preview
draw_texture(Control::get_icon("overbright_indicator", "ColorPicker"), normal->get_offset());
}
} break;
case MainLoop::NOTIFICATION_WM_QUIT_REQUEST: {