TableFormattingContext.h 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #pragma once
  2. #include "../../../Include/RmlUi/Core/Types.h"
  3. #include "FormattingContext.h"
  4. #include "TableFormattingDetails.h"
  5. namespace Rml {
  6. class Box;
  7. class TableGrid;
  8. class TableWrapper;
  9. struct TrackBox;
  10. using TrackBoxList = Vector<TrackBox>;
  11. /*
  12. Formats a table element and its parts according to table layout rules.
  13. */
  14. class TableFormattingContext final : public FormattingContext {
  15. public:
  16. static UniquePtr<LayoutBox> Format(ContainerBox* parent_container, Element* element, const Box* override_initial_box);
  17. private:
  18. TableFormattingContext() = default;
  19. using BoxList = Vector<Box>;
  20. /// Format the table and its children.
  21. /// @param[out] table_content_size The final size of the table which will be determined by the size of its columns, rows, and spacing.
  22. /// @param[out] table_overflow_size Overflow size in case the contents of any cells overflow their cell box (without being caught by the cell).
  23. /// @param[out] table_baseline The baseline of the table wrapper, in terms of the vertical distance from its top-left border corner.
  24. /// @note Expects the table grid to have been built, and all table parameters to be set already.
  25. void FormatTable(Vector2f& table_content_size, Vector2f& table_overflow_size, float& table_baseline) const;
  26. // Determines the column widths, and populates the columns.
  27. void DetermineColumnWidths(TrackBoxList& columns, float& table_content_width) const;
  28. // Generate the initial boxes for all cells, content height may be indeterminate for now (-1).
  29. void InitializeCellBoxes(BoxList& cells, const TrackBoxList& columns) const;
  30. // Determines the row heights, and populates the rows.
  31. void DetermineRowHeights(TrackBoxList& rows, BoxList& cells, float& table_content_height) const;
  32. // Format the table row and row group elements.
  33. void FormatRows(const TrackBoxList& rows, float table_content_width) const;
  34. // Format the table row and row group elements.
  35. void FormatColumns(const TrackBoxList& columns, float table_content_height) const;
  36. // Format the table cell elements.
  37. void FormatCells(BoxList& cells, Vector2f& table_overflow_size, const TrackBoxList& rows, const TrackBoxList& columns,
  38. float& table_baseline) const;
  39. Element* element_table = nullptr;
  40. TableWrapper* table_wrapper_box = nullptr;
  41. TableGrid grid;
  42. bool table_auto_height = false;
  43. Vector2f table_min_size, table_max_size;
  44. Vector2f table_gap;
  45. Vector2f table_content_offset;
  46. Vector2f table_initial_content_size;
  47. };
  48. } // namespace Rml