Merge lp:~majcherlk/widelands/bug-1387784 into lp:widelands

Proposed by Lukasz
Status: Work in progress
Proposed branch: lp:~majcherlk/widelands/bug-1387784
Merge into: lp:widelands
Diff against target: 27 lines (+11/-0)
1 file modified
src/ui_basic/textarea.cc (+11/-0)
To merge this branch: bzr merge lp:~majcherlk/widelands/bug-1387784
Reviewer Review Type Date Requested Status
SirVer Needs Fixing
Review via email: mp+242672@code.launchpad.net

Description of the change

Now when the text doesn't fit in the Warehouse window the font is changed to smaller one.

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

Welcome Lukasz and thanks for the patch :).

This patch is technically correct, but they drag a dependency on wui (widelands ui) into basic ui which is not desirable. basic ui is more fundamental than wui.

review: Needs Fixing
Revision history for this message
GunChleoc (gunchleoc) wrote :

We will have another method of fixing this once the fh1 branch has been merged. The new renderer creates a LayoutInfo object that will have the resulting size recorded, so we can hook into that.

I would also go for picking the compressed font before reducing the font size. This will be possible after the fonts branch has been merged.

Revision history for this message
Lukasz (majcherlk) wrote :

Thanks for information and suggestions,
I will try fix that after fonts branch merge.

Revision history for this message
SirVer (sirver) wrote :

I am setting this back to work in progress so that it gets out of the review queue. Please ping here if you continued working on it.

Unmerged revisions

7277. By Lukasz

using smaller font when text is overflowing

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/ui_basic/textarea.cc'
2--- src/ui_basic/textarea.cc 2014-11-22 10:18:20 +0000
3+++ src/ui_basic/textarea.cc 2014-11-24 15:39:15 +0000
4@@ -20,6 +20,7 @@
5 #include "ui_basic/textarea.h"
6
7 #include "graphic/font_handler.h"
8+#include "wui/text_constants.h"
9
10 namespace UI {
11
12@@ -118,6 +119,16 @@
13 if (m_text == text)
14 return;
15
16+ int font_size=UI_FONT_SIZE_SMALL;
17+ m_textstyle.font=Font::get(UI_FONT_SMALL);
18+
19+ if(this->get_parent()->get_inner_w() != 0){
20+ while(font_size>0 && m_textstyle.calc_bare_width(text) > this->get_parent()->get_inner_w()){
21+ font_size--;
22+ m_textstyle.font=Font::get(UI_FONT_NAME, font_size);
23+ }
24+ }
25+
26 if (m_layoutmode == AutoMove)
27 collapse(); // collapse() implicitly updates
28

Subscribers

People subscribed via source and target branches

to status/vote changes: