X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fpanel.cpp;h=836d991eb73e3b226d859b5c2c4a2da7acf5037a;hb=31e9ee682f8a9cd77c97ed9dc142283559ddaacc;hp=c763e6e811afa5cd63926fb1971f047fb37e5c70;hpb=a38c924ff32081f5cd67c2b0e2d5ca61f0e99de2;p=libs%2Fgltk.git diff --git a/source/panel.cpp b/source/panel.cpp index c763e6e..836d991 100644 --- a/source/panel.cpp +++ b/source/panel.cpp @@ -1,174 +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)) - { - if(Widget *wdg=get_child_at(x, y)) - { - wdg->button_press(x-geom.x, y-geom.y, btn); - pointer_grab=btn; - set_input_focus(wdg); - } - } + 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); + for(list::const_iterator i=children.begin(); i!=children.end(); ++i) + if((*i)->widget->is_visible()) + (*i)->widget->render(renderer); + } +} - if(btn==pointer_grab) - { - pointer_grab=0; +void Panel::on_geometry_change() +{ + if(layout) + layout->update(); +} - set_pointer_focus(get_child_at(x, y)); - } - } - else if(geom.is_inside(x, y)) +void Panel::on_child_added(Widget &wdg) +{ + if(layout) { - if(Widget *wdg=get_child_at(x, y)) - wdg->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) { - Widget *wdg=get_child_at(x, y); - set_pointer_focus(wdg); - if(wdg) - wdg->pointer_motion(x-geom.x, y-geom.y); + 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