Pioneer
GuiMeterBar.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 GUIMETERBAR_H
5 #define GUIMETERBAR_H
6 
7 #include "Color.h"
8 #include "GuiFixed.h"
9 #include "GuiLabel.h"
10 
11 /* A cute horizontal bar readout of some value from 0 to 1,
12  with a text label also. Hull and weapon temperature are shown with these */
13 namespace Gui {
14  class MeterBar : public Gui::Fixed {
15  public:
16  MeterBar(float width, const char *label, const ::Color &graphCol);
17  virtual ~MeterBar() {}
18  virtual void Draw();
19  virtual void GetSizeRequested(float size[2]);
20  void SetValue(float v) { m_barValue = Clamp(v, 0.0f, 1.0f); }
21  void SetColor(const ::Color &c) { m_barColor = c; }
22 
23  private:
24  float m_requestedWidth;
25  Gui::Label *m_label;
26  ::Color m_barColor;
27  float m_barValue;
28  std::unique_ptr<Graphics::Drawables::RoundEdgedRect> m_outer;
29  std::unique_ptr<Graphics::Drawables::RoundEdgedRect> m_inner;
30  };
31 } // namespace Gui
32 
33 #endif /* GUIMETERBAR_H */
Color4ub Color
Definition: Color.h:197
Definition: GuiFixed.h:14
Definition: GuiLabel.h:17
Definition: GuiMeterBar.h:14
MeterBar(float width, const char *label, const ::Color &graphCol)
Definition: GuiMeterBar.cpp:14
void SetValue(float v)
Definition: GuiMeterBar.h:20
virtual void Draw()
Definition: GuiMeterBar.cpp:24
virtual ~MeterBar()
Definition: GuiMeterBar.h:17
virtual void GetSizeRequested(float size[2])
Definition: GuiMeterBar.cpp:58
void SetColor(const ::Color &c)
Definition: GuiMeterBar.h:21
const T & Clamp(const T &x, const T &min, const T &max)
Definition: libs.h:69
Definition: Gui.cpp:10
Definition: Color.h:66