diff options
author | Juan Linietsky <reduzio@gmail.com> | 2017-01-04 20:28:28 -0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-01-04 20:28:28 -0300 |
commit | d8e54b1e2620be99a3f1fdc7df11009f5a107eaa (patch) | |
tree | b3fec61b3c469385537d8c290b4091dd8d40f6ee /scene/gui | |
parent | 9e477babb3bf0ce5179395c2a5155a3f3cd36798 (diff) | |
parent | 6d38f79dc59ec4f273d766dde0baba0196078c1c (diff) |
Merge pull request #7431 from MarianoGnu/gles3
Fix Color Picker
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/color_picker.cpp | 60 | ||||
-rw-r--r-- | scene/gui/color_picker.h | 5 |
2 files changed, 40 insertions, 25 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 8000b5b110..bd0ee2d420 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -40,9 +40,7 @@ void ColorPicker::_notification(int p_what) { switch(p_what) { case NOTIFICATION_THEME_CHANGED: { - uv_edit->set_texture(get_icon("color_main")); - w_edit->set_texture(get_icon("color_hue")); - sample->set_texture(get_icon("color_sample")); + //sample->set_texture(get_icon("color_sample")); _update_controls(); } break; @@ -50,8 +48,6 @@ void ColorPicker::_notification(int p_what) { case NOTIFICATION_ENTER_TREE: { btn_pick->set_icon(get_icon("screen_picker", "ColorPicker")); - uv_edit->get_child(0)->cast_to<Control>()->update(); - w_edit->get_child(0)->cast_to<Control>()->update(); _update_color(); } @@ -273,14 +269,39 @@ void ColorPicker::_hsv_draw(int p_wich,Control* c) if (!c) return; if (p_wich==0) { + Vector<Point2> points; + points.push_back(Vector2()); + points.push_back(Vector2(c->get_size().x,0)); + 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()); + c->draw_polygon(points,colors); + Vector<Color> colors2; + Color col = color; + col.set_hsv(color.get_h(),1,1); + col.a = 0; + colors2.push_back(col); + col.a = 1; + colors2.push_back(col); + col.set_hsv(color.get_h(),1,0); + colors2.push_back(col); + col.a = 0; + colors2.push_back(col); + c->draw_polygon(points,colors); 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); - Color col = color; + col = color; col.a=1; c->draw_line(Point2(x,0),Point2(x,c->get_size().y),col.inverted()); c->draw_line(Point2(0, y),Point2(c->get_size().x, y),col.inverted()); c->draw_line(Point2(x,y),Point2(x,y),Color(1,1,1),2); } 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; Color col=Color(); col.set_hsv(h,1,1); @@ -476,35 +497,30 @@ ColorPicker::ColorPicker() : HBoxContainer *hb_edit = memnew( HBoxContainer ); - uv_edit= memnew ( TextureFrame ); + uv_edit= memnew ( Control ); uv_edit->set_ignore_mouse(false); uv_edit->connect("input_event", this, "_uv_input"); - Control *c= memnew( Control ); - uv_edit->add_child(c); - c->set_area_as_parent_rect(); - c->set_stop_mouse(false); + uv_edit->set_stop_mouse(false); + uv_edit->set_custom_minimum_size(Size2 (256,256)); Vector<Variant> args=Vector<Variant>(); args.push_back(0); - args.push_back(c); - c->connect("draw",this,"_hsv_draw",args); + args.push_back(uv_edit); + uv_edit->connect("draw",this,"_hsv_draw",args); add_child(hb_edit); - w_edit= memnew( TextureFrame ); - - w_edit->set_ignore_mouse(false); + w_edit= memnew( Control ); + w_edit->set_ignore_mouse(false); + w_edit->set_custom_minimum_size(Size2(30,256)); w_edit->connect("input_event", this, "_w_input"); - c= memnew( Control ); - w_edit->add_child(c); - c->set_area_as_parent_rect(); - c->set_stop_mouse(false); args.clear(); args.push_back(1); - args.push_back(c); - c->connect("draw",this,"_hsv_draw",args); + args.push_back(w_edit); + w_edit->connect("draw",this,"_hsv_draw",args); + hb_edit->add_child(uv_edit); hb_edit->add_child(memnew( VSeparator )); diff --git a/scene/gui/color_picker.h b/scene/gui/color_picker.h index 557635ec4a..c6a8ef7725 100644 --- a/scene/gui/color_picker.h +++ b/scene/gui/color_picker.h @@ -39,7 +39,6 @@ #include "scene/gui/texture_frame.h" #include "scene/gui/tool_button.h" #include "scene/gui/check_button.h" -#include "scene/resources/material.h" class ColorPicker : public BoxContainer { @@ -49,8 +48,8 @@ private: Control *screen; Image last_capture; - TextureFrame *uv_edit; - TextureFrame *w_edit; + Control *uv_edit; + Control *w_edit; TextureFrame *sample; TextureFrame *preset; Button *bt_add_preset; |