Merge lp:~widelands-dev/widelands/buttons into lp:widelands

Proposed by GunChleoc
Status: Merged
Merged at revision: 7565
Proposed branch: lp:~widelands-dev/widelands/buttons
Merge into: lp:widelands
Diff against target: 241 lines (+12/-64)
7 files modified
src/ui_basic/button.cc (+11/-17)
src/ui_basic/button.h (+0/-5)
src/ui_basic/helpwindow.cc (+0/-3)
src/ui_basic/spinbox.cc (+0/-28)
src/ui_basic/spinbox.h (+0/-2)
src/ui_basic/table.cc (+0/-2)
src/wui/multiplayersetupgroup.cc (+1/-7)
To merge this branch: bzr merge lp:~widelands-dev/widelands/buttons
Reviewer Review Type Date Requested Status
TiborB Approve
Review via email: mp+274064@code.launchpad.net

Description of the change

Buttons now use the new font renderer and have uniform font size and style (the style was uniform in practice, but there was some code to set it individually that I got rid of).

Deleted draw_caret in Button class because it is unused.

To post a comment you must log in.
Revision history for this message
TiborB (tiborb95) wrote :

I think this can go as well. I tested this but could not see any difference :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ui_basic/button.cc'
2--- src/ui_basic/button.cc 2015-09-26 09:07:40 +0000
3+++ src/ui_basic/button.cc 2015-10-19 10:46:00 +0000
4@@ -20,7 +20,7 @@
5 #include "ui_basic/button.h"
6
7 #include "base/log.h"
8-#include "graphic/font_handler.h"
9+#include "graphic/font_handler1.h"
10 #include "graphic/image.h"
11 #include "graphic/rendertarget.h"
12 #include "graphic/text_constants.h"
13@@ -54,14 +54,11 @@
14 m_title (title_text),
15 m_pic_background(bg_pic),
16 m_pic_custom (nullptr),
17- m_textstyle(UI::TextStyle::ui_small()),
18- m_clr_down (229, 161, 2),
19- m_draw_caret (false)
20+ m_clr_down (229, 161, 2)
21 {
22 // Automatically resize for font height and give it a margin.
23 if (h < 1) {
24- int new_height = m_textstyle.font->height() + 4;
25- set_desired_size(w, new_height);
26+ set_desired_size(w, UI::g_fh1->render(as_uifont("."))->height() + 4);
27 }
28 set_thinks(false);
29 }
30@@ -87,9 +84,7 @@
31 m_time_nextact (0),
32 m_pic_background(bg_pic),
33 m_pic_custom (fg_pic),
34- m_textstyle(UI::TextStyle::ui_small()),
35- m_clr_down (229, 161, 2),
36- m_draw_caret (false)
37+ m_clr_down (229, 161, 2)
38 {
39 set_thinks(false);
40 }
41@@ -219,14 +214,13 @@
42 }
43
44 } else if (m_title.length()) {
45- // otherwise draw title string centered
46-
47- m_textstyle.fg = m_enabled ? UI_FONT_CLR_FG : UI_FONT_CLR_DISABLED;
48-
49- UI::g_fh->draw_text
50- (dst, m_textstyle, Point(get_w() / 2, get_h() / 2),
51- m_title, Align_Center,
52- m_draw_caret ? m_title.length() : std::numeric_limits<uint32_t>::max());
53+ // Otherwise draw title string centered
54+ const Image* entry_text_im = UI::g_fh1->render(
55+ as_uifont(m_title,
56+ UI_FONT_SIZE_SMALL,
57+ m_enabled ? UI_FONT_CLR_FG : UI_FONT_CLR_DISABLED));
58+ dst.blit(Point((get_w() - entry_text_im->width()) / 2, (get_h() - entry_text_im->height()) / 2),
59+ entry_text_im);
60 }
61
62 // draw border
63
64=== modified file 'src/ui_basic/button.h'
65--- src/ui_basic/button.h 2015-09-11 07:19:29 +0000
66+++ src/ui_basic/button.h 2015-10-19 10:46:00 +0000
67@@ -65,9 +65,6 @@
68 bool enabled() const {return m_enabled;}
69 void set_enabled(bool on);
70 void set_repeating(bool const on) {m_repeating = on;}
71- void set_draw_caret(bool draw_caret) {m_draw_caret = draw_caret;}
72- void set_font(Font * font) {m_textstyle.font = font;}
73- void set_textstyle(const UI::TextStyle& textstyle) {m_textstyle = textstyle;}
74 bool is_snap_target() const override {return true;}
75
76 // Drawing and event handlers
77@@ -110,10 +107,8 @@
78
79 const Image* m_pic_background; // background texture (picture ID)
80 const Image* m_pic_custom; // custom icon on the button
81- UI::TextStyle m_textstyle;
82
83 RGBColor m_clr_down; // color of border while a flat button is "down"
84- bool m_draw_caret;
85 };
86
87 } // namespace UI
88
89=== modified file 'src/ui_basic/helpwindow.cc'
90--- src/ui_basic/helpwindow.cc 2015-10-02 07:02:00 +0000
91+++ src/ui_basic/helpwindow.cc 2015-10-19 10:46:00 +0000
92@@ -85,9 +85,6 @@
93 g_gr->images().get("pics/but5.png"),
94 _("OK"), std::string(), true, false);
95 btn->sigclicked.connect(boost::bind(&HelpWindow::clicked_ok, boost::ref(*this)));
96- btn->set_font(Font::get((UI::g_fh1->fontset()).serif(),
97- (fontsize < 12 ? 12 : fontsize)));
98-
99 textarea->set_size(in_width - 10, in_height - 10 - (2 * but_height));
100 focus();
101 }
102
103=== modified file 'src/ui_basic/spinbox.cc'
104--- src/ui_basic/spinbox.cc 2015-07-29 08:05:50 +0000
105+++ src/ui_basic/spinbox.cc 2015-10-19 10:46:00 +0000
106@@ -173,8 +173,6 @@
107
108 m_buttons.push_back(sbi->butMinus);
109 m_buttons.push_back(sbi->butPlus);
110-
111- set_font(UI::g_fh1->fontset().serif(), UI_FONT_SIZE_SMALL, UI_FONT_CLR_FG);
112 }
113
114 SpinBox::~SpinBox() {
115@@ -296,32 +294,6 @@
116
117
118 /**
119- * Sets the font of all UI elements
120- *
121- * @deprecated, see set_textstyle
122- */
123-void SpinBox::set_font(const std::string & name, int32_t size, RGBColor color)
124-{
125- set_textstyle(TextStyle::makebold(Font::get(name, size), color));
126-}
127-
128-/**
129- * Sets the font and textstyle of all UI elements
130- */
131-void SpinBox::set_textstyle(const TextStyle & textstyle)
132-{
133- sbi->text->set_textstyle(textstyle);
134- sbi->butPlus->set_font(textstyle.font);
135- sbi->butMinus->set_font(textstyle.font);
136- if (m_big) {
137- sbi->butTenPlus->set_font(textstyle.font);
138- sbi->butTenMinus->set_font(textstyle.font);
139- }
140- update();
141-}
142-
143-
144-/**
145 * Searches for value in sbi->valrep
146 * \returns the place where value was found or -1 if the value wasn't found.
147 */
148
149=== modified file 'src/ui_basic/spinbox.h'
150--- src/ui_basic/spinbox.h 2014-09-29 19:25:24 +0000
151+++ src/ui_basic/spinbox.h 2015-10-19 10:46:00 +0000
152@@ -53,8 +53,6 @@
153 std::string get_unit();
154 Align align() const;
155 void set_align(Align);
156- void set_font(const std::string &, int32_t, RGBColor);
157- void set_textstyle(const TextStyle & style);
158 void add_replacement(int32_t, std::string);
159 void remove_replacement(int32_t);
160 bool has_replacement(int32_t);
161
162=== modified file 'src/ui_basic/table.cc'
163--- src/ui_basic/table.cc 2015-09-26 09:07:40 +0000
164+++ src/ui_basic/table.cc 2015-10-19 10:46:00 +0000
165@@ -108,7 +108,6 @@
166 title, tooltip_string, true, false);
167 c.btn->sigclicked.connect
168 (boost::bind(&Table::header_button_clicked, boost::ref(*this), m_columns.size()));
169- c.btn->set_font(Font::get(m_fontname, m_fontsize));
170 }
171 c.width = width;
172 c.alignment = alignment;
173@@ -157,7 +156,6 @@
174 title, "", true, false);
175 column.btn->sigclicked.connect
176 (boost::bind(&Table::header_button_clicked, boost::ref(*this), col));
177- column.btn->set_font(Font::get(m_fontname, m_fontsize));
178 } else if (title.empty()) { // had title before, not now
179 if (column.btn) {
180 delete column.btn;
181
182=== modified file 'src/wui/multiplayersetupgroup.cc'
183--- src/wui/multiplayersetupgroup.cc 2015-09-04 06:16:58 +0000
184+++ src/wui/multiplayersetupgroup.cc 2015-10-19 10:46:00 +0000
185@@ -69,7 +69,6 @@
186 type->sigclicked.connect
187 (boost::bind
188 (&MultiPlayerClientGroup::toggle_type, boost::ref(*this)));
189- type->set_font(font);
190 add(type, UI::Box::AlignCenter);
191 } else { // just a shown client
192 type_icon = new UI::Icon
193@@ -156,7 +155,6 @@
194 int32_t const /* x */, int32_t const /* y */, int32_t const w, int32_t const h,
195 GameSettingsProvider * const settings,
196 NetworkPlayerSettingsBackend * const npsb,
197- UI::Font * font,
198 std::map<std::string, const Image* > & tp,
199 std::map<std::string, std::string> & tn)
200 :
201@@ -186,7 +184,6 @@
202 type->sigclicked.connect
203 (boost::bind
204 (&MultiPlayerPlayerGroup::toggle_type, boost::ref(*this)));
205- type->set_font(font);
206 add(type, UI::Box::AlignCenter);
207 tribe = new UI::Button
208 (this, "player_tribe",
209@@ -196,7 +193,6 @@
210 tribe->sigclicked.connect
211 (boost::bind
212 (&MultiPlayerPlayerGroup::toggle_tribe, boost::ref(*this)));
213- tribe->set_font(font);
214 add(tribe, UI::Box::AlignCenter);
215 tribe->set_draw_flat_background(true);
216 init = new UI::Button
217@@ -207,7 +203,6 @@
218 init->sigclicked.connect
219 (boost::bind
220 (&MultiPlayerPlayerGroup::toggle_init, boost::ref(*this)));
221- init->set_font(font);
222 add(init, UI::Box::AlignCenter);
223 team = new UI::Button
224 (this, "player_team",
225@@ -217,7 +212,6 @@
226 team->sigclicked.connect
227 (boost::bind
228 (&MultiPlayerPlayerGroup::toggle_team, boost::ref(*this)));
229- team->set_font(font);
230 add(team, UI::Box::AlignCenter);
231 }
232
233@@ -466,7 +460,7 @@
234 multi_player_player_groups.at(i) = new MultiPlayerPlayerGroup
235 (&playerbox, i,
236 0, 0, playerbox.get_w(), buth,
237- s, npsb.get(), UI::Font::get(fname, fsize),
238+ s, npsb.get(),
239 m_tribepics, m_tribenames);
240 playerbox.add(multi_player_player_groups.at(i), 1);
241 }

Subscribers

People subscribed via source and target branches

to status/vote changes: