TextureLayoutRectangle.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * This source file is part of libRocket, the HTML/CSS Interface Middleware
  3. *
  4. * For the latest information, see http://www.librocket.com
  5. *
  6. * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. *
  26. */
  27. #ifndef TEXTURELAYOUTRECTANGLE_H
  28. #define TEXTURELAYOUTRECTANGLE_H
  29. namespace Rocket {
  30. namespace Core {
  31. /**
  32. A texture layout rectangle is an area positioned with a texture layout.
  33. @author Peter
  34. */
  35. class TextureLayoutRectangle
  36. {
  37. public:
  38. TextureLayoutRectangle(int id, const 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. const Vector2i& GetPosition() const;
  46. /// Returns the rectangle's dimensions.
  47. /// @return The rectangle's dimensions.
  48. const 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, const 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. }
  80. }
  81. #endif