Layout.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #ifndef LAYOUT_H_
  2. #define LAYOUT_H_
  3. #include "Ref.h"
  4. namespace gameplay
  5. {
  6. class Container;
  7. /**
  8. * The layout interface for UI containers.
  9. *
  10. * Implementations of this interface are responsible for positioning, resizing
  11. * and then calling update on all the controls within a container.
  12. */
  13. class Layout : public Ref
  14. {
  15. friend class Container;
  16. public:
  17. /**
  18. * Layout types available to containers.
  19. */
  20. enum Type
  21. {
  22. /**
  23. * Flow layout: Controls are placed next to one another horizontally
  24. * until the right-most edge of the container is reached, at which point
  25. * a new row is started.
  26. */
  27. LAYOUT_FLOW,
  28. /**
  29. * Vertical layout: Controls are placed next to one another vertically until
  30. * the bottom-most edge of the container is reached.
  31. */
  32. LAYOUT_VERTICAL,
  33. /**
  34. * Absolute layout: Controls are not modified at all by this layout.
  35. * They must be positioned and sized manually.
  36. */
  37. LAYOUT_ABSOLUTE
  38. };
  39. /**
  40. * Get the type of this layout.
  41. *
  42. * @return The type of this layout.
  43. */
  44. virtual Type getType() = 0;
  45. protected:
  46. /**
  47. * Position, resize, and update the controls within a container.
  48. *
  49. * @param container The container to update.
  50. */
  51. virtual void update(const Container* container) = 0;
  52. };
  53. }
  54. #endif