]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/toggle.cpp
Refactor widget autosizing
[libs/gltk.git] / source / toggle.cpp
index 451926956d12520de95ff4ba6aff7e9049556249..fe6518dda722b57fc6ffda3c2481d4e42ae63047 100644 (file)
@@ -17,21 +17,10 @@ Toggle::Toggle(const string &t):
        set_text(t);
 }
 
-void Toggle::autosize()
+void Toggle::autosize_special(const Part &part, Geometry &ageom)
 {
-       if(!style)
-               return;
-
-       Widget::autosize();
-
-       if(const Part *text_part = style->get_part("text"))
-       {
-               const Sides &margin = text_part->get_margin();
-               geom.w = max(geom.w, text.get_width()+margin.left+margin.right);
-               geom.h = max(geom.h, text.get_height()+margin.top+margin.bottom);
-       }
-
-       rebuild();
+       if(part.get_name()=="text")
+               text.autosize(part, ageom);
 }
 
 void Toggle::set_text(const string &t)