5 #include <SFML/Graphics/Drawable.hpp> 6 #include <SFML/Graphics/Texture.hpp> 7 #include <SFML/Graphics/Transformable.hpp> 8 #include <SFML/Graphics/RenderTexture.hpp> 9 #include <SFML/Graphics/VertexArray.hpp> 10 #include <SFML/System/Vector2.hpp> 12 #include <NasNas/core/data/Rect.hpp> 15 class NineSlice :
public sf::Drawable,
public sf::Transformable {
17 enum class Mode { Stretch, Repeat };
19 explicit NineSlice(Mode mode=Mode::Stretch);
20 explicit NineSlice(
const sf::Texture& texture, Mode mode=Mode::Stretch);
21 NineSlice(
const sf::Texture& texture,
const sf::IntRect& rect, Mode mode=Mode::Stretch);
23 void setMode(Mode mode);
25 void setTexture(
const sf::Texture& texture,
bool reset_rect =
false);
26 void setTextureRect(
const sf::IntRect& rect);
27 void setSlices(
int left,
int right,
int top,
int bottom);
29 void setSize(
const sf::Vector2i& size);
30 void setSize(
int width,
int height);
31 auto getSize() ->
const sf::Vector2f&;
33 auto getGlobalBounds()
const -> sf::FloatRect;
36 void draw(sf::RenderTarget& target, sf::RenderStates states)
const override;
37 void updateVertices();
40 enum { CENTER, LEFT, RIGHT, TOP, BOT, TL, TR, BL, BR };
54 Slices m_texture_slices;
55 const sf::Texture* m_texture =
nullptr;
57 sf::VertexArray m_vertices;