X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;ds=sidebyside;f=source%2Froot.cpp;h=e867fae63653ebf39f10e4398fa5c5f83d3a301a;hb=3bdb7fd6873ca45ce7e7754040b69b0d941eef31;hp=a90ea5a23d9eec4a3b3bacc34b94fb1a912b8b4c;hpb=79af58bcfa941e0f2c33b172c9e924522ebcdfea;p=libs%2Fgltk.git diff --git a/source/root.cpp b/source/root.cpp index a90ea5a..e867fae 100644 --- a/source/root.cpp +++ b/source/root.cpp @@ -8,6 +8,7 @@ #include "label.h" #include "style.h" #include "root.h" +#include "systemkeyboardinput.h" namespace Msp { namespace GLtk { @@ -15,6 +16,7 @@ namespace GLtk { Root::Root(const Resources &r, Graphics::Window &window): resources(r), keyboard(new Input::Keyboard(window)), + input_method(0), mouse(new Input::Mouse(window)), touchscreen(0), own_input(true) @@ -25,6 +27,7 @@ Root::Root(const Resources &r, Graphics::Window &window): Root::Root(const Resources &r, Graphics::Window *window, Input::Keyboard *k, Input::Mouse *m, Input::Touchscreen *t): resources(r), keyboard(k), + input_method(0), mouse(m), touchscreen(t), own_input(false) @@ -64,12 +67,8 @@ void Root::init(Graphics::Window *window) mouse->signal_axis_motion.connect(sigc::mem_fun(this, &Root::axis_motion_event)); } - if(keyboard) - { - keyboard->signal_button_press.connect(sigc::mem_fun(this, &Root::key_press_event)); - keyboard->signal_button_release.connect(sigc::mem_fun(this, &Root::key_release_event)); - keyboard->signal_character.connect(sigc::mem_fun(this, &Root::character_event)); - } + if(keyboard && !input_method) + input_method = new SystemKeyboardInput(*this, *keyboard); if(touchscreen) { @@ -82,6 +81,7 @@ void Root::init(Graphics::Window *window) Root::~Root() { delete shprog; + delete input_method; if(own_input) { delete keyboard; @@ -135,8 +135,11 @@ void Root::tick() } } -void Root::render() const +void Root::render(const GL::Tag &tag) const { + if(tag.id) + return; + GL::Bind bind_blend(GL::Blend::alpha()); GL::Renderer renderer(&camera); @@ -144,6 +147,15 @@ void Root::render() const Widget::render(renderer); } +void Root::render(GL::Renderer &renderer, const GL::Tag &tag) const +{ + if(tag.id) + return; + + renderer.end(); + render(tag); +} + bool Root::button_press_event(unsigned btn) { if(visible) @@ -206,52 +218,6 @@ bool Root::axis_motion_event(unsigned, float, float) return false; } -bool Root::key_press_event(unsigned key) -{ - // XXX Modifiers - if(visible) - { - Widget *old_focus = input_focus; - - key_press(key, 0); - - if(input_focus || old_focus) - return true; - } - - return false; -} - -bool Root::key_release_event(unsigned key) -{ - if(visible) - { - Widget *old_focus = input_focus; - - key_release(key, 0); - - if(input_focus || old_focus) - return true; - } - - return false; -} - -bool Root::character_event(StringCodec::unichar ch) -{ - if(visible) - { - Widget *old_focus = input_focus; - - character(ch); - - if(input_focus || old_focus) - return true; - } - - return false; -} - bool Root::touch_press_event(unsigned finger) { if(visible)