TextureLayoutRectangle.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #pragma once
  2. #include "../../Include/RmlUi/Core/Types.h"
  3. namespace Rml {
  4. /**
  5. A texture layout rectangle is an area positioned with a texture layout.
  6. */
  7. class TextureLayoutRectangle {
  8. public:
  9. TextureLayoutRectangle(int id, Vector2i dimensions);
  10. ~TextureLayoutRectangle();
  11. /// Returns the rectangle's id.
  12. /// @return The rectangle's id.
  13. int GetId() const;
  14. /// Returns the rectangle's position; this is only valid if it has been placed.
  15. /// @return The rectangle's position within its texture.
  16. Vector2i GetPosition() const;
  17. /// Returns the rectangle's dimensions.
  18. /// @return The rectangle's dimensions.
  19. Vector2i GetDimensions() const;
  20. /// Places the rectangle within a texture.
  21. /// @param[in] texture_index The index of the texture this rectangle is placed on.
  22. /// @param[in] position The position within the texture of this rectangle's top-left corner.
  23. void Place(int texture_index, Vector2i position);
  24. /// Unplaces the rectangle.
  25. void Unplace();
  26. /// Returns the rectangle's placed state.
  27. /// @return True if the rectangle has been placed, false if not.
  28. bool IsPlaced() const;
  29. /// Sets the rectangle's texture data and stride.
  30. /// @param[in] texture_data The pointer to the top-left corner of the texture's data.
  31. /// @param[in] texture_stride The stride of the texture data, in bytes.
  32. void Allocate(byte* texture_data, int texture_stride);
  33. /// Returns the index of the texture this rectangle is placed on.
  34. /// @return The texture index.
  35. int GetTextureIndex();
  36. /// Returns the rectangle's allocated texture data.
  37. /// @return The texture data.
  38. byte* GetTextureData();
  39. /// Returns the stride of the rectangle's texture data.
  40. /// @return The texture data stride.
  41. int GetTextureStride() const;
  42. private:
  43. int id;
  44. Vector2i dimensions;
  45. int texture_index;
  46. Vector2i texture_position;
  47. byte* texture_data;
  48. int texture_stride;
  49. };
  50. } // namespace Rml