layout.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #ifndef LAYOUT_H
  2. #define LAYOUT_H
  3. #include <vector>
  4. #include <functional>
  5. #include "implementation.h"
  6. template <typename Range>
  7. int2 select_corner(const Range& rng, int2 direction) noexcept;
  8. template <typename ForwardItr>
  9. constexpr void layout_bounds(ForwardItr begin, ForwardItr end, const int2& spacing);
  10. template <typename Range>
  11. constexpr void layout_bounds(Range range, const int2& spacing)
  12. {
  13. using std::begin;
  14. using std::end;
  15. layout_bounds(begin(range), end(range), spacing);
  16. }
  17. template <typename Range>
  18. class bounds_layout : public movable_bounds
  19. {
  20. public:
  21. bounds_layout(Range elements, int2 spacing = int2::zero());
  22. bounds_layout(int2 spacing);
  23. bounds_layout& operator+=(const int2&) override;
  24. range2D update();
  25. private:
  26. Range elements;
  27. int2 spacing;
  28. };
  29. template <typename R> bounds_layout(R) -> bounds_layout<R>;
  30. template <typename R> bounds_layout(R, int2) -> bounds_layout<R>;
  31. using bounds_layout_vector = bounds_layout<std::vector<i_movable_bounds<int2>*>>;
  32. #endif /* end of include guard */