summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-09-27 22:03:22 +0200
committerGitHub <noreply@github.com>2019-09-27 22:03:22 +0200
commit5966c6b646bb7e673c2ad66a76d3ef7e9873656b (patch)
tree5a12ea60f5c32a5cd3d27a412e773badc7a61e35 /scene/gui
parent8868fd2d2841357e3500105d07e145c96fc3e974 (diff)
parent70c4e96623821ff1b6ed62a5f8604b37b40ede7b (diff)
Merge pull request #32379 from Calinou/colorpicker-add-overbright-indicator
Draw an indicator to denote overbright colors in ColorPicker
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/color_picker.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index 6dd9e401f6..ffe011e5f7 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -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: {