mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:08:10 +00:00

Input events have nothing to do with layout, so let's not send them to layout nodes. The job of Paintable starts to become clear. It represents a paintable item that can be rendered into the viewport, which means it can also be targeted by the mouse cursor.
28 lines
933 B
C++
28 lines
933 B
C++
/*
|
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/Painting/Paintable.h>
|
|
|
|
namespace Web::Painting {
|
|
|
|
class TextPaintable : public Paintable {
|
|
public:
|
|
static NonnullRefPtr<TextPaintable> create(Layout::TextNode const&);
|
|
|
|
Layout::TextNode const& layout_node() const { return static_cast<Layout::TextNode const&>(Paintable::layout_node()); }
|
|
|
|
virtual bool wants_mouse_events() const override;
|
|
virtual void handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers) override;
|
|
virtual void handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers) override;
|
|
virtual void handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers) override;
|
|
|
|
private:
|
|
explicit TextPaintable(Layout::TextNode const&);
|
|
};
|
|
|
|
}
|