diff --git a/src/guiengine/engine.cpp b/src/guiengine/engine.cpp
index 2cdd35d1d..6f74e94f9 100644
--- a/src/guiengine/engine.cpp
+++ b/src/guiengine/engine.cpp
@@ -350,6 +350,9 @@
and plain icons. Other widgets will also automativally manage the position
and size of their children, for instance ribbons.
+ Another possible value is "fit", which will make a \
fit to its
+ contents.
+
\n
\subsection prop9 PROP_MAX_WIDTH, PROP_MAX_HEIGHT
Names in XML files: \c "max_width", \c "max_height"
diff --git a/src/guiengine/layout_manager.cpp b/src/guiengine/layout_manager.cpp
index 3d933ffbe..b6a283057 100644
--- a/src/guiengine/layout_manager.cpp
+++ b/src/guiengine/layout_manager.cpp
@@ -178,7 +178,37 @@ void LayoutManager::readCoords(Widget* self)
}
// ---- if this widget has children, get their size size. this can helpful determine its optimal size
- int child_max_width = -1, child_max_height = -1;
+ if (self->m_properties[PROP_WIDTH] == "fit" || self->m_properties[PROP_HEIGHT] == "fit")
+ {
+ int child_max_width = -1, child_max_height = -1;
+ for (int child=0; childm_children.size(); child++)
+ {
+ if (self->m_children[child].m_absolute_w > -1)
+ {
+ if (child_max_width == -1 || self->m_children[child].m_absolute_w > child_max_width)
+ {
+ child_max_width = self->m_children[child].m_absolute_w;
+ }
+ }
+
+ if (self->m_children[child].m_absolute_h > -1)
+ {
+ if (child_max_height == -1 || self->m_children[child].m_absolute_h > child_max_height)
+ {
+ child_max_height = self->m_children[child].m_absolute_h;
+ }
+ }
+ }
+
+ if (self->m_properties[PROP_WIDTH] == "fit")
+ {
+ self->m_absolute_w = child_max_width;
+ }
+ if (self->m_properties[PROP_HEIGHT] == "fit")
+ {
+ self->m_absolute_h = child_max_height;
+ }
+ }
// ---- read dimension
// width