diff options
author | Mariano Suligoy <marianognu.easyrpg@gmail.com> | 2016-10-19 19:43:49 -0300 |
---|---|---|
committer | Mariano Suligoy <marianognu.easyrpg@gmail.com> | 2016-10-19 19:43:49 -0300 |
commit | 6d38f79dc59ec4f273d766dde0baba0196078c1c (patch) | |
tree | 42c98a0f1c8c205f40087bc385d57d7a774fd855 /scene | |
parent | 1527cf8c0d17891dd0ebf99d484f83daa46eba3c (diff) |
Fix Color Picker
Replace shaders with procedurally generated controls
Diffstat (limited to 'scene')
-rw-r--r-- | scene/gui/color_picker.cpp | 60 | ||||
-rw-r--r-- | scene/gui/color_picker.h | 5 | ||||
-rw-r--r-- | scene/resources/default_theme/color_picker_hue.png | bin | 132 -> 146 bytes | |||
-rw-r--r-- | scene/resources/default_theme/color_picker_main.png | bin | 310 -> 0 bytes | |||
-rw-r--r-- | scene/resources/default_theme/default_theme.cpp | 6 | ||||
-rwxr-xr-x[-rw-r--r--] | scene/resources/default_theme/make_header.py | 0 | ||||
-rw-r--r-- | scene/resources/default_theme/theme_data.h | 43 | ||||
-rw-r--r-- | scene/resources/default_theme/uv_editor.gsl | 19 | ||||
-rw-r--r-- | scene/resources/default_theme/w_editor.gsl | 11 |
9 files changed, 41 insertions, 103 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 3d9c07ac86..24387ad6f0 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 b742454361..2c6cfd4964 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; diff --git a/scene/resources/default_theme/color_picker_hue.png b/scene/resources/default_theme/color_picker_hue.png Binary files differindex 9bdd24f4fe..de2cd0c2bf 100644 --- a/scene/resources/default_theme/color_picker_hue.png +++ b/scene/resources/default_theme/color_picker_hue.png diff --git a/scene/resources/default_theme/color_picker_main.png b/scene/resources/default_theme/color_picker_main.png Binary files differdeleted file mode 100644 index 0498628180..0000000000 --- a/scene/resources/default_theme/color_picker_main.png +++ /dev/null diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp index 266de77ca0..2ddc3e7576 100644 --- a/scene/resources/default_theme/default_theme.cpp +++ b/scene/resources/default_theme/default_theme.cpp @@ -834,15 +834,9 @@ void fill_default_theme(Ref<Theme>& t, const Ref<Font> & default_font, const Ref t->set_icon("screen_picker","ColorPicker", make_icon( icon_color_pick_png ) ); t->set_icon("add_preset","ColorPicker", make_icon( icon_add_png ) ); - t->set_icon("color_area", "ColorPicker", make_icon( color_picker_main_png)); t->set_icon("color_hue", "ColorPicker", make_icon( color_picker_hue_png)); t->set_icon("color_sample", "ColorPicker", make_icon( color_picker_sample_png)); - t->set_shader("uv_editor", "ColorPicker", make_shader("", uv_editor_shader_code, "")); - t->set_shader("w_editor", "ColorPicker", make_shader("", w_editor_shader_code, "")); - - - // TooltipPanel Ref<StyleBoxTexture> style_tt = make_stylebox( tooltip_bg_png,4,4,4,4); diff --git a/scene/resources/default_theme/make_header.py b/scene/resources/default_theme/make_header.py index 2d3f989e01..2d3f989e01 100644..100755 --- a/scene/resources/default_theme/make_header.py +++ b/scene/resources/default_theme/make_header.py diff --git a/scene/resources/default_theme/theme_data.h b/scene/resources/default_theme/theme_data.h index 913ea9b5e9..46fd770a27 100644 --- a/scene/resources/default_theme/theme_data.h +++ b/scene/resources/default_theme/theme_data.h @@ -70,12 +70,7 @@ static const unsigned char close_hl_png[]={ static const unsigned char color_picker_hue_png[]={ -0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x10,0x0,0x0,0x1,0x0,0x8,0x2,0x0,0x0,0x0,0x35,0x30,0x61,0x19,0x0,0x0,0x0,0x9,0x70,0x48,0x59,0x73,0x0,0x0,0xb,0x13,0x0,0x0,0xb,0x13,0x1,0x0,0x9a,0x9c,0x18,0x0,0x0,0x0,0x7,0x74,0x49,0x4d,0x45,0x7,0xe0,0x9,0x18,0xc,0x24,0x18,0xa9,0xb3,0x2c,0xb7,0x0,0x0,0x0,0x23,0x49,0x44,0x41,0x54,0x68,0xde,0xed,0xc1,0x31,0x1,0x0,0x0,0x0,0xc2,0xa0,0xf5,0x4f,0x6d,0xd,0xf,0xa0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0xbe,0xd,0x31,0x0,0x0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0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x0,0x80,0x1b,0x1,0x2d,0x0,0x1,0x9e,0xcb,0xc2,0xed,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82 +0x89,0x50,0x4e,0x47,0xd,0xa,0x1a,0xa,0x0,0x0,0x0,0xd,0x49,0x48,0x44,0x52,0x0,0x0,0x0,0x1,0x0,0x0,0x1,0x0,0x8,0x2,0x0,0x0,0x0,0xfd,0x5c,0x8b,0xcf,0x0,0x0,0x0,0x59,0x49,0x44,0x41,0x54,0x28,0x91,0xcd,0xd0,0x31,0xa,0x3,0x31,0x10,0x43,0xd1,0x87,0xc0,0xf6,0xfd,0x8f,0x1b,0xdb,0x30,0x69,0x76,0x21,0x65,0xd8,0x14,0x71,0xf1,0xf9,0x8c,0x84,0x9a,0x51,0x44,0x13,0xfd,0x21,0xe3,0x87,0xed,0xf7,0xa8,0xcd,0x2a,0x99,0x8e,0x46,0x2b,0x94,0xd0,0x43,0xb,0xe3,0x64,0xb3,0x2a,0xa6,0x93,0xb9,0x9f,0x9a,0x4e,0x3a,0x69,0x97,0xc7,0xe5,0x3b,0x1b,0xff,0xef,0x6d,0xa5,0xec,0x30,0xc3,0xeb,0xf2,0xc,0xeb,0xe3,0x5e,0x27,0xf4,0x8a,0x37,0x75,0x7b,0x8a,0xe5,0x90,0x9a,0xab,0x81,0x0,0x0,0x0,0x0,0x49,0x45,0x4e,0x44,0xae,0x42,0x60,0x82 }; @@ -577,39 +572,3 @@ static const unsigned char window_resizer_png[]={ -static const char *uv_editor_shader_code= - "vec3 nd1sl2=vec3(UV,0);" - "uniform float H=0;" - "float nd4sl0=H;" - "float nd7sl0=nd1sl2.x;" - "float nd7sl1=nd1sl2.y;" - "float nd7sl2=nd1sl2.z;" - "float nd2sl1def=-1;" - "float nd2sl0=nd7sl1*nd2sl1def;" - "float nd6sl1def=1;" - "float nd6sl0=nd2sl0+nd6sl1def;" - "vec3 nd3sl0=vec3(nd4sl0,nd7sl0,nd6sl0);" - "vec3 nd5sl0;" - "{" - " vec3 c = nd3sl0;" - " vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);" - " vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);" - " nd5sl0=c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);" - "}" - "COLOR.rgb=nd5sl0;"; - - -static const char *w_editor_shader_code= - "vec3 nd1sl2=vec3(UV,0);" - "float nd2sl1=1-nd1sl2.y;" - "vec3 nd3sl0=vec3(nd2sl1,1,1);" - "vec3 nd6sl0;" - "{" - " vec3 c = nd3sl0;" - " vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);" - " vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);" - " nd6sl0=c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);" - "}" - "COLOR.rgb=nd6sl0;"; - - diff --git a/scene/resources/default_theme/uv_editor.gsl b/scene/resources/default_theme/uv_editor.gsl deleted file mode 100644 index 8c24e76dd5..0000000000 --- a/scene/resources/default_theme/uv_editor.gsl +++ /dev/null @@ -1,19 +0,0 @@ -vec3 nd1sl2=vec3(UV,0);
-uniform float H=0;
-float nd4sl0=H;
-float nd7sl0=nd1sl2.x;
-float nd7sl1=nd1sl2.y;
-float nd7sl2=nd1sl2.z;
-float nd2sl1def=-1;
-float nd2sl0=nd7sl1*nd2sl1def;
-float nd6sl1def=1;
-float nd6sl0=nd2sl0+nd6sl1def;
-vec3 nd3sl0=vec3(nd4sl0,nd7sl0,nd6sl0);
-vec3 nd5sl0;
-{
- vec3 c = nd3sl0;
- vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
- vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
- nd5sl0=c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
-}
-COLOR.rgb=nd5sl0;
\ No newline at end of file diff --git a/scene/resources/default_theme/w_editor.gsl b/scene/resources/default_theme/w_editor.gsl deleted file mode 100644 index 6d2dd9a0bb..0000000000 --- a/scene/resources/default_theme/w_editor.gsl +++ /dev/null @@ -1,11 +0,0 @@ -vec3 nd1sl2=vec3(UV,0);
-float nd2sl1=1-nd1sl2.y;
-vec3 nd3sl0=vec3(nd2sl1,1,1);
-vec3 nd6sl0;
-{
- vec3 c = nd3sl0;
- vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
- vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
- nd6sl0=c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
-}
-COLOR.rgb=nd6sl0;
\ No newline at end of file |