2022-03-10 16:46:44 +01:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
2022-03-10 16:46:44 +01:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2024-10-14 16:07:56 +02:00
|
|
|
#include <LibWeb/Layout/TextNode.h>
|
2022-03-10 23:13:37 +01:00
|
|
|
#include <LibWeb/Painting/PaintableBox.h>
|
2022-03-10 16:46:44 +01:00
|
|
|
|
|
|
|
|
namespace Web::Painting {
|
|
|
|
|
|
2023-01-11 14:02:53 +01:00
|
|
|
class TextPaintable final : public Paintable {
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_CELL(TextPaintable, Paintable);
|
|
|
|
|
GC_DECLARE_ALLOCATOR(TextPaintable);
|
2023-01-11 12:51:49 +01:00
|
|
|
|
2022-03-10 16:46:44 +01:00
|
|
|
public:
|
2024-11-15 04:01:23 +13:00
|
|
|
static GC::Ref<TextPaintable> create(Layout::TextNode const&, String const& text_for_rendering);
|
2022-03-10 16:46:44 +01:00
|
|
|
|
|
|
|
|
Layout::TextNode const& layout_node() const { return static_cast<Layout::TextNode const&>(Paintable::layout_node()); }
|
|
|
|
|
|
2022-03-10 22:46:35 +01:00
|
|
|
virtual bool wants_mouse_events() const override;
|
2022-11-02 17:35:53 +00:00
|
|
|
virtual DispatchEventOfSameName handle_mousedown(Badge<EventHandler>, CSSPixelPoint, unsigned button, unsigned modifiers) override;
|
|
|
|
|
virtual DispatchEventOfSameName handle_mouseup(Badge<EventHandler>, CSSPixelPoint, unsigned button, unsigned modifiers) override;
|
|
|
|
|
virtual DispatchEventOfSameName handle_mousemove(Badge<EventHandler>, CSSPixelPoint, unsigned button, unsigned modifiers) override;
|
2022-03-10 22:46:35 +01:00
|
|
|
|
2024-01-25 19:21:56 +01:00
|
|
|
void set_text_decoration_thickness(CSSPixels thickness) { m_text_decoration_thickness = thickness; }
|
|
|
|
|
CSSPixels text_decoration_thickness() const { return m_text_decoration_thickness; }
|
|
|
|
|
|
2024-03-18 10:25:57 +01:00
|
|
|
String const& text_for_rendering() const { return m_text_for_rendering; }
|
|
|
|
|
|
2022-03-10 16:46:44 +01:00
|
|
|
private:
|
2024-03-18 10:25:07 +01:00
|
|
|
virtual bool is_text_paintable() const override { return true; }
|
|
|
|
|
|
2024-03-18 10:25:57 +01:00
|
|
|
TextPaintable(Layout::TextNode const&, String const& text_for_rendering);
|
2024-01-25 19:21:56 +01:00
|
|
|
|
2024-03-18 10:25:57 +01:00
|
|
|
String m_text_for_rendering;
|
2024-01-25 19:21:56 +01:00
|
|
|
CSSPixels m_text_decoration_thickness { 0 };
|
2022-03-10 16:46:44 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|