Author: mordante
Date: Wed Aug 13 20:49:41 2008
New Revision: 28567
URL: http://svn.gna.org/viewcvs/wesnoth?rev=28567&view=rev
Log:
Add the option to transfer the label text to the tooltip when no tooltip
defined.
This option is enabled by default (not tested with a multiline label yet).
Modified:
trunk/src/gui/widgets/control.cpp
trunk/src/gui/widgets/control.hpp
trunk/src/gui/widgets/window_builder.cpp
trunk/src/gui/widgets/window_builder_private.hpp
Modified: trunk/src/gui/widgets/control.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/control.cpp?rev=28567&r1=28566&r2=28567&view=diff
==============================================================================
--- trunk/src/gui/widgets/control.cpp (original)
+++ trunk/src/gui/widgets/control.cpp Wed Aug 13 20:49:41 2008
@@ -44,6 +44,7 @@
visible_(true),
label_(),
multiline_label_(false),
+ use_tooltip_on_label_overflow_(true),
tooltip_(),
help_message_(),
canvas_(canvas_count),
@@ -184,6 +185,14 @@
canvas.set_height(rect.h);
}
+ // Note we assume that the best size has been queried but otherwise it
+ // should return false.
+ if(renderer_.is_truncated()
+ && use_tooltip_on_label_overflow_ && tooltip_.empty()) {
+
+ set_tooltip(label_);
+ }
+
// inherited
twidget::set_size(rect);
}
Modified: trunk/src/gui/widgets/control.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/control.hpp?rev=28567&r1=28566&r2=28567&view=diff
==============================================================================
--- trunk/src/gui/widgets/control.hpp (original)
+++ trunk/src/gui/widgets/control.hpp Wed Aug 13 20:49:41 2008
@@ -155,9 +155,13 @@
void set_visible(const bool visible = true)
{ if(visible_ != visible) { visible_ = visible; set_dirty();} }
- // Getter isn't needed yet will be added when needed.
+ bool get_multiline_label() const { return multiline_label_; }
void set_multiline_label(const bool multiline = true)
{ if(multiline != multiline_label_) { multiline_label_ =
multiline; set_dirty(); } }
+
+ bool get_use_tooltip_on_label_overflow() const { return
use_tooltip_on_label_overflow_; }
+ void set_use_tooltip_on_label_overflow(const bool use_tooltip = true)
+ { use_tooltip_on_label_overflow_ = use_tooltip; }
const t_string& label() const { return label_; }
void set_label(const t_string& label);
@@ -205,6 +209,13 @@
* multiple lines of text we need to find the best width/height
combination.
*/
bool multiline_label_;
+
+ /**
+ * If the text doesn't fit on the label should the text be used as
tooltip?
+ *
+ * This only happens if the tooltip is empty.
+ */
+ bool use_tooltip_on_label_overflow_;
/**
* Tooltip text.
Modified: trunk/src/gui/widgets/window_builder.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window_builder.cpp?rev=28567&r1=28566&r2=28567&view=diff
==============================================================================
--- trunk/src/gui/widgets/window_builder.cpp (original)
+++ trunk/src/gui/widgets/window_builder.cpp Wed Aug 13 20:49:41 2008
@@ -432,7 +432,9 @@
definition(cfg["definition"]),
label(cfg["label"]),
tooltip(cfg["tooltip"]),
- help(cfg["help"])
+ help(cfg["help"]),
+ use_tooltip_on_label_overflow(
+ utils::string_bool("use_tooltip_on_label_overflow", true))
{
/*WIKI
* @page = GUIToolkitWML
@@ -476,6 +478,12 @@
* but in general (if used) this message
* should show more help. This defines the
* text of that message.
+ *
+ * use_tooltip_on_label_overflow (bool = true)
+ * If the text on the label is truncated
and
+ * the tooltip is empty the label can be
+ * used for the tooltip. If this variale is
+ * set to true this will happen.
* @end_table
*
*/
@@ -498,6 +506,7 @@
control->set_label(label);
control->set_tooltip(tooltip);
control->set_help_message(help);
+
control->set_use_tooltip_on_label_overflow(use_tooltip_on_label_overflow);
}
tbuilder_button::tbuilder_button(const config& cfg) :
Modified: trunk/src/gui/widgets/window_builder_private.hpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/window_builder_private.hpp?rev=28567&r1=28566&r2=28567&view=diff
==============================================================================
--- trunk/src/gui/widgets/window_builder_private.hpp (original)
+++ trunk/src/gui/widgets/window_builder_private.hpp Wed Aug 13 20:49:41 2008
@@ -44,6 +44,7 @@
t_string label;
t_string tooltip;
t_string help;
+ bool use_tooltip_on_label_overflow;
};
struct tbuilder_button : public tbuilder_control
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits