2020-01-18 05:38:21 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 05:38:21 -03:00
|
|
|
*/
|
|
|
|
|
|
2019-02-10 08:07:13 -02:00
|
|
|
#pragma once
|
|
|
|
|
|
2020-02-16 05:17:49 -03:00
|
|
|
#include <LibGUI/Forward.h>
|
2020-02-06 16:33:02 -03:00
|
|
|
#include <LibGUI/Layout.h>
|
2020-02-16 05:17:49 -03:00
|
|
|
#include <LibGfx/Orientation.h>
|
2019-02-10 08:07:13 -02:00
|
|
|
|
2020-02-02 11:07:41 -03:00
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
|
|
class BoxLayout : public Layout {
|
2020-03-05 05:21:46 -03:00
|
|
|
C_OBJECT(BoxLayout);
|
2020-09-18 04:49:51 -03:00
|
|
|
|
2019-02-10 08:07:13 -02:00
|
|
|
public:
|
2020-09-18 04:49:51 -03:00
|
|
|
virtual ~BoxLayout() override { }
|
2019-02-10 08:07:13 -02:00
|
|
|
|
2020-02-16 05:17:49 -03:00
|
|
|
Gfx::Orientation orientation() const { return m_orientation; }
|
2019-02-10 08:07:13 -02:00
|
|
|
|
2020-02-02 11:07:41 -03:00
|
|
|
virtual void run(Widget&) override;
|
2021-01-04 14:17:14 -03:00
|
|
|
virtual Gfx::IntSize preferred_size() const override;
|
2019-02-10 08:07:13 -02:00
|
|
|
|
2020-03-05 05:21:46 -03:00
|
|
|
protected:
|
|
|
|
|
explicit BoxLayout(Gfx::Orientation);
|
|
|
|
|
|
2019-02-10 08:07:13 -02:00
|
|
|
private:
|
2021-01-04 14:17:14 -03:00
|
|
|
int preferred_primary_size() const;
|
|
|
|
|
int preferred_secondary_size() const;
|
|
|
|
|
|
2020-02-16 05:17:49 -03:00
|
|
|
Gfx::Orientation m_orientation;
|
2019-02-10 08:07:13 -02:00
|
|
|
};
|
2020-02-02 05:48:11 -03:00
|
|
|
|
2020-02-06 10:44:13 -03:00
|
|
|
class VerticalBoxLayout final : public BoxLayout {
|
2020-03-05 05:21:46 -03:00
|
|
|
C_OBJECT(VerticalBoxLayout);
|
2020-09-18 04:49:51 -03:00
|
|
|
|
2020-02-02 05:48:11 -03:00
|
|
|
public:
|
2020-02-06 10:44:13 -03:00
|
|
|
explicit VerticalBoxLayout()
|
2020-02-16 05:17:49 -03:00
|
|
|
: BoxLayout(Gfx::Orientation::Vertical)
|
2020-02-02 05:48:11 -03:00
|
|
|
{
|
|
|
|
|
}
|
2020-09-18 04:49:51 -03:00
|
|
|
virtual ~VerticalBoxLayout() override { }
|
2020-02-02 05:48:11 -03:00
|
|
|
};
|
|
|
|
|
|
2020-02-06 10:44:13 -03:00
|
|
|
class HorizontalBoxLayout final : public BoxLayout {
|
2020-03-05 05:21:46 -03:00
|
|
|
C_OBJECT(HorizontalBoxLayout);
|
2020-09-18 04:49:51 -03:00
|
|
|
|
2020-02-02 05:48:11 -03:00
|
|
|
public:
|
2020-02-06 10:44:13 -03:00
|
|
|
explicit HorizontalBoxLayout()
|
2020-02-16 05:17:49 -03:00
|
|
|
: BoxLayout(Gfx::Orientation::Horizontal)
|
2020-02-02 05:48:11 -03:00
|
|
|
{
|
|
|
|
|
}
|
2020-09-18 04:49:51 -03:00
|
|
|
virtual ~HorizontalBoxLayout() override { }
|
2020-02-02 05:48:11 -03:00
|
|
|
};
|
2020-02-02 11:07:41 -03:00
|
|
|
|
|
|
|
|
}
|