-/* $Id$
-
-This file is part of libmspgltk
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
#include <msp/gl/bindable.h>
#include <msp/gl/immediate.h>
#include <msp/gl/matrix.h>
#include "image.h"
#include "part.h"
+#include "style.h"
using namespace std;
focusable = false;
}
+void Image::autosize()
+{
+ if(!style)
+ return;
+
+ Widget::autosize();
+
+ if(const Part *image_part = style->get_part("image"))
+ {
+ const Sides &margin = image_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);
+ }
+ else
+ {
+ geom.w = max(geom.w, margin.left+margin.right);
+ geom.h = max(geom.h, margin.top+margin.bottom);
+ }
+ }
+}
+
void Image::set_image(const GL::Texture2D *i)
{
image = i;
+ signal_autosize_changed.emit();
}
void Image::set_keep_aspect(bool ka)