FifeGUI 0.3.0
A C++ GUI library designed for games.
activitybaritem.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_ACTIVITYBARITEM_HPP_
5#define INCLUDE_FIFECHAN_WIDGETS_ACTIVITYBARITEM_HPP_
6
7// Standard library includes
8#include <memory>
9#include <string>
10
11// Platform config include
12#include "fifechan/platform.hpp"
13
14// Project headers (subdirs before local)
15#include "fifechan/listeners/widgetlistener.hpp"
16#include "fifechan/widgets/togglebutton.hpp"
17#include "fifechan/widgets/tooltip.hpp"
18
19namespace fcn
20{
29 class FIFEGUI_API ActivityBarItem : public ToggleButton
30 {
31 public:
39 explicit ActivityBarItem(std::string const & icon, std::string tooltip = "", Widget* panel = nullptr);
40
41 ~ActivityBarItem() override;
42
43 ActivityBarItem(ActivityBarItem const &) = delete;
44 ActivityBarItem& operator=(ActivityBarItem const &) = delete;
46 ActivityBarItem& operator=(ActivityBarItem&&) = delete;
47
54 void setPanel(Widget* panel);
55
62 Widget* getPanel() const;
63
71 void setPanelVisible(bool visible);
72
78 void setSize(int size);
79
85 int getSize() const;
86
93 void setTooltip(std::string const & tooltip);
94
101 std::string const & getTooltip() const;
102
103 // Inherited from ToggleButton
104
105 void setSelected(bool selected) override;
106 void toggleSelected() override;
107
108 // Inherited from Button/MouseListener
109
110 void mouseEntered(MouseEvent& mouseEvent) override;
111 void mouseExited(MouseEvent& mouseEvent) override;
112
113 protected:
114 // Inherited from WidgetListener (via ToggleButton/Button)
115
116 void widgetHidden(Event const & event) override;
117 void widgetShown(Event const & event) override;
118
122 Widget* mPanel{nullptr};
123
127 int mSize{40};
128
132 std::string mTooltip;
133
137 std::unique_ptr<Tooltip> mTooltipWidget;
138
139 private:
143 void syncButtonToPanel();
144
148 void syncPanelToButton();
149 };
150} // namespace fcn
151
152#endif // INCLUDE_FIFECHAN_WIDGETS_ACTIVITYBARITEM_HPP_
void toggleSelected() override
Toggles the check box between being selected and not being selected.
ActivityBarItem(std::string const &icon, std::string tooltip="", Widget *panel=nullptr)
Constructor.
std::unique_ptr< Tooltip > mTooltipWidget
Tooltip widget instance (lazily created).
void widgetShown(Event const &event) override
Invoked when a widget is shown, i.e it's set to be visible.
Widget * getPanel() const
Gets the target panel that this item controls.
void setPanel(Widget *panel)
Sets the target panel that this item controls.
std::string const & getTooltip() const
Gets the tooltip text for this activity bar item.
std::string mTooltip
Tooltip text for this item.
void setTooltip(std::string const &tooltip)
Sets the tooltip text for this activity bar item.
void setPanelVisible(bool visible)
Sets the panel visibility and updates button state accordingly.
void setSize(int size)
Sets the default size for activity bar items.
void setSelected(bool selected) override
Sets the check box to be selected or not.
int mSize
Default size for items.
int getSize() const
Gets the default size.
void widgetHidden(Event const &event) override
Invoked when a widget is hidden, i.e it's set to be not visible.
Widget * mPanel
Panel that this item controls.
void mouseEntered(MouseEvent &mouseEvent) override
Called when the mouse has entered into the widget area.
void mouseExited(MouseEvent &mouseEvent) override
Called when the mouse has exited the widget area.
Base class for all GUI event objects.
Definition event.hpp:25
Represents a mouse event.
Abstract base class defining the common behavior, properties, and lifecycle of all GUI elements.
Definition widget.hpp:56
Used replacement tokens by configure_file():