FifeGUI 0.2.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#include <vector>
9
10#include "fifechan/point.hpp"
11#include "fifechan/widget.hpp"
12
13namespace fcn
14{
15 class Graphics;
16
26 class FIFEGUI_API PieGraph : public Widget
27 {
28 public:
32 PieGraph();
33
39 explicit PieGraph(Point center);
40
41 ~PieGraph() override = default;
42
43 PieGraph(PieGraph const &) = delete;
44 PieGraph& operator=(PieGraph const &) = delete;
45 PieGraph(PieGraph&&) = delete;
46 PieGraph& operator=(PieGraph&&) = delete;
47
53 void setCenterX(int x);
54
60 void setCenterY(int y);
61
68 void setCenter(int x, int y);
69
75 int getCenterX() const;
76
82 int getCenterY() const;
83
89 void setCenter(Point const & center);
90
96 Point const & getCenter() const;
97
103 void setRadius(int radius);
104
110 int getRadius() const;
111
119 void addSegment(int startAngle, int stopAngle, Color const & color);
120
124 void clearSegments();
125
131 void setOpaque(bool opaque);
132
136 bool isOpaque() const;
137
141 void draw(Graphics* graphics) override;
142
143 protected:
146
149
152
158 {
161
164
167 };
168
170 std::vector<PieGraphSegment> m_segments;
171 };
172}; // namespace fcn
173
174#endif // INCLUDE_FIFECHAN_WIDGETS_PIEGRAPH_HPP_
Color.
Definition color.hpp:56
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
Definition graphics.hpp:57
Point m_center
The center point of the pie graph.
Definition piegraph.hpp:148
int getCenterX() const
Get the center x-coordinate.
Definition piegraph.cpp:36
bool m_opaque
True if the pie graph is drawn opaque.
Definition piegraph.hpp:145
PieGraph()
Default constructor.
Definition piegraph.cpp:16
void addSegment(int startAngle, int stopAngle, Color const &color)
Add a segment to the pie graph.
Definition piegraph.cpp:66
void setRadius(int radius)
Set the radius of the pie graph.
Definition piegraph.cpp:56
void setCenterX(int x)
Set the center x-coordinate.
Definition piegraph.cpp:20
int getRadius() const
Get the radius of the pie graph.
Definition piegraph.cpp:61
int getCenterY() const
Get the center y-coordinate.
Definition piegraph.cpp:41
int m_radius
The radius of the pie graph in pixels.
Definition piegraph.hpp:151
Point const & getCenter() const
Get the center point.
Definition piegraph.cpp:51
bool isOpaque() const
Definition piegraph.cpp:85
std::vector< PieGraphSegment > m_segments
The list of segments that make up the pie graph.
Definition piegraph.hpp:170
void clearSegments()
Remove all segments from the pie graph.
Definition piegraph.cpp:75
void draw(Graphics *graphics) override
Draws this widget.
Definition piegraph.cpp:90
void setCenterY(int y)
Set the center y-coordinate.
Definition piegraph.cpp:25
void setOpaque(bool opaque)
Sets the opacity of the graph.
Definition piegraph.cpp:80
void setCenter(int x, int y)
Set the center coordinates.
Definition piegraph.cpp:30
Represents a 2D coordinate (X, Y).
Definition point.hpp:29
Widget()
Constructor.
Definition widget.cpp:36
Represents a single segment of a pie graph (angles and color).
Definition piegraph.hpp:158
int stopAngle
Stop angle in degrees.
Definition piegraph.hpp:163
Color color
Color of the segment.
Definition piegraph.hpp:166
int startAngle
Start angle in degrees.
Definition piegraph.hpp:160