mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-10 02:54:54 +03:00
f7e034d4b2
Previously, Frames could set both these properties along with a thickness to confusing effect: Most shapes of the same shadowing only differentiated at a thickness >= 2, and some not at all. This led to a lot of creative but ultimately superfluous choices in the code. Instead let's streamline our options, automate thickness, and get the right look without so much guesswork. Plain shadowing has been consolidated into a single Plain style, and 0 thickness can be had by setting style to NoFrame.
41 lines
1.1 KiB
C++
41 lines
1.1 KiB
C++
/*
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibGUI/Widget.h>
|
|
#include <LibGfx/StylePainter.h>
|
|
|
|
namespace GUI {
|
|
|
|
class Frame : public Widget {
|
|
C_OBJECT(Frame)
|
|
public:
|
|
virtual ~Frame() override = default;
|
|
|
|
int frame_thickness() const;
|
|
|
|
virtual Margins content_margins() const override { return { frame_thickness() }; }
|
|
|
|
Gfx::FrameStyle frame_style() const { return m_style; }
|
|
void set_frame_style(Gfx::FrameStyle);
|
|
|
|
Gfx::IntRect frame_inner_rect_for_size(Gfx::IntSize size) const { return { frame_thickness(), frame_thickness(), size.width() - frame_thickness() * 2, size.height() - frame_thickness() * 2 }; }
|
|
Gfx::IntRect frame_inner_rect() const { return frame_inner_rect_for_size(size()); }
|
|
|
|
virtual Gfx::IntRect children_clip_rect() const override;
|
|
|
|
protected:
|
|
Frame();
|
|
void paint_event(PaintEvent&) override;
|
|
|
|
private:
|
|
Gfx::FrameStyle m_style { Gfx::FrameStyle::NoFrame };
|
|
};
|
|
|
|
}
|