BoxLayout.h 1.2 KB

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