TGUI  1.6.1
Loading...
Searching...
No Matches
Picture.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2024 Bruno Van de Velde (vdv_b@tgui.eu)
5//
6// This software is provided 'as-is', without any express or implied warranty.
7// In no event will the authors be held liable for any damages arising from the use of this software.
8//
9// Permission is granted to anyone to use this software for any purpose,
10// including commercial applications, and to alter it and redistribute it freely,
11// subject to the following restrictions:
12//
13// 1. The origin of this software must not be misrepresented;
14// you must not claim that you wrote the original software.
15// If you use this software in a product, an acknowledgment
16// in the product documentation would be appreciated but is not required.
17//
18// 2. Altered source versions must be plainly marked as such,
19// and must not be misrepresented as being the original software.
20//
21// 3. This notice may not be removed or altered from any source distribution.
22//
24
25#ifndef TGUI_PICTURE_HPP
26#define TGUI_PICTURE_HPP
27
28#include <TGUI/Widgets/ClickableWidget.hpp>
29#include <TGUI/Renderers/PictureRenderer.hpp>
30
32
33TGUI_MODULE_EXPORT namespace tgui
34{
38 class TGUI_API Picture : public ClickableWidget
39 {
40 public:
41
42 using Ptr = std::shared_ptr<Picture>;
43 using ConstPtr = std::shared_ptr<const Picture>;
44
45 static constexpr const char StaticWidgetType[] = "Picture";
46
54 Picture(const char* typeName = StaticWidgetType, bool initRenderer = true);
55
61 TGUI_NODISCARD static Picture::Ptr create();
62
82 TGUI_NODISCARD static Picture::Ptr create(const Texture& texture, bool transparentTexture = false);
83
91 TGUI_NODISCARD static Picture::Ptr copy(const Picture::ConstPtr& picture);
92
97 TGUI_NODISCARD PictureRenderer* getSharedRenderer() override;
98 TGUI_NODISCARD const PictureRenderer* getSharedRenderer() const override;
99
105 TGUI_NODISCARD PictureRenderer* getRenderer() override;
106
114 void setSize(const Layout2d& size) override;
115 using Widget::setSize;
116
124 TGUI_DEPRECATED("Use setIgnoreMouseEvents instead") void ignoreMouseEvents(bool ignore = true);
125
131 TGUI_DEPRECATED("Use getIgnoreMouseEvents instead") TGUI_NODISCARD bool isIgnoringMouseEvents() const;
132
139 TGUI_NODISCARD bool canGainFocus() const override;
140
146 TGUI_NODISCARD bool isMouseOnWidget(Vector2f pos) const override;
147
151 void leftMouseReleased(Vector2f pos) override;
152
159 void draw(BackendRenderTarget& target, RenderStates states) const override;
160
162 protected:
163
173 TGUI_NODISCARD Signal& getSignal(String signalName) override;
174
176 public:
177
178 SignalVector2f onDoubleClick = {"DoubleClicked"};
179
181 protected:
182
188 void rendererChanged(const String& property) override;
189
193 TGUI_NODISCARD std::unique_ptr<DataIO::Node> save(SavingRenderersMap& renderers) const override;
194
198 void load(const std::unique_ptr<DataIO::Node>& node, const LoadingRenderersMap& renderers) override;
199
201 // This function is called every frame with the time passed since the last frame.
203 bool updateTime(Duration elapsedTime) override;
204
206 // Makes a copy of the widget
208 TGUI_NODISCARD Widget::Ptr clone() const override;
209
211 protected:
212
213 Sprite m_sprite;
214
215 bool m_ignoringMouseEvents = false; // TGUI_NEXT: Remove this property
216
217 // Will be set to true after the first click, but gets reset to false when the second click does not occur soon after
218 bool m_possibleDoubleClick = false;
219 };
220
222}
223
225
226#endif // TGUI_PICTURE_HPP
Base class for render targets.
Definition BackendRenderTarget.hpp:46
Clickable widget.
Definition ClickableWidget.hpp:38
Wrapper for durations.
Definition Duration.hpp:55
Class to store the position or size of a widget.
Definition Layout.hpp:323
Definition PictureRenderer.hpp:35
Picture widget.
Definition Picture.hpp:39
std::shared_ptr< Picture > Ptr
Shared widget pointer.
Definition Picture.hpp:42
PictureRenderer * getRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
std::shared_ptr< const Picture > ConstPtr
Shared constant widget pointer.
Definition Picture.hpp:43
void rendererChanged(const String &property) override
Function called when one of the properties of the renderer is changed.
static Picture::Ptr copy(const Picture::ConstPtr &picture)
Makes a copy of another picture.
Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
PictureRenderer * getSharedRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
void setSize(const Layout2d &size) override
Changes the size of the picture.
static Picture::Ptr create(const Texture &texture, bool transparentTexture=false)
Creates a new picture widget.
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
static Picture::Ptr create()
Creates a new empty picture widget.
std::unique_ptr< DataIO::Node > save(SavingRenderersMap &renderers) const override
Saves the widget as a tree node in order to save it to a file.
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:61
Definition Sprite.hpp:47
Wrapper class to store strings.
Definition String.hpp:96
Texture wrapper that internally reuses resources when multiple Texture objects are loaded from the sa...
Definition Texture.hpp:57
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition Widget.hpp:86
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:38
States used for drawing.
Definition RenderStates.hpp:38