BoxLayout.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibGUI/Forward.h>
  8. #include <LibGUI/Layout.h>
  9. #include <LibGfx/Orientation.h>
  10. namespace GUI {
  11. class BoxLayout : public Layout {
  12. C_OBJECT(BoxLayout);
  13. public:
  14. virtual ~BoxLayout() override { }
  15. Gfx::Orientation orientation() const { return m_orientation; }
  16. virtual void run(Widget&) override;
  17. virtual Gfx::IntSize preferred_size() const override;
  18. protected:
  19. explicit BoxLayout(Gfx::Orientation);
  20. private:
  21. int preferred_primary_size() const;
  22. int preferred_secondary_size() const;
  23. Gfx::Orientation m_orientation;
  24. };
  25. class VerticalBoxLayout final : public BoxLayout {
  26. C_OBJECT(VerticalBoxLayout);
  27. public:
  28. explicit VerticalBoxLayout()
  29. : BoxLayout(Gfx::Orientation::Vertical)
  30. {
  31. }
  32. virtual ~VerticalBoxLayout() override { }
  33. };
  34. class HorizontalBoxLayout final : public BoxLayout {
  35. C_OBJECT(HorizontalBoxLayout);
  36. public:
  37. explicit HorizontalBoxLayout()
  38. : BoxLayout(Gfx::Orientation::Horizontal)
  39. {
  40. }
  41. virtual ~HorizontalBoxLayout() override { }
  42. };
  43. }