2020-01-18 05:38:21 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
2022-02-26 14:50:04 -03:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2020-01-18 05:38:21 -03:00
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 05:38:21 -03:00
|
|
|
*/
|
|
|
|
|
|
2019-03-28 11:30:29 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
2020-02-06 16:33:02 -03:00
|
|
|
#include <LibGUI/Widget.h>
|
2020-09-18 04:49:51 -03:00
|
|
|
#include <LibGfx/StylePainter.h>
|
2019-03-28 11:30:29 -03:00
|
|
|
|
2020-02-02 11:07:41 -03:00
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
|
|
class Frame : public Widget {
|
|
|
|
|
C_OBJECT(Frame)
|
2019-03-28 11:30:29 -03:00
|
|
|
public:
|
2022-02-26 14:50:04 -03:00
|
|
|
virtual ~Frame() override = default;
|
2019-03-28 11:30:29 -03:00
|
|
|
|
|
|
|
|
int frame_thickness() const { return m_thickness; }
|
2020-04-24 13:55:29 -03:00
|
|
|
void set_frame_thickness(int thickness);
|
2019-03-28 11:30:29 -03:00
|
|
|
|
2021-09-15 18:12:28 -03:00
|
|
|
virtual Margins content_margins() const override { return { frame_thickness() }; }
|
|
|
|
|
|
2020-02-06 07:56:38 -03:00
|
|
|
Gfx::FrameShadow frame_shadow() const { return m_shadow; }
|
|
|
|
|
void set_frame_shadow(Gfx::FrameShadow shadow) { m_shadow = shadow; }
|
2019-03-28 11:30:29 -03:00
|
|
|
|
2020-02-06 07:56:38 -03:00
|
|
|
Gfx::FrameShape frame_shape() const { return m_shape; }
|
|
|
|
|
void set_frame_shape(Gfx::FrameShape shape) { m_shape = shape; }
|
2019-03-28 11:30:29 -03:00
|
|
|
|
2022-04-01 14:58:27 -03:00
|
|
|
Gfx::IntRect frame_inner_rect_for_size(Gfx::IntSize const& size) const { return { m_thickness, m_thickness, size.width() - m_thickness * 2, size.height() - m_thickness * 2 }; }
|
2020-06-10 05:57:59 -03:00
|
|
|
Gfx::IntRect frame_inner_rect() const { return frame_inner_rect_for_size(size()); }
|
2019-03-28 11:30:29 -03:00
|
|
|
|
2020-08-25 16:25:35 -03:00
|
|
|
virtual Gfx::IntRect children_clip_rect() const override;
|
|
|
|
|
|
2019-03-28 11:30:29 -03:00
|
|
|
protected:
|
2020-02-23 08:07:13 -03:00
|
|
|
Frame();
|
2020-02-02 11:07:41 -03:00
|
|
|
void paint_event(PaintEvent&) override;
|
2019-03-28 11:30:29 -03:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
int m_thickness { 0 };
|
2020-02-06 07:56:38 -03:00
|
|
|
Gfx::FrameShadow m_shadow { Gfx::FrameShadow::Plain };
|
|
|
|
|
Gfx::FrameShape m_shape { Gfx::FrameShape::NoFrame };
|
2019-03-28 11:30:29 -03:00
|
|
|
};
|
2020-02-02 11:07:41 -03:00
|
|
|
|
|
|
|
|
}
|