X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpanel.cpp;h=c17fe4b261e74650a55349c62f314b39d710b06f;hb=1597579a34a8d87d4dea0a0cdc0895e6247b6126;hp=d3e8df0c374c0f190e4da38ffb50617a588613a4;hpb=68c4aa0eaaade8b163cf9b3a96aa640ea16b1def;p=libs%2Fgltk.git diff --git a/source/panel.cpp b/source/panel.cpp index d3e8df0..c17fe4b 100644 --- a/source/panel.cpp +++ b/source/panel.cpp @@ -1,145 +1,200 @@ +#include +#include +#include +#include "button.h" +#include "column.h" +#include "draghandle.h" +#include "dropdown.h" +#include "entry.h" +#include "grid.h" +#include "hslider.h" +#include "image.h" +#include "indicator.h" +#include "label.h" +#include "list.h" #include "panel.h" #include "part.h" +#include "row.h" +#include "stack.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) +Panel::Panel(): + layout(0) { - update_style(); + input_type = INPUT_NAVIGATION; } 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::autosize_special(const Part &part, Geometry &ageom) const +{ + if(part.get_name()=="children" && layout) + layout->autosize(ageom); } -void Panel::button_release(int x, int y, unsigned btn) +void Panel::render_special(const Part &part, GL::Renderer &renderer) const { - if(pointer_grab>0) + if(part.get_name()=="children") { - 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; - } - } + for(list::const_iterator i=children.begin(); i!=children.end(); ++i) + if((*i)->widget->is_visible()) + (*i)->widget->render(renderer); } - else if(geom.is_inside(x, y)) +} + +void Panel::on_geometry_change() +{ + if(layout) + layout->update(); +} + +void Panel::on_child_added(Widget &wdg) +{ + if(layout) { - 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); + layout->add_widget(wdg); + signal_autosize_changed.emit(); } } -void Panel::pointer_motion(int x, int y) +void Panel::on_child_removed(Widget &wdg) { - if(pointer_grab>0) - pointer_focus->pointer_motion(x-geom.x, y-geom.y); - else if(geom.is_inside(x, y)) + if(layout) { - 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); + layout->remove_widget(wdg); + signal_autosize_changed.emit(); } } -void Panel::key_press(unsigned key, unsigned mod, wchar_t ch) + +Panel::Loader::Loader(Panel &p, map &m): + DataFile::DerivedObjectLoader(p), + wdg_map(m), + last_widget(0) { - if(input_focus) - input_focus->key_press(key, mod, ch); + add("button", &Loader::child