Author: mordante
Date: Tue Sep 30 20:34:27 2008
New Revision: 29795
URL: http://svn.gna.org/viewcvs/wesnoth?rev=29795&view=rev
Log:
Allow values <= 0 to set no maximum width/height.
Some parts of the engine use 0 as no maximum width, so this change fixes
the text to always be detected as truncated (width 0 always truncates).
This should make the layout system slighty faster and also avoid future
problems.
Modified:
trunk/src/text.cpp
trunk/src/text.hpp
Modified: trunk/src/text.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/text.cpp?rev=29795&r1=29794&r2=29795&view=diff
==============================================================================
--- trunk/src/text.cpp (original)
+++ trunk/src/text.cpp Tue Sep 30 20:34:27 2008
@@ -289,8 +289,12 @@
return *this;
}
-ttext& ttext::set_maximum_width(const int width)
-{
+ttext& ttext::set_maximum_width(int width)
+{
+ if(width <= 0) {
+ width = -1;
+ }
+
if(width != maximum_width_) {
pango_layout_set_width(layout_, width == -1 ? -1 : width *
PANGO_SCALE);
maximum_width_ = width;
@@ -301,8 +305,12 @@
return *this;
}
-ttext& ttext::set_maximum_height(const int height)
-{
+ttext& ttext::set_maximum_height(int height)
+{
+ if(height <= 0) {
+ height = -1;
+ }
+
if(height != maximum_height_) {
/**
* @todo See whether we can make pango 1.20 mandatory before Wesnoth 1.6 is
Modified: trunk/src/text.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/text.hpp?rev=29795&r1=29794&r2=29795&view=diff
==============================================================================
--- trunk/src/text.hpp (original)
+++ trunk/src/text.hpp Tue Sep 30 20:34:27 2008
@@ -171,9 +171,9 @@
ttext& set_foreground_colour(const Uint32 colour);
- ttext& set_maximum_width(const int width);
-
- ttext& set_maximum_height(const int height);
+ ttext& set_maximum_width(int width);
+
+ ttext& set_maximum_height(int height);
ttext& set_ellipse_mode(const PangoEllipsizeMode ellipse_mode);
@@ -205,10 +205,19 @@
Uint32 foreground_colour_;
/**
- * The maximum width of the text, -1 means no maximum. */
+ * The maximum width of the text.
+ *
+ * Values less or equal to 0 mean no maximum and are internally stored
as
+ * -1, since that's the value pango uses for it.
+ */
int maximum_width_;
- /** The maximum height of the text, -1 means no maximum . */
+ /**
+ * The maximum height of the text.
+ *
+ * Values less or equal to 0 mean no maximum and are internally stored
as
+ * -1, since that's the value pango uses for it.
+ */
int maximum_height_;
/** The way too long text is shown depends on this mode. */
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits