FifeGUI 0.2.0
A C++ GUI library designed for games.
icon.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_ICON_HPP_
6#define INCLUDE_FIFECHAN_WIDGETS_ICON_HPP_
7
8#include <string>
9
10#include "fifechan/image.hpp"
11#include "fifechan/platform.hpp"
12#include "fifechan/widget.hpp"
13
14namespace fcn
15{
21 class FIFEGUI_API Icon : public Widget
22 {
23 public:
24 Icon();
25
31 explicit Icon(std::string const & filename);
32
38 explicit Icon(Image const * image);
39
40 ~Icon() override;
41
42 Icon(Icon const &) = delete;
43 Icon& operator=(Icon const &) = delete;
44 Icon(Icon&&) = delete;
45 Icon& operator=(Icon&&) = delete;
46
53 void setImage(std::string const & filename);
54
61 void setImage(Image const * image);
62
68 Image const * getImage() const;
69
75 void setScaling(bool scale);
76
82 bool isScaling() const;
83
89 void setTiling(bool tile);
90
96 bool isTiling() const;
97
103 void setOpaque(bool opaque);
104
108 bool isOpaque() const;
109
110 // Inherited from Widget
111
113
114 void resizeToContent(bool recursion) override;
115 void adjustSize() override;
116 void draw(Graphics* graphics) override;
117
118 protected:
122 Image const * mImage{nullptr};
123
129 bool mInternalImage{false};
130
132 bool mScale{false};
133
135 bool mTile{false};
136
138 bool mOpaque{true};
139
149 void adjustSizeImpl();
150 };
151} // namespace fcn
152
153#endif // INCLUDE_FIFECHAN_WIDGETS_ICON_HPP_
Abstract interface providing primitive drawing functions (lines, rectangles, etc.).
Definition graphics.hpp:57
bool mOpaque
True if opaque, otherwise false.
Definition icon.hpp:138
void setTiling(bool tile)
Sets if the image should be tiled to widget size.
Definition icon.cpp:82
void adjustSize() override
Resizes the widget's size to fit the content exactly.
Definition icon.cpp:103
bool mTile
True if tiling is enabled, otherwise false.
Definition icon.hpp:135
bool mInternalImage
True if the image has been loaded internally, false otherwise.
Definition icon.hpp:129
bool isTiling() const
Gets if the image is tiled to widget size.
Definition icon.cpp:77
bool isScaling() const
Gets if the image is scaled to widget size.
Definition icon.cpp:67
void resizeToContent(bool recursion) override
Resize this widget to fit its content.
Definition icon.cpp:97
bool isOpaque() const
Definition icon.cpp:92
Image const * getImage() const
Gets the current image.
Definition icon.cpp:62
bool mScale
True if scaling is enabled, otherwise false.
Definition icon.hpp:132
Image const * mImage
The image to display.
Definition icon.hpp:122
void draw(Graphics *graphics) override
Draws the widget.
Definition icon.cpp:123
void setOpaque(bool opaque)
Sets the opacity of the background.
Definition icon.cpp:87
void setScaling(bool scale)
Sets if the image should be scaled to widget size.
Definition icon.cpp:72
void setImage(std::string const &filename)
Sets the image to display.
Definition icon.cpp:40
Abstract holder for image data.
Definition image.hpp:32
Widget()
Constructor.
Definition widget.cpp:36
void resizeToContent()
Resizes the widget's size to fit the content exactly, calls recursively all childs.
Definition widget.hpp:1417