This repository was archived by the owner on Sep 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathuiwidgets_panel.h
More file actions
106 lines (67 loc) · 2.71 KB
/
Copy pathuiwidgets_panel.h
File metadata and controls
106 lines (67 loc) · 2.71 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#pragma once
#include <mutex>
#include <queue>
#include <map>
#include <flutter/fml/memory/ref_counted.h>
#include "shell/platform/unity/gfx_worker_task_runner.h"
#include "lib/ui/window/pointer_data.h"
#include "runtime/mono_api.h"
#include "cocoa_task_runner.h"
#include "unity_surface_manager.h"
namespace uiwidgets {
enum UIWidgetsWindowType {
InvalidPanel = 0,
GameObjectPanel = 1,
EditorWindowPanel = 2
};
enum UIWidgetsTouchPhase
{
TouchBegan,
TouchEnded,
TouchMoved,
TouchCancelled
};
class UIWidgetsPanel : public fml::RefCountedThreadSafe<UIWidgetsPanel> {
FML_FRIEND_MAKE_REF_COUNTED(UIWidgetsPanel);
public:
typedef void (*EntrypointCallback)(Mono_Handle handle);
static fml::RefPtr<UIWidgetsPanel> Create(
Mono_Handle handle, UIWidgetsWindowType window_type, EntrypointCallback entrypoint_callback);
~UIWidgetsPanel();
void* OnEnable(size_t width, size_t height, float device_pixel_ratio, const char* streaming_assets_path, const char* settings);
void MonoEntrypoint();
void OnDisable();
void* OnRenderTexture(size_t width, size_t height,
float dpi);
bool ReleaseNativeRenderTexture();
int RegisterTexture(void* native_texture_ptr);
void UnregisterTexture(int texture_id);
std::chrono::nanoseconds ProcessMessages();
void ProcessVSync(double frame_duration);
void VSyncCallback(intptr_t baton);
void SetEventLocationFromCursorPosition(UIWidgetsPointerEvent* event_data);
void OnKeyDown(int keyCode, bool isKeyDown, int64_t modifier);
void OnMouseMove(float x, float y, int button);
void OnScroll(float x, float y, float px, float py);
void OnMouseDown(float x, float y, int button);
void OnMouseUp(float x, float y, int button);
void OnMouseLeave();
bool NeedUpdateByPlayerLoop();
bool NeedUpdateByEditorLoop();
private:
UIWidgetsPanel(Mono_Handle handle, UIWidgetsWindowType window_type, EntrypointCallback entrypoint_callback);
void CreateInternalUIWidgetsEngine(size_t width, size_t height, float device_pixel_ratio, const char* streaming_assets_path, const char* settings);
void dispatchTouches(float x, float y, int button, UIWidgetsTouchPhase evtType);
static PointerData::Change PointerDataChangeFromUITouchPhase(UIWidgetsTouchPhase phase);
static PointerData::DeviceKind DeviceKindFromTouchType();
Mono_Handle handle_;
EntrypointCallback entrypoint_callback_;
UIWidgetsWindowType window_type_;
std::unique_ptr<UnitySurfaceManager> surface_manager_;
std::unique_ptr<GfxWorkerTaskRunner> gfx_worker_task_runner_;
std::unique_ptr<CocoaTaskRunner> task_runner_;
UIWidgetsEngine engine_ = nullptr;
std::vector<intptr_t> vsync_batons_;
bool process_events_ = false;
};
} // namespace uiwidgets