wdg_map(m),
last_widget(0)
{
- add("button", &Loader::child<Button>);
+ add_child_type<Button>("button");
add("column", &Loader::arrangement<Column>);
add("constraint",&Loader::constraint);
- add("draghandle",&Loader::child<DragHandle>);
- add("dropdown", &Loader::child<Dropdown>);
- add("entry", &Loader::child<Entry>);
+ add_child_type<DragHandle>("draghandle");
+ add_child_type<Dropdown>("dropdown");
+ add_child_type<Entry>("entry");
add("expand", &Loader::expand);
add("ghost", &Loader::ghost);
add("gravity", &Loader::gravity);
add("grid", &Loader::grid);
- add("hslider", &Loader::child<HSlider>);
- add("image", &Loader::child<Image>);
- add("indicator", &Loader::child<Indicator>);
- add("label", &Loader::child<Label>);
+ add_child_type<HSlider>("hslider");
+ add_child_type<Image>("image");
+ add_child_type<Indicator>("indicator");
+ add_child_type<Label>("label");
add("layout", &Loader::layout);
- add("list", &Loader::child<List>);
- add("panel", &Loader::panel);
+ add_child_type<List>("list");
+ add_child_type<Panel>("panel");
add("row", &Loader::arrangement<Row>);
add("stack", &Loader::arrangement<Stack>);
- add("toggle", &Loader::child<Toggle>);
- add("vslider", &Loader::child<VSlider>);
+ add_child_type<Toggle>("toggle");
+ add_child_type<VSlider>("vslider");
+}
+
+template<typename T>
+void Panel::Loader::add_child_type(const string &keyword)
+{
+ add(keyword, &Loader::child<T>);
+ add(keyword, &Loader::unnamed_child<T>);
}
Layout &Panel::Loader::get_layout()
template<typename T>
void Panel::Loader::child(const string &n)
{
- RefPtr<T> chl = new T();
- load_sub(*chl);
- obj.add(*chl.get());
- last_widget = wdg_map[n] = chl.release();
+ unnamed_child<T>();
+ wdg_map[n] = last_widget;
}
void Panel::Loader::constraint(Layout::ConstraintType type, const string &n)
load_sub_with(ldr);
}
-void Panel::Loader::panel(const string &n)
+template<typename T>
+void Panel::Loader::unnamed_child()
{
- RefPtr<Panel> p = new Panel();
- load_sub(*p, wdg_map);
- obj.add(*p.get());
- last_widget = wdg_map[n] = p.release();
+ RefPtr<T> chl = new T();
+ load_sub(*chl);
+ obj.add(*chl.get());
+ last_widget = chl.release();
}
+template<>
+void Panel::Loader::unnamed_child<Panel>()
+{
+ RefPtr<Panel> pnl = new Panel();
+ load_sub(*pnl, wdg_map);
+ obj.add(*pnl.get());
+ last_widget = pnl.release();
+}
template<typename T>
Panel::ArrangedLoader<T>::ArrangedLoader(Loader &ldr, T &arr):