← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1509791 into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1509791 into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)
Related bugs:
  Bug #1509791 in widelands: "Flickering while mouseover the first time"
  https://bugs.launchpad.net/widelands/+bug/1509791

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1509791/+merge/278243

Fixes flickering with mouse over wares in warehouse window.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1509791 into lp:widelands.
=== modified file 'src/ui_basic/textarea.cc'
--- src/ui_basic/textarea.cc	2015-10-03 07:21:52 +0000
+++ src/ui_basic/textarea.cc	2015-11-21 15:58:12 +0000
@@ -192,19 +192,11 @@
 {
 	int32_t x = get_x();
 	int32_t y = get_y();
-	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();
-	}
+
+	// TODO(GunChleoc): Calling the font renderer here will make things flicker while mousing over
+	// Wares in the warehouse window. So, we use calc_bare_width, although it's not exact.
+	uint32_t w = m_textstyle.calc_bare_width(m_text);
+	uint16_t h = m_textstyle.font->height();
 
 	if      (m_align & Align_HCenter)
 		x -= w >> 1;

=== modified file 'src/ui_basic/textarea.h'
--- src/ui_basic/textarea.h	2014-11-27 12:02:08 +0000
+++ src/ui_basic/textarea.h	2015-11-21 15:58:12 +0000
@@ -96,7 +96,6 @@
 
 	LayoutMode m_layoutmode;
 	std::string m_text;
-	const Image* m_text_image;
 	Align m_align;
 	UI::TextStyle m_textstyle;
 };


Follow ups