X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fbutton.cpp;h=0dd20c7a6abb841cd4d2f9e98d1b75030d912d98;hb=3ac64a18ea1825174b84adb8570368df51e66231;hp=57e5fa42f57981cfb3398576b5a6563b3d5b4843;hpb=707b59d45ae50b69c94918f8f74313283b304597;p=libs%2Fgltk.git diff --git a/source/button.cpp b/source/button.cpp index 57e5fa4..0dd20c7 100644 --- a/source/button.cpp +++ b/source/button.cpp @@ -8,11 +8,9 @@ using namespace std; namespace Msp { namespace GLtk { -Button::Button(const std::string &t): - text(), - icon(0), - pressed(false) +Button::Button(const std::string &t) { + input_type = INPUT_NAVIGATION; set_text(t); } @@ -32,13 +30,13 @@ void Button::set_text(const std::string &t) { text = t; signal_autosize_changed.emit(); - rebuild(); + mark_rebuild(); } void Button::set_icon(const GL::Texture2D *i) { icon = i; - rebuild(); + mark_rebuild(); } void Button::rebuild_special(const Part &part) @@ -56,15 +54,15 @@ void Button::rebuild_special(const Part &part) GL::MeshBuilder bld(part_cache.create_mesh(part, *icon)); bld.color(1.0f, 1.0f, 1.0f); - bld.begin(GL::QUADS); + bld.begin(GL::TRIANGLE_STRIP); + bld.texcoord(0, 1); + bld.vertex(rgeom.x, rgeom.y+rgeom.h); bld.texcoord(0, 0); bld.vertex(rgeom.x, rgeom.y); - bld.texcoord(1, 0); - bld.vertex(rgeom.x+rgeom.w, rgeom.y); bld.texcoord(1, 1); bld.vertex(rgeom.x+rgeom.w, rgeom.y+rgeom.h); - bld.texcoord(0, 1); - bld.vertex(rgeom.x, rgeom.y+rgeom.h); + bld.texcoord(1, 0); + bld.vertex(rgeom.x+rgeom.w, rgeom.y); bld.end(); } } @@ -102,6 +100,16 @@ void Button::pointer_motion(int x, int y) } } +bool Button::navigate(Navigation nav) +{ + if(nav==NAV_ACTIVATE) + signal_clicked.emit(); + else + return false; + + return true; +} + void Button::on_style_change() { text.set_style(style);