summaryrefslogtreecommitdiff
path: root/src/gfx_layout.h
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2013-07-06 18:54:26 +0000
committerfrosch <frosch@openttd.org>2013-07-06 18:54:26 +0000
commit3fa1b4e8c32041d4b9b76664b4d53ef5e13a4e5f (patch)
tree5942d20f19c84dd940024f867144ff023df4ce23 /src/gfx_layout.h
parent3c0fbaaa1386565bc9f248a834396b84c081cc1a (diff)
downloadopenttd-3fa1b4e8c32041d4b9b76664b4d53ef5e13a4e5f.tar.xz
(svn r25567) -Codechange: Revive dead DrawStringParams as FontState.
Diffstat (limited to 'src/gfx_layout.h')
-rw-r--r--src/gfx_layout.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/src/gfx_layout.h b/src/gfx_layout.h
index 0fadd5126..6dbf3f872 100644
--- a/src/gfx_layout.h
+++ b/src/gfx_layout.h
@@ -24,6 +24,44 @@
#endif /* WITH_ICU */
/**
+ * Text drawing parameters, which can change while drawing a line, but are kept between multiple parts
+ * of the same text, e.g. on line breaks.
+ */
+struct FontState {
+ FontSize fontsize; ///< Current font size.
+ TextColour cur_colour; ///< Current text colour.
+ TextColour prev_colour; ///< Text colour from before the last colour switch.
+
+ FontState(TextColour colour, FontSize fontsize) : fontsize(fontsize), cur_colour(colour), prev_colour(colour) {}
+
+ /**
+ * Switch to new colour \a c.
+ * @param c New colour to use.
+ */
+ inline void SetColour(TextColour c)
+ {
+ assert(c >= TC_BLUE && c <= TC_BLACK);
+ this->prev_colour = this->cur_colour;
+ this->cur_colour = c;
+ }
+
+ /** Switch to previous colour. */
+ inline void SetPreviousColour()
+ {
+ Swap(this->cur_colour, this->prev_colour);
+ }
+
+ /**
+ * Switch to using a new font \a f.
+ * @param f New font to use.
+ */
+ inline void SetFontSize(FontSize f)
+ {
+ this->fontsize = f;
+ }
+};
+
+/**
* Container with information about a font.
*/
class Font ICU_FONTINSTANCE {