LabelablePaintable.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. JS_CELL(LabelablePaintable, PaintableBox);
  16. public:
  17. Layout::FormAssociatedLabelableNode const& layout_box() const;
  18. Layout::FormAssociatedLabelableNode& layout_box();
  19. virtual bool wants_mouse_events() const override { return true; }
  20. virtual DispatchEventOfSameName handle_mousedown(Badge<EventHandler>, CSSPixelPoint, unsigned button, unsigned modifiers) override;
  21. virtual DispatchEventOfSameName handle_mouseup(Badge<EventHandler>, CSSPixelPoint, unsigned button, unsigned modifiers) override;
  22. virtual DispatchEventOfSameName handle_mousemove(Badge<EventHandler>, CSSPixelPoint, unsigned buttons, unsigned modifiers) override;
  23. void handle_associated_label_mousedown(Badge<Layout::Label>);
  24. void handle_associated_label_mouseup(Badge<Layout::Label>);
  25. void handle_associated_label_mousemove(Badge<Layout::Label>, bool is_inside_node_or_label);
  26. bool being_pressed() const { return m_being_pressed; }
  27. // NOTE: Only the HTML node associated with this paintable should call this!
  28. void set_being_pressed(bool being_pressed);
  29. protected:
  30. LabelablePaintable(Layout::LabelableNode const&);
  31. private:
  32. bool m_being_pressed { false };
  33. bool m_tracking_mouse { false };
  34. };
  35. }