Merge lp:~widelands-dev/widelands/multiline_textarea into lp:widelands
- multiline_textarea
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | 7745 | ||||
Proposed branch: | lp:~widelands-dev/widelands/multiline_textarea | ||||
Merge into: | lp:widelands | ||||
Diff against target: |
521 lines (+94/-126) 12 files modified
src/graphic/text/rt_render.cc (+4/-4) src/graphic/text_constants.h (+0/-4) src/graphic/text_layout.cc (+15/-3) src/graphic/text_layout.h (+4/-0) src/graphic/wordwrap.cc (+7/-12) src/graphic/wordwrap.h (+1/-8) src/ui_basic/messagebox.cc (+3/-2) src/ui_basic/multilineeditbox.cc (+1/-1) src/ui_basic/multilinetextarea.cc (+46/-65) src/ui_basic/multilinetextarea.h (+11/-19) src/ui_fsmenu/fileview.cc (+0/-4) src/ui_fsmenu/launch_mpg.cc (+2/-4) |
||||
To merge this branch: | bzr merge lp:~widelands-dev/widelands/multiline_textarea | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
SirVer | Approve | ||
Review via email: mp+283736@code.launchpad.net |
Commit message
MultilineTextarea now uses the new font renderer directly instead of WordWrap.
Description of the change
MultilineTextarea now uses the new font renderer directly instead of WordWrap.
Removed the Impl pattern, but we still need to use Richtext, because the new font handler still has some bugs with richtext strings.
This also fixes the remaining superfluous scrollbar button with Gaelic Spinboxes in the Options window.
bunnybot (widelandsofficial) wrote : | # |
kaputtnik (franku) wrote : | # |
Don't know if this is related to richtext, but some fonts are displayed bigger than other fonts. In result the scrollbar button is shown when the font size is bigger. This applies to most RTL languages.
There are several failures in console like:
No corresponding locale found - trying to set it via LANGUAGE=si, LANG=si
Font set 'défaut' for locale 'fr' does not exist; using default instead.
Font set 'défaut' for locale 'fr' does not exist; using default instead.
Don't know Language "si" locale "fr" but with this settings most strings are empty (f.e. no button labels anymore).
I am wondering also about the spelling of the word 'défaut'... the circumflex on the e and missing 'l'. I think this should be 'default' instead of 'défaut'?
bunnybot (widelandsofficial) wrote : | # |
Continuous integration builds have changed state:
Travis build 371. State: passed. Details: https:/
Appveyor build 278. State: success. Details: https:/
GunChleoc (gunchleoc) wrote : | # |
"défaut" is a screwup by a French translator and I have already fixed it on Transifex.
I know that the scrollbar shows up when the font size is bigger sometimes, this is expected behaviour and not related to this branch. All the screens that show this need to be switched over to Box layout. This will mean a lot of code, so I am planning to fix this up for build 20. We need the bigger font size though, because some fonts show up so small that they are unreadable.
wl-zocker (wl-zocker) wrote : | # |
Does this "default" has to be translatable at all? I had also translated it to German (it's fixed).
TiborB (tiborb95) wrote : | # |
Is this supposed to fix the bug-1532279 - because it is linked here but marked as fix committed. Anyway, the bug is no longer here and code looks good to me.
GunChleoc (gunchleoc) wrote : | # |
There was one remaining instance of that bug for Gaelic language only in the options window, which has now disappeared.
The reason for this is to speed up rendering - you should notice that map descriptions now load faster again.
@wl-zocker: it is "translatable" in the sense that you use it to pick your font set - instructions are on Transifex, but nobody seems to read them. Unfortunately, it is not possible to add comments to JSON files.
kaputtnik (franku) wrote : | # |
> The reason for this is to speed up rendering - you should notice that map descriptions now load faster again.
Yes indeed... works well :-)
GunChleoc (gunchleoc) wrote : | # |
@bunnybot merge
SirVer (sirver) wrote : | # |
Sorry, I am late to the review-party. I try to do one code review per day these days - not more. But I do not always manage.
Just one minor style fix, I suggest to just do it in any other branch you are working on.
Otherwise this is an awesome change. The font handler is really coming together now.
GunChleoc (gunchleoc) wrote : | # |
Thanks - bookmarked for fixing :)
Preview Diff
1 | === modified file 'src/graphic/text/rt_render.cc' |
2 | --- src/graphic/text/rt_render.cc 2016-01-18 19:35:25 +0000 |
3 | +++ src/graphic/text/rt_render.cc 2016-01-26 07:50:51 +0000 |
4 | @@ -824,11 +824,11 @@ |
5 | if (a.has("align")) { |
6 | const std::string align = a["align"].get_string(); |
7 | if (align == "right") { |
8 | + m_ns.halign = UI::Align::Align_Right; |
9 | + } else if (align == "center" || align == "middle") { |
10 | + m_ns.halign = UI::Align::Align_Center; |
11 | + } else { |
12 | m_ns.halign = UI::Align::Align_Left; |
13 | - } else if (align == "center" || align == "middle") { |
14 | - m_ns.halign = UI::Align::Align_Center; |
15 | - } else { |
16 | - m_ns.halign = UI::Align::Align_Right; |
17 | } |
18 | } |
19 | m_ns.halign = mirror_alignment(m_ns.halign); |
20 | |
21 | === modified file 'src/graphic/text_constants.h' |
22 | --- src/graphic/text_constants.h 2015-05-30 12:19:57 +0000 |
23 | +++ src/graphic/text_constants.h 2016-01-26 07:50:51 +0000 |
24 | @@ -24,7 +24,6 @@ |
25 | |
26 | /// Font Sizes |
27 | #define UI_FONT_SIZE_BIG 22 |
28 | -#define UI_FONT_SIZE_PROSA 18 |
29 | #define UI_FONT_SIZE_SMALL 14 |
30 | #define UI_FONT_SIZE_ULTRASMALL 10 |
31 | |
32 | @@ -35,9 +34,6 @@ |
33 | #define UI_FONT_CLR_DISABLED RGBColor(127, 127, 127) |
34 | #define UI_FONT_CLR_WARNING RGBColor(255, 22, 22) |
35 | |
36 | -/// Prosa font color |
37 | -#define PROSA_FONT_CLR_FG RGBColor(255, 255, 0) |
38 | - |
39 | /// Tooltip font color |
40 | #define UI_FONT_TOOLTIP_CLR RGBColor(255, 255, 0) |
41 | |
42 | |
43 | === modified file 'src/graphic/text_layout.cc' |
44 | --- src/graphic/text_layout.cc 2015-12-13 18:32:28 +0000 |
45 | +++ src/graphic/text_layout.cc 2016-01-26 07:50:51 +0000 |
46 | @@ -54,12 +54,24 @@ |
47 | f % txt; |
48 | return f.str(); |
49 | } |
50 | + |
51 | std::string as_uifont(const std::string & txt, int size, const RGBColor& clr) { |
52 | + return as_aligned(txt, UI::Align::Align_Left, size, clr); |
53 | +} |
54 | + |
55 | +std::string as_aligned(const std::string & txt, UI::Align align, int ptsize, const RGBColor& clr) { |
56 | + std::string alignment = "left"; |
57 | + if ((align & UI::Align_Horizontal) == UI::Align::Align_Right) { |
58 | + alignment = "right"; |
59 | + } else if ((align & UI::Align_Horizontal) == UI::Align::Align_HCenter) { |
60 | + alignment = "center"; |
61 | + } |
62 | + |
63 | // UI Text is always bold due to historic reasons |
64 | static boost::format |
65 | - f("<rt><p><font face=serif size=%i bold=1 shadow=1 color=%s>%s</font></p></rt>"); |
66 | - |
67 | - f % size; |
68 | + f("<rt><p align=%s><font face=serif size=%i bold=1 shadow=1 color=%s>%s</font></p></rt>"); |
69 | + f % alignment; |
70 | + f % ptsize; |
71 | f % clr.hex_value(); |
72 | f % txt; |
73 | return f.str(); |
74 | |
75 | === modified file 'src/graphic/text_layout.h' |
76 | --- src/graphic/text_layout.h 2015-10-09 08:35:26 +0000 |
77 | +++ src/graphic/text_layout.h 2016-01-26 07:50:51 +0000 |
78 | @@ -23,6 +23,7 @@ |
79 | #include <string> |
80 | #include <unicode/uchar.h> |
81 | |
82 | +#include "graphic/align.h" |
83 | #include "graphic/font.h" |
84 | #include "graphic/color.h" |
85 | #include "graphic/text_constants.h" |
86 | @@ -45,6 +46,9 @@ |
87 | */ |
88 | std::string as_uifont |
89 | (const std::string&, int ptsize = UI_FONT_SIZE_SMALL, const RGBColor& clr = UI_FONT_CLR_FG); |
90 | +std::string as_aligned(const std::string & txt, UI::Align align, int ptsize = UI_FONT_SIZE_SMALL, |
91 | + const RGBColor& clr = UI_FONT_CLR_FG); |
92 | + |
93 | std::string as_tooltip(const std::string&); |
94 | std::string as_waresinfo(const std::string&); |
95 | std::string as_window_title(const std::string&); |
96 | |
97 | === modified file 'src/graphic/wordwrap.cc' |
98 | --- src/graphic/wordwrap.cc 2016-01-23 09:18:49 +0000 |
99 | +++ src/graphic/wordwrap.cc 2016-01-26 07:50:51 +0000 |
100 | @@ -66,12 +66,12 @@ |
101 | * and a default-constructed text style. |
102 | */ |
103 | WordWrap::WordWrap() : |
104 | - m_wrapwidth(std::numeric_limits<uint32_t>::max()), m_draw_caret(false), mode_(WordWrap::Mode::kDisplay) |
105 | + m_wrapwidth(std::numeric_limits<uint32_t>::max()), m_draw_caret(false) |
106 | { |
107 | } |
108 | |
109 | WordWrap::WordWrap(const TextStyle & style, uint32_t gwrapwidth) : |
110 | - m_style(style), m_draw_caret(false), mode_(WordWrap::Mode::kDisplay) |
111 | + m_style(style), m_draw_caret(false) |
112 | { |
113 | m_wrapwidth = gwrapwidth; |
114 | |
115 | @@ -112,9 +112,8 @@ |
116 | * Perform the wrapping computations for the given text and fill in |
117 | * the private data containing the wrapped results. |
118 | */ |
119 | -void WordWrap::wrap(const std::string & text, WordWrap::Mode mode) |
120 | +void WordWrap::wrap(const std::string & text) |
121 | { |
122 | - mode_ = mode; |
123 | m_lines.clear(); |
124 | |
125 | std::string::size_type line_start = 0; |
126 | @@ -378,17 +377,13 @@ |
127 | } |
128 | |
129 | const Image* entry_text_im = |
130 | - UI::g_fh1->render(mode_ == WordWrap::Mode::kDisplay ? |
131 | - as_uifont(m_lines[line].text, |
132 | - m_style.font->size() - UI::g_fh1->fontset().size_offset(), |
133 | - m_style.fg) : |
134 | - as_editorfont(m_lines[line].text, |
135 | - m_style.font->size() - UI::g_fh1->fontset().size_offset(), |
136 | - m_style.fg)); |
137 | + UI::g_fh1->render(as_editorfont(m_lines[line].text, |
138 | + m_style.font->size() - UI::g_fh1->fontset().size_offset(), |
139 | + m_style.fg)); |
140 | UI::correct_for_align(alignment, entry_text_im->width(), fontheight, &point); |
141 | dst.blit(point, entry_text_im); |
142 | |
143 | - if (mode_ == WordWrap::Mode::kEditor && m_draw_caret && line == caretline) { |
144 | + if (m_draw_caret && line == caretline) { |
145 | std::string line_to_caret = m_lines[line].text.substr(0, caretpos); |
146 | // TODO(GunChleoc): Arabic: Fix cursor position for BIDI text. |
147 | int caret_x = text_width(line_to_caret, m_style.font->size()); |
148 | |
149 | === modified file 'src/graphic/wordwrap.h' |
150 | --- src/graphic/wordwrap.h 2015-12-13 09:09:21 +0000 |
151 | +++ src/graphic/wordwrap.h 2016-01-26 07:50:51 +0000 |
152 | @@ -33,11 +33,6 @@ |
153 | * Helper struct that provides word wrapping and related functionality. |
154 | */ |
155 | struct WordWrap { |
156 | - enum class Mode { |
157 | - kDisplay, |
158 | - kEditor |
159 | - }; |
160 | - |
161 | WordWrap(); |
162 | WordWrap(const TextStyle & style, uint32_t wrapwidth = std::numeric_limits<uint32_t>::max()); |
163 | |
164 | @@ -46,7 +41,7 @@ |
165 | |
166 | uint32_t wrapwidth() const; |
167 | |
168 | - void wrap(const std::string & text, WordWrap::Mode mode = WordWrap::Mode::kDisplay); |
169 | + void wrap(const std::string & text); |
170 | |
171 | uint32_t width() const; |
172 | uint32_t height() const; |
173 | @@ -82,8 +77,6 @@ |
174 | uint32_t m_wrapwidth; |
175 | bool m_draw_caret; |
176 | |
177 | - WordWrap::Mode mode_; |
178 | - |
179 | std::vector<LineData> m_lines; |
180 | }; |
181 | |
182 | |
183 | === modified file 'src/ui_basic/messagebox.cc' |
184 | --- src/ui_basic/messagebox.cc 2015-12-13 09:46:58 +0000 |
185 | +++ src/ui_basic/messagebox.cc 2016-01-26 07:50:51 +0000 |
186 | @@ -21,6 +21,7 @@ |
187 | |
188 | #include "base/i18n.h" |
189 | #include "graphic/font_handler.h" |
190 | +#include "graphic/font_handler1.h" |
191 | #include "graphic/graphic.h" |
192 | #include "ui_basic/button.h" |
193 | #include "ui_basic/multilinetextarea.h" |
194 | @@ -61,8 +62,8 @@ |
195 | text.c_str(), align); |
196 | |
197 | uint32_t width, height; |
198 | - std::string font = d->textarea->get_font_name(); |
199 | - int32_t fontsize = d->textarea->get_font_size(); |
200 | + std::string font = UI::g_fh1->fontset().serif(); |
201 | + int32_t fontsize = UI_FONT_SIZE_SMALL; |
202 | |
203 | UI::g_fh->get_size(font, fontsize, text, width, height, maxwidth); |
204 | // stupid heuristic to avoid excessively long lines |
205 | |
206 | === modified file 'src/ui_basic/multilineeditbox.cc' |
207 | --- src/ui_basic/multilineeditbox.cc 2015-10-23 12:05:36 +0000 |
208 | +++ src/ui_basic/multilineeditbox.cc 2016-01-26 07:50:51 +0000 |
209 | @@ -566,7 +566,7 @@ |
210 | ww.set_style(textstyle); |
211 | ww.set_wrapwidth(owner.get_w() - ms_scrollbar_w); |
212 | |
213 | - ww.wrap(text, WordWrap::Mode::kEditor); |
214 | + ww.wrap(text); |
215 | ww_valid = true; |
216 | |
217 | int32_t textheight = ww.height(); |
218 | |
219 | === modified file 'src/ui_basic/multilinetextarea.cc' |
220 | --- src/ui_basic/multilinetextarea.cc 2015-10-09 09:30:12 +0000 |
221 | +++ src/ui_basic/multilinetextarea.cc 2016-01-26 07:50:51 +0000 |
222 | @@ -19,28 +19,18 @@ |
223 | |
224 | #include "ui_basic/multilinetextarea.h" |
225 | |
226 | +#include <boost/algorithm/string.hpp> |
227 | #include <boost/bind.hpp> |
228 | |
229 | -#include "graphic/font_handler.h" |
230 | #include "graphic/font_handler1.h" |
231 | -#include "graphic/richtext.h" |
232 | +#include "graphic/rendertarget.h" |
233 | #include "graphic/text/font_set.h" |
234 | #include "graphic/text_constants.h" |
235 | -#include "graphic/text_layout.h" |
236 | -#include "graphic/wordwrap.h" |
237 | |
238 | namespace UI { |
239 | |
240 | static const uint32_t RICHTEXT_MARGIN = 2; |
241 | |
242 | -struct MultilineTextarea::Impl { |
243 | - bool isrichtext; |
244 | - WordWrap ww; |
245 | - RichText rt; |
246 | - |
247 | - Impl() : isrichtext(false) {} |
248 | -}; |
249 | - |
250 | MultilineTextarea::MultilineTextarea |
251 | (Panel * const parent, |
252 | const int32_t x, const int32_t y, const uint32_t w, const uint32_t h, |
253 | @@ -49,8 +39,9 @@ |
254 | const bool always_show_scrollbar) |
255 | : |
256 | Panel (parent, x, y, w, h), |
257 | - m(new Impl), |
258 | m_text (text), |
259 | + m_style(UI::TextStyle::ui_small()), |
260 | + isrichtext(false), |
261 | m_scrollbar (this, get_w() - scrollbar_w(), 0, scrollbar_w(), h, false), |
262 | m_scrollmode(ScrollNormal) |
263 | { |
264 | @@ -62,44 +53,18 @@ |
265 | |
266 | m_scrollbar.moved.connect(boost::bind(&MultilineTextarea::scrollpos_changed, this, _1)); |
267 | |
268 | - UI::FontSet fontset = UI::g_fh1->fontset(); |
269 | - m_scrollbar.set_singlestepsize(g_fh->get_fontheight(fontset.serif(), UI_FONT_SIZE_SMALL)); |
270 | - m_scrollbar.set_pagesize(h - 2 * g_fh->get_fontheight(fontset.serif(), UI_FONT_SIZE_BIG)); |
271 | + m_scrollbar.set_singlestepsize(UI::g_fh1->render(as_uifont(".", UI_FONT_SIZE_SMALL))->height()); |
272 | + m_scrollbar.set_pagesize(h - 2 * UI::g_fh1->render(as_uifont(".", UI_FONT_SIZE_BIG))->height()); |
273 | m_scrollbar.set_steps(1); |
274 | m_scrollbar.set_force_draw(always_show_scrollbar); |
275 | |
276 | - set_font(fontset.serif(), UI_FONT_SIZE_SMALL, UI_FONT_CLR_FG); |
277 | + recompute(); |
278 | |
279 | update(0, 0, get_eff_w(), get_h()); |
280 | } |
281 | |
282 | |
283 | /** |
284 | - * Free allocated resources |
285 | -*/ |
286 | -MultilineTextarea::~MultilineTextarea() |
287 | -{ |
288 | -} |
289 | - |
290 | -/** |
291 | - * Change the font used for non-richtext text. |
292 | - */ |
293 | -void MultilineTextarea::set_font(std::string name, int32_t size, RGBColor fg) |
294 | -{ |
295 | - m_fontname = name; |
296 | - m_fontsize = size; |
297 | - m_fcolor = fg; |
298 | - |
299 | - TextStyle style; |
300 | - style.font = Font::get(m_fontname, m_fontsize); |
301 | - style.fg = m_fcolor; |
302 | - style.bold = true; // for historic reasons |
303 | - |
304 | - m->ww.set_style(style); |
305 | - recompute(); |
306 | -} |
307 | - |
308 | -/** |
309 | * Replace the current text with a new one. |
310 | * Fix up scrolling state if necessary. |
311 | */ |
312 | @@ -110,7 +75,7 @@ |
313 | } |
314 | |
315 | /** |
316 | - * Recompute the word wrapping or rich-text layouting, |
317 | + * Recompute the text rendering or rich-text layouting, |
318 | * and adjust scrollbar settings accordingly. |
319 | */ |
320 | void MultilineTextarea::recompute() |
321 | @@ -121,15 +86,16 @@ |
322 | bool scroolbar_was_enabled = m_scrollbar.is_enabled(); |
323 | for (int i = 0; i < 2; ++i) { |
324 | if (m_text.compare(0, 3, "<rt")) { |
325 | - m->isrichtext = false; |
326 | - m->ww.set_wrapwidth(get_eff_w()); |
327 | - m->ww.wrap(m_text); |
328 | - height = m->ww.height(); |
329 | + isrichtext = false; |
330 | + boost::replace_all(m_text, "\n", "<br>"); |
331 | + const Image* text_im = UI::g_fh1->render(as_uifont(m_text, m_style.font->size(), m_style.fg), |
332 | + get_eff_w() - 2 * RICHTEXT_MARGIN); |
333 | + height = text_im->height(); |
334 | } else { |
335 | - m->isrichtext = true; |
336 | - m->rt.set_width(get_eff_w() - 2 * RICHTEXT_MARGIN); |
337 | - m->rt.parse(m_text); |
338 | - height = m->rt.height() + 2 * RICHTEXT_MARGIN; |
339 | + isrichtext = true; |
340 | + rt.set_width(get_eff_w() - 2 * RICHTEXT_MARGIN); |
341 | + rt.parse(m_text); |
342 | + height = rt.height() + 2 * RICHTEXT_MARGIN; |
343 | } |
344 | |
345 | bool setbottom = false; |
346 | @@ -183,22 +149,37 @@ |
347 | */ |
348 | void MultilineTextarea::draw(RenderTarget & dst) |
349 | { |
350 | - if (m->isrichtext) { |
351 | - m->rt.draw(dst, Point(RICHTEXT_MARGIN, RICHTEXT_MARGIN - m_scrollbar.get_scrollpos())); |
352 | + if (isrichtext) { |
353 | + rt.draw(dst, Point(RICHTEXT_MARGIN, RICHTEXT_MARGIN - m_scrollbar.get_scrollpos())); |
354 | } else { |
355 | - int32_t anchor = 0; |
356 | - |
357 | - switch (m_align & Align_Horizontal) { |
358 | - case Align_HCenter: |
359 | - anchor = get_eff_w() / 2; |
360 | - break; |
361 | - case Align_Right: |
362 | - anchor = get_eff_w(); |
363 | - break; |
364 | - default: |
365 | - break; |
366 | + const Image* text_im = UI::g_fh1->render(as_aligned(m_text, m_align, m_style.font->size(), m_style.fg), |
367 | + get_eff_w() - 2 * RICHTEXT_MARGIN); |
368 | + |
369 | + uint32_t blit_width = std::min(text_im->width(), static_cast<int>(get_eff_w())); |
370 | + uint32_t blit_height = std::min(text_im->height(), static_cast<int>(get_inner_h())); |
371 | + |
372 | + if (blit_width > 0 && blit_height > 0) { |
373 | + int32_t anchor = 0; |
374 | + Align alignment = mirror_alignment(m_align); |
375 | + switch (alignment & Align_Horizontal) { |
376 | + case Align_HCenter: |
377 | + anchor = (get_eff_w() - blit_width) / 2; |
378 | + break; |
379 | + case Align_Right: |
380 | + anchor = get_eff_w() - blit_width - RICHTEXT_MARGIN; |
381 | + break; |
382 | + default: |
383 | + anchor = RICHTEXT_MARGIN; |
384 | + break; |
385 | + } |
386 | + |
387 | + dst.blitrect_scale( |
388 | + Rect(anchor, 0, blit_width, blit_height), |
389 | + text_im, |
390 | + Rect(0, m_scrollbar.get_scrollpos(), blit_width, blit_height), |
391 | + 1., |
392 | + BlendMode::UseAlpha); |
393 | } |
394 | - m->ww.draw(dst, Point(anchor, -m_scrollbar.get_scrollpos()), m_align); |
395 | } |
396 | } |
397 | |
398 | |
399 | === modified file 'src/ui_basic/multilinetextarea.h' |
400 | --- src/ui_basic/multilinetextarea.h 2015-09-27 09:03:23 +0000 |
401 | +++ src/ui_basic/multilinetextarea.h 2016-01-26 07:50:51 +0000 |
402 | @@ -24,6 +24,8 @@ |
403 | |
404 | #include "graphic/align.h" |
405 | #include "graphic/color.h" |
406 | +#include "graphic/richtext.h" |
407 | +#include "graphic/text_layout.h" |
408 | #include "ui_basic/panel.h" |
409 | #include "ui_basic/scrollbar.h" |
410 | |
411 | @@ -46,7 +48,6 @@ |
412 | const std::string & text = std::string(), |
413 | const Align = Align_Left, |
414 | const bool always_show_scrollbar = false); |
415 | - ~MultilineTextarea(); |
416 | |
417 | const std::string & get_text() const {return m_text;} |
418 | ScrollMode get_scrollmode() const {return m_scrollmode;} |
419 | @@ -54,12 +55,10 @@ |
420 | void set_text(const std::string &); |
421 | void set_scrollmode(ScrollMode mode); |
422 | |
423 | - void set_font(std::string name, int32_t size, RGBColor fg); |
424 | - |
425 | uint32_t scrollbar_w() const {return 24;} |
426 | uint32_t get_eff_w() const {return m_scrollbar.is_enabled() ? get_w() - scrollbar_w() : get_w();} |
427 | |
428 | - void set_color(RGBColor fg) {m_fcolor = fg;} |
429 | + void set_color(RGBColor fg) {m_style.fg = fg;} |
430 | |
431 | // Drawing and event handlers |
432 | void draw(RenderTarget &) override; |
433 | @@ -67,29 +66,22 @@ |
434 | bool handle_mousewheel(uint32_t which, int32_t x, int32_t y) override; |
435 | void scroll_to_top(); |
436 | |
437 | - const char * get_font_name() {return m_fontname.c_str();} |
438 | - int32_t get_font_size() {return m_fontsize;} |
439 | - RGBColor & get_font_clr () {return m_fcolor;} |
440 | +protected: |
441 | + void layout() override; |
442 | |
443 | private: |
444 | - struct Impl; |
445 | - |
446 | - std::unique_ptr<Impl> m; |
447 | - |
448 | void recompute(); |
449 | void scrollpos_changed(int32_t pixels); |
450 | |
451 | std::string m_text; |
452 | + UI::TextStyle m_style; |
453 | + Align m_align; |
454 | + |
455 | + bool isrichtext; |
456 | + RichText rt; |
457 | + |
458 | Scrollbar m_scrollbar; |
459 | ScrollMode m_scrollmode; |
460 | - |
461 | -protected: |
462 | - void layout() override; |
463 | - |
464 | - Align m_align; |
465 | - std::string m_fontname; |
466 | - int32_t m_fontsize; |
467 | - RGBColor m_fcolor; |
468 | }; |
469 | |
470 | } |
471 | |
472 | === modified file 'src/ui_fsmenu/fileview.cc' |
473 | --- src/ui_fsmenu/fileview.cc 2015-08-06 17:14:34 +0000 |
474 | +++ src/ui_fsmenu/fileview.cc 2016-01-26 07:50:51 +0000 |
475 | @@ -77,8 +77,6 @@ |
476 | title.set_font(ui_fn(), fs_big(), UI_FONT_CLR_FG); |
477 | title.set_pos |
478 | (Point((get_inner_w() - title.get_w()) / 2, get_h() * 167 / 1000)); |
479 | - |
480 | - textview.set_font(UI::g_fh1->fontset().serif(), UI_FONT_SIZE_PROSA, PROSA_FONT_CLR_FG); |
481 | } |
482 | |
483 | void FullscreenMenuTextView::set_text(const std::string & text) |
484 | @@ -117,8 +115,6 @@ |
485 | UI::UniqueWindow(&parent, "file_view", ®, 0, 0, ""), |
486 | textview(this, 0, 0, 560, 240) |
487 | { |
488 | - textview.set_font(UI::g_fh1->fontset().serif(), UI_FONT_SIZE_PROSA, PROSA_FONT_CLR_FG); |
489 | - |
490 | set_inner_size(560, 240); |
491 | |
492 | if (get_usedefaultpos()) |
493 | |
494 | === modified file 'src/ui_fsmenu/launch_mpg.cc' |
495 | --- src/ui_fsmenu/launch_mpg.cc 2016-01-23 16:00:40 +0000 |
496 | +++ src/ui_fsmenu/launch_mpg.cc 2016-01-26 07:50:51 +0000 |
497 | @@ -209,8 +209,6 @@ |
498 | m_clients .set_font(m_fn, m_fs, RGBColor(0, 255, 0)); |
499 | m_players .set_font(m_fn, m_fs, RGBColor(0, 255, 0)); |
500 | m_map .set_font(m_fn, m_fs, RGBColor(0, 255, 0)); |
501 | - m_client_info.set_font(m_fn, m_fs, UI_FONT_CLR_FG); |
502 | - m_map_info .set_font(m_fn, m_fs, UI_FONT_CLR_FG); |
503 | |
504 | m_mapname .set_text(_("(no map)")); |
505 | m_map_info.set_text(_("The host has not yet selected a map or saved game.")); |
506 | @@ -480,13 +478,13 @@ |
507 | |
508 | if (settings.mapfilename != m_filename_proof) { |
509 | if (!g_fs->file_exists(settings.mapfilename)) { |
510 | - m_client_info.set_font(m_fn, m_fs, UI_FONT_CLR_WARNING); |
511 | + m_client_info.set_color(UI_FONT_CLR_WARNING); |
512 | m_client_info.set_text |
513 | (_("The selected file can not be found. If it is not automatically " |
514 | "transferred to you, please write to the host about this problem.")); |
515 | } else { |
516 | // Reset font color |
517 | - m_client_info.set_font(m_fn, m_fs, UI_FONT_CLR_FG); |
518 | + m_client_info.set_color(UI_FONT_CLR_FG); |
519 | |
520 | // Update local nr of players - needed for the client UI |
521 | m_nr_players = settings.players.size(); |
Hi, I am bunnybot (https:/ /github. com/widelands/ bunnybot).
I am keeping the source branch lp:~widelands-dev/widelands/multiline_textarea mirrored to https:/ /github. com/widelands/ widelands/ tree/_widelands _dev_widelands_ multiline_ textarea
You can give me commands by starting a line with @bunnybot <command>. I understand:
merge: Merges the source branch into the target branch, closing the merge proposal. I will use the proposed commit message if it is set.