2022-03-10 21:46:35 +00:00
|
|
|
/*
|
2024-10-04 11:19:50 +00:00
|
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
2022-03-14 23:05:55 +00:00
|
|
|
* Copyright (c) 2022, sin-ack <sin-ack@protonmail.com>
|
2022-03-10 21:46:35 +00:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-03-14 23:05:55 +00:00
|
|
|
#include <LibWeb/HTML/FormAssociatedElement.h>
|
|
|
|
#include <LibWeb/Layout/FormAssociatedLabelableNode.h>
|
2022-03-10 22:13:37 +00:00
|
|
|
#include <LibWeb/Painting/PaintableBox.h>
|
2022-03-10 21:46:35 +00:00
|
|
|
|
|
|
|
namespace Web::Painting {
|
|
|
|
|
2022-03-14 23:05:55 +00:00
|
|
|
// FIXME: Splinter this into FormAssociatedLabelablePaintable once
|
|
|
|
// ProgressPaintable switches over to this.
|
2022-03-10 21:46:35 +00:00
|
|
|
class LabelablePaintable : public PaintableBox {
|
2024-11-14 15:01:23 +00:00
|
|
|
GC_CELL(LabelablePaintable, PaintableBox);
|
2023-01-11 11:51:49 +00:00
|
|
|
|
2022-03-10 21:46:35 +00:00
|
|
|
public:
|
2022-03-14 23:05:55 +00:00
|
|
|
Layout::FormAssociatedLabelableNode const& layout_box() const;
|
|
|
|
Layout::FormAssociatedLabelableNode& layout_box();
|
2022-03-10 21:46:35 +00:00
|
|
|
|
2022-03-14 23:05:55 +00:00
|
|
|
virtual bool wants_mouse_events() const override { return true; }
|
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 buttons, unsigned modifiers) override;
|
2022-03-14 23:05:55 +00:00
|
|
|
|
|
|
|
void handle_associated_label_mousedown(Badge<Layout::Label>);
|
|
|
|
void handle_associated_label_mouseup(Badge<Layout::Label>);
|
|
|
|
void handle_associated_label_mousemove(Badge<Layout::Label>, bool is_inside_node_or_label);
|
|
|
|
|
|
|
|
bool being_pressed() const { return m_being_pressed; }
|
|
|
|
// NOTE: Only the HTML node associated with this paintable should call this!
|
|
|
|
void set_being_pressed(bool being_pressed);
|
2022-03-10 21:46:35 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
LabelablePaintable(Layout::LabelableNode const&);
|
2022-03-14 23:05:55 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
bool m_being_pressed { false };
|
|
|
|
bool m_tracking_mouse { false };
|
2022-03-10 21:46:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|