Pioneer
GuiLabel.h
Go to the documentation of this file.
1 // Copyright © 2008-2021 Pioneer Developers. See AUTHORS.txt for details
2 // Licensed under the terms of the GPL v3. See licenses/GPL-3.txt
3 
4 #ifndef _GUILABEL_H
5 #define _GUILABEL_H
6 
7 #include "GuiTextLayout.h"
8 #include "GuiWidget.h"
9 #include <SDL_stdinc.h>
10 #include <string>
11 
12 namespace Text {
13  class TextureFont;
14 }
15 
16 namespace Gui {
17  class Label : public Widget {
18  public:
19  Label(const char *text, TextLayout::ColourMarkupMode colourMarkupMode = TextLayout::ColourMarkupUse);
20  Label(const std::string &text, TextLayout::ColourMarkupMode colourMarkupMode = TextLayout::ColourMarkupUse);
21  virtual void Draw();
22  virtual ~Label();
23  virtual void GetSizeRequested(float size[2]);
24  void SetText(const char *text);
25  void SetText(const std::string &text);
26  Label *Shadow(bool isOn)
27  {
28  m_shadow = isOn;
29  return this;
30  }
31  Label *Color(Uint8 r, Uint8 g, Uint8 b);
33 
34  private:
35  void Init(const std::string &text, TextLayout::ColourMarkupMode colourMarkupMode);
36  void UpdateLayout();
37  void RecalcSize();
38  std::string m_text;
39  ::Color m_color;
40  bool m_shadow;
41  Uint32 m_dlist;
43  std::unique_ptr<TextLayout> m_layout;
44  TextLayout::ColourMarkupMode m_colourMarkupMode;
45  bool m_needsUpdate;
46  };
47 } // namespace Gui
48 
49 #endif /* _GUILABEL_H */
Color4ub Color
Definition: Color.h:197
Definition: GuiLabel.h:17
void SetText(const char *text)
Definition: GuiLabel.cpp:68
virtual ~Label()
Definition: GuiLabel.cpp:20
Label * Color(Uint8 r, Uint8 g, Uint8 b)
Definition: GuiLabel.cpp:51
Label * Shadow(bool isOn)
Definition: GuiLabel.h:26
Label(const char *text, TextLayout::ColourMarkupMode colourMarkupMode=TextLayout::ColourMarkupUse)
Definition: GuiLabel.cpp:10
virtual void Draw()
Definition: GuiLabel.cpp:82
virtual void GetSizeRequested(float size[2])
Definition: GuiLabel.cpp:106
ColourMarkupMode
Definition: GuiTextLayout.h:16
@ ColourMarkupUse
Definition: GuiTextLayout.h:19
Definition: GuiWidget.h:14
Definition: TextureFont.h:34
Definition: Gui.cpp:10
Definition: GuiLabel.h:12
Definition: Color.h:66