diff options
author | Juan Linietsky <reduzio@gmail.com> | 2016-10-03 16:33:42 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2016-10-03 21:35:16 +0200 |
commit | 22d83bc9f655d5ae7a1b49709c4c1b663725daf5 (patch) | |
tree | a817195c08d4713a70ca014a3f63f5937934fe36 /scene/gui | |
parent | 78d97b060a6873a454e710380cb9ef1bde5e4c65 (diff) |
Begining of GLES3 renderer:
-Most 2D drawing is implemented
-Missing shaders
-Missing all 3D
-Editor needs to be set on update always to be used, otherwise it does not refresh
-Large parts of editor not working
Diffstat (limited to 'scene/gui')
-rw-r--r-- | scene/gui/color_picker.cpp | 76 | ||||
-rw-r--r-- | scene/gui/patch_9_frame.cpp | 2 |
2 files changed, 40 insertions, 38 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp index 5e66544153..27bdb581e1 100644 --- a/scene/gui/color_picker.cpp +++ b/scene/gui/color_picker.cpp @@ -59,6 +59,10 @@ void ColorPicker::_notification(int p_what) { w_material->set_shader(get_shader("w_editor")); update_material(uv_material,color,h,s,v); update_material(w_material,color,h,s,v); + uv_edit->set_texture(get_icon("color_main")); + w_edit->set_texture(get_icon("color_hue")); + sample->set_texture(get_icon("color_sample")); + _update_controls(); } break; @@ -192,10 +196,24 @@ void ColorPicker::_update_presets() { Size2 size=bt_add_preset->get_size(); preset->set_custom_minimum_size(Size2(size.width*presets.size(),size.height)); - Image i(size.x*presets.size(),size.y, false, Image::FORMAT_RGB); - for (int y=0;y<size.y;y++) - for (int x=0;x<size.x*presets.size();x++) - i.put_pixel(x,y,presets[(int)x/size.x]); + + DVector<uint8_t> img; + img.resize(size.x*presets.size()*size.y*3); + + { + DVector<uint8_t>::Write w=img.write(); + for (int y=0;y<size.y;y++) { + for (int x=0;x<size.x*presets.size();x++) { + int ofs = (y*(size.x*presets.size())+x)*3; + w[ofs+0]=uint8_t(CLAMP(presets[(int)x/size.x].r*255.0,0,255)); + w[ofs+1]=uint8_t(CLAMP(presets[(int)x/size.x].g*255.0,0,255)); + w[ofs+2]=uint8_t(CLAMP(presets[(int)x/size.x].b*255.0,0,255)); + } + } + } + + Image i(size.x*presets.size(),size.y, false, Image::FORMAT_RGB8,img); + Ref<ImageTexture> t; t.instance(); t->create_from_image(i); @@ -394,15 +412,23 @@ void ColorPicker::_screen_input(const InputEvent &ev) } else if (ev.type==InputEvent::MOUSE_MOTION) { const InputEventMouse &mev = ev.mouse_motion; Viewport *r=get_tree()->get_root(); - if (!r->get_rect().has_point(Point2(mev.global_x,mev.global_y))) + if (!r->get_visible_rect().has_point(Point2(mev.global_x,mev.global_y))) return; Image img =r->get_screen_capture(); if (!img.empty()) { last_capture=img; r->queue_screen_capture(); } - if (!last_capture.empty()) - set_color(last_capture.get_pixel(mev.global_x,mev.global_y)); + if (!last_capture.empty()) { + int pw = last_capture.get_format()==Image::FORMAT_RGBA8?4:3; + int ofs = (mev.global_y*last_capture.get_width()+mev.global_x)*pw; + + DVector<uint8_t>::Read r = last_capture.get_data().read(); + + Color c( r[ofs+0]/255.0, r[ofs+1]/255.0, r[ofs+2]/255.0 ); + + set_color(c); + } } } @@ -474,16 +500,10 @@ ColorPicker::ColorPicker() : HBoxContainer *hb_edit = memnew( HBoxContainer ); uv_edit= memnew ( TextureFrame ); - Image i(256, 256, false, Image::FORMAT_RGB); - for (int y=0;y<256;y++) - for (int x=0;x<256;x++) - i.put_pixel(x,y,Color()); - Ref<ImageTexture> t; - t.instance(); - t->create_from_image(i); - uv_edit->set_texture(t); + + + uv_edit->set_ignore_mouse(false); - uv_edit->set_custom_minimum_size(Size2(256,256)); uv_edit->connect("input_event", this, "_uv_input"); Control *c= memnew( Control ); uv_edit->add_child(c); @@ -497,16 +517,9 @@ ColorPicker::ColorPicker() : add_child(hb_edit); w_edit= memnew( TextureFrame ); - i = Image(15, 256, false, Image::FORMAT_RGB); - for (int y=0;y<256;y++) - for (int x=0;x<15;x++) - i.put_pixel(x,y,Color()); - Ref<ImageTexture> tw; - tw.instance(); - tw->create_from_image(i); - w_edit->set_texture(tw); - w_edit->set_ignore_mouse(false); - w_edit->set_custom_minimum_size(Size2(15,256)); + + + w_edit->set_ignore_mouse(false); w_edit->connect("input_event", this, "_w_input"); c= memnew( Control ); w_edit->add_child(c); @@ -594,17 +607,6 @@ ColorPicker::ColorPicker() : set_color(Color(1,1,1)); - i.create(256,20,false,Image::FORMAT_RGB); - for (int y=0;y<20;y++) - for(int x=0;x<256;x++) - if ((x/4+y/4)%2) - i.put_pixel(x,y,Color(1,1,1)); - else - i.put_pixel(x,y,Color(0.6,0.6,0.6)); - Ref<ImageTexture> t_smpl; - t_smpl.instance(); - t_smpl->create_from_image(i); - sample->set_texture(t_smpl); HBoxContainer *bbc = memnew( HBoxContainer ); add_child(bbc); diff --git a/scene/gui/patch_9_frame.cpp b/scene/gui/patch_9_frame.cpp index 9ad6398359..ed1abbadee 100644 --- a/scene/gui/patch_9_frame.cpp +++ b/scene/gui/patch_9_frame.cpp @@ -39,7 +39,7 @@ void Patch9Frame::_notification(int p_what) { Size2 s=get_size(); RID ci = get_canvas_item(); - VS::get_singleton()->canvas_item_add_style_box(ci,Rect2(Point2(),s),region_rect,texture->get_rid(),Vector2(margin[MARGIN_LEFT],margin[MARGIN_TOP]),Vector2(margin[MARGIN_RIGHT],margin[MARGIN_BOTTOM]),draw_center,modulate); + VS::get_singleton()->canvas_item_add_nine_patch(ci,Rect2(Point2(),s),region_rect,texture->get_rid(),Vector2(margin[MARGIN_LEFT],margin[MARGIN_TOP]),Vector2(margin[MARGIN_RIGHT],margin[MARGIN_BOTTOM]),VS::NINE_PATCH_STRETCH,VS::NINE_PATCH_STRETCH,draw_center,modulate); // draw_texture_rect(texture,Rect2(Point2(),s),false,modulate); /* |