Serenity Operating System
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
8#pragma once
9
10#include <LibGUI/Forward.h>
11#include <LibGUI/Layout.h>
12#include <LibGfx/Orientation.h>
13
14namespace GUI {
15
16class BoxLayout : public Layout {
17 C_OBJECT(BoxLayout);
18
19public:
20 virtual ~BoxLayout() override = default;
21
22 Gfx::Orientation orientation() const { return m_orientation; }
23
24 virtual void run(Widget&) override;
25 virtual UISize preferred_size() const override;
26 virtual UISize min_size() const override;
27
28protected:
29 explicit BoxLayout(Gfx::Orientation, Margins = {}, int spacing = Layout::default_spacing);
30
31private:
32 Gfx::Orientation m_orientation;
33};
34
35class VerticalBoxLayout final : public BoxLayout {
36 C_OBJECT(VerticalBoxLayout);
37
38private:
39 explicit VerticalBoxLayout(Margins margins = {}, int spacing = Layout::default_spacing)
40 : BoxLayout(Gfx::Orientation::Vertical, margins, spacing)
41 {
42 }
43 virtual ~VerticalBoxLayout() override = default;
44};
45
46class HorizontalBoxLayout final : public BoxLayout {
47 C_OBJECT(HorizontalBoxLayout);
48
49private:
50 explicit HorizontalBoxLayout(Margins margins = {}, int spacing = Layout::default_spacing)
51 : BoxLayout(Gfx::Orientation::Horizontal, margins, spacing)
52 {
53 }
54 virtual ~HorizontalBoxLayout() override = default;
55};
56
57}