TGUI  1.0-alpha
CanvasSDL.hpp
1
2//
3// TGUI - Texus' Graphical User Interface
4// Copyright (C) 2012-2022 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
26#ifndef TGUI_CANVAS_SDL_HPP
27#define TGUI_CANVAS_SDL_HPP
28
29#include <TGUI/Config.hpp>
30#include <TGUI/Backend/Renderer/SDL_Renderer/BackendTextureSDL.hpp>
31#include <TGUI/Backend/Renderer/BackendRenderTarget.hpp>
32#include <TGUI/Widgets/ClickableWidget.hpp>
33
34#include <TGUI/extlibs/IncludeSDL.hpp>
35
37
38namespace tgui
39{
66 class TGUI_API CanvasSDL : public ClickableWidget
67 {
68 public:
69
70 typedef std::shared_ptr<CanvasSDL> Ptr;
71 typedef std::shared_ptr<const CanvasSDL> ConstPtr;
72
73
81 CanvasSDL(const char* typeName = "CanvasSDL", bool initRenderer = true);
82
83
87 CanvasSDL(const CanvasSDL& copy);
88
89
93 CanvasSDL(CanvasSDL&& copy) = default;
94
95
99 CanvasSDL& operator= (const CanvasSDL& right);
100
101
105 CanvasSDL& operator= (CanvasSDL&& right) = default;
106
107
116 static CanvasSDL::Ptr create(Layout2d size = {"100%", "100%"});
117
118
128
129
136 void setSize(const Layout2d& size) override;
137 using Widget::setSize;
138
139
147 void draw(BackendRenderTarget& target, RenderStates states) const override;
148
149
156 bool canGainFocus() const override;
157
158
168 SDL_Texture* getTextureTarget()
169 {
170 return m_textureTarget;
171 }
172
173
175 protected:
176
178 // Makes a copy of the widget
180 Widget::Ptr clone() const override;
181
182
184 protected:
185
186 SDL_Texture* m_textureTarget = nullptr;
187 Vector2u m_textureSize;
188 Vector2u m_usedTextureSize;
189 std::shared_ptr<BackendTextureSDL> m_backendTexture;
190 };
191}
192
194
195#endif // TGUI_CANVAS_SDL_HPP
Base class for render targets.
Definition: BackendRenderTarget.hpp:48
Definition: CanvasSDL.hpp:67
void setSize(const Layout2d &size) override
Changes the size of the widget.
static CanvasSDL::Ptr create(Layout2d size={"100%", "100%"})
Creates a new canvas widget.
void draw(BackendRenderTarget &target, RenderStates states) const override
Draw the widget to a render target.
CanvasSDL(CanvasSDL &&copy)=default
Default move constructor.
bool canGainFocus() const override
Returns whether the widget can gain focus.
SDL_Texture * getTextureTarget()
Access the internal texture on which you can render.
Definition: CanvasSDL.hpp:168
std::shared_ptr< CanvasSDL > Ptr
Shared widget pointer.
Definition: CanvasSDL.hpp:70
static CanvasSDL::Ptr copy(CanvasSDL::ConstPtr canvas)
Makes a copy of another canvas.
Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
CanvasSDL(const CanvasSDL &copy)
Copy constructor.
std::shared_ptr< const CanvasSDL > ConstPtr
Shared constant widget pointer.
Definition: CanvasSDL.hpp:71
Clickable widget.
Definition: ClickableWidget.hpp:40
Class to store the position or size of a widget.
Definition: Layout.hpp:284
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition: Widget.hpp:73
virtual void setSize(const Layout2d &size)
Changes the size of the widget.
Namespace that contains all TGUI functions and classes.
Definition: AbsoluteOrRelativeValue.hpp:36
States used for drawing.
Definition: RenderStates.hpp:39