LabelablePaintable.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2022, sin-ack <sin-ack@protonmail.com>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <LibWeb/HTML/FormAssociatedElement.h>
  9. #include <LibWeb/Layout/FormAssociatedLabelableNode.h>
  10. #include <LibWeb/Painting/PaintableBox.h>
  11. namespace Web::Painting {
  12. // FIXME: Splinter this into FormAssociatedLabelablePaintable once
  13. // ProgressPaintable switches over to this.
  14. class LabelablePaintable : public PaintableBox {
  15. public:
  16. Layout::FormAssociatedLabelableNode const& layout_box() const;
  17. Layout::FormAssociatedLabelableNode& layout_box();
  18. virtual bool wants_mouse_events() const override { return true; }
  19. virtual DispatchEventOfSameName handle_mousedown(Badge<EventHandler>, Gfx::IntPoint const&, unsigned button, unsigned modifiers) override;
  20. virtual DispatchEventOfSameName handle_mouseup(Badge<EventHandler>, Gfx::IntPoint const&, unsigned button, unsigned modifiers) override;
  21. virtual DispatchEventOfSameName handle_mousemove(Badge<EventHandler>, Gfx::IntPoint const&, unsigned buttons, unsigned modifiers) override;
  22. void handle_associated_label_mousedown(Badge<Layout::Label>);
  23. void handle_associated_label_mouseup(Badge<Layout::Label>);
  24. void handle_associated_label_mousemove(Badge<Layout::Label>, bool is_inside_node_or_label);
  25. bool being_pressed() const { return m_being_pressed; }
  26. // NOTE: Only the HTML node associated with this paintable should call this!
  27. void set_being_pressed(bool being_pressed);
  28. protected:
  29. LabelablePaintable(Layout::LabelableNode const&);
  30. private:
  31. bool m_being_pressed { false };
  32. bool m_tracking_mouse { false };
  33. };
  34. }