Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
NineSlicePanel Class Reference

Resource responsible for resizing a texture using the 9-slice technique, for use in UI elements. More...

#include <nine_slice_panel.hpp>

Inheritance diagram for NineSlicePanel:
ToyMaker::Resource< NineSlicePanel > ToyMaker::IResource

Public Types

enum  ScaleMode : uint8_t { STRETCH , TILE }
 The type of texture sampling to be used on the resizable regions of the base texture.
 

Public Member Functions

 NineSlicePanel (std::shared_ptr< ToyMaker::Texture > baseTexture, SDL_FRect contentRegionUV)
 Constructs a new NineSlicePanel aspect.
 
 ~NineSlicePanel ()
 Destroys the NineSlicePanel object.
 
std::shared_ptr< ToyMaker::TexturegenerateTexture (glm::uvec2 contentDimensions) const
 Generates a new texture based on this panel resource, where the dimensions of the central region of the resource is specified by the caller.
 
uint32_t getOffsetPixelLeft () const
 Gets the width, in pixels, of the panel slices on the left hand side of this resource's base texture.
 
uint32_t getOffsetPixelRight () const
 Gets the width, in pixels, of the panel slices on the right hand side of this resource's base texture.
 
uint32_t getOffsetPixelBottom () const
 Gets the height, in pixels, of the panel slices on the bottom side of this resource's base texture.
 
uint32_t getOffsetPixelTop () const
 Gets the height, in pixels, of the panel slices on the top side of this resource's base texture.
 
- Public Member Functions inherited from ToyMaker::Resource< NineSlicePanel >
std::string getResourceTypeName_ () const override
 Get the resource type string for this resource.
 
- Public Member Functions inherited from ToyMaker::IResource
virtual ~IResource ()=default
 Destroy the IResource object.
 

Static Public Member Functions

static std::string getResourceTypeName ()
 Gets the resource type string associated with this class.
 

Private Attributes

std::shared_ptr< ToyMaker::TexturemTexture {}
 The base texture used to generate new textures.
 
SDL_FRect mContentRegion { .x{0.f}, .y{0.f}, .w{1.f}, .h{1.f} }
 The central region of the texture, resized to fit any content placed within a panel generated from this resource.
 
std::shared_ptr< ToyMaker::ShaderProgrammShaderHandle { nullptr }
 The shader responsible for producing panell textures from a base texture.
 
GLuint mVertexArrayObject {}
 The vertex array object used by this resource's panel shader.
 

Additional Inherited Members

- Protected Member Functions inherited from ToyMaker::Resource< NineSlicePanel >
 Resource (int explicitlyInitializeMe)
 Construct a new resource object.
 
- Protected Member Functions inherited from ToyMaker::IResource
 IResource ()=default
 Construct a new IResource object.
 
- Static Protected Member Functions inherited from ToyMaker::IResource
template<typename TResource>
static void RegisterResource ()
 Registers this resource as a Resource type with the ResourceDatabase.
 

Detailed Description

Resource responsible for resizing a texture using the 9-slice technique, for use in UI elements.

The base texture provided to this panel is divided into 9 regions

  • The 4 regions at the corners of the texture are locked, and are not resized along with the panel.
  • The regions of the top and bottom edges can be stretched or tiled horizontally. Similarly, the left and right edge regions can be extended vertically.
  • The region in the center can be resized arbitrarily along both axes along with the panel.

To facilitate this, this aspect computes a new albedo texture and static mesh for the StaticModel component of its SimObject whenever it receives a resize request.

Constructor & Destructor Documentation

◆ NineSlicePanel()

NineSlicePanel::NineSlicePanel ( std::shared_ptr< ToyMaker::Texture > baseTexture,
SDL_FRect contentRegionUV )

Constructs a new NineSlicePanel aspect.

Parameters
baseTextureThe texture to use as the basis for the panel produced by this aspect.
contentRegionUVThe rectangle, in UV coordinates, of the central region of the rectangle, determining the way the base texture is sliced.

Member Function Documentation

◆ generateTexture()

std::shared_ptr< ToyMaker::Texture > NineSlicePanel::generateTexture ( glm::uvec2 contentDimensions) const

Generates a new texture based on this panel resource, where the dimensions of the central region of the resource is specified by the caller.

Parameters
contentDimensionsThe dimensions of the central region of the resource, where content should be placed.
Returns
std::shared_ptr<ToyMaker::Texture> The texture produced.

◆ getOffsetPixelBottom()

uint32_t NineSlicePanel::getOffsetPixelBottom ( ) const

Gets the height, in pixels, of the panel slices on the bottom side of this resource's base texture.

Returns
uint32_t The height, in pixels, of the bottom side panel texture slices.

◆ getOffsetPixelLeft()

uint32_t NineSlicePanel::getOffsetPixelLeft ( ) const

Gets the width, in pixels, of the panel slices on the left hand side of this resource's base texture.

Returns
uint32_t The width, in pixels, of left hand side panel texture slices.

◆ getOffsetPixelRight()

uint32_t NineSlicePanel::getOffsetPixelRight ( ) const

Gets the width, in pixels, of the panel slices on the right hand side of this resource's base texture.

Returns
uint32_t The width, in pixels, of the right hand side panel texture slices.

◆ getOffsetPixelTop()

uint32_t NineSlicePanel::getOffsetPixelTop ( ) const

Gets the height, in pixels, of the panel slices on the top side of this resource's base texture.

Returns
uint32_t The height, in pixels, of the top side panel texture slices.

◆ getResourceTypeName()

static std::string NineSlicePanel::getResourceTypeName ( )
inlinestatic

Gets the resource type string associated with this class.

Returns
std::string This class' resource type string.

The documentation for this class was generated from the following files: