]> git.tdb.fi Git - libs/gltk.git/blobdiff - source/image.cpp
Refactor widget autosizing
[libs/gltk.git] / source / image.cpp
index 2735ab611e6a059e73faccae8aa079a0c47e8876..8e14328c84b85aa073661cdb2dede39806715f20 100644 (file)
@@ -15,29 +15,22 @@ Image::Image(const GL::Texture2D *i):
        focusable = false;
 }
 
-void Image::autosize()
+void Image::autosize_special(const Part &part, Geometry &ageom)
 {
-       if(!style)
-               return;
-
-       Widget::autosize();
-
-       if(const Part *image_part = style->get_part("image"))
+       if(part.get_name()=="image")
        {
-               const Sides &margin = image_part->get_margin();
+               const Sides &margin = part.get_margin();
                if(image)
                {
-                       geom.w = max(geom.w, image->get_width()+margin.left+margin.right);
-                       geom.h = max(geom.h, image->get_height()+margin.top+margin.bottom);
+                       ageom.w = max(ageom.w, image->get_width()+margin.left+margin.right);
+                       ageom.h = max(ageom.h, image->get_height()+margin.top+margin.bottom);
                }
                else
                {
-                       geom.w = max(geom.w, margin.left+margin.right);
-                       geom.h = max(geom.h, margin.top+margin.bottom);
+                       ageom.w = max(ageom.w, margin.left+margin.right);
+                       ageom.h = max(ageom.h, margin.top+margin.bottom);
                }
        }
-
-       rebuild();
 }
 
 void Image::set_image(const GL::Texture2D *i)