TGUI  1.3-dev
Loading...
Searching...
No Matches
CanvasRaylib.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_CANVAS_RAYLIB_HPP
26#define TGUI_CANVAS_RAYLIB_HPP
27
28#include <TGUI/Backend/Renderer/Raylib/BackendTextureRaylib.hpp>
29
30#if !TGUI_BUILD_AS_CXX_MODULE
31 #include <TGUI/Backend/Renderer/BackendRenderTarget.hpp>
32 #include <TGUI/Widgets/CanvasBase.hpp>
33#endif
34
35#include <raylib.h>
36
38
39TGUI_MODULE_EXPORT namespace tgui
40{
65 class TGUI_API CanvasRaylib : public CanvasBase
66 {
67 public:
68
69 using Ptr = std::shared_ptr<CanvasRaylib>;
70 using ConstPtr = std::shared_ptr<const CanvasRaylib>;
71
72 static constexpr const char StaticWidgetType[] = "CanvasRaylib";
73
77 ~CanvasRaylib() override;
78
86 CanvasRaylib(const char* typeName = StaticWidgetType, bool initRenderer = true);
87
92
96 CanvasRaylib(CanvasRaylib&& copy) = default;
97
101 CanvasRaylib& operator= (const CanvasRaylib& right);
102
106 CanvasRaylib& operator= (CanvasRaylib&& right) = default;
107
116 TGUI_NODISCARD static CanvasRaylib::Ptr create(const Layout2d& size = {"100%", "100%"});
117
126 TGUI_NODISCARD static CanvasRaylib::Ptr copy(const CanvasRaylib::ConstPtr& canvas);
127
134 void setSize(const Layout2d& size) override;
135 using Widget::setSize;
136
144 void draw(BackendRenderTarget& target, RenderStates states) const override;
145
153 TGUI_NODISCARD RenderTexture2D& getTextureTarget()
154 {
155 return m_textureTarget;
156 }
157
159 protected:
160
162 // Makes a copy of the widget
164 TGUI_NODISCARD Widget::Ptr clone() const override;
165
167 protected:
168
169 RenderTexture2D m_textureTarget;
170 Vector2u m_textureSize;
171 Vector2u m_usedTextureSize;
172 std::shared_ptr<BackendTextureRaylib> m_backendTexture;
173 };
174}
175
177
178#endif // TGUI_CANVAS_RAYLIB_HPP
Base class for render targets.
Definition BackendRenderTarget.hpp:48
This class is used as base class for the backend-specific canvas widgets.
Definition CanvasBase.hpp:39
Definition CanvasRaylib.hpp:66
std::shared_ptr< CanvasRaylib > Ptr
Shared widget pointer.
Definition CanvasRaylib.hpp:69
TGUI_NODISCARD Widget::Ptr clone() const override
Makes a copy of the widget if you don't know its exact type.
std::shared_ptr< const CanvasRaylib > ConstPtr
Shared constant widget pointer.
Definition CanvasRaylib.hpp:70
CanvasRaylib(const CanvasRaylib &copy)
Copy constructor.
void setSize(const Layout2d &size) override
Changes the size of the widget.
TGUI_NODISCARD RenderTexture2D & getTextureTarget()
Access the internal render texture to which you can render.
Definition CanvasRaylib.hpp:153
CanvasRaylib(CanvasRaylib &&copy)=default
Default move constructor.
static TGUI_NODISCARD CanvasRaylib::Ptr copy(const CanvasRaylib::ConstPtr &canvas)
Makes a copy of another canvas.
void draw(BackendRenderTarget &target, RenderStates states) const override
Draw the widget to a render target.
~CanvasRaylib() override
Destructor.
static TGUI_NODISCARD CanvasRaylib::Ptr create(const Layout2d &size={"100%", "100%"})
Creates a new canvas widget.
Class to store the position or size of a widget.
Definition Layout.hpp:305
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