1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 22:38:12 +00:00
serenity/Userland/Libraries/LibWeb/Painting/VideoPaintable.h
Timothy Flynn 4555e3b8d2 LibWeb: Begin painting video controls on HTMLVideoElement layout nodes
If the video element has a 'controls' attribute, we now paint some basic
video controls over the video element. If no frame has been decoded yet,
we paint a play button on the center of the element.

If a frame has been decoded, we paint that frame and paint a control bar
on the bottom of the frame. This control bar currently only contains a
play/pause button, depending on the video's playback state. We will only
paint the control bar if the video is paused or hovered.
2023-04-08 22:04:14 +02:00

39 lines
1.3 KiB
C++

/*
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Optional.h>
#include <LibWeb/Forward.h>
#include <LibWeb/Painting/PaintableBox.h>
namespace Web::Painting {
class VideoPaintable final : public PaintableBox {
JS_CELL(VideoPaintable, PaintableBox);
public:
static JS::NonnullGCPtr<VideoPaintable> create(Layout::VideoBox const&);
virtual void paint(PaintContext&, PaintPhase) const override;
Layout::VideoBox& layout_box();
Layout::VideoBox const& layout_box() const;
private:
VideoPaintable(Layout::VideoBox const&);
virtual bool wants_mouse_events() const override { return true; }
virtual DispatchEventOfSameName handle_mouseup(Badge<EventHandler>, CSSPixelPoint, unsigned button, unsigned modifiers) override;
virtual DispatchEventOfSameName handle_mousemove(Badge<EventHandler>, CSSPixelPoint, unsigned buttons, unsigned modifiers) override;
void paint_loaded_video_controls(PaintContext&, HTML::HTMLVideoElement const&, DevicePixelRect video_rect, Optional<DevicePixelPoint> const& mouse_position) const;
void paint_placeholder_video_controls(PaintContext&, DevicePixelRect video_rect, Optional<DevicePixelPoint> const& mouse_position) const;
Optional<CSSPixelPoint> m_mouse_position;
};
}