TGUI  0.7.4
Canvas.hpp
1 //
3 // TGUI - Texus's Graphical User Interface
4 // Copyright (C) 2012-2017 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_HPP
27 #define TGUI_CANVAS_HPP
28 
29 
30 #include <TGUI/Widgets/ClickableWidget.hpp>
31 
33 
34 namespace tgui
35 {
37 
38  class TGUI_API Canvas : public ClickableWidget
39  {
40  public:
41 
42  typedef std::shared_ptr<Canvas> Ptr;
43  typedef std::shared_ptr<const Canvas> ConstPtr;
44 
45 
52  Canvas(const Layout2d& size = {100, 100});
53 
54 
62  Canvas(const Layout& width, const Layout& height);
63 
64 
71  Canvas(const Canvas& copy);
72 
73 
82  Canvas& operator= (const Canvas& right);
83 
84 
93  static Canvas::Ptr create(Layout2d size = {100, 100});
94 
95 
104  static Canvas::Ptr copy(Canvas::ConstPtr canvas);
105 
106 
119  virtual void setPosition(const Layout2d& position) override;
121 
122 
129  virtual void setSize(const Layout2d& size) override;
131 
132 
141  void clear(const Color& color = sf::Color(0, 0, 0, 255));
142 
143 
151  void draw(const sf::Drawable& drawable, const sf::RenderStates& states = sf::RenderStates::Default);
152 
153 
163  void draw(const sf::Vertex* vertices, unsigned int vertexCount,
164  sf::PrimitiveType type, const sf::RenderStates& states = sf::RenderStates::Default);
165 
166 
175  void display();
176 
177 
184  virtual void setOpacity(float opacity) override;
185 
186 
188  protected:
189 
191  // Makes a copy of the widget
193  virtual Widget::Ptr clone() const override
194  {
195  return std::make_shared<Canvas>(*this);
196  }
197 
198 
200  // Draws the widget on the render target.
202  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
203 
204 
206  protected:
207 
208  sf::RenderTexture m_renderTexture;
209  sf::Sprite m_sprite;
210  };
211 
213 }
214 
216 
217 #endif // TGUI_CANVAS_HPP
Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:33
Implicit converter for colors.
Definition: Color.hpp:39
Class to store the position or size of a widget.
Definition: Layout.hpp:262
virtual Widget::Ptr clone() const override
Makes a copy of the widget if you don&#39;t know its exact type.
Definition: Canvas.hpp:193
Class to store the left, top, width or height of a widget.
Definition: Layout.hpp:120
virtual void setSize(const Layout2d &size)
Changes the size of the widget.
virtual void setPosition(const Layout2d &position)
set the position of the widget
Clickable widget.
Definition: ClickableWidget.hpp:55
std::shared_ptr< const Canvas > ConstPtr
Shared constant widget pointer.
Definition: Canvas.hpp:43
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition: Widget.hpp:75
std::shared_ptr< Canvas > Ptr
Shared widget pointer.
Definition: Canvas.hpp:42
Definition: Canvas.hpp:38