26#ifndef TGUI_CANVAS_HPP
27#define TGUI_CANVAS_HPP
29#include <TGUI/Config.hpp>
31#if TGUI_HAS_BACKEND_SFML
33#include <TGUI/Widgets/ClickableWidget.hpp>
34#include <SFML/Graphics/RenderTexture.hpp>
35#include <SFML/Graphics/Sprite.hpp>
47 typedef std::shared_ptr<CanvasSFML>
Ptr;
48 typedef std::shared_ptr<const CanvasSFML>
ConstPtr;
58 CanvasSFML(
const char* typeName =
"Canvas",
bool initRenderer =
true);
114 using Widget::setSize;
180 void draw(
const sf::Drawable& drawable,
const sf::RenderStates& states = {});
192 void draw(
const sf::Vertex* vertices, std::size_t vertexCount,
193 sf::PrimitiveType type,
const sf::RenderStates& states = {});
246 return m_renderTexture;
267 return std::make_shared<CanvasSFML>(*
this);
274 sf::RenderTexture m_renderTexture;
280 using Canvas = CanvasSFML;
Base class for render targets.
Definition BackendRenderTarget.hpp:48
IntRect getViewport() const
Get the viewport of the currently applied view, applied to this canvas.
CanvasSFML(const CanvasSFML ©)
Copy constructor.
CanvasSFML(CanvasSFML &©)
Move constructor.
void setView(const sf::View &view)
Change the current active view.
void setSize(const Layout2d &size) override
Changes the size of the widget.
std::shared_ptr< CanvasSFML > Ptr
Shared widget pointer.
Definition Canvas.hpp:47
void draw(BackendRenderTargetBase &target, RenderStates states) const override
Draw the widget to a render target.
sf::RenderTexture & getRenderTexture()
Access the internal render texture that the canvas widget uses to draw on.
Definition Canvas.hpp:244
void draw(const sf::Vertex *vertices, std::size_t vertexCount, sf::PrimitiveType type, const sf::RenderStates &states={})
Draws primitives defined by an array of vertices.
const sf::View & getView() const
Get the view currently in use in the canvas.
void draw(const sf::Drawable &drawable, const sf::RenderStates &states={})
Draws a drawable object to the canvas.
static CanvasSFML::Ptr create(Layout2d size={"100%", "100%"})
Creates a new canvas widget.
const sf::View & getDefaultView() const
Get the default view of the canvas.
void clear(Color color=Color::Black)
Clears the entire canvas with a single color.
void rendererChanged(const String &property) override
Function called when one of the properties of the renderer is changed.
void display()
Updates the contents of the canvas.
bool canGainFocus() const override
Returns whether the widget can gain focus.
std::shared_ptr< const CanvasSFML > ConstPtr
Shared constant widget pointer.
Definition Canvas.hpp:48
void draw(const tgui::Sprite &sprite, const RenderStates &states={})
Draws a TGUI sprite to the canvas.
static CanvasSFML::Ptr copy(CanvasSFML::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.
Definition Canvas.hpp:265
Wrapper for colors.
Definition Color.hpp:63
Class to store the position or size of a widget.
Definition Layout.hpp:262
Wrapper class to store strings.
Definition String.hpp:79
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:36
States used for drawing.
Definition RenderStates.hpp:39