TextureLayoutRow.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. #include "TextureLayoutRectangle.h"
  3. namespace Rml {
  4. class TextureLayout;
  5. /**
  6. A texture layout row is a single row of rectangles positioned vertically within a texture.
  7. */
  8. class TextureLayoutRow {
  9. public:
  10. TextureLayoutRow();
  11. ~TextureLayoutRow();
  12. /// Attempts to position unplaced rectangles from the layout into this row.
  13. /// @param[in] layout The layout to position rectangles from.
  14. /// @param[in] width The maximum width of this row.
  15. /// @param[in] y The y-coordinate of this row.
  16. /// @return The number of placed rectangles.
  17. int Generate(TextureLayout& layout, int width, int y);
  18. /// Assigns allocated texture data to all rectangles in this row.
  19. /// @param[in] texture_data The pointer to the beginning of the texture's data.
  20. /// @param[in] stride The stride of the texture's surface, in bytes;
  21. void Allocate(byte* texture_data, int stride);
  22. /// Returns the height of the row.
  23. /// @return The row's height.
  24. int GetHeight() const;
  25. /// Resets the placed status for all of the rectangles within this row.
  26. void Unplace();
  27. private:
  28. using RectangleList = Vector<TextureLayoutRectangle*>;
  29. int height;
  30. RectangleList rectangles;
  31. };
  32. } // namespace Rml