FifeGUI 0.2.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(
40 std::string const & icon, std::string const & tooltip = "", Widget* panel = nullptr);
41
42 ~ActivityBarItem() override;
43
44 ActivityBarItem(ActivityBarItem const &) = delete;
45 ActivityBarItem& operator=(ActivityBarItem const &) = delete;
47 ActivityBarItem& operator=(ActivityBarItem&&) = delete;
48
55 void setPanel(Widget* panel);
56
63 Widget* getPanel() const;
64
72 void setPanelVisible(bool visible);
73
79 void setSize(int size);
80
86 int getSize() const;
87
94 void setTooltip(std::string const & tooltip);
95
102 std::string const & getTooltip() const;
103
104 // Inherited from ToggleButton
105
106 void setSelected(bool selected) override;
107 void toggleSelected() override;
108
109 // Inherited from Button/MouseListener
110
111 void mouseEntered(MouseEvent& mouseEvent) override;
112 void mouseExited(MouseEvent& mouseEvent) override;
113
114 protected:
115 // Inherited from WidgetListener (via ToggleButton/Button)
116
117 void widgetHidden(Event const & event) override;
118 void widgetShown(Event const & event) override;
119
123 Widget* mPanel{nullptr};
124
128 int mSize{40};
129
133 std::string mTooltip;
134
138 std::unique_ptr<Tooltip> mTooltipWidget;
139
140 private:
144 void syncButtonToPanel();
145
149 void syncPanelToButton();
150 };
151} // namespace fcn
152
153#endif // INCLUDE_FIFECHAN_WIDGETS_ACTIVITYBARITEM_HPP_
void toggleSelected() override
Toggles the check box between being selected and not being selected.
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.
ActivityBarItem(std::string const &icon, std::string const &tooltip="", Widget *panel=nullptr)
Constructor.
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:55
Used replacement tokens by configure_file():