mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:57:44 +00:00
LibWeb: Let Paintable perform the painting
This patch adds a bunch of Paintable subclasses, each corresponding to the Layout::Node subclasses that had a paint() override. All painting logic is moved from layout nodes into their corresponding paintables. Paintables are now created by asking a Layout::Box to produce one: static NonnullOwnPtr<Paintable> Layout::Box::create_paintable() Note that inline nodes still have their painting logic. Since they are not boxes, and all paintables have a corresponding box, we'll need to come up with some other solution for them.
This commit is contained in:
parent
f6497b64ac
commit
02b316fd5c
64 changed files with 1307 additions and 602 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.org>
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -11,7 +12,7 @@
|
|||
#include <LibWeb/HTML/BrowsingContext.h>
|
||||
#include <LibWeb/Layout/Label.h>
|
||||
#include <LibWeb/Layout/RadioButton.h>
|
||||
#include <LibWeb/Painting/Paintable.h>
|
||||
#include <LibWeb/Painting/RadioButtonPaintable.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
||||
|
@ -26,18 +27,6 @@ RadioButton::~RadioButton()
|
|||
{
|
||||
}
|
||||
|
||||
void RadioButton::paint(PaintContext& context, Painting::PaintPhase phase)
|
||||
{
|
||||
if (!is_visible())
|
||||
return;
|
||||
|
||||
LabelableNode::paint(context, phase);
|
||||
|
||||
if (phase == Painting::PaintPhase::Foreground) {
|
||||
Gfx::StylePainter::paint_radio_button(context.painter(), enclosing_int_rect(m_paint_box->absolute_rect()), context.palette(), dom_node().checked(), m_being_pressed);
|
||||
}
|
||||
}
|
||||
|
||||
void RadioButton::handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned)
|
||||
{
|
||||
if (button != GUI::MouseButton::Primary || !dom_node().enabled())
|
||||
|
@ -125,4 +114,9 @@ void RadioButton::set_checked_within_group()
|
|||
});
|
||||
}
|
||||
|
||||
OwnPtr<Painting::Paintable> RadioButton::create_paintable() const
|
||||
{
|
||||
return Painting::RadioButtonPaintable::create(*this);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue