X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpanel.cpp;h=c7b1574979d7883d8f03c44816dc6152eb1daf4a;hb=43a75e4e9be56c58be5e224f19016bb14b56a7ef;hp=d3e8df0c374c0f190e4da38ffb50617a588613a4;hpb=68c4aa0eaaade8b163cf9b3a96aa640ea16b1def;p=libs%2Fgltk.git diff --git a/source/panel.cpp b/source/panel.cpp index d3e8df0..c7b1574 100644 --- a/source/panel.cpp +++ b/source/panel.cpp @@ -1,145 +1,115 @@ +#include +#include +#include "button.h" +#include "dropdown.h" +#include "entry.h" +#include "hslider.h" +#include "indicator.h" +#include "label.h" +#include "layout.h" +#include "list.h" #include "panel.h" #include "part.h" +#include "table.h" +#include "toggle.h" +#include "vslider.h" + +using namespace std; namespace Msp { namespace GLtk { -Panel::Panel(const Resources &r): - Widget(r), - pointer_focus(0), - pointer_grab(0), - input_focus(0) -{ - update_style(); -} +Panel::Panel(): + layout(0) +{ } Panel::~Panel() { - for(ChildSeq::iterator i=children.begin(); i!=children.end(); ++i) - delete *i; + delete layout; + layout = 0; } -void Panel::button_press(int x, int y, unsigned btn) +void Panel::set_layout(Layout *l) { - if(pointer_grab>0) - pointer_focus->button_press(x-geom.x, y-geom.y, btn); - else if(geom.is_inside(x, y)) - { - for(ChildSeq::iterator i=children.begin(); i!=children.end(); ++i) - if((*i)->get_geometry().is_inside(x-geom.x, y-geom.y)) - { - (*i)->button_press(x-geom.x, y-geom.y, btn); - pointer_grab=btn; - set_input_focus(*i); - } - } + l->set_container(*this); + delete layout; + layout = l; } -void Panel::button_release(int x, int y, unsigned btn) +void Panel::autosize() { - if(pointer_grab>0) - { - pointer_focus->button_release(x-geom.x, y-geom.y, btn); - - if(btn==pointer_grab) - { - pointer_grab=0; - - for(ChildSeq::iterator i=children.begin(); i!=children.end(); ++i) - if((*i)->get_geometry().is_inside(x-geom.x, y-geom.y)) - { - set_pointer_focus(*i); - break; - } - } - } - else if(geom.is_inside(x, y)) - { - for(ChildSeq::iterator i=children.begin(); i!=children.end(); ++i) - if((*i)->get_geometry().is_inside(x-geom.x, y-geom.y)) - (*i)->button_release(x-geom.x, y-geom.y, btn); - } + if(layout) + layout->autosize(); } -void Panel::pointer_motion(int x, int y) +void Panel::render_special(const Part &part, GL::Renderer &renderer) const { - if(pointer_grab>0) - pointer_focus->pointer_motion(x-geom.x, y-geom.y); - else if(geom.is_inside(x, y)) + if(part.get_name()=="children") { - bool found=false; - for(ChildSeq::iterator i=children.begin(); i!=children.end(); ++i) - if((*i)->get_geometry().is_inside(x-geom.x, y-geom.y)) - { - set_pointer_focus(*i); - (*i)->pointer_motion(x-geom.x, y-geom.y); - found=true; - } - - if(!found) - set_pointer_focus(0); + for(list::const_iterator i=children.begin(); i!=children.end(); ++i) + if((*i)->widget->is_visible()) + (*i)->widget->render(renderer); } } -void Panel::key_press(unsigned key, unsigned mod, wchar_t ch) +void Panel::on_geometry_change() { - if(input_focus) - input_focus->key_press(key, mod, ch); + if(layout) + layout->update(); } -void Panel::key_release(unsigned key, unsigned mod) +void Panel::on_child_added(Widget &wdg) { - if(input_focus) - input_focus->key_release(key, mod); + if(layout) + { + layout->add_widget(wdg); + signal_autosize_changed.emit(); + } } -void Panel::focus_out() +void Panel::on_child_removed(Widget &wdg) { - set_input_focus(0); + if(layout) + { + layout->remove_widget(wdg); + signal_autosize_changed.emit(); + } } -void Panel::add(Widget &wdg) -{ - children.push_back(&wdg); -} -void Panel::render_part(const Part &part) const +Panel::Loader::Loader(Panel &p, map &m): + Widget::Loader(p), + pnl(p), + wdg_map(m) { - if(part.get_name()=="children") - { - for(ChildSeq::const_iterator i=children.begin(); i!=children.end(); ++i) - (*i)->render(); - } - else - Widget::render_part(part); + add("button", &Loader::child