diff options
author | remorse107 <robertmorse107@gmail.com> | 2017-06-14 22:22:33 -0500 |
---|---|---|
committer | Robert Morse <robertmorse107@gmail.com> | 2017-06-15 06:32:57 -0500 |
commit | 61feec28cf331336b11078c711bffb895f686941 (patch) | |
tree | 98c57a5f6956928a715c6f37ddf8a584173da36f | |
parent | f8bd4884570fafc36bbad82ec662d27276d1c7a5 (diff) |
Color Picker Fixed Appearance
Corrected bug with color picker hue section and with the wrong color array being sent to the 256x256 palette selector.
Color Picker Fixed Appearance and clang Format
-rw-r--r-- | scene/gui/color_picker.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index f0e486aa50..d3bdc401ab 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -156,6 +156,8 @@ void ColorPicker::_update_color() { _update_text_value(); sample->update(); + uv_edit->update(); + w_edit->update(); updating = false; } @@ -263,10 +265,10 @@ void ColorPicker::_hsv_draw(int p_wich, Control *c) { points.push_back(c->get_size()); points.push_back(Vector2(0, c->get_size().y)); Vector<Color> colors; - colors.push_back(Color(1, 1, 1)); - colors.push_back(Color(1, 1, 1)); - colors.push_back(Color()); - colors.push_back(Color()); + colors.push_back(Color(1, 1, 1, 1)); + colors.push_back(Color(1, 1, 1, 1)); + colors.push_back(Color(0, 0, 0, 1)); + colors.push_back(Color(0, 0, 0, 1)); c->draw_polygon(points, colors); Vector<Color> colors2; Color col = color; @@ -279,7 +281,7 @@ void ColorPicker::_hsv_draw(int p_wich, Control *c) { colors2.push_back(col); col.a = 0; colors2.push_back(col); - c->draw_polygon(points, colors); + c->draw_polygon(points, colors2); int x = CLAMP(c->get_size().x * s, 0, c->get_size().x); int y = CLAMP(c->get_size().y - c->get_size().y * v, 0, c->get_size().y); col = color; @@ -290,7 +292,7 @@ void ColorPicker::_hsv_draw(int p_wich, Control *c) { } else if (p_wich == 1) { Ref<Texture> hue = get_icon("color_hue", "ColorPicker"); c->draw_texture_rect(hue, Rect2(Point2(), c->get_size())); - int y = c->get_size().y - c->get_size().y * h; + int y = c->get_size().y - c->get_size().y * (1.0 - h); Color col = Color(); col.set_hsv(h, 1, 1); c->draw_line(Point2(0, y), Point2(c->get_size().x, y), col.inverted()); @@ -343,7 +345,7 @@ void ColorPicker::_w_input(const Ref<InputEvent> &ev) { if (bev->is_pressed() && bev->get_button_index() == BUTTON_LEFT) { changing_color = true; - h = 1 - ((float)bev->get_position().y) / 256.0; + h = 1 - (256.0 - (float)bev->get_position().y) / 256.0; } else { changing_color = false; @@ -362,7 +364,8 @@ void ColorPicker::_w_input(const Ref<InputEvent> &ev) { if (!changing_color) return; float y = CLAMP((float)mev->get_position().y, 0, 256); - h = 1.0 - y / 256.0; + //h = 1.0 - y / 256.0; + h = y / 256.0; color.set_hsv(h, s, v, color.a); last_hsv = color; set_pick_color(color); |