summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/UIEvents/MouseEvent.h
blob: 8f56dac9e54d5fc00f0bdf153d051ad6b68a8e2d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/TypeCasts.h>
#include <LibWeb/UIEvents/UIEvent.h>

namespace Web::UIEvents {

class MouseEvent final : public UIEvents::UIEvent {
public:
    using WrapperType = Bindings::MouseEventWrapper;

    static NonnullRefPtr<MouseEvent> create(const FlyString& event_name, i32 offset_x, i32 offset_y, i32 client_x, i32 client_y)
    {
        return adopt_ref(*new MouseEvent(event_name, offset_x, offset_y, client_x, client_y));
    }

    virtual ~MouseEvent() override;

    i32 offset_x() const { return m_offset_x; }
    i32 offset_y() const { return m_offset_y; }
    i32 client_x() const { return m_client_x; }
    i32 client_y() const { return m_client_y; }

protected:
    MouseEvent(const FlyString& event_name, i32 offset_x, i32 offset_y, i32 client_x, i32 client_y);

private:
    void set_event_characteristics();

    i32 m_offset_x { 0 };
    i32 m_offset_y { 0 };
    i32 m_client_x { 0 };
    i32 m_client_y { 0 };
};

}