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(Widget *wdg=get_child_at(x, y))
+ {
+ wdg->button_press(x-geom.x, y-geom.y, btn);
+ pointer_grab=btn;
+ set_input_focus(wdg);
+ }
}
}
{
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;
- }
+ set_pointer_focus(get_child_at(x, y));
}
}
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(Widget *wdg=get_child_at(x, y))
+ wdg->button_release(x-geom.x, y-geom.y, btn);
}
}
pointer_focus->pointer_motion(x-geom.x, y-geom.y);
else if(geom.is_inside(x, y))
{
- 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);
+ Widget *wdg=get_child_at(x, y);
+ set_pointer_focus(wdg);
+ if(wdg)
+ wdg->pointer_motion(x-geom.x, y-geom.y);
}
}
if(part.get_name()=="children")
{
for(ChildSeq::const_iterator i=children.begin(); i!=children.end(); ++i)
- (*i)->render();
+ if((*i)->is_visible())
+ (*i)->render();
}
else
Widget::render_part(part);
}
}
+Widget *Panel::get_child_at(int x, int y)
+{
+ for(ChildSeq::reverse_iterator i=children.rbegin(); i!=children.rend(); ++i)
+ if((*i)->is_visible() && (*i)->get_geometry().is_inside(x-geom.x, y-geom.y))
+ return *i;
+
+ return 0;
+}
+
Panel::Loader::Loader(Panel &p, map<string, Widget *> &m):
Widget::Loader(p),
- panel(p),
+ pnl(p),
wdg_map(m)
{
add("label", &Loader::child<Label>);
+ add("panel", &Loader::panel);
}
template<typename T>
void Panel::Loader::child(const string &n)
{
- RefPtr<T> chl=new T(panel.res);
+ RefPtr<T> chl=new T(pnl.res);
load_sub(*chl);
- panel.add(*chl.get());
+ pnl.add(*chl.get());
wdg_map[n]=chl.release();
}
+void Panel::Loader::panel(const string &n)
+{
+ RefPtr<Panel> p=new Panel(pnl.res);
+ load_sub(*p, wdg_map);
+ pnl.add(*p.get());
+ wdg_map[n]=p.release();
+}
+
} // namespace GLtk
} // namespace Msp
public:
Loader(Widget &);
+ Widget &get_object() const { return wdg; }
private:
void position(int, int);
void size(unsigned, unsigned);
void set_geometry(const Geometry &);
void set_style(const std::string &);
const Geometry &get_geometry() const { return geom; }
+ bool is_visible() const { return visible; }
void render() const;
virtual void button_press(int, int, unsigned) { }
virtual void button_release(int, int, unsigned) { }
std::string style_name;
const Style *style;
State state;
+ bool visible;
Widget(const Resources &);
virtual const char *get_class() const { return "widget"; }