widelands-dev team mailing list archive
-
widelands-dev team
-
Mailing list archive
-
Message #04427
[Merge] lp:~widelands-dev/widelands/textareas_and_labels into lp:widelands
GunChleoc has proposed merging lp:~widelands-dev/widelands/textareas_and_labels into lp:widelands.
Requested reviews:
Widelands Developers (widelands-dev)
For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/textareas_and_labels/+merge/274054
Textareas now use the new font handler. Added automatic resizing for labels.
- Table headers change their height automatically according to font size.
- Spinboxes size their buttons according to font height; replaced button label texts with images.
- Split checkboxes into pictorial and textual checkboxes. Textual checkboxes own their labels and can resize them.
- Progresswindow text uses new font handler.
- Sliders use new font handler.
--
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/textareas_and_labels into lp:widelands.
=== added file 'pics/scrollbar_left_fast.png'
Binary files pics/scrollbar_left_fast.png 1970-01-01 00:00:00 +0000 and pics/scrollbar_left_fast.png 2015-10-10 20:55:10 +0000 differ
=== added file 'pics/scrollbar_right_fast.png'
Binary files pics/scrollbar_right_fast.png 1970-01-01 00:00:00 +0000 and pics/scrollbar_right_fast.png 2015-10-10 20:55:10 +0000 differ
=== modified file 'src/editor/ui_menus/editor_main_menu_load_or_save_map.cc'
--- src/editor/ui_menus/editor_main_menu_load_or_save_map.cc 2015-10-02 09:26:57 +0000
+++ src/editor/ui_menus/editor_main_menu_load_or_save_map.cc 2015-10-10 20:55:10 +0000
@@ -80,15 +80,11 @@
_("Show Map Names"));
vbox->add(show_mapnames_, UI::Box::AlignLeft, true);
- cb_dont_localize_mapnames_ = new UI::Checkbox(vbox, Point(0, 0));
+ /** TRANSLATORS: Checkbox title. If this checkbox is enabled, map names aren't translated. */
+ cb_dont_localize_mapnames_ = new UI::Checkbox(vbox, Point(0, 0), _("Show original map names"));
cb_dont_localize_mapnames_->set_state(false);
vbox->add_space(2 * padding_);
vbox->add(cb_dont_localize_mapnames_, UI::Box::AlignLeft, true);
- vbox->add_space(padding_);
- UI::Textarea* ta_dont_localize_mapnames =
- /** TRANSLATORS: Checkbox title. If this checkbox is enabled, map names aren't translated. */
- new UI::Textarea(vbox, _("Show original map names"), UI::Align_CenterLeft);
- vbox->add(ta_dont_localize_mapnames, UI::Box::AlignLeft);
vbox->set_size(get_inner_w(), buth_);
table_.set_column_compare(0, boost::bind(&MainMenuLoadOrSaveMap::compare_players, this, _1, _2));
@@ -102,8 +98,6 @@
// We don't need the unlocalizing option if there is nothing to unlocalize.
// We know this after the list is filled.
cb_dont_localize_mapnames_->set_visible(has_translated_mapname_);
- ta_dont_localize_mapnames->set_visible(has_translated_mapname_);
-
cb_dont_localize_mapnames_->changedto.connect(
boost::bind(&MainMenuLoadOrSaveMap::fill_table, boost::ref(*this)));
show_mapnames_->sigclicked.connect(
=== modified file 'src/editor/ui_menus/editor_main_menu_map_options.cc'
--- src/editor/ui_menus/editor_main_menu_map_options.cc 2015-10-02 07:02:00 +0000
+++ src/editor/ui_menus/editor_main_menu_map_options.cc 2015-10-10 20:55:10 +0000
@@ -217,10 +217,8 @@
*/
void MainMenuMapOptions::add_tag_checkbox(UI::Box* parent, std::string tag, std::string displ_name) {
UI::Box* box = new UI::Box(parent, 0, 0, UI::Box::Horizontal, max_w_, checkbox_space_, 0);
- UI::Checkbox* cb = new UI::Checkbox(box, Point(0, 0));
+ UI::Checkbox* cb = new UI::Checkbox(box, Point(0, 0), displ_name);
box->add(cb, UI::Box::AlignLeft, true);
- box->add_space(padding_);
- box->add(new UI::Textarea(box, displ_name, UI::Align_CenterLeft), UI::Box::AlignLeft);
box->add_space(checkbox_space_);
parent->add(box, UI::Box::AlignLeft);
parent->add_space(padding_);
=== modified file 'src/editor/ui_menus/editor_main_menu_random_map.cc'
--- src/editor/ui_menus/editor_main_menu_random_map.cc 2015-10-05 06:53:34 +0000
+++ src/editor/ui_menus/editor_main_menu_random_map.cc 2015-10-10 20:55:10 +0000
@@ -237,13 +237,10 @@
// ---------- Island mode ----------
- Point pos(get_inner_w() - spacing - height, posy);
- m_island_mode = new UI::Checkbox(this, pos);
+ m_island_mode = new UI::Checkbox(this, Point(posx, posy), _("Island mode"));
m_island_mode->set_state(true);
m_island_mode->changed.connect
(boost::bind(&MainMenuNewRandomMap::button_clicked, this, ButtonId::SWITCH_ISLAND_MODE));
-
- new UI::Textarea(this, posx, posy, _("Island mode:"));
posy += height + spacing;
=== modified file 'src/graphic/font.cc'
--- src/graphic/font.cc 2015-09-22 07:21:52 +0000
+++ src/graphic/font.cc 2015-10-10 20:55:10 +0000
@@ -52,11 +52,12 @@
/**
* Open a font file and load the corresponding font.
*/
-Font::Font(const std::string & name, int size)
+Font::Font(const std::string & name, int input_size)
{
// Load the TrueType Font
std::string filename = "i18n/fonts/";
filename += name;
+ m_size = input_size;
// We must keep this File Read open, otherwise the following calls are
// crashing. do not know why...
@@ -66,7 +67,7 @@
if (!ops)
throw wexception("could not load font!: RWops Pointer invalid");
- m_font = TTF_OpenFontIndexRW(ops, 1, size, 0);
+ m_font = TTF_OpenFontIndexRW(ops, 1, input_size, 0);
if (!m_font)
throw wexception("could not load font!: %s", TTF_GetError());
@@ -108,6 +109,14 @@
}
/**
+ * \return the maximum height of glyphs of this font.
+ */
+uint32_t Font::size() const
+{
+ return m_size;
+}
+
+/**
* \return the maximum ascent from the font baseline
*/
uint32_t Font::ascent() const
=== modified file 'src/graphic/font.h'
--- src/graphic/font.h 2014-11-27 12:02:08 +0000
+++ src/graphic/font.h 2015-10-10 20:55:10 +0000
@@ -45,6 +45,7 @@
static void shutdown();
static Font * get(const std::string & name, int size);
+ uint32_t size() const;
uint32_t ascent() const;
uint32_t height() const;
uint32_t lineskip() const;
@@ -64,6 +65,8 @@
*/
int32_t m_computed_typical_miny;
int32_t m_computed_typical_maxy;
+
+ int m_size;
};
} // namespace UI
=== modified file 'src/logic/building.cc'
--- src/logic/building.cc 2015-02-05 11:26:01 +0000
+++ src/logic/building.cc 2015-10-10 20:55:10 +0000
@@ -30,7 +30,6 @@
#include "base/wexception.h"
#include "economy/flag.h"
#include "economy/request.h"
-#include "graphic/font_handler.h"
#include "graphic/font_handler1.h"
#include "graphic/graphic.h"
#include "graphic/rendertarget.h"
=== modified file 'src/logic/editor_game_base.cc'
--- src/logic/editor_game_base.cc 2015-02-09 05:57:08 +0000
+++ src/logic/editor_game_base.cc 2015-10-10 20:55:10 +0000
@@ -30,7 +30,6 @@
#include "economy/flag.h"
#include "economy/road.h"
#include "graphic/color.h"
-#include "graphic/font_handler.h"
#include "graphic/graphic.h"
#include "graphic/image_io.h"
#include "graphic/texture_atlas.h"
=== modified file 'src/ui_basic/checkbox.cc'
--- src/ui_basic/checkbox.cc 2014-11-08 14:59:03 +0000
+++ src/ui_basic/checkbox.cc 2015-10-10 20:55:10 +0000
@@ -19,8 +19,12 @@
#include "ui_basic/checkbox.h"
+#include "graphic/font_handler1.h"
#include "graphic/graphic.h"
#include "graphic/rendertarget.h"
+#include "graphic/text_layout.h"
+
+constexpr int kPadding = 4;
namespace UI {
/**
@@ -34,23 +38,43 @@
const Image* pic,
const std::string & tooltip_text)
:
- Panel (parent, p.x, p.y, STATEBOX_WIDTH, STATEBOX_HEIGHT, tooltip_text),
- m_flags(Is_Enabled)
-{
- if (pic) {
- uint16_t w = pic->width();
- uint16_t h = pic->height();
+ Panel (parent, p.x, p.y, kStateboxSize, kStateboxSize, tooltip_text),
+ m_flags(Is_Enabled),
+ rendered_text_(nullptr)
+{
+ uint16_t w = pic->width();
+ uint16_t h = pic->height();
+ set_desired_size(w, h);
+ set_size(w, h);
+
+ set_flags(Has_Custom_Picture, true);
+ m_pic_graphics = pic;
+}
+
+Statebox::Statebox
+ (Panel * const parent,
+ Point const p,
+ const std::string& label_text,
+ const std::string & tooltip_text,
+ uint32_t width)
+ :
+ Panel (parent, p.x, p.y, kStateboxSize, kStateboxSize, tooltip_text),
+ m_flags(Is_Enabled),
+ rendered_text_(
+ label_text.empty() ?
+ nullptr :
+ UI::g_fh1->render(as_uifont(label_text),
+ width > (kStateboxSize + kPadding) ? width - kStateboxSize - kPadding : 0))
+{
+ m_pic_graphics = g_gr->images().get("pics/checkbox_light.png");
+ if (rendered_text_) {
+ int w = rendered_text_->width() + kPadding + m_pic_graphics->width() / 2;
+ int h = std::max(rendered_text_->height(), m_pic_graphics->height());
set_desired_size(w, h);
set_size(w, h);
-
- set_flags(Has_Custom_Picture, true);
- m_pic_graphics = pic;
- } else
- m_pic_graphics =
- g_gr->images().get("pics/checkbox_light.png");
+ }
}
-
Statebox::~Statebox()
{
}
@@ -114,18 +138,30 @@
(Rect(Point(0, 0), get_w(), get_h()), RGBColor(100, 100, 80));
}
} else {
- static_assert(0 <= STATEBOX_WIDTH, "assert(0 <= STATEBOX_WIDTH) failed.");
- static_assert(0 <= STATEBOX_HEIGHT, "assert(0 <= STATEBOX_HEIGHT) failed.");
+ static_assert(0 <= kStateboxSize, "assert(0 <= STATEBOX_WIDTH) failed.");
+ static_assert(0 <= kStateboxSize, "assert(0 <= STATEBOX_HEIGHT) failed.");
+ Point image_anchor(0, 0);
+ Point text_anchor(kStateboxSize + kPadding, 0);
+
+ if (rendered_text_) {
+ if (UI::g_fh1->fontset().is_rtl()) {
+ text_anchor.x = 0;
+ image_anchor.x = rendered_text_->width() + kPadding;
+ image_anchor.y = (get_h() - kStateboxSize) / 2;
+ }
+ dst.blit(text_anchor, rendered_text_, BlendMode::UseAlpha, UI::Align::Align_Left);
+ }
+
dst.blitrect
- (Point(0, 0),
+ (image_anchor,
m_pic_graphics,
Rect
- (Point(m_flags & Is_Checked ? STATEBOX_WIDTH : 0, 0),
- STATEBOX_WIDTH, STATEBOX_HEIGHT));
+ (Point(m_flags & Is_Checked ? kStateboxSize : 0, 0),
+ kStateboxSize, kStateboxSize));
if (m_flags & Is_Highlighted)
dst.draw_rect
- (Rect(Point(0, 0), STATEBOX_WIDTH + 1, STATEBOX_HEIGHT + 1), RGBColor(100, 100, 80));
+ (Rect(image_anchor, kStateboxSize + 1, kStateboxSize + 1), RGBColor(100, 100, 80));
}
}
=== modified file 'src/ui_basic/checkbox.h'
--- src/ui_basic/checkbox.h 2014-07-14 10:45:44 +0000
+++ src/ui_basic/checkbox.h 2015-10-10 20:55:10 +0000
@@ -25,8 +25,7 @@
#include "graphic/color.h"
#include "ui_basic/panel.h"
-#define STATEBOX_WIDTH 20
-#define STATEBOX_HEIGHT 20
+constexpr int kStateboxSize = 20;
namespace UI {
@@ -35,11 +34,27 @@
* Serves as base for Checkbox and Radiobutton.
*/
struct Statebox : public Panel {
+
+ /**
+ * Pictorial Statebox
+ */
Statebox
(Panel * parent,
Point,
- const Image* pic = nullptr,
+ const Image* pic,
const std::string & tooltip_text = std::string());
+
+ /**
+ * Textual Statebox
+ * If width is set to 0, the checkbox will set its width automatically.
+ * Otherwise, it will take up multiple lines if necessary (automatic height).
+ */
+ Statebox
+ (Panel * parent,
+ Point,
+ const std::string& label_text,
+ const std::string & tooltip_text = std::string(),
+ uint32_t width = 0);
~Statebox();
boost::signals2::signal<void ()> changed;
@@ -81,6 +96,7 @@
m_flags |= flags;
}
const Image* m_pic_graphics;
+ const Image* rendered_text_;
};
@@ -91,14 +107,32 @@
* state
*/
struct Checkbox : public Statebox {
+
+ /**
+ * Pictorial Checkbox
+ */
Checkbox
(Panel * const parent,
Point const p,
- const Image* pic = nullptr,
- const std::string & tooltip_text = std::string())
+ const Image* pic,
+ const std::string & tooltip_text = std::string())
: Statebox(parent, p, pic, tooltip_text)
{}
+ /**
+ * Textual Checkbox
+ * If width is set to 0, the checkbox will set its width automatically.
+ * Otherwise, it will take up multiple lines if necessary (automatic height).
+ */
+ Checkbox
+ (Panel * const parent,
+ Point const p,
+ const std::string& label_text,
+ const std::string & tooltip_text = std::string(),
+ uint32_t width = 0)
+ : Statebox(parent, p, label_text, tooltip_text, width)
+ {}
+
private:
void clicked() override;
};
=== modified file 'src/ui_basic/helpwindow.cc'
--- src/ui_basic/helpwindow.cc 2015-10-02 07:02:00 +0000
+++ src/ui_basic/helpwindow.cc 2015-10-10 20:55:10 +0000
@@ -27,7 +27,6 @@
#include "base/i18n.h"
#include "base/log.h"
#include "graphic/font.h"
-#include "graphic/font_handler.h"
#include "graphic/font_handler1.h"
#include "graphic/graphic.h"
#include "graphic/text/font_set.h"
=== modified file 'src/ui_basic/icongrid.cc'
--- src/ui_basic/icongrid.cc 2015-09-09 18:49:58 +0000
+++ src/ui_basic/icongrid.cc 2015-10-10 20:55:10 +0000
@@ -19,11 +19,7 @@
#include "ui_basic/icongrid.h"
-#include "base/log.h"
-#include "graphic/font_handler.h"
-#include "graphic/rendertarget.h"
#include "ui_basic/button.h"
-#include "ui_basic/mouse_constants.h"
namespace UI {
=== modified file 'src/ui_basic/multilineeditbox.cc'
--- src/ui_basic/multilineeditbox.cc 2015-10-05 06:53:34 +0000
+++ src/ui_basic/multilineeditbox.cc 2015-10-10 20:55:10 +0000
@@ -22,7 +22,6 @@
#include <boost/bind.hpp>
#include "base/utf8.h"
-#include "graphic/font_handler.h"
#include "graphic/rendertarget.h"
#include "graphic/text_layout.h"
#include "graphic/wordwrap.h"
=== modified file 'src/ui_basic/progresswindow.cc'
--- src/ui_basic/progresswindow.cc 2014-12-11 10:27:30 +0000
+++ src/ui_basic/progresswindow.cc 2015-10-10 20:55:10 +0000
@@ -24,7 +24,6 @@
#endif
#include "base/i18n.h"
-#include "graphic/font_handler.h"
#include "graphic/font_handler1.h"
#include "graphic/graphic.h"
#include "graphic/rendertarget.h"
@@ -60,8 +59,8 @@
m_label_center.y = yres * PROGRESS_LABEL_POSITION_Y / 100;
Rect wnd_rect(Point(0, 0), xres, yres);
- const uint32_t h = g_fh->get_fontheight(UI::g_fh1->fontset().serif(),
- UI_FONT_SIZE_SMALL);
+ const uint32_t h = UI::g_fh1->render(as_uifont("."))->height();
+
m_label_rectangle.x = xres / 4;
m_label_rectangle.w = xres / 2;
m_label_rectangle.y =
@@ -103,10 +102,10 @@
draw_background(rt, xres, yres);
rt.fill_rect(m_label_rectangle, PROGRESS_FONT_COLOR_BG);
-
- UI::TextStyle ts(UI::TextStyle::ui_small());
- ts.fg = PROGRESS_FONT_COLOR_FG;
- UI::g_fh->draw_text(rt, ts, m_label_center, description, Align_Center);
+ rt.blit(m_label_center,
+ UI::g_fh1->render(as_uifont(description, UI_FONT_SIZE_SMALL, PROGRESS_FONT_COLOR_FG)),
+ BlendMode::UseAlpha,
+ Align_Center);
g_gr->update();
#ifdef _WIN32
=== modified file 'src/ui_basic/slider.cc'
--- src/ui_basic/slider.cc 2015-07-27 10:00:48 +0000
+++ src/ui_basic/slider.cc 2015-10-10 20:55:10 +0000
@@ -20,7 +20,7 @@
#include <cmath>
-#include "graphic/font_handler.h"
+#include "graphic/font_handler1.h"
#include "graphic/rendertarget.h"
#include "graphic/text_layout.h"
#include "ui_basic/mouse_constants.h"
@@ -567,7 +567,7 @@
// here, we take into account the h_gap introduced by HorizontalSlider
w / (2 * labels_in.size()) - cursor_size / 2, 0,
w - (w / labels_in.size()) + cursor_size,
- h - UI::TextStyle::ui_small().font->lineskip() - 2,
+ h - UI::g_fh1->render(as_uifont("."))->height() - 2,
0, labels_in.size() - 1, m_value,
background_picture_id,
tooltip_text,
@@ -588,16 +588,14 @@
{
Panel::draw(dst);
- UI::TextStyle ts = UI::TextStyle::ui_small();
-
uint32_t gap_1 = get_w() / (2 * labels.size());
uint32_t gap_n = get_w() / labels.size();
for (uint32_t i = 0; i < labels.size(); i++) {
- UI::g_fh->draw_text
- (dst, ts,
- Point(gap_1 + i * gap_n, get_h() + 2),
- labels[i], UI::Align_BottomCenter);
+ dst.blit(Point(gap_1 + i * gap_n, get_h() + 2),
+ UI::g_fh1->render(as_uifont(labels[i])),
+ BlendMode::UseAlpha,
+ Align_BottomCenter);
}
}
@@ -615,7 +613,7 @@
slider.set_pos(Point(w / (2 * labels.size()) - slider.m_cursor_size / 2, 0));
slider.set_size
(w - (w / labels.size()) + slider.m_cursor_size,
- h - UI::TextStyle::ui_small().font->lineskip() - 2);
+ h - UI::g_fh1->render(as_uifont("."))->height() - 2);
Panel::layout();
}
=== modified file 'src/ui_basic/spinbox.cc'
--- src/ui_basic/spinbox.cc 2015-07-29 08:05:50 +0000
+++ src/ui_basic/spinbox.cc 2015-10-10 20:55:10 +0000
@@ -55,131 +55,127 @@
/// Background tile style of buttons.
const Image* background;
- /// Alignment of the text. Vertical alignment is always centered.
- Align align;
-
/// Special names for specific Values
std::vector<IntValueTextReplacement> valrep;
/// The UI parts
Textarea * text;
- Button * butPlus;
- Button * butMinus;
- Button * butTenPlus;
- Button * butTenMinus;
+ Button * button_plus;
+ Button * button_minus;
+ Button * button_ten_plus;
+ Button * button_ten_minus;
};
/**
* SpinBox constructor:
*
* initializes a new spinbox with either two (big = false) or four (big = true)
- * buttons. w must be >= 20 else the spinbox would become useless and so
+ * buttons. w must be >= the normal textarea height, else the spinbox would become useless and so
* throws an exception.
+ * The spinbox' height is set automatically according to the height of its textarea.
*/
SpinBox::SpinBox
(Panel * const parent,
- const int32_t x, const int32_t y, const uint32_t w, const uint32_t h,
+ const int32_t x, const int32_t y, const uint32_t w,
int32_t const startval, int32_t const minval, int32_t const maxval,
- const std::string & unit,
+ const std::string& unit,
const Image* background,
- bool const big,
- Align const alignm)
+ bool const big)
:
- Panel(parent, x, y, w, h),
- m_big(big),
- sbi(new SpinBoxImpl)
+ Panel(parent, x, y, w, 1), // Height needs to be > 0, otherwise the panel won't resize.
+ big_(big),
+ sbi_(new SpinBoxImpl)
{
- sbi->value = startval;
- sbi->min = minval;
- sbi->max = maxval;
- sbi->unit = unit;
-
- sbi->background = background;
- sbi->align = alignm;
-
- if (w < 20)
- throw wexception("Not enough space to draw spinbox");
- int32_t butw = h;
- int32_t textw = w - butw * 32 / 5;
-
- int32_t but_plus_x;
- int32_t but_minus_x;
- int32_t text_x;
-
- if (m_big) {
- but_plus_x = w - butw * 31 / 10;
- but_minus_x = butw * 21 / 10;
-
+ sbi_->value = startval;
+ sbi_->min = minval;
+ sbi_->max = maxval;
+ sbi_->unit = unit;
+ sbi_->background = background;
+
+ uint32_t padding = 2;
+
+ uint32_t texth = UI::g_fh1->render(as_uifont("."))->height();
+ box_ = new UI::Box(this, 0, 0, UI::Box::Horizontal, w, texth, padding);
+
+#ifndef NDEBUG // only in debug builds
+ if (w < (big_ ? 7 * texth : 3 * texth)) {
+ throw wexception("Not enough space to draw spinbox. Width %d is smaller than required width %d",
+ w, (big_ ? 7 * texth : 3 * texth));
+ }
+#endif
+
+ sbi_->button_minus =
+ new Button
+ (box_, "-",
+ 0, 0, texth, texth,
+ sbi_->background,
+ g_gr->images().get(big_? "pics/scrollbar_left.png" : "pics/scrollbar_down.png"),
+ _("Decrease the value"));
+ sbi_->button_plus =
+ new Button
+ (box_, "+",
+ 0, 0, texth, texth,
+ sbi_->background,
+ g_gr->images().get(big_? "pics/scrollbar_right.png" : "pics/scrollbar_up.png"),
+ _("Increase the value"));
+
+ if (big_) {
+ sbi_->button_ten_minus =
+ new Button
+ (box_, "--",
+ 0, 0, 2 * texth, texth,
+ sbi_->background,
+ g_gr->images().get("pics/scrollbar_left_fast.png"),
+ _("Decrease the value by 10"));
+ sbi_->button_ten_plus =
+ new Button
+ (box_, "++",
+ 0, 0, 2 * texth, texth,
+ sbi_->background,
+ g_gr->images().get("pics/scrollbar_right_fast.png"),
+ _("Increase the value by 10"));
+
+ sbi_->button_ten_plus->sigclicked.connect(boost::bind(&SpinBox::change_value, boost::ref(*this), 10));
+ sbi_->button_ten_minus->sigclicked.connect(boost::bind(&SpinBox::change_value, boost::ref(*this), -10));
+ sbi_->button_ten_plus->set_repeating(true);
+ sbi_->button_ten_minus->set_repeating(true);
+ buttons_.push_back(sbi_->button_ten_minus);
+ buttons_.push_back(sbi_->button_ten_plus);
+
+ sbi_->text =
+ new UI::Textarea(
+ box_, 0, 0,
+ w - 2 * sbi_->button_ten_plus->get_w() - 2 * sbi_->button_minus->get_w() - 4 * padding, texth,
+ "", Align_Center);
+
+ box_->add(sbi_->button_ten_minus, UI::Box::AlignCenter);
+ box_->add(sbi_->button_minus, UI::Box::AlignCenter);
+ box_->add(sbi_->text, UI::Box::AlignCenter);
+ box_->add(sbi_->button_plus, UI::Box::AlignCenter);
+ box_->add(sbi_->button_ten_plus, UI::Box::AlignCenter);
} else {
- but_plus_x = w - butw;
- but_minus_x = 0;
- textw = textw + 4 * butw;
- }
- while (textw <= 0) {
- butw = butw * 3 / 4;
- textw = w - butw * 32 / 5;
- }
- text_x = (w - textw) / 2;
-
- std::string unit_text = std::to_string(sbi->value);
- if (! sbi->unit.empty()) {
- /** TRANSLATORS: %i = number, %s = unit, e.g. "5 pixels" in the advanced options */
- unit_text = (boost::format(_("%1$i %2$s")) % sbi->value % sbi->unit.c_str()).str();
- }
-
- sbi->text = new UI::Textarea
- (this, text_x, 0, textw, h, unit_text, Align_Center);
-
- sbi->butPlus =
- new Button
- (this, "+",
- but_plus_x, 0, butw, butw,
- sbi->background,
- "+", _("Increase the value"),
- true, false);
- sbi->butPlus->sigclicked.connect(boost::bind(&SpinBox::change_value, boost::ref(*this), 1));
- sbi->butMinus =
- new Button
- (this, "-",
- but_minus_x, 0, butw, butw,
- sbi->background,
- "-", _("Decrease the value"),
- true, false);
- sbi->butMinus->sigclicked.connect(boost::bind(&SpinBox::change_value, boost::ref(*this), -1));
- sbi->butPlus->set_repeating(true);
- sbi->butMinus->set_repeating(true);
- if (m_big) {
- sbi->butTenPlus =
- new Button
- (this, "++",
- w - 2 * butw, 0, butw * 2, butw,
- sbi->background,
- "++", _("Increase the value by 10"),
- true, false);
- sbi->butTenPlus->sigclicked.connect(boost::bind(&SpinBox::change_value, boost::ref(*this), 10));
- sbi->butTenMinus =
- new Button
- (this, "--",
- 0, 0, butw * 2, butw,
- sbi->background,
- "--", _("Decrease the value by 10"),
- true, false);
- sbi->butTenMinus->sigclicked.connect(boost::bind(&SpinBox::change_value, boost::ref(*this), -10));
- sbi->butTenPlus->set_repeating(true);
- sbi->butTenMinus->set_repeating(true);
- m_buttons.push_back(sbi->butTenMinus);
- m_buttons.push_back(sbi->butTenPlus);
- }
-
- m_buttons.push_back(sbi->butMinus);
- m_buttons.push_back(sbi->butPlus);
-
- set_font(UI::g_fh1->fontset().serif(), UI_FONT_SIZE_SMALL, UI_FONT_CLR_FG);
+ sbi_->text = new UI::Textarea(box_, 0, 0,
+ w - 2 * sbi_->button_minus->get_w() - 2 * padding, texth,
+ "", Align_Center);
+ box_->add(sbi_->button_minus, UI::Box::AlignCenter);
+ box_->add(sbi_->text, UI::Box::AlignCenter);
+ box_->add(sbi_->button_plus, UI::Box::AlignCenter);
+ }
+
+ sbi_->button_plus->sigclicked.connect(boost::bind(&SpinBox::change_value, boost::ref(*this), 1));
+ sbi_->button_minus->sigclicked.connect(boost::bind(&SpinBox::change_value, boost::ref(*this), -1));
+ sbi_->button_plus->set_repeating(true);
+ sbi_->button_minus->set_repeating(true);
+ buttons_.push_back(sbi_->button_minus);
+ buttons_.push_back(sbi_->button_plus);
+ box_->set_size(w, texth);
+ set_size(w, texth);
+ update();
}
SpinBox::~SpinBox() {
- delete sbi;
- sbi = nullptr;
+ delete sbi_;
+ sbi_ = nullptr;
}
@@ -189,22 +185,23 @@
void SpinBox::update()
{
bool was_in_list = false;
- for (const IntValueTextReplacement& value : sbi->valrep) {
- if (value.value == sbi->value) {
- sbi->text->set_text(value.text);
+ for (const IntValueTextReplacement& value : sbi_->valrep) {
+ if (value.value == sbi_->value) {
+ sbi_->text->set_text(value.text);
was_in_list = true;
break;
}
}
if (!was_in_list) {
- sbi->text->set_text((boost::format(_("%1$i %2$s")) % sbi->value % sbi->unit.c_str()).str());
+ /** TRANSLATORS: %i = number, %s = unit, e.g. "5 pixels" in the advanced options */
+ sbi_->text->set_text((boost::format(_("%1$i %2$s")) % sbi_->value % sbi_->unit.c_str()).str());
}
- sbi->butMinus->set_enabled(sbi->min < sbi->value);
- sbi->butPlus ->set_enabled (sbi->value < sbi->max);
- if (m_big) {
- sbi->butTenMinus->set_enabled(sbi->min < sbi->value);
- sbi->butTenPlus ->set_enabled (sbi->value < sbi->max);
+ sbi_->button_minus->set_enabled(sbi_->min < sbi_->value);
+ sbi_->button_plus ->set_enabled(sbi_->value < sbi_->max);
+ if (big_) {
+ sbi_->button_ten_minus->set_enabled(sbi_->min < sbi_->value);
+ sbi_->button_ten_plus ->set_enabled(sbi_->value < sbi_->max);
}
}
@@ -214,7 +211,7 @@
*/
void SpinBox::change_value(int32_t const value)
{
- set_value(value + sbi->value);
+ set_value(value + sbi_->value);
}
@@ -223,11 +220,11 @@
*/
void SpinBox::set_value(int32_t const value)
{
- sbi->value = value;
- if (sbi->value > sbi->max)
- sbi->value = sbi->max;
- else if (sbi->value < sbi->min)
- sbi->value = sbi->min;
+ sbi_->value = value;
+ if (sbi_->value > sbi_->max)
+ sbi_->value = sbi_->max;
+ else if (sbi_->value < sbi_->min)
+ sbi_->value = sbi_->min;
update();
}
@@ -237,12 +234,12 @@
*/
void SpinBox::set_interval(int32_t const min, int32_t const max)
{
- sbi->max = max;
- sbi->min = min;
- if (sbi->value > max)
- sbi->value = max;
- else if (sbi->value < min)
- sbi->value = min;
+ sbi_->max = max;
+ sbi_->min = min;
+ if (sbi_->value > max)
+ sbi_->value = max;
+ else if (sbi_->value < min)
+ sbi_->value = min;
update();
}
@@ -252,7 +249,7 @@
*/
void SpinBox::set_unit(const std::string & unit)
{
- sbi->unit = unit;
+ sbi_->unit = unit;
update();
}
@@ -262,7 +259,7 @@
*/
int32_t SpinBox::get_value()
{
- return sbi->value;
+ return sbi_->value;
}
/**
@@ -270,54 +267,7 @@
*/
std::string SpinBox::get_unit()
{
- return sbi->unit;
-}
-
-
-/**
- * \returns the text alignment
- */
-Align SpinBox::align() const
-{
- return sbi->align;
-}
-
-
-/**
- * Set a new alignment.
- */
-void SpinBox::set_align(Align alignm)
-{
- if (alignm != sbi->align) {
- sbi->align = alignm;
- update();
- }
-}
-
-
-/**
- * Sets the font of all UI elements
- *
- * @deprecated, see set_textstyle
- */
-void SpinBox::set_font(const std::string & name, int32_t size, RGBColor color)
-{
- set_textstyle(TextStyle::makebold(Font::get(name, size), color));
-}
-
-/**
- * Sets the font and textstyle of all UI elements
- */
-void SpinBox::set_textstyle(const TextStyle & textstyle)
-{
- sbi->text->set_textstyle(textstyle);
- sbi->butPlus->set_font(textstyle.font);
- sbi->butMinus->set_font(textstyle.font);
- if (m_big) {
- sbi->butTenPlus->set_font(textstyle.font);
- sbi->butTenMinus->set_font(textstyle.font);
- }
- update();
+ return sbi_->unit;
}
@@ -325,10 +275,10 @@
* Searches for value in sbi->valrep
* \returns the place where value was found or -1 if the value wasn't found.
*/
-int32_t SpinBox::find_replacement(int32_t value)
+int32_t SpinBox::find_replacement(int32_t value) const
{
- for (uint32_t i = 0; i < sbi->valrep.size(); ++i)
- if (sbi->valrep[i].value == value)
+ for (uint32_t i = 0; i < sbi_->valrep.size(); ++i)
+ if (sbi_->valrep[i].value == value)
return i;
return -1;
}
@@ -338,15 +288,15 @@
* Adds a replacement text for a specific value
* overwrites an old replacement if one exists.
*/
-void SpinBox::add_replacement(int32_t value, std::string text)
+void SpinBox::add_replacement(int32_t value, const std::string& text)
{
if (int32_t i = find_replacement(value) >= 0)
- sbi->valrep[i].text = text;
+ sbi_->valrep[i].text = text;
else {
IntValueTextReplacement newtr;
newtr.value = value;
newtr.text = text;
- sbi->valrep.push_back(newtr);
+ sbi_->valrep.push_back(newtr);
}
update();
}
@@ -358,14 +308,14 @@
void SpinBox::remove_replacement(int32_t value)
{
if (int32_t i = find_replacement(value) >= 0) {
- sbi->valrep[i].text = (boost::format(_("%1$i %2$s")) % value % sbi->unit.c_str()).str();
+ sbi_->valrep[i].text = (boost::format(_("%1$i %2$s")) % value % sbi_->unit.c_str()).str();
}
}
/**
* \returns true, if find_replacement returns an int >= 0
*/
-bool SpinBox::has_replacement(int32_t value)
+bool SpinBox::has_replacement(int32_t value) const
{
return find_replacement(value) >= 0;
}
=== modified file 'src/ui_basic/spinbox.h'
--- src/ui_basic/spinbox.h 2014-09-29 19:25:24 +0000
+++ src/ui_basic/spinbox.h 2015-10-10 20:55:10 +0000
@@ -24,6 +24,7 @@
#include <list>
#include "graphic/align.h"
+#include "ui_basic/box.h"
#include "ui_basic/button.h"
#include "graphic/graphic.h"
@@ -34,42 +35,36 @@
struct TextStyle;
/// A spinbox is an UI element for setting the integer value of a variable.
-struct SpinBox : public Panel {
+class SpinBox : public Panel {
+public:
SpinBox
- (Panel *,
- int32_t x, int32_t y, uint32_t w, uint32_t h,
+ (Panel*,
+ int32_t x, int32_t y, uint32_t w,
int32_t startval, int32_t minval, int32_t maxval,
- const std::string & unit = std::string(),
- const Image* buttonbackground =
- g_gr->images().get("pics/but2.png"),
- bool big = false,
- Align align = Align_Center);
+ const std::string& unit = std::string(),
+ const Image* buttonbackground = g_gr->images().get("pics/but3.png"),
+ bool big = false);
~SpinBox();
void set_value(int32_t);
void set_interval(int32_t min, int32_t max);
- void set_unit(const std::string &);
+ void set_unit(const std::string&);
int32_t get_value();
std::string get_unit();
- Align align() const;
- void set_align(Align);
- void set_font(const std::string &, int32_t, RGBColor);
- void set_textstyle(const TextStyle & style);
- void add_replacement(int32_t, std::string);
+ void add_replacement(int32_t, const std::string&);
void remove_replacement(int32_t);
- bool has_replacement(int32_t);
- const std::vector<UI::Button*> & get_buttons() {return m_buttons;}
+ bool has_replacement(int32_t) const;
+ const std::vector<UI::Button*>& get_buttons() {return buttons_;}
private:
void update();
void change_value(int32_t);
- int32_t find_replacement(int32_t value);
-
- const bool m_big;
-
- SpinBoxImpl * sbi;
-
- std::vector<UI::Button*> m_buttons;
+ int32_t find_replacement(int32_t value) const;
+
+ const bool big_;
+ SpinBoxImpl* sbi_;
+ std::vector<UI::Button*> buttons_;
+ UI::Box* box_;
};
}
=== modified file 'src/ui_basic/table.cc'
--- src/ui_basic/table.cc 2015-09-26 09:07:40 +0000
+++ src/ui_basic/table.cc 2015-10-10 20:55:10 +0000
@@ -22,7 +22,6 @@
#include <boost/bind.hpp>
#include "graphic/font.h"
-#include "graphic/font_handler.h"
#include "graphic/font_handler1.h"
#include "graphic/graphic.h"
#include "graphic/rendertarget.h"
@@ -50,10 +49,9 @@
:
Panel (parent, x, y, w, h),
m_total_width (0),
- m_fontname (UI::g_fh1->fontset().serif()),
m_fontsize (UI_FONT_SIZE_SMALL),
- m_headerheight (g_fh->get_fontheight(m_fontname, m_fontsize) + 4),
- m_lineheight (g_fh->get_fontheight(m_fontname, m_fontsize)),
+ m_headerheight (UI::g_fh1->render(as_uifont(".", m_fontsize))->height() + 4),
+ m_lineheight (UI::g_fh1->render(as_uifont(".", m_fontsize))->height()),
m_scrollbar (nullptr),
m_scrollpos (0),
m_selection (no_selection_index()),
@@ -108,7 +106,6 @@
title, tooltip_string, true, false);
c.btn->sigclicked.connect
(boost::bind(&Table::header_button_clicked, boost::ref(*this), m_columns.size()));
- c.btn->set_font(Font::get(m_fontname, m_fontsize));
}
c.width = width;
c.alignment = alignment;
@@ -135,9 +132,8 @@
false);
m_scrollbar->moved.connect(boost::bind(&Table::set_scrollpos, this, _1));
m_scrollbar->set_steps(1);
- uint32_t const lineheight = g_fh->get_fontheight(m_fontname, m_fontsize);
- m_scrollbar->set_singlestepsize(lineheight);
- m_scrollbar->set_pagesize(get_h() - lineheight);
+ m_scrollbar->set_singlestepsize(m_lineheight);
+ m_scrollbar->set_pagesize(get_h() - m_lineheight);
}
}
@@ -157,7 +153,6 @@
title, "", true, false);
column.btn->sigclicked.connect
(boost::bind(&Table::header_button_clicked, boost::ref(*this), col));
- column.btn->set_font(Font::get(m_fontname, m_fontsize));
} else if (title.empty()) { // had title before, not now
if (column.btn) {
delete column.btn;
@@ -480,10 +475,6 @@
Table<void *>::EntryRecord & Table<void *>::add
(void * const entry, const bool do_select)
{
- int32_t entry_height = g_fh->get_fontheight(m_fontname, m_fontsize);
- if (entry_height > m_lineheight)
- m_lineheight = entry_height;
-
EntryRecord & result = *new EntryRecord(entry);
m_entry_records.push_back(&result);
result.m_data.resize(m_columns.size());
=== modified file 'src/ui_basic/table.h'
--- src/ui_basic/table.h 2015-09-26 09:07:40 +0000
+++ src/ui_basic/table.h 2015-10-10 20:55:10 +0000
@@ -185,11 +185,6 @@
void set_sort_descending(bool const descending) {
m_sort_descending = descending;
}
- void set_font(const std::string & fontname, int32_t const fontsize) {
- m_fontname = fontname;
- m_fontsize = fontsize;
- m_headerheight = fontsize * 8 / 5;
- }
void sort
(uint32_t Begin = 0,
@@ -270,7 +265,6 @@
Columns m_columns;
uint32_t m_total_width;
- std::string m_fontname;
uint32_t m_fontsize;
uint32_t m_headerheight;
int32_t m_lineheight;
=== modified file 'src/ui_basic/textarea.cc'
--- src/ui_basic/textarea.cc 2014-11-27 12:02:08 +0000
+++ src/ui_basic/textarea.cc 2015-10-10 20:55:10 +0000
@@ -19,7 +19,8 @@
#include "ui_basic/textarea.h"
-#include "graphic/font_handler.h"
+#include "graphic/font_handler1.h"
+#include "graphic/rendertarget.h"
namespace UI {
@@ -141,14 +142,20 @@
*/
void Textarea::draw(RenderTarget & dst)
{
- if (m_text.length()) {
+ if (!m_text.empty()) {
Point anchor
- (m_align & Align_HCenter ?
- get_w() / 2 : m_align & Align_Right ? get_w() : 0,
- m_align & Align_VCenter ?
- get_h() / 2 : m_align & Align_Bottom ? get_h() : 0);
+ (m_align & Align_HCenter ?
+ get_w() / 2 : m_align & Align_Right ? get_w() : 0,
+ m_align & Align_VCenter ?
+ get_h() / 2 : m_align & Align_Bottom ? get_h() : 0);
- g_fh->draw_text(dst, m_textstyle, anchor, m_text, m_align);
+ dst.blit(anchor,
+ UI::g_fh1->render(
+ as_uifont(m_text,
+ m_textstyle.font->size() - UI::g_fh1->fontset().size_offset(),
+ m_textstyle.fg)),
+ BlendMode::UseAlpha,
+ m_align);
}
}
@@ -185,8 +192,19 @@
{
int32_t x = get_x();
int32_t y = get_y();
- uint32_t w = m_textstyle.calc_bare_width(m_text);
- uint16_t h = m_textstyle.font->height();
+ const Image* image = UI::g_fh1->render(
+ as_uifont(m_text,
+ m_textstyle.font->size() - UI::g_fh1->fontset().size_offset(),
+ m_textstyle.fg));
+ uint32_t w = image->width();
+ uint16_t h = image->height();
+ // We want empty textareas to have height
+ if (m_text.empty()) {
+ h = UI::g_fh1->render(
+ as_uifont(".",
+ m_textstyle.font->size() - UI::g_fh1->fontset().size_offset(),
+ m_textstyle.fg))->height();
+ }
if (m_align & Align_HCenter)
x -= w >> 1;
@@ -207,9 +225,19 @@
*/
void Textarea::update_desired_size()
{
- uint32_t w = m_textstyle.calc_bare_width(m_text);
- uint16_t h = m_textstyle.font->height();
-
+ const Image* image = UI::g_fh1->render(
+ as_uifont(m_text,
+ m_textstyle.font->size() - UI::g_fh1->fontset().size_offset(),
+ m_textstyle.fg));
+ uint32_t w = image->width();
+ uint16_t h = image->height();
+ // We want empty textareas to have height
+ if (m_text.empty()) {
+ h = UI::g_fh1->render(
+ as_uifont(".",
+ m_textstyle.font->size() - UI::g_fh1->fontset().size_offset(),
+ m_textstyle.fg))->height();
+ }
set_desired_size(w, h);
}
=== modified file 'src/ui_fsmenu/internet_lobby.cc'
--- src/ui_fsmenu/internet_lobby.cc 2015-09-04 06:16:58 +0000
+++ src/ui_fsmenu/internet_lobby.cc 2015-10-10 20:55:10 +0000
@@ -130,7 +130,6 @@
servername .set_font(m_fn, m_fs, UI_FONT_CLR_FG);
// prepare the lists
- clientsonline .set_font(m_fn, m_fs);
std::string t_tip = (boost::format("%s%s%s%s%s%s%s%s%s%s")
% "<rt><p><font underline=yes>"
% _("User Status")
=== modified file 'src/ui_fsmenu/internet_lobby.h'
--- src/ui_fsmenu/internet_lobby.h 2015-08-05 10:44:37 +0000
+++ src/ui_fsmenu/internet_lobby.h 2015-10-10 20:55:10 +0000
@@ -30,7 +30,6 @@
#include "ui_basic/button.h"
#include "ui_basic/editbox.h"
#include "ui_basic/listselect.h"
-#include "ui_basic/spinbox.h"
#include "ui_basic/table.h"
#include "ui_basic/textarea.h"
#include "wui/gamechatpanel.h"
=== modified file 'src/ui_fsmenu/launch_mpg.cc'
--- src/ui_fsmenu/launch_mpg.cc 2015-09-04 06:16:58 +0000
+++ src/ui_fsmenu/launch_mpg.cc 2015-10-10 20:55:10 +0000
@@ -201,8 +201,6 @@
(&FullscreenMenuLaunchMPG::help_clicked,
boost::ref(*this)));
- m_wincondition_type.set_textstyle(UI::TextStyle::ui_small());
-
m_lua = new LuaInterface();
win_condition_clicked();
=== modified file 'src/ui_fsmenu/launch_spg.cc'
--- src/ui_fsmenu/launch_spg.cc 2015-08-06 17:20:13 +0000
+++ src/ui_fsmenu/launch_spg.cc 2015-10-10 20:55:10 +0000
@@ -132,9 +132,7 @@
m_cur_wincondition = -1;
win_condition_clicked();
- m_title .set_textstyle(UI::TextStyle::ui_big());
- m_mapname.set_textstyle(UI::TextStyle::ui_small());
- m_wincondition_type.set_textstyle(UI::TextStyle::ui_small());
+ m_title.set_textstyle(UI::TextStyle::ui_big());
UI::TextStyle tsmaller
(UI::TextStyle::makebold
=== modified file 'src/ui_fsmenu/mapselect.cc'
--- src/ui_fsmenu/mapselect.cc 2015-10-05 06:53:34 +0000
+++ src/ui_fsmenu/mapselect.cc 2015-10-10 20:55:10 +0000
@@ -80,7 +80,7 @@
UI::Box::Horizontal, checkbox_space_, get_w());
// Must be initialized before tag checkboxes
- cb_dont_localize_mapnames_ = new UI::Checkbox(vbox, Point(0, 0));
+ cb_dont_localize_mapnames_ = new UI::Checkbox(vbox, Point(0, 0), _("Show original map names"));
cb_dont_localize_mapnames_->set_state(false);
cb_dont_localize_mapnames_->changedto.connect
(boost::bind(&FullscreenMenuMapSelect::fill_table, boost::ref(*this)));
@@ -90,12 +90,6 @@
cb_show_all_maps_->set_state(true);
vbox->add(cb_dont_localize_mapnames_, UI::Box::AlignLeft, true);
- UI::Textarea * ta_dont_localize_mapnames =
- /** TRANSLATORS: Checkbox title. If this checkbox is enabled, map names aren't translated. */
- new UI::Textarea(vbox, _("Show original map names"), UI::Align_CenterLeft);
- vbox->add_space(padding_);
- vbox->add(ta_dont_localize_mapnames, UI::Box::AlignLeft);
- vbox->add_space(checkbox_space_);
vbox->set_size(get_w() - 2 * tablex_, checkbox_space_);
vbox = new UI::Box(this,
@@ -131,7 +125,6 @@
// We don't need the unlocalizing option if there is nothing to unlocalize.
// We know this after the list is filled.
cb_dont_localize_mapnames_->set_visible(has_translated_mapname_);
- ta_dont_localize_mapnames->set_visible(has_translated_mapname_);
}
void FullscreenMenuMapSelect::think()
@@ -390,16 +383,12 @@
int32_t id = tags_ordered_.size();
tags_ordered_.push_back(tag);
- UI::Checkbox * cb = new UI::Checkbox(box, Point(0, 0));
+ UI::Checkbox * cb = new UI::Checkbox(box, Point(0, 0), displ_name);
cb->changedto.connect
(boost::bind(&FullscreenMenuMapSelect::_tagbox_changed, this, id, _1));
box->add(cb, UI::Box::AlignLeft, true);
- UI::Textarea * ta = new UI::Textarea(box, displ_name, UI::Align_CenterLeft);
- box->add_space(padding_);
- box->add(ta, UI::Box::AlignLeft);
box->add_space(checkbox_space_);
-
tags_checkboxes_.push_back(cb);
return cb;
=== modified file 'src/ui_fsmenu/netsetup_lan.cc'
--- src/ui_fsmenu/netsetup_lan.cc 2015-09-04 06:16:58 +0000
+++ src/ui_fsmenu/netsetup_lan.cc 2015-10-10 20:55:10 +0000
@@ -113,7 +113,6 @@
playername .changed.connect
(boost::bind(&FullscreenMenuNetSetupLAN::change_playername, this));
playername .set_font(ui_fn(), fs_small(), UI_FONT_CLR_FG);
- opengames .set_font(ui_fn(), fs_small());
opengames .add_column(m_lisw * 2 / 5, _("Host"));
opengames .add_column(m_lisw * 2 / 5, _("Map"));
opengames .add_column(m_lisw / 5, _("State"));
=== modified file 'src/ui_fsmenu/options.cc'
--- src/ui_fsmenu/options.cc 2015-09-28 06:41:58 +0000
+++ src/ui_fsmenu/options.cc 2015-10-10 20:55:10 +0000
@@ -144,38 +144,22 @@
m_fullscreen (this, Point(m_hmargin,
m_reslist.get_y() +
- m_reslist.get_h() + m_padding)),
- m_label_fullscreen
- (this,
- m_hmargin + m_fullscreen.get_w() + m_padding,
- m_reslist.get_y() + m_reslist.get_h() + m_padding,
- m_reslist.get_w() - m_fullscreen.get_w() - m_padding,
- m_fullscreen.get_h(),
- _("Fullscreen"), UI::Align_VCenter),
-
+ m_reslist.get_h() + m_padding),
+ _("Fullscreen")),
m_inputgrab (this, Point(m_hmargin,
- m_label_fullscreen.get_y() +
- m_label_fullscreen.get_h() + m_padding)),
- m_label_inputgrab
- (this,
- m_hmargin + m_inputgrab.get_w() + m_padding,
- m_label_fullscreen.get_y() + m_label_fullscreen.get_h() + m_padding,
- m_reslist.get_w() - m_inputgrab.get_w() - m_padding,
- m_inputgrab.get_h(),
- _("Grab Input"), UI::Align_VCenter),
-
+ m_fullscreen.get_y() +
+ m_fullscreen.get_h() + m_padding),
+ _("Grab Input")),
m_label_maxfps
(this,
m_hmargin,
- m_label_inputgrab.get_y() + m_label_inputgrab.get_h() + m_padding,
- m_reslist.get_w() - 80, m_inputgrab.get_h(),
+ m_inputgrab.get_y() + m_inputgrab.get_h() + m_padding,
+ m_reslist.get_w() - 105, m_inputgrab.get_h(),
_("Maximum FPS:"), UI::Align_VCenter),
m_sb_maxfps
(this,
- m_hmargin + m_reslist.get_w() - 80, m_label_maxfps.get_y(),
- 80, m_vbutw,
- opt.maxfps, 0, 99, "",
- g_gr->images().get("pics/but1.png")),
+ m_hmargin + m_reslist.get_w() - 105, m_label_maxfps.get_y(), 105,
+ opt.maxfps, 0, 99, ""),
// First options block 'general options', second column
@@ -192,23 +176,12 @@
m_music (this, Point(m_label_language.get_x(),
m_language_list.get_y() +
- m_language_list.get_h() + m_padding)),
- m_label_music
- (this,
- m_label_language.get_x() + m_music.get_w() + m_padding,
- m_language_list.get_y() + m_language_list.get_h() + m_padding,
- m_language_list.get_w(), m_music.get_h(),
- _("Enable Music"), UI::Align_VCenter),
-
+ m_language_list.get_h() + m_padding),
+ _("Enable Music")),
m_fx (this, Point(m_label_language.get_x(),
- m_label_music.get_y() +
- m_label_music.get_h() + m_padding)),
- m_label_fx
- (this,
- m_label_language.get_x() + m_fx.get_w() + m_padding,
- m_label_music.get_y() + m_label_music.get_h() + m_padding,
- m_language_list.get_w(), m_fx.get_h(),
- _("Enable Sound Effects"), UI::Align_VCenter),
+ m_music.get_y() +
+ m_music.get_h() + m_padding),
+ _("Enable Sound Effects")),
// Second options block 'In-game options'
// Title 2
@@ -217,67 +190,39 @@
get_w() / 2, get_h() / 2,
_("In-game Options"), UI::Align_HCenter),
- m_single_watchwin (this, Point(m_hmargin, m_offset_second_group)),
- m_label_single_watchwin
- (this,
- m_single_watchwin.get_x() + m_single_watchwin.get_w() + m_padding,
- m_offset_second_group,
- get_w() - 2 * m_hmargin - m_single_watchwin.get_w(), m_single_watchwin.get_h(),
- /** TRANSLATORS: A watchwindow is a window where you keep watching an object or a map region,*/
- /** TRANSLATORS: and it also lets you jump to it on the map. */
- _("Use single watchwindow mode"), UI::Align_VCenter),
+ /** TRANSLATORS: A watchwindow is a window where you keep watching an object or a map region,*/
+ /** TRANSLATORS: and it also lets you jump to it on the map. */
+ m_single_watchwin (this, Point(m_hmargin, m_offset_second_group), _("Use single watchwindow mode")),
m_auto_roadbuild_mode (this, Point(m_single_watchwin.get_x(),
- m_label_single_watchwin.get_y() +
- m_label_single_watchwin.get_h() + m_padding)),
- m_label_auto_roadbuild_mode
- (this,
- m_auto_roadbuild_mode.get_x() + m_auto_roadbuild_mode.get_w() + m_padding,
- m_label_single_watchwin.get_y() + m_label_single_watchwin.get_h() + m_padding,
- get_w() - 2 * m_hmargin - m_auto_roadbuild_mode.get_w(), m_auto_roadbuild_mode.get_h(),
- _("Start building road after placing a flag"), UI::Align_VCenter),
-
+ m_single_watchwin.get_y() +
+ m_single_watchwin.get_h() + m_padding),
+ _("Start building road after placing a flag")),
m_show_workarea_preview
(this, Point(m_auto_roadbuild_mode.get_x(),
- m_label_auto_roadbuild_mode.get_y() +
- m_label_auto_roadbuild_mode.get_h() + m_padding)),
- m_label_show_workarea_preview
- (this,
- m_show_workarea_preview.get_x() + m_show_workarea_preview.get_w() + m_padding,
- m_label_auto_roadbuild_mode.get_y() + m_label_auto_roadbuild_mode.get_h() + m_padding,
- get_w() - 2 * m_hmargin - m_show_workarea_preview.get_w(), m_show_workarea_preview.get_h(),
- _("Show buildings area preview"), UI::Align_VCenter),
+ m_auto_roadbuild_mode.get_y() +
+ m_auto_roadbuild_mode.get_h() + m_padding),
+ _("Show buildings area preview")),
m_snap_win_overlap_only
(this, Point(m_show_workarea_preview.get_x(),
- m_label_show_workarea_preview.get_y() +
- m_label_show_workarea_preview.get_h() + m_padding)),
- m_label_snap_win_overlap_only
- (this,
- m_snap_win_overlap_only.get_x() + m_snap_win_overlap_only.get_w() + m_padding,
- m_label_show_workarea_preview.get_y() + m_label_show_workarea_preview.get_h() + m_padding,
- get_w() - 2 * m_hmargin - m_snap_win_overlap_only.get_w(), m_snap_win_overlap_only.get_h(),
- _("Snap windows only when overlapping"), UI::Align_VCenter),
+ m_show_workarea_preview.get_y() +
+ m_show_workarea_preview.get_h() + m_padding),
+ _("Snap windows only when overlapping")),
m_dock_windows_to_edges (this, Point(m_snap_win_overlap_only.get_x(),
- m_label_snap_win_overlap_only.get_y() +
- m_label_snap_win_overlap_only.get_h() + m_padding)),
- m_label_dock_windows_to_edges
- (this,
- m_dock_windows_to_edges.get_x() + m_dock_windows_to_edges.get_w() + m_padding,
- m_label_snap_win_overlap_only.get_y() + m_label_snap_win_overlap_only.get_h() + m_padding,
- get_w() - 2 * m_hmargin - m_dock_windows_to_edges.get_w(), m_dock_windows_to_edges.get_h(),
- _("Dock windows to edges"), UI::Align_VCenter),
-
+ m_snap_win_overlap_only.get_y() +
+ m_snap_win_overlap_only.get_h() + m_padding),
+ _("Dock windows to edges")),
m_sb_autosave
(this,
get_w() - m_hmargin - 240,
m_dock_windows_to_edges.get_y() + m_dock_windows_to_edges.get_h() + m_padding,
- 240, m_vbutw,
+ 240,
/** TRANSLATORS: Options: Save game automatically every: */
/** TRANSLATORS: This will have a number added in front of it */
opt.autosave / 60, 0, 100, ngettext("minute", "minutes", opt.autosave / 60),
- g_gr->images().get("pics/but1.png"), true),
+ g_gr->images().get("pics/but3.png"), true),
m_label_autosave
(this,
m_dock_windows_to_edges.get_x(),
@@ -290,11 +235,11 @@
(this,
get_w() - m_hmargin - 240,
m_sb_autosave.get_y() + m_sb_autosave.get_h() + m_padding,
- 240, m_vbutw,
+ 240,
/** TRANSLATORS: Options: Remove Replays older than: */
/** TRANSLATORS: This will have a number added in front of it */
opt.remove_replays, 0, 365, ngettext("day", "days", opt.remove_replays),
- g_gr->images().get("pics/but1.png"), true),
+ g_gr->images().get("pics/but3.png"), true),
m_label_remove_replays
(this,
m_label_autosave.get_x(),
@@ -537,56 +482,38 @@
// Spinboxes
m_sb_dis_panel
(this,
- get_w() - m_hmargin - (get_w() / 5), m_label_snap_dis_panel.get_y(),
- get_w() / 5, m_vbutw,
- opt.panel_snap_distance, 0, 99, ngettext("pixel", "pixels", opt.panel_snap_distance),
- g_gr->images().get("pics/but1.png")),
+ get_w() - m_hmargin - (get_w() / 5), m_label_snap_dis_panel.get_y(), get_w() / 5,
+ opt.panel_snap_distance, 0, 99, ngettext("pixel", "pixels", opt.panel_snap_distance)),
m_sb_dis_border
(this,
- get_w() - m_hmargin - (get_w() / 5), m_label_snap_dis_border.get_y(),
- get_w() / 5, m_vbutw,
- opt.border_snap_distance, 0, 99, ngettext("pixel", "pixels", opt.border_snap_distance),
- g_gr->images().get("pics/but1.png")),
+ get_w() - m_hmargin - (get_w() / 5), m_label_snap_dis_border.get_y(), get_w() / 5,
+ opt.border_snap_distance, 0, 99, ngettext("pixel", "pixels", opt.border_snap_distance)),
m_transparent_chat (this, Point(m_hmargin,
m_label_snap_dis_border.get_y() +
- m_label_snap_dis_border.get_h() + m_space)),
- m_label_transparent_chat
- (this,
- m_hmargin + m_transparent_chat.get_w() + m_padding, m_transparent_chat.get_y(),
- get_w() - 2 * m_hmargin - m_transparent_chat.get_w() - m_padding, 40,
- _("Show in-game chat with transparent background"), UI::Align_VCenter),
+ m_label_snap_dis_border.get_h() + m_space),
+ _("Show in-game chat with transparent background"),
+ "", get_w() - 2 * m_hmargin),
m_message_sound
(this, Point(m_hmargin,
- m_label_transparent_chat.get_y() +
- m_label_transparent_chat.get_h() + m_padding)),
- m_label_message_sound
- (this,
- m_hmargin + m_message_sound.get_w() + m_padding, m_message_sound.get_y(),
- get_w() - 2 * m_hmargin - m_message_sound.get_w() - m_padding, 40,
+ m_transparent_chat.get_y() +
+ m_transparent_chat.get_h() + m_padding),
_("Play a sound at message arrival"),
- UI::Align_VCenter),
+ "", get_w() - 2 * m_hmargin),
m_nozip (this, Point(m_hmargin,
- m_label_message_sound.get_y() +
- m_label_message_sound.get_h() + m_padding)),
- m_label_nozip
- (this,
- m_hmargin + m_nozip.get_w() + m_padding, m_nozip.get_y(),
- get_w() - 2 * m_hmargin - m_nozip.get_w() - m_padding, 40,
- _("Do not zip widelands data files (maps, replays and savegames)"),
- UI::Align_VCenter),
+ m_message_sound.get_y() +
+ m_message_sound.get_h() + m_padding),
+ _("Do not zip widelands data files (maps, replays and savegames)"),
+ "", get_w() - 2 * m_hmargin),
m_remove_syncstreams (this, Point(m_hmargin,
- m_label_nozip.get_y() +
- m_label_nozip.get_h() + m_padding)),
- m_label_remove_syncstreams
- (this,
- m_hmargin + m_remove_syncstreams.get_w() + m_padding, m_remove_syncstreams.get_y(),
- get_w() - 2 * m_hmargin - m_remove_syncstreams.get_w() - m_padding, 40,
- _("Remove Syncstream dumps on startup"), UI::Align_VCenter),
+ m_nozip.get_y() +
+ m_nozip.get_h() + m_padding),
+ _("Remove Syncstream dumps on startup"),
+ "", get_w() - 2 * m_hmargin),
os(opt)
{
=== modified file 'src/ui_fsmenu/options.h'
--- src/ui_fsmenu/options.h 2015-08-05 10:44:37 +0000
+++ src/ui_fsmenu/options.h 2015-10-10 20:55:10 +0000
@@ -101,30 +101,21 @@
UI::Textarea m_label_resolution;
UI::Listselect<void *> m_reslist;
UI::Checkbox m_fullscreen;
- UI::Textarea m_label_fullscreen;
UI::Checkbox m_inputgrab;
- UI::Textarea m_label_inputgrab;
UI::Textarea m_label_maxfps;
UI::SpinBox m_sb_maxfps;
UI::Textarea m_label_language;
UI::Listselect<std::string> m_language_list;
UI::Checkbox m_music;
- UI::Textarea m_label_music;
UI::Checkbox m_fx;
- UI::Textarea m_label_fx;
UI::Textarea m_label_game_options;
UI::Checkbox m_single_watchwin;
- UI::Textarea m_label_single_watchwin;
UI::Checkbox m_auto_roadbuild_mode;
- UI::Textarea m_label_auto_roadbuild_mode;
UI::Checkbox m_show_workarea_preview;
- UI::Textarea m_label_show_workarea_preview;
UI::Checkbox m_snap_win_overlap_only;
- UI::Textarea m_label_snap_win_overlap_only;
UI::Checkbox m_dock_windows_to_edges;
- UI::Textarea m_label_dock_windows_to_edges;
UI::SpinBox m_sb_autosave;
UI::Textarea m_label_autosave;
UI::SpinBox m_sb_remove_replays;
@@ -176,13 +167,9 @@
UI::Textarea m_label_snap_dis_panel, m_label_snap_dis_border;
UI::SpinBox m_sb_dis_panel, m_sb_dis_border;
UI::Checkbox m_transparent_chat;
- UI::MultilineTextarea m_label_transparent_chat;
UI::Checkbox m_message_sound;
- UI::MultilineTextarea m_label_message_sound;
UI::Checkbox m_nozip;
- UI::MultilineTextarea m_label_nozip;
UI::Checkbox m_remove_syncstreams;
- UI::MultilineTextarea m_label_remove_syncstreams;
OptionsCtrl::OptionsStruct os;
};
=== modified file 'src/wui/game_options_sound_menu.cc'
--- src/wui/game_options_sound_menu.cc 2015-08-02 10:12:49 +0000
+++ src/wui/game_options_sound_menu.cc 2015-10-10 20:55:10 +0000
@@ -27,25 +27,16 @@
:
UI::UniqueWindow
(&gb, "sound_options_menu", ®istry, 160, 160, _("Sound Options")),
-ingame_music(this, Point(hmargin(), vmargin())),
-ingame_music_label
- (this,
- hmargin() + STATEBOX_WIDTH + hspacing(), vmargin(),
- _("Enable Music")),
-ingame_sound(this, Point(hmargin(), vmargin() + STATEBOX_HEIGHT + vspacing())),
-ingame_sound_label
- (this,
- hmargin() + STATEBOX_WIDTH + hspacing(),
- vmargin() + STATEBOX_HEIGHT + vspacing(),
- _("Enable Sound Effects")),
+ingame_music(this, Point(hmargin(), vmargin()), _("Enable Music")),
+ingame_sound(this, Point(hmargin(), vmargin() + kStateboxSize + vspacing()), _("Enable Sound Effects")),
ingame_music_volume_label
(this,
- hmargin(), vmargin() + 2 * (STATEBOX_HEIGHT + vspacing()) + vbigspacing(),
+ hmargin(), vmargin() + 2 * (kStateboxSize + vspacing()) + vbigspacing(),
_("Music Volume")),
ingame_music_volume
(this,
hmargin(),
- vmargin() + 2 * (STATEBOX_HEIGHT + vspacing()) + vbigspacing()
+ vmargin() + 2 * (kStateboxSize + vspacing()) + vbigspacing()
+ 1 * vspacing() + ingame_music_volume_label.get_h(),
get_inner_w() - 2 * hmargin(), slideh(),
0, g_sound_handler.get_max_volume(), g_sound_handler.get_music_volume(),
@@ -53,13 +44,13 @@
ingame_sound_volume_label
(this,
hmargin(),
- vmargin() + 2 * (STATEBOX_HEIGHT + vspacing()) + vbigspacing()
+ vmargin() + 2 * (kStateboxSize + vspacing()) + vbigspacing()
+ 2 * vspacing() + slideh() + ingame_music_volume_label.get_h(),
_("Sound Effects Volume")),
ingame_sound_volume
(this,
hmargin(),
- vmargin() + 2 * (STATEBOX_HEIGHT + vspacing()) + vbigspacing()
+ vmargin() + 2 * (kStateboxSize + vspacing()) + vbigspacing()
+ 3 * vspacing() + slideh()
+ ingame_music_volume_label.get_h() + ingame_music_volume_label.get_h(),
get_inner_w() - 2 * hmargin(), slideh(),
@@ -92,8 +83,8 @@
(boost::bind(&GameOptionsSoundMenu::sound_volume_changed, this, _1));
uint32_t boxes_width =
- STATEBOX_WIDTH + hspacing() +
- std::max(ingame_music_label.get_w(), ingame_sound_label.get_w());
+ kStateboxSize + hspacing() +
+ std::max(ingame_music.get_w(), ingame_sound.get_w());
uint32_t labels_width = std::max
(ingame_music_volume_label.get_w(), ingame_sound_volume_label.get_w());
@@ -101,7 +92,7 @@
(std::max
(static_cast<uint32_t>(get_inner_w()),
2 * hmargin() + std::max(boxes_width, labels_width)),
- 2 * vmargin() + 2 * (STATEBOX_HEIGHT + vspacing())
+ 2 * vmargin() + 2 * (kStateboxSize + vspacing())
+ vbigspacing() + 3 * vspacing() + 2 * slideh()
+ ingame_music_volume_label.get_h() + ingame_music_volume_label.get_h());
=== modified file 'src/wui/game_options_sound_menu.h'
--- src/wui/game_options_sound_menu.h 2014-09-10 08:55:04 +0000
+++ src/wui/game_options_sound_menu.h 2015-10-10 20:55:10 +0000
@@ -33,9 +33,7 @@
private:
UI::Checkbox ingame_music;
- UI::Textarea ingame_music_label;
UI::Checkbox ingame_sound;
- UI::Textarea ingame_sound_label;
UI::Textarea ingame_music_volume_label;
UI::HorizontalSlider ingame_music_volume;
=== modified file 'src/wui/interactive_player.cc'
--- src/wui/interactive_player.cc 2015-05-14 09:39:23 +0000
+++ src/wui/interactive_player.cc 2015-10-10 20:55:10 +0000
@@ -30,7 +30,6 @@
#include "base/macros.h"
#include "economy/flag.h"
#include "game_io/game_loader.h"
-#include "graphic/font_handler.h"
#include "logic/building.h"
#include "logic/cmd_queue.h"
#include "logic/constants.h"
=== modified file 'src/wui/login_box.cc'
--- src/wui/login_box.cc 2015-10-02 07:02:00 +0000
+++ src/wui/login_box.cc 2015-10-10 20:55:10 +0000
@@ -50,14 +50,13 @@
_("WARNING: Password will be shown and saved readable!"),
UI::Align_Left);
- cb_register = new UI::Checkbox(this, Point(margin, 110));
- ta_register =
- new UI::Textarea(this, 40, 110, _("Log in to a registered account"));
+ cb_register = new UI::Checkbox(this, Point(margin, 110),
+ _("Log in to a registered account"),
+ "", get_inner_w() - 2 * margin);
- cb_auto_log = new UI::Checkbox(this, Point(margin, 135));
- ta_auto_log = new UI::MultilineTextarea
- (this, 40, 135, get_inner_w() - cb_auto_log->get_w() - margin, 35,
- _("Automatically use this login information from now on."));
+ cb_auto_log = new UI::Checkbox(this, Point(margin, 135),
+ _("Automatically use this login information from now on."),
+ "", get_inner_w() - 2 * margin);
UI::Button * loginbtn = new UI::Button
(this, "login",
=== modified file 'src/wui/login_box.h'
--- src/wui/login_box.h 2015-08-05 14:50:23 +0000
+++ src/wui/login_box.h 2015-10-10 20:55:10 +0000
@@ -47,8 +47,6 @@
UI::Checkbox * cb_auto_log;
UI::Textarea * ta_nickname;
UI::Textarea * ta_password;
- UI::Textarea * ta_register;
- UI::MultilineTextarea * ta_auto_log;
UI::MultilineTextarea * pwd_warning;
};
=== modified file 'src/wui/playerdescrgroup.cc'
--- src/wui/playerdescrgroup.cc 2015-02-28 16:02:49 +0000
+++ src/wui/playerdescrgroup.cc 2015-10-10 20:55:10 +0000
@@ -65,8 +65,7 @@
int32_t xplayertribe = w * 80 / 125;
int32_t xplayerinit = w * 55 / 125;
d->plr_name = new UI::Textarea(this, xplrname, 0, xplayertype - xplrname, h);
- d->plr_name->set_textstyle(UI::TextStyle::ui_small());
- d->btnEnablePlayer = new UI::Checkbox(this, Point(xplayertype - 23, 0));
+ d->btnEnablePlayer = new UI::Checkbox(this, Point(xplayertype - 23, 0), "");
d->btnEnablePlayer->changedto.connect
(boost::bind(&PlayerDescriptionGroup::enable_player, this, _1));
d->btnPlayerType = new UI::Button
=== modified file 'src/wui/soldierlist.cc'
--- src/wui/soldierlist.cc 2015-09-26 09:07:40 +0000
+++ src/wui/soldierlist.cc 2015-10-10 20:55:10 +0000
@@ -23,6 +23,7 @@
#include <boost/format.hpp>
#include "base/macros.h"
+#include "graphic/font_handler1.h"
#include "graphic/graphic.h"
#include "graphic/rendertarget.h"
#include "logic/building.h"
@@ -398,18 +399,17 @@
m_soldierpanel.set_mouseover(boost::bind(&SoldierList::mouseover, this, _1));
m_soldierpanel.set_click(boost::bind(&SoldierList::eject, this, _1));
- const UI::TextStyle & style = UI::TextStyle::ui_small();
// We don't want translators to translate this twice, so it's a bit involved.
- uint32_t maxtextwidth = std::max
- (style.calc_bare_width(_("Click soldier to send away")),
- style.calc_bare_width(
- (boost::format("%s ") // We need some extra space to fix bug 724169
- /** TRANSLATORS: Health, Attack, Defense, Evade */
- % (boost::format(_("HP: %1$u/%2$u AT: %3$u/%4$u DE: %5$u/%6$u EV: %7$u/%8$u"))
- % 8 % 8
- % 8 % 8
- % 8 % 8
- % 8 % 8)).str()));
+ int w = UI::g_fh1->render(
+ as_uifont((boost::format("%s ") // We need some extra space to fix bug 724169
+ /** TRANSLATORS: Health, Attack, Defense, Evade */
+ % (boost::format(_("HP: %1$u/%2$u AT: %3$u/%4$u DE: %5$u/%6$u EV: %7$u/%8$u"))
+ % 8 % 8
+ % 8 % 8
+ % 8 % 8
+ % 8 % 8)).str()))->width();
+ uint32_t maxtextwidth = std::max(w,
+ UI::g_fh1->render(as_uifont(_("Click soldier to send away")))->width());
set_min_desired_breadth(maxtextwidth + 4);
UI::Box * buttons = new UI::Box(this, 0, 0, UI::Box::Horizontal);
=== modified file 'src/wui/transport_ui.cc'
--- src/wui/transport_ui.cc 2014-11-30 18:49:38 +0000
+++ src/wui/transport_ui.cc 2015-10-10 20:55:10 +0000
@@ -18,7 +18,6 @@
*/
#include "economy/economy.h"
-#include "graphic/font_handler.h"
#include "graphic/graphic.h"
#include "graphic/rendertarget.h"
#include "logic/player.h"
=== modified file 'src/wui/waresdisplay.cc'
--- src/wui/waresdisplay.cc 2015-01-11 22:27:33 +0000
+++ src/wui/waresdisplay.cc 2015-10-10 20:55:10 +0000
@@ -25,7 +25,6 @@
#include "base/i18n.h"
#include "base/wexception.h"
-#include "graphic/font_handler.h"
#include "graphic/font_handler1.h"
#include "graphic/graphic.h"
#include "graphic/rendertarget.h"
Follow ups