--- --- TGUI: include/TGUI/Widgets/Picture.hpp Source File
TGUI  1.x-dev
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
92 TGUI_NODISCARD static Picture::Ptr copy(const Picture::ConstPtr& picture);
93
98 TGUI_NODISCARD PictureRenderer* getSharedRenderer() override;
99 TGUI_NODISCARD const PictureRenderer* getSharedRenderer() const override;
100
106 TGUI_NODISCARD PictureRenderer* getRenderer() override;
107
116 void setSize(const Layout2d& size) override;
117 using Widget::setSize;
118
126 TGUI_DEPRECATED("Use setIgnoreMouseEvents instead") void ignoreMouseEvents(bool ignore = true);
127
133 TGUI_DEPRECATED("Use getIgnoreMouseEvents instead") TGUI_NODISCARD bool isIgnoringMouseEvents() const;
134
141 TGUI_NODISCARD bool canGainFocus() const override;
142
149 TGUI_NODISCARD bool isMouseOnWidget(Vector2f pos) const override;
150
154 void leftMouseReleased(Vector2f pos) override;
155
163 void draw(BackendRenderTarget& target, RenderStates states) const override;
164
166 protected:
167
177 TGUI_NODISCARD Signal& getSignal(String signalName) override;
178
180 public:
181
182 SignalVector2f onDoubleClick = {"DoubleClicked"};
183
185 protected:
186
193 void rendererChanged(const String& property) override;
194
198 TGUI_NODISCARD std::unique_ptr<DataIO::Node> save(SavingRenderersMap& renderers) const override;
199
203 void load(const std::unique_ptr<DataIO::Node>& node, const LoadingRenderersMap& renderers) override;
204
206 // This function is called every frame with the time passed since the last frame.
208 bool updateTime(Duration elapsedTime) override;
209
211 // Makes a copy of the widget
213 TGUI_NODISCARD Widget::Ptr clone() const override;
214
216 protected:
217
218 Sprite m_sprite;
219
220 bool m_ignoringMouseEvents = false; // TGUI_NEXT: Remove this property
221
222 // Will be set to true after the first click, but gets reset to false when the second click does not occur soon after
223 bool m_possibleDoubleClick = false;
224 };
225
227}
228
230
231#endif // TGUI_PICTURE_HPP
Base class for render targets.
Definition BackendRenderTarget.hpp:48
Clickable widget.
Definition ClickableWidget.hpp:40
Wrapper for durations.
Definition Duration.hpp:56
Class to store the position or size of a widget.
Definition Layout.hpp:328
Picture widget.
Definition Picture.hpp:39
std::shared_ptr< Picture > Ptr
Shared widget pointer.
Definition Picture.hpp:42
static TGUI_NODISCARD Picture::Ptr copy(const Picture::ConstPtr &picture)
Makes a copy of another picture.
std::shared_ptr< const Picture > ConstPtr
Shared constant widget pointer.
Definition Picture.hpp:43
static TGUI_NODISCARD Picture::Ptr create()
Creates a new empty picture widget.
void rendererChanged(const String &property) override
Function called when one of the properties of the renderer is changed.
TGUI_NODISCARD 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.
TGUI_NODISCARD PictureRenderer * getRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
static TGUI_NODISCARD Picture::Ptr create(const Texture &texture, bool transparentTexture=false)
Creates a new picture widget.
TGUI_NODISCARD 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.
TGUI_NODISCARD Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
void load(const std::unique_ptr< DataIO::Node > &node, const LoadingRenderersMap &renderers) override
Loads the widget from a tree of nodes.
Definition PictureRenderer.hpp:37
Signal to which the user can subscribe to get callbacks from.
Definition Signal.hpp:62
Definition Sprite.hpp:48
Wrapper class to store strings.
Definition String.hpp:101
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:87
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:39
States used for drawing.
Definition RenderStates.hpp:39