BoxLayout.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 Gfx::IntSize preferred_size() const override;
  19. protected:
  20. explicit BoxLayout(Gfx::Orientation);
  21. private:
  22. int preferred_primary_size() const;
  23. int preferred_secondary_size() const;
  24. Gfx::Orientation m_orientation;
  25. };
  26. class VerticalBoxLayout final : public BoxLayout {
  27. C_OBJECT(VerticalBoxLayout);
  28. private:
  29. explicit VerticalBoxLayout()
  30. : BoxLayout(Gfx::Orientation::Vertical)
  31. {
  32. }
  33. virtual ~VerticalBoxLayout() override = default;
  34. };
  35. class HorizontalBoxLayout final : public BoxLayout {
  36. C_OBJECT(HorizontalBoxLayout);
  37. private:
  38. explicit HorizontalBoxLayout()
  39. : BoxLayout(Gfx::Orientation::Horizontal)
  40. {
  41. }
  42. virtual ~HorizontalBoxLayout() override = default;
  43. };
  44. }