FifeGUI 0.2.0
A C++ GUI library designed for games.
activitybar.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_ACTIVITYBAR_HPP_
5#define INCLUDE_FIFECHAN_WIDGETS_ACTIVITYBAR_HPP_
6
7// Platform config include
8#include "fifechan/platform.hpp"
9
10// Standard library includes
11#include <list>
12
13// Project headers (subdirs before local)
14#include "fifechan/listeners/actionlistener.hpp"
15#include "fifechan/widgets/container.hpp"
16
17namespace fcn
18{
27 class FIFEGUI_API ActivityBar : public Container, public ActionListener
28 {
29 public:
35 explicit ActivityBar(int width = 48);
36
37 ~ActivityBar() override = default;
38
39 ActivityBar(ActivityBar const &) = delete;
40 ActivityBar& operator=(ActivityBar const &) = delete;
41 ActivityBar(ActivityBar&&) = delete;
42 ActivityBar& operator=(ActivityBar&&) = delete;
43
50 void setWidth(int width) override;
51
58 // cppcheck-suppress duplInheritedMember
59 int getWidth() const;
60
67 void setSpacing(unsigned int spacing);
68
75 unsigned int getSpacing() const;
76
82 // cppcheck-suppress duplInheritedMember
83 void addActionListener(ActionListener* listener);
84
90 // cppcheck-suppress duplInheritedMember
91 void removeActionListener(ActionListener* listener);
92
96 void showAll();
97
101 void hideAll();
102
103 // Inherited from Container
104
105 void resizeToContent(bool recursion = true) override;
106 void adjustSize() override;
107 void draw(Graphics* graphics) override;
108
109 protected:
110 // Inherited from ActionListener
111
112 void action(ActionEvent const & event) override;
113
114 private:
118 int mWidth;
119
123 unsigned int mSpacing{4};
124
128 // cppcheck-suppress duplInheritedMember
129 std::list<ActionListener*> mActionListeners;
130 };
131} // namespace fcn
132
133#endif // INCLUDE_FIFECHAN_WIDGETS_ACTIVITYBAR_HPP_
Represents an action trigger (e.g., button click).
void hideAll()
Hides all panels (toggles all buttons to unselected state).
void showAll()
Shows all panels (toggles all buttons to selected state).
void addActionListener(ActionListener *listener)
Adds an action listener to the activity bar.
void resizeToContent(bool recursion=true) override
Resizes the widget's size to fit the content exactly, calls recursively all childs.
void adjustSize() override
Resizes the widget's size to fit the content exactly.
ActivityBar(int width=48)
Constructor.
void setSpacing(unsigned int spacing)
Sets the spacing between items.
void removeActionListener(ActionListener *listener)
Removes an action listener from the activity bar.
unsigned int getSpacing() const
Gets the spacing between items.
void setWidth(int width) override
Sets the width of the activity bar.
void action(ActionEvent const &event) override
Handles an action event emitted by a widget.
int getWidth() const
Gets the width of the activity bar.
void draw(Graphics *graphics) override
Draws the widget.
Container()
Constructor.
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
Definition graphics.hpp:58
Used replacement tokens by configure_file():