Author: sh-sh-sh
Date: Thu Aug 21 19:56:44 2008
New Revision: 50297
URL: http://svn.opensuse.org/viewcvs/yast?rev=50297&view=rev
Log:
better resize behaviour in pathological cases
Modified:
trunk/libyui/src/YButtonBox.cc
trunk/libyui/src/YButtonBox.h
Modified: trunk/libyui/src/YButtonBox.cc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/libyui/src/YButtonBox.cc?rev=50297&r1=50296&r2=50297&view=diff
==============================================================================
--- trunk/libyui/src/YButtonBox.cc (original)
+++ trunk/libyui/src/YButtonBox.cc Thu Aug 21 19:56:44 2008
@@ -34,7 +34,7 @@
using std::list;
-YButtonBoxLayoutPolicy YButtonBox::_layoutPolicy;
+YButtonBoxLayoutPolicy YButtonBox::_layoutPolicy = kdeLayoutPolicy();
YButtonBoxMargins YButtonBox::_defaultMargins;
@@ -163,12 +163,34 @@
int prefWidth = preferredWidth();
int prefHeight = preferredHeight();
YButtonBoxMargins margins = priv->margins;
+ bool equalSizeButtons = _layoutPolicy.equalSizeButtons;
//
// Horizontal layout
//
-
+
+ if ( width < prefWidth ) // Not enough horizontal space
+ {
+ if ( equalSizeButtons )
+ {
+ // Try not enforcing the same width:
+ //
+ // If one button is very much larger than most others, that one
+ // button will greatly distort the overall layout. If we simply cut
+ // some pixels off every button, for sure that one very large
+ // button will become unreadable. So let's try first with buttons
+ // getting just the size they really need.
+ //
+ // Of course, we might still have cut some pixels off all buttons
+ // if that also is too wide, but in that case we can't do very much
+ // anyway.
+
+ equalSizeButtons = false;
+ prefWidth = preferredWidth( equalSizeButtons );
+ }
+ }
+
int widthLoss = 0;
if ( width < prefWidth ) // Not enough horizontal space
@@ -255,7 +277,7 @@
}
}
-
+
//
// Vertical layout
//
@@ -282,17 +304,17 @@
//
// Set child widget positions and sizes from left to right
//
-
+
int x_pos = margins.left;
int buttonWidth = 0;
- if ( _layoutPolicy.equalSizeButtons )
+ if ( equalSizeButtons )
{
buttonWidth = maxChildSize( YD_HORIZ );
buttonWidth -= widthLoss;
}
-
+
for ( vector