FifeGUI 0.2.0
A C++ GUI library designed for games.
panel.hpp
1// SPDX-License-Identifier: LGPL-2.1-or-later OR BSD-3-Clause
2// SPDX-FileCopyrightText: 2026 Fifengine contributors
3
4#ifndef INCLUDE_FIFECHAN_WIDGETS_PANEL_HPP_
5#define INCLUDE_FIFECHAN_WIDGETS_PANEL_HPP_
6
7// Standard library includes
8#include <string>
9
10// Platform config include
11#include "fifechan/platform.hpp"
12
13// Project headers (subdirs before local)
14#include "fifechan/listeners/mouselistener.hpp"
15#include "fifechan/widgets/container.hpp"
16
17namespace fcn
18{
27 enum class VisibilityState : std::uint8_t
28 {
29 Visible,
30 Hidden,
31 Collapsed
32 };
33
42 class FIFEGUI_API Panel : public Container, public MouseListener
43 {
44 public:
48 Panel();
49
57
65
72 void setCollapsedWidth(int width);
73
80 int getCollapsedWidth() const;
81
89 // cppcheck-suppress duplInheritedMember
90 void setVisible(bool visible);
91
96 void adjustSize() override;
97
104 void setTitle(std::string const & title);
105
112 std::string const & getTitle() const;
113
120 void setClosable(bool closable);
121
128 bool isClosable() const;
129
130 protected:
136 void draw(Graphics* graphics) override;
137
141 void mousePressed(MouseEvent& event) override;
142
150 virtual bool handleContentClick(MouseEvent& event);
151
152 private:
153 std::string mTitle;
154 bool mClosable = true;
155
156 Rectangle mCloseButtonBounds;
157
158 VisibilityState mVisibilityState = VisibilityState::Visible;
159 int mCollapsedWidth = 10;
160 };
161} // namespace fcn
162
163#endif // INCLUDE_FIFECHAN_WIDGETS_PANEL_HPP_
Container()
Constructor.
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
Definition graphics.hpp:58
Represents a mouse event.
MouseListener(MouseListener const &)=default
Copy constructor.
virtual bool handleContentClick(MouseEvent &event)
Handles content area mouse clicks.
Definition panel.cpp:210
int getCollapsedWidth() const
Gets the collapsed width.
Definition panel.cpp:39
void setClosable(bool closable)
Sets whether the panel has a close button.
Definition panel.cpp:78
void draw(Graphics *graphics) override
Draws the panel content.
Definition panel.cpp:88
VisibilityState getVisibilityState() const
Gets the visibility state of the panel.
Definition panel.cpp:29
Panel()
Constructor.
Definition panel.cpp:19
void setCollapsedWidth(int width)
Sets the width when the panel is collapsed.
Definition panel.cpp:34
void adjustSize() override
Adjusts the panel size based on its visibility state.
Definition panel.cpp:55
void setTitle(std::string const &title)
Sets the panel title.
Definition panel.cpp:68
void setVisibilityState(VisibilityState state)
Sets the visibility state of the panel.
Definition panel.cpp:24
bool isClosable() const
Checks if the panel has a close button.
Definition panel.cpp:83
void mousePressed(MouseEvent &event) override
Definition panel.cpp:187
std::string const & getTitle() const
Gets the panel title.
Definition panel.cpp:73
void setVisible(bool visible)
Sets whether the panel is visible.
Definition panel.cpp:45
Represents a rectangular area (X, Y, Width, Height).
Definition rectangle.hpp:22
Used replacement tokens by configure_file():
VisibilityState
Defines the visibility state of a Panel.
Definition panel.hpp:28