2
0

TextureLayoutRectangle.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. * This source file is part of RmlUi, the HTML/CSS Interface Middleware
  3. *
  4. * For the latest information, see http://github.com/mikke89/RmlUi
  5. *
  6. * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
  7. * Copyright (c) 2019-2023 The RmlUi Team, and contributors
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10. * of this software and associated documentation files (the "Software"), to deal
  11. * in the Software without restriction, including without limitation the rights
  12. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. * copies of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be included in
  17. * all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. * THE SOFTWARE.
  26. *
  27. */
  28. #ifndef TEXTURELAYOUTRECTANGLE_H
  29. #define TEXTURELAYOUTRECTANGLE_H
  30. #include "../../Include/RmlUi/Core/Types.h"
  31. namespace Rml {
  32. /**
  33. A texture layout rectangle is an area positioned with a texture layout.
  34. @author Peter
  35. */
  36. class TextureLayoutRectangle {
  37. public:
  38. TextureLayoutRectangle(int id, Vector2i dimensions);
  39. ~TextureLayoutRectangle();
  40. /// Returns the rectangle's id.
  41. /// @return The rectangle's id.
  42. int GetId() const;
  43. /// Returns the rectangle's position; this is only valid if it has been placed.
  44. /// @return The rectangle's position within its texture.
  45. Vector2i GetPosition() const;
  46. /// Returns the rectangle's dimensions.
  47. /// @return The rectangle's dimensions.
  48. Vector2i GetDimensions() const;
  49. /// Places the rectangle within a texture.
  50. /// @param[in] texture_index The index of the texture this rectangle is placed on.
  51. /// @param[in] position The position within the texture of this rectangle's top-left corner.
  52. void Place(int texture_index, Vector2i position);
  53. /// Unplaces the rectangle.
  54. void Unplace();
  55. /// Returns the rectangle's placed state.
  56. /// @return True if the rectangle has been placed, false if not.
  57. bool IsPlaced() const;
  58. /// Sets the rectangle's texture data and stride.
  59. /// @param[in] texture_data The pointer to the top-left corner of the texture's data.
  60. /// @param[in] texture_stride The stride of the texture data, in bytes.
  61. void Allocate(byte* texture_data, int texture_stride);
  62. /// Returns the index of the texture this rectangle is placed on.
  63. /// @return The texture index.
  64. int GetTextureIndex();
  65. /// Returns the rectangle's allocated texture data.
  66. /// @return The texture data.
  67. byte* GetTextureData();
  68. /// Returns the stride of the rectangle's texture data.
  69. /// @return The texture data stride.
  70. int GetTextureStride() const;
  71. private:
  72. int id;
  73. Vector2i dimensions;
  74. int texture_index;
  75. Vector2i texture_position;
  76. byte* texture_data;
  77. int texture_stride;
  78. };
  79. } // namespace Rml
  80. #endif