mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:38:12 +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.
39 lines
1.4 KiB
C++
39 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/Layout/ButtonBox.h>
|
|
#include <LibWeb/Painting/LabelablePaintable.h>
|
|
|
|
namespace Web::Painting {
|
|
|
|
class ButtonPaintable final : public LabelablePaintable {
|
|
public:
|
|
static NonnullRefPtr<ButtonPaintable> create(Layout::ButtonBox const&);
|
|
|
|
virtual void paint(PaintContext&, PaintPhase) const override;
|
|
|
|
Layout::ButtonBox const& layout_box() const;
|
|
Layout::ButtonBox& layout_box();
|
|
|
|
virtual bool wants_mouse_events() const override { return true; }
|
|
virtual void handle_mousedown(Badge<EventHandler>, Gfx::IntPoint const&, unsigned button, unsigned modifiers) override;
|
|
virtual void handle_mouseup(Badge<EventHandler>, Gfx::IntPoint const&, unsigned button, unsigned modifiers) override;
|
|
virtual void handle_mousemove(Badge<EventHandler>, Gfx::IntPoint const&, unsigned buttons, unsigned modifiers) override;
|
|
|
|
private:
|
|
ButtonPaintable(Layout::ButtonBox const&);
|
|
|
|
virtual void handle_associated_label_mousedown(Badge<Layout::Label>) override;
|
|
virtual void handle_associated_label_mouseup(Badge<Layout::Label>) override;
|
|
virtual void handle_associated_label_mousemove(Badge<Layout::Label>, bool is_inside_node_or_label) override;
|
|
|
|
bool m_being_pressed { false };
|
|
bool m_tracking_mouse { false };
|
|
};
|
|
|
|
}
|