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
98 lines (63 loc) · 2.45 KB
/
Copy pathuiwidgets_panel.h
File metadata and controls
98 lines (63 loc) · 2.45 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
#pragma once
#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 "unity_surface_manager.h"
#include "android_task_runner.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(void* native_texture_ptr, size_t width, size_t height,
float device_pixel_ratio, const char* streaming_assets_path,
const char* settings);
void MonoEntrypoint();
void OnDisable();
void OnRenderTexture(void* native_texture_ptr, size_t width, size_t height,
float dpi);
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 OnKeyDown(int keyCode, bool isKeyDown, int64_t modifier);
void OnMouseMove(float x, float y, int button);
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 dispatchTouches(float x, float y, int button, UIWidgetsTouchPhase evtType);
static PointerData::Change PointerDataChangeFromUITouchPhase(UIWidgetsTouchPhase phase);
static PointerData::DeviceKind DeviceKindFromTouchType();
Mono_Handle handle_;
UIWidgetsWindowType window_type_;
EntrypointCallback entrypoint_callback_;
std::unique_ptr<UnitySurfaceManager> surface_manager_;
GLuint fbo_ = 0;
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