← Back to team overview

widelands-dev team mailing list archive

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

 

Lukasz has proposed merging lp:~majcherlk/widelands/bug-1387784 into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~majcherlk/widelands/bug-1387784/+merge/242672

Now when the text doesn't fit in the Warehouse window the font is changed to smaller one.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~majcherlk/widelands/bug-1387784 into lp:widelands.
=== modified file 'src/ui_basic/textarea.cc'
--- src/ui_basic/textarea.cc	2014-11-22 10:18:20 +0000
+++ src/ui_basic/textarea.cc	2014-11-24 15:39:15 +0000
@@ -20,6 +20,7 @@
 #include "ui_basic/textarea.h"
 
 #include "graphic/font_handler.h"
+#include "wui/text_constants.h"
 
 namespace UI {
 
@@ -118,6 +119,16 @@
 	if (m_text == text)
 		return;
 
+	int font_size=UI_FONT_SIZE_SMALL;
+	m_textstyle.font=Font::get(UI_FONT_SMALL);
+
+	if(this->get_parent()->get_inner_w() != 0){
+		while(font_size>0 && m_textstyle.calc_bare_width(text) > this->get_parent()->get_inner_w()){
+			font_size--;
+			m_textstyle.font=Font::get(UI_FONT_NAME, font_size);
+		}
+	}
+
 	if (m_layoutmode == AutoMove)
 		collapse(); // collapse() implicitly updates