X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fdropdown.cpp;h=4d18187a7fb28642934dd5a5aeb0adb0038e85b6;hb=50bf1ef2e2c3c38de20f6996a6c5ed0066111177;hp=5f49b9ef33396dea8cd8141d92dcfe52386f9cfd;hpb=af13797a82b242a3cd8fdd405b057a9e311631ac;p=libs%2Fgltk.git diff --git a/source/dropdown.cpp b/source/dropdown.cpp index 5f49b9e..4d18187 100644 --- a/source/dropdown.cpp +++ b/source/dropdown.cpp @@ -18,6 +18,7 @@ namespace GLtk { Dropdown::Dropdown(const Resources &r): Widget(r), list(new List(res)), + dropped(false), list_active(false) { list->signal_item_selected.connect(sigc::mem_fun(this, &Dropdown::list_item_selected)); @@ -43,14 +44,16 @@ void Dropdown::button_press(int x, int y, unsigned btn) list->button_press(x-lgeom.x, y-lgeom.y, btn); list_active=true; } - else if(state==ACTIVE) + else if(dropped) { - state=HOVER; + dropped=false; + state&=~ACTIVE; parent->ungrab_pointer(*this); } else if(btn==1) { - state=ACTIVE; + dropped=true; + state|=ACTIVE; if(parent) { @@ -79,23 +82,11 @@ void Dropdown::pointer_motion(int x, int y) } } -void Dropdown::pointer_enter() -{ - if(state==NORMAL) - state=HOVER; -} - -void Dropdown::pointer_leave() -{ - if(state==HOVER) - state=NORMAL; -} - void Dropdown::render_special(const Part &part) const { if(part.get_name()=="text") render_text(part, text); - else if(part.get_name()=="list" && state==ACTIVE) + else if(part.get_name()=="list" && dropped) list->render(); } @@ -109,7 +100,8 @@ void Dropdown::list_item_selected(unsigned index, const std::string &item) text=item; list_active=false; - state=NORMAL; + dropped=false; + state&=~ACTIVE; if(parent) parent->ungrab_pointer(*this);