Explorar el Código

new function TextMetrics::clearText() (#1046)

Libor Čapák hace 8 años
padre
commit
b0eac0a809
Se han modificado 2 ficheros con 9 adiciones y 5 borrados
  1. 6 5
      examples/common/font/text_metrics.cpp
  2. 3 0
      examples/common/font/text_metrics.h

+ 6 - 5
examples/common/font/text_metrics.cpp

@@ -10,12 +10,13 @@
 
 
 TextMetrics::TextMetrics(FontManager* _fontManager)
 TextMetrics::TextMetrics(FontManager* _fontManager)
 	: m_fontManager(_fontManager)
 	: m_fontManager(_fontManager)
-	, m_width(0)
-	, m_height(0)
-	, m_x(0)
-	, m_lineHeight(0)
-	, m_lineGap(0)
 {
 {
+	clearText();
+}
+
+void TextMetrics::clearText()
+{
+	m_width = m_height = m_x = m_lineHeight = m_lineGap = 0;
 }
 }
 
 
 void TextMetrics::appendText(FontHandle _fontHandle, const char* _string)
 void TextMetrics::appendText(FontHandle _fontHandle, const char* _string)

+ 3 - 0
examples/common/font/text_metrics.h

@@ -25,6 +25,9 @@ public:
 	/// Return the height of the measured text.
 	/// Return the height of the measured text.
 	float getHeight() const { return m_height; }
 	float getHeight() const { return m_height; }
 
 
+	/// Clear the width and height of the measured text.
+	void clearText();
+
 private:
 private:
 	FontManager* m_fontManager;
 	FontManager* m_fontManager;
 	float m_width;
 	float m_width;