X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpanel.cpp;h=836d991eb73e3b226d859b5c2c4a2da7acf5037a;hb=31e9ee682f8a9cd77c97ed9dc142283559ddaacc;hp=c93d430be07f16a988fa1a120af013104cd8889e;hpb=e7bc29984e91ee36555d6a4e4eece22170d10ba4;p=libs%2Fgltk.git diff --git a/source/panel.cpp b/source/panel.cpp index c93d430..836d991 100644 --- a/source/panel.cpp +++ b/source/panel.cpp @@ -1,167 +1,196 @@ +#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 "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) +{ } + +Panel::~Panel() { - update_style(); + delete layout; + layout = 0; } -Panel::~Panel() +void Panel::set_layout(Layout *l) { - for(ChildSeq::iterator i=children.begin(); i!=children.end(); ++i) - delete *i; + l->set_container(*this); + delete layout; + layout = l; } -void Panel::button_press(int x, int y, unsigned btn) +void Panel::autosize_special(const Part &part, Geometry &ageom) { - 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); - } - } + 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