From: Mikko Rasa Date: Sun, 1 Jun 2008 18:24:32 +0000 (+0000) Subject: Clear focus in Panel if focused child is removed X-Git-Tag: 0.9~8 X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=9b29612d1cde85fee9b3f011e86a5cabe5dbcce3;p=libs%2Fgltk.git Clear focus in Panel if focused child is removed Translate keys from system to internal codes in Root Some GL coloring tweaks --- diff --git a/source/entry.cpp b/source/entry.cpp index 9f7c761..efb4b45 100644 --- a/source/entry.cpp +++ b/source/entry.cpp @@ -8,6 +8,7 @@ Distributed under the LGPL #include #include #include +#include #include "entry.h" #include "graphic.h" #include "part.h" @@ -15,13 +16,15 @@ Distributed under the LGPL using namespace std; +#include + namespace Msp { namespace GLtk { Entry::Entry(const Resources &r, const string &t): Widget(r), text(t), - edit_pos(0) + edit_pos(text.size()) { update_style(); } @@ -29,30 +32,29 @@ Entry::Entry(const Resources &r, const string &t): void Entry::set_text(const string &t) { text=t; - if(edit_pos>text.size()) - edit_pos=text.size(); + edit_pos=text.size(); } void Entry::key_press(unsigned key, unsigned, wchar_t ch) { - if(key==100) + if(key==Input::KEY_LEFT) { if(edit_pos>0) --edit_pos; } - else if(key==102) + else if(key==Input::KEY_RIGHT) { if(edit_pos0) text.erase(--edit_pos, 1); } else { - text+=ch; + text.insert(edit_pos, Codecs::encode(Codecs::ustring(1, ch))); ++edit_pos; } } diff --git a/source/graphic.cpp b/source/graphic.cpp index 0c874c8..9b613a7 100644 --- a/source/graphic.cpp +++ b/source/graphic.cpp @@ -21,9 +21,6 @@ Graphic::Graphic(): void Graphic::render(unsigned wd, unsigned ht) const { - GL::VertexArray varr((GL::TEXCOORD2, GL::VERTEX2)); - RefPtr vab=varr.modify(); - vector x, y; create_coords(0.0f-shadow.left, wd+shadow.right, border.left, border.right, slice.w-border.left-border.right, x); create_coords(0.0f-shadow.bottom, ht+shadow.top, border.bottom, border.top, slice.h-border.bottom-border.top, y); @@ -38,7 +35,8 @@ void Graphic::render(unsigned wd, unsigned ht) const unsigned ymax=y.size()-(border.top ? 2 : 3); texture->bind(); - GL::Immediate imm((GL::TEXCOORD2,GL::VERTEX2)); + GL::Immediate imm((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2)); + imm.color(1.0f, 1.0f, 1.0f); imm.begin(GL::QUADS); for(unsigned i=ymin; i<=ymax; ++i) { diff --git a/source/panel.cpp b/source/panel.cpp index 4d0d5d1..a4b2769 100644 --- a/source/panel.cpp +++ b/source/panel.cpp @@ -50,6 +50,11 @@ void Panel::remove(Widget &wdg) ChildSeq::iterator i=find(children.begin(), children.end(), &wdg); if(i!=children.end()) { + if(&wdg==pointer_focus) + set_pointer_focus(0, 0); + if(&wdg==input_focus) + set_input_focus(0); + set_parent(wdg, 0); children.erase(i); } diff --git a/source/root.cpp b/source/root.cpp index 224e5bc..1c030e8 100644 --- a/source/root.cpp +++ b/source/root.cpp @@ -5,6 +5,7 @@ Copyright © 2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ +#include #include "root.h" namespace Msp { @@ -55,13 +56,13 @@ void Root::pointer_motion_event(int x, int y) void Root::key_press_event(unsigned key, unsigned mod, wchar_t ch) { if(visible) - key_press(key, mod, ch); + key_press(Input::key_from_sys(key), mod, ch); } void Root::key_release_event(unsigned key, unsigned mod) { if(visible) - key_release(key, mod); + key_release(Input::key_from_sys(key), mod); } void Root::translate_coords(int &x, int &y) diff --git a/source/widget.cpp b/source/widget.cpp index be1f0a0..efb6155 100644 --- a/source/widget.cpp +++ b/source/widget.cpp @@ -5,6 +5,7 @@ Copyright © 2007 Mikko Rasa, Mikkosoft Productions Distributed under the LGPL */ +#include #include #include #include @@ -108,9 +109,9 @@ void Widget::render_text(const Part &part, const string &text) const GL::scale_uniform(font_size); const GL::Color &color=style->get_font_color(); - glColor3f(color.r, color.g, color.b); - font->draw_string(text); - glColor3f(1, 1, 1); + GL::Immediate imm((GL::COLOR4_UBYTE, GL::TEXCOORD2, GL::VERTEX2)); + imm.color(color.r, color.g, color.b); + font->draw_string(text, imm); GL::pop_matrix(); }