[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Wesnoth-cvs-commits] wesnoth/src preferences.cpp widgets/button.cpp
From: |
Guillaume Melquiond |
Subject: |
[Wesnoth-cvs-commits] wesnoth/src preferences.cpp widgets/button.cpp |
Date: |
Sun, 29 May 2005 16:52:40 -0400 |
CVSROOT: /cvsroot/wesnoth
Module name: wesnoth
Branch:
Changes by: Guillaume Melquiond <address@hidden> 05/05/29 20:52:40
Modified files:
src : preferences.cpp
src/widgets : button.cpp
Log message:
Fix text being written outside the buttons in the multiplayer setup
screen by moving text ellipsis at size computation time. It means that changing
the size won't provoke an ellipsis now, but it doesn't matter since the
previous funcitonality was buggy and unused.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/preferences.cpp.diff?tr1=1.158&tr2=1.159&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/wesnoth/wesnoth/src/widgets/button.cpp.diff?tr1=1.65&tr2=1.66&r1=text&r2=text
Patches:
Index: wesnoth/src/preferences.cpp
diff -u wesnoth/src/preferences.cpp:1.158 wesnoth/src/preferences.cpp:1.159
--- wesnoth/src/preferences.cpp:1.158 Mon May 16 22:44:19 2005
+++ wesnoth/src/preferences.cpp Sun May 29 20:52:40 2005
@@ -1,4 +1,4 @@
-/* $Id: preferences.cpp,v 1.158 2005/05/16 22:44:19 ydirson Exp $ */
+/* $Id: preferences.cpp,v 1.159 2005/05/29 20:52:40 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -1048,6 +1048,7 @@
const config* const adv = get_advanced_pref();
if(adv != NULL) {
const config& pref = *adv;
+ advanced_button_.set_width(0);
advanced_button_.set_label(pref["name"]);
std::string value = prefs[pref["field"]];
if(value.empty()) {
Index: wesnoth/src/widgets/button.cpp
diff -u wesnoth/src/widgets/button.cpp:1.65 wesnoth/src/widgets/button.cpp:1.66
--- wesnoth/src/widgets/button.cpp:1.65 Mon May 16 22:44:20 2005
+++ wesnoth/src/widgets/button.cpp Sun May 29 20:52:40 2005
@@ -1,4 +1,4 @@
-/* $Id: button.cpp,v 1.65 2005/05/16 22:44:20 ydirson Exp $ */
+/* $Id: button.cpp,v 1.66 2005/05/29 20:52:40 silene Exp $ */
/*
Copyright (C) 2003 by David White <address@hidden>
Part of the Battle for Wesnoth Project http://wesnoth.whitevine.net
@@ -36,8 +36,6 @@
button_(true), state_(NORMAL), type_(type), enabled_(true),
pressed_(false),
spacing_(spacing), base_height_(0), base_width_(0)
{
- set_label(label);
-
if(button_image_name.empty() && type == TYPE_PRESS) {
button_image_name = "button";
} else if(button_image_name.empty() && type == TYPE_CHECK) {
@@ -69,7 +67,7 @@
base_height_ = button_image->h;
base_width_ = button_image->w;
- calculate_size();
+ set_label(label);
if(type == TYPE_PRESS) {
image_.assign(scale_surface(button_image,location().w,location().h));
@@ -86,10 +84,20 @@
void button::calculate_size()
{
- textRect_ = screen_area();
+ SDL_Rect const &loc = location();
+ bool change_size = loc.h == 0 || loc.w == 0;
- textRect_ = font::draw_text(NULL,textRect_,font_size,
- font::BUTTON_COLOUR,label_,0,0);
+ if (!change_size) {
+ unsigned w = loc.w - (type_ == TYPE_PRESS ? horizontal_padding :
+
checkbox_horizontal_padding + base_width_);
+ label_ = font::make_text_ellipsis(label_, font_size, w);
+ }
+
+ textRect_ = font::draw_text(NULL, screen_area(), font_size,
+ font::BUTTON_COLOUR, label_, 0, 0);
+
+ if (!change_size)
+ return;
#ifdef USE_TINY_GUI
set_height(textRect_.h+vertical_padding);
@@ -182,8 +190,7 @@
}
video().blit_surface(loc.x, loc.y, image);
- const std::string etext = font::make_text_ellipsis(label_, font_size,
loc.w);
- font::draw_text(&video(), clipArea, font_size, button_colour, etext,
textx, texty);
+ font::draw_text(&video(), clipArea, font_size, button_colour, label_,
textx, texty);
update_rect(loc);
}
@@ -199,7 +206,6 @@
void button::set_label(const std::string& val)
{
- bg_restore();
label_ = val;
//if we have a list of items, use the first one that isn't an image
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Wesnoth-cvs-commits] wesnoth/src preferences.cpp widgets/button.cpp,
Guillaume Melquiond <=