X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Froot.cpp;h=ef83bb9de3af842b8fe37878d1f4eb2185d36c12;hb=6deafc9f236b90175a303944815f7c0eac1c95c1;hp=b4c16cfe8bf7973ded8a5f2b387b23c189f80bbd;hpb=4b52d16bc895f9d969383d7a7d6a3558c1972cc5;p=libs%2Fgltk.git diff --git a/source/root.cpp b/source/root.cpp index b4c16cf..ef83bb9 100644 --- a/source/root.cpp +++ b/source/root.cpp @@ -1,19 +1,16 @@ #include -#include -#include -#include #include -#include #include #include "label.h" #include "style.h" +#include "resources.h" #include "root.h" #include "systemkeyboardinput.h" namespace Msp { namespace GLtk { -Root::Root(const Resources &r, Graphics::Window &window): +Root::Root(Resources &r, Graphics::Window &window): resources(r), keyboard(new Input::Keyboard(window)), input_method(0), @@ -24,7 +21,7 @@ Root::Root(const Resources &r, Graphics::Window &window): init(&window); } -Root::Root(const Resources &r, Graphics::Window *window, Input::Keyboard *k, Input::Mouse *m, Input::Touchscreen *t): +Root::Root(Resources &r, Graphics::Window *window, Input::Keyboard *k, Input::Mouse *m, Input::Touchscreen *t): resources(r), keyboard(k), input_method(0), @@ -46,17 +43,14 @@ void Root::init(Graphics::Window *window) camera.set_orthographic(geom.w, geom.h); update_camera(); - if(GL::ARB_shader_objects) - { - shprog = new GL::Program; - GL::ProgramBuilder::StandardFeatures features; - features.material = true; - features.texture = true; - GL::ProgramBuilder(features).add_shaders(*shprog); - shprog->link(); - } - else - shprog = 0; + shprog = &resources.get("ui.shader"); + + blend.enabled = true; + blend.src_factor = GL::SRC_ALPHA; + blend.dst_factor = GL::ONE_MINUS_SRC_ALPHA; + + if(keyboard) + set_state(FOCUS); update_style(); @@ -80,7 +74,6 @@ void Root::init(Graphics::Window *window) Root::~Root() { - delete shprog; delete input_method; if(own_input) { @@ -91,6 +84,12 @@ Root::~Root() void Root::tick() { + Time::TimeStamp t = Time::now(); + Time::TimeDelta dt = (last_tick ? t-last_tick : Time::zero); + last_tick = t; + + animate(dt); + if(tooltip_timeout && Time::now()>tooltip_timeout) { std::string tip; @@ -135,12 +134,21 @@ void Root::tick() } } -void Root::render() const +void Root::setup_frame(GL::Renderer &) +{ + rebuild_hierarchy(); +} + +void Root::render(GL::Renderer &renderer, GL::Tag tag) const { - GL::Bind bind_blend(GL::Blend::alpha()); + if(tag.id) + return; - GL::Renderer renderer(&camera); + GL::Renderer::Push push(renderer); + renderer.set_camera(camera); renderer.set_shader_program(shprog); + renderer.set_blend(&blend); + renderer.set_depth_test(0); Widget::render(renderer); } @@ -275,9 +283,9 @@ void Root::update_camera() camera.set_orthographic(geom.w, geom.h); } -void Root::on_geometry_change() +void Root::on_size_change() { - Panel::on_geometry_change(); + Panel::on_size_change(); update_camera(); }