X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Froot.cpp;h=713477488a13ce6a5c2954c5daba94cc318ff487;hb=7286d604956ddffcbfa2df6567de866f3d5df3a2;hp=e867fae63653ebf39f10e4398fa5c5f83d3a301a;hpb=3bdb7fd6873ca45ce7e7754040b69b0d941eef31;p=libs%2Fgltk.git diff --git a/source/root.cpp b/source/root.cpp index e867fae..7134774 100644 --- a/source/root.cpp +++ b/source/root.cpp @@ -1,9 +1,9 @@ #include #include #include +#include #include #include -#include #include #include "label.h" #include "style.h" @@ -13,7 +13,7 @@ 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 +24,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), @@ -58,6 +58,9 @@ void Root::init(Graphics::Window *window) else shprog = 0; + if(keyboard) + set_state(FOCUS); + update_style(); if(mouse) @@ -91,6 +94,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,11 +144,8 @@ void Root::tick() } } -void Root::render(const GL::Tag &tag) const +void Root::render() const { - if(tag.id) - return; - GL::Bind bind_blend(GL::Blend::alpha()); GL::Renderer renderer(&camera); @@ -152,8 +158,12 @@ void Root::render(GL::Renderer &renderer, const GL::Tag &tag) const if(tag.id) return; - renderer.end(); - render(tag); + GL::Renderer::Push push(renderer); + renderer.set_camera(camera); + renderer.set_shader_program(shprog); + GL::BindRestore bind_blend(GL::Blend::alpha()); + GL::BindRestore unbind_dtest(static_cast(0)); + Widget::render(renderer); } bool Root::button_press_event(unsigned btn) @@ -287,9 +297,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(); }