FifeGUI 0.3.0
A C++ GUI library designed for games.
piegraph.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later OR BSD-3-Clause
2// SPDX-FileCopyrightText: 2004 - 2008 Olof Naessén and Per Larsson
3// SPDX-FileCopyrightText: 2013 - 2026 Fifengine contributors
4
5#ifndef INCLUDE_FIFECHAN_WIDGETS_PIEGRAPH_HPP_
6#define INCLUDE_FIFECHAN_WIDGETS_PIEGRAPH_HPP_
7
8// Standard library includes
9#include <vector>
10
11// Project headers (subdirs before local)
12#include "fifechan/point.hpp"
13#include "fifechan/widget.hpp"
14
15namespace fcn
16{
17 class Graphics;
18
28 class FIFEGUI_API PieGraph : public Widget
29 {
30 public:
34 PieGraph();
35
41 explicit PieGraph(Point center);
42
43 ~PieGraph() override = default;
44
45 PieGraph(PieGraph const &) = delete;
46 PieGraph& operator=(PieGraph const &) = delete;
47 PieGraph(PieGraph&&) = delete;
48 PieGraph& operator=(PieGraph&&) = delete;
49
55 void setCenterX(int x);
56
62 void setCenterY(int y);
63
70 void setCenter(int x, int y);
71
77 int getCenterX() const;
78
84 int getCenterY() const;
85
91 void setCenter(Point const & center);
92
98 Point const & getCenter() const;
99
105 void setRadius(int radius);
106
112 int getRadius() const;
113
121 void addSegment(int startAngle, int stopAngle, Color const & color);
122
126 void clearSegments();
127
133 void setOpaque(bool opaque);
134
138 bool isOpaque() const;
139
143 void draw(Graphics* graphics) override;
144
145 protected:
148
151
154
160 {
163
166
169 };
170
172 std::vector<PieGraphSegment> m_segments;
173 };
174}; // namespace fcn
175
176#endif // INCLUDE_FIFECHAN_WIDGETS_PIEGRAPH_HPP_
Color.
Definition color.hpp:58
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
Definition graphics.hpp:58
Point m_center
The center point of the pie graph.
Definition piegraph.hpp:150
int getCenterX() const
Get the center x-coordinate.
Definition piegraph.cpp:44
bool m_opaque
True if the pie graph is drawn opaque.
Definition piegraph.hpp:147
PieGraph()
Default constructor.
Definition piegraph.cpp:20
void addSegment(int startAngle, int stopAngle, Color const &color)
Add a segment to the pie graph.
Definition piegraph.cpp:74
void setRadius(int radius)
Set the radius of the pie graph.
Definition piegraph.cpp:64
void setCenterX(int x)
Set the center x-coordinate.
Definition piegraph.cpp:28
int getRadius() const
Get the radius of the pie graph.
Definition piegraph.cpp:69
int getCenterY() const
Get the center y-coordinate.
Definition piegraph.cpp:49
int m_radius
The radius of the pie graph in pixels.
Definition piegraph.hpp:153
Point const & getCenter() const
Get the center point.
Definition piegraph.cpp:59
bool isOpaque() const
Definition piegraph.cpp:93
std::vector< PieGraphSegment > m_segments
The list of segments that make up the pie graph.
Definition piegraph.hpp:172
void clearSegments()
Remove all segments from the pie graph.
Definition piegraph.cpp:83
void draw(Graphics *graphics) override
Draws this widget.
Definition piegraph.cpp:98
void setCenterY(int y)
Set the center y-coordinate.
Definition piegraph.cpp:33
void setOpaque(bool opaque)
Sets the opacity of the graph.
Definition piegraph.cpp:88
void setCenter(int x, int y)
Set the center coordinates.
Definition piegraph.cpp:38
Represents a 2D coordinate (X, Y).
Definition point.hpp:34
Widget()
Constructor.
Definition widget.cpp:52
Used replacement tokens by configure_file():
Represents a single segment of a pie graph (angles and color).
Definition piegraph.hpp:160
int stopAngle
Stop angle in degrees.
Definition piegraph.hpp:165
Color color
Color of the segment.
Definition piegraph.hpp:168
int startAngle
Start angle in degrees.
Definition piegraph.hpp:162