TGUI  0.8-dev
Picture.hpp
1 //
3 // TGUI - Texus' 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_PICTURE_HPP
27 #define TGUI_PICTURE_HPP
28 
29 
30 #include <TGUI/Widgets/ClickableWidget.hpp>
31 
33 
34 namespace tgui
35 {
44  class TGUI_API Picture : public ClickableWidget
45  {
46  public:
47 
48  typedef std::shared_ptr<Picture> Ptr;
49  typedef std::shared_ptr<const Picture> ConstPtr;
50 
51 
55  Picture();
56 
57 
76  Picture(const Texture& texture, bool fullyClickable = true);
77 
78 
99  static Picture::Ptr create(const Texture& texture = {}, bool fullyClickable = true);
100 
101 
110  static Picture::Ptr copy(Picture::ConstPtr picture);
111 
112 
131  void setTexture(const Texture& texture, bool fullyClickable = true);
132 
133 
141  const sf::String& getLoadedFilename() const;
142 
143 
152  virtual void setSize(const Layout2d& size) override;
154 
155 
168  void setSmooth(bool smooth = true);
169 
170 
179  bool isSmooth() const;
180 
181 
185  virtual bool mouseOnWidget(sf::Vector2f pos) const override;
186 
187 
191  virtual void leftMouseReleased(sf::Vector2f pos) override;
192 
193 
201  virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
202 
203 
205  protected:
206 
213  virtual void rendererChanged(const std::string& property) override;
214 
215 
217  // This function is called every frame with the time passed since the last frame.
219  virtual void update(sf::Time elapsedTime) override;
220 
221 
223  // Makes a copy of the widget
225  virtual Widget::Ptr clone() const override
226  {
227  return std::make_shared<Picture>(*this);
228  }
229 
230 
232  protected:
233 
234  Sprite m_sprite;
235 
236  // Set to false when clicks on transparent parts of the picture should go to the widgets behind the picture
237  bool m_fullyClickable = true;
238 
239  // Will be set to true after the first click, but gets reset to false when the second click does not occur soon after
240  bool m_possibleDoubleClick = false;
241  };
242 
244 }
245 
247 
248 #endif // TGUI_PICTURE_HPP
Namespace that contains all TGUI functions and classes.
Definition: Animation.hpp:33
Definition: Sprite.hpp:40
Class to store the position or size of a widget.
Definition: Layout.hpp:263
virtual void setSize(const Layout2d &size)
Changes the size of the widget.
Clickable widget.
Definition: ClickableWidget.hpp:55
std::shared_ptr< Widget > Ptr
Shared widget pointer.
Definition: Widget.hpp:76
std::shared_ptr< const Picture > ConstPtr
Shared constant widget pointer.
Definition: Picture.hpp:49
Definition: Texture.hpp:39
std::shared_ptr< Picture > Ptr
Shared widget pointer.
Definition: Picture.hpp:48
virtual Widget::Ptr clone() const override
Makes a copy of the widget if you don&#39;t know its exact type.
Definition: Picture.hpp:225
Picture widget.
Definition: Picture.hpp:44