Author: mordante
Date: Sun Mar 6 11:48:35 2011
New Revision: 48782
URL: http://svn.gna.org/viewcvs/wesnoth?rev=48782&view=rev
Log:
Let an image widget honours its size limits.
Now uses code more like the tcontrol class. The issue was spotted by
fendrin.
Modified:
trunk/changelog
trunk/src/gui/widgets/image.cpp
Modified: trunk/changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=48782&r1=48781&r2=48782&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Sun Mar 6 11:48:35 2011
@@ -31,6 +31,7 @@
* Add 1.25, 1.75 and 3.0 animation speed factors to display preferences
(feature request #15713).
* Implemented: The expose event in gui2.
+ * Fixed: Image widget now honours its minimum and maximum size.
* WML engine:
* Allow [color_range] and [color_palette] nodes to be inserted at top-level
by add-ons to globally define custom ranges and palettes.
Modified: trunk/src/gui/widgets/image.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/image.cpp?rev=48782&r1=48781&r2=48782&view=diff
==============================================================================
--- trunk/src/gui/widgets/image.cpp (original)
+++ trunk/src/gui/widgets/image.cpp Sun Mar 6 11:48:35 2011
@@ -36,13 +36,33 @@
{
surface image(image::get_image(image::locator(label())));
- tpoint result(0, 0);
- if(image) {
- result = tpoint(image->w, image->h);
+ if(!image) {
+ DBG_GUI_L << LOG_HEADER << " empty image return default.\n";
+ return get_config_default_size();
+ }
+
+ const tpoint minimum = get_config_default_size();
+ const tpoint maximum = get_config_maximum_size();
+
+ tpoint result = tpoint(image->w, image->h);
+
+ if(minimum.x > 0 && result.x < minimum.x) {
+ DBG_GUI_L << LOG_HEADER << " increase width to minimum.\n";
+ result.x = minimum.x;
+ } else if(maximum.x > 0 && result.x > maximum.x) {
+ DBG_GUI_L << LOG_HEADER << " decrease width to maximum.\n";
+ result.x = maximum.x;
+ }
+
+ if(minimum.y > 0 && result.y < minimum.y) {
+ DBG_GUI_L << LOG_HEADER << " increase height to minimum.\n";
+ result.y = minimum.y;
+ } else if(maximum.y > 0 && result.y > maximum.y) {
+ DBG_GUI_L << LOG_HEADER << " decrease height to maximum.\n";
+ result.y = maximum.y;
}
DBG_GUI_L << LOG_HEADER
- << " empty image " << !image
<< " result " << result
<< ".\n";
return result;
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits