Pioneer
GuiLabelSet.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 GUILABELSET_H
5 #define GUILABELSET_H
6 
7 #include "GuiWidget.h"
8 #include <vector>
9 
10 /*
11  * Collection of clickable labels. Used by the WorldView for clickable
12  * bodies, and SystemView, SectorView etc.
13  */
14 namespace Gui {
15  class LabelSet : public Widget {
16  public:
17  class LabelSetItem {
18  public:
19  LabelSetItem(std::string text_, sigc::slot<void> onClick_, float screenx_, float screeny_) :
20  text(text_),
21  hasOwnColor(false),
22  onClick(onClick_),
23  screenx(screenx_),
24  screeny(screeny_)
25  {
26  }
27  LabelSetItem(std::string text_, sigc::slot<void> onClick_, float screenx_, float screeny_, const Color &c) :
28  text(text_),
29  color(c),
30  hasOwnColor(true),
31  onClick(onClick_),
32  screenx(screenx_),
33  screeny(screeny_)
34  {
35  }
36  std::string text;
39  sigc::slot<void> onClick;
40  float screenx, screeny;
42  };
43 
44  LabelSet();
46  virtual void Draw();
47  virtual void GetSizeRequested(float size[2]);
48  void Clear();
49  void Add(std::string text, sigc::slot<void> onClick, float screenx, float screeny);
51  void Add(std::string text, sigc::slot<void> onClick, float screenx, float screeny, const Color &col);
52  void SetLabelsClickable(bool v) { m_labelsClickable = v; }
53  void SetLabelsVisible(bool v) { m_labelsVisible = v; }
54  void SetLabelColor(const Color &c) { m_labelColor = c; }
55 
56  private:
57  bool CanPutItem(float x, float y);
58 
59  std::vector<LabelSetItem> m_items;
60  bool m_labelsVisible;
61  bool m_labelsClickable;
62  Color m_labelColor;
63 
65  };
66 } // namespace Gui
67 
68 #endif /* GUILABELSET_H */
Definition: GuiLabelSet.h:17
float screenx
Definition: GuiLabelSet.h:40
bool hasOwnColor
Definition: GuiLabelSet.h:38
LabelSetItem(std::string text_, sigc::slot< void > onClick_, float screenx_, float screeny_)
Definition: GuiLabelSet.h:19
float screeny
Definition: GuiLabelSet.h:40
sigc::slot< void > onClick
Definition: GuiLabelSet.h:39
LabelSetItem(std::string text_, sigc::slot< void > onClick_, float screenx_, float screeny_, const Color &c)
Definition: GuiLabelSet.h:27
std::string text
Definition: GuiLabelSet.h:36
RefCountedPtr< Graphics::VertexBuffer > m_vb
Definition: GuiLabelSet.h:41
Color color
Definition: GuiLabelSet.h:37
Definition: GuiLabelSet.h:15
virtual void GetSizeRequested(float size[2])
Definition: GuiLabelSet.cpp:69
void SetLabelColor(const Color &c)
Definition: GuiLabelSet.h:54
void Add(std::string text, sigc::slot< void > onClick, float screenx, float screeny)
Definition: GuiLabelSet.cpp:41
LabelSet()
Definition: GuiLabelSet.cpp:8
void Clear()
Definition: GuiLabelSet.cpp:55
bool OnMouseDown(MouseButtonEvent *e)
Definition: GuiLabelSet.cpp:18
void SetLabelsVisible(bool v)
Definition: GuiLabelSet.h:53
void SetLabelsClickable(bool v)
Definition: GuiLabelSet.h:52
virtual void Draw()
Definition: GuiLabelSet.cpp:60
Definition: GuiWidget.h:14
Definition: Gui.cpp:10
Definition: Color.h:66
Definition: GuiEvents.h:8