]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/list.cpp
Add a helper class for single-child list items
[libs/gltk.git] / source / list.cpp
index 005f6fa8ea29cc2a57cd23152f46167dacf922a1..9be88e52c9ce65acecdf98b550d78a5db9a672ee 100644 (file)
@@ -538,6 +538,21 @@ void List::Item::render_special(const Part &part, GL::Renderer &renderer) const
 }
 
 
+void List::SimpleItem::on_style_change()
+{
+       if(!style || children.empty())
+               return;
+
+       Widget *child = children.front()->widget;
+       child->autosize();
+       if(const Part *part = style->get_part("children"))
+       {
+               const Sides &margin = part->get_margin();
+               child->set_position(margin.left, margin.bottom);
+       }
+}
+
+
 void List::MultiColumnItem::check_widths(vector<unsigned> &widths) const
 {
        if(widths.size()<children.size())
@@ -610,19 +625,6 @@ List::BasicItem::BasicItem(const string &text):
        add(label);
 }
 
-void List::BasicItem::on_style_change()
-{
-       if(!style)
-               return;
-
-       label.autosize();
-       if(const Part *part = style->get_part("children"))
-       {
-               const Sides &margin = part->get_margin();
-               label.set_position(margin.left, margin.bottom);
-       }
-}
-
 
 List::Loader::Loader(List &l):
        DataFile::DerivedObjectLoader<List, Widget::Loader>(l)