androidwindow.h

main 100 lines · 2.3 KB Raw
Alex Alex Commit Client Upload Part 2 19/10/2026 00:06
1#ifndef ANDROID_WINDOW_H
2#define ANDROID_WINDOW_H
3
4#include "platformwindow.h"
5
6class AndroidWindow : public PlatformWindow {
7 enum EventType {
8 TOUCH_DOWN,
9 TOUCH_UP,
10 TOUCH_MOTION,
11 TOUCH_LONGPRESS,
12 KEY_DOWN,
13 KEY_UP,
14 TEXTINPUT,
15 EVENT_UNDEFINED
16 };
17
18 enum NativeMessage {
19 RECREATE_CONTEXT,
20 APP_TERMINATE
21 };
22
23 void internalInitGL();
24 void internalDestroyGL();
25
26 void internalCheckGL();
27 void internalChooseGL();
28 void internalCreateGLContext();
29 void internalDestroyGLContext();
30 void internalConnectGLContext();
31
32
33public:
34 AndroidWindow();
35 ~AndroidWindow();
36
37 void init();
38 void init(struct android_app* app);
39 void terminate();
40 void move(const Point& pos);
41 void resize(const Size& size);
42 void show();
43 void hide();
44 void minimize();
45 void maximize();
46 void poll();
47 void swapBuffers();
48 void showMouse();
49 void hideMouse();
50
51 void setMouseCursor(int cursorId);
52 void restoreMouseCursor();
53
54 void setTitle(const std::string& title);
55 void setMinimumSize(const Size& minimumSize);
56 void setFullscreen(bool fullscreen);
57 void setVerticalSync(bool enable);
58 void setIcon(const std::string& iconFile);
59 void setClipboardText(const std::string& text);
60
61 Size getDisplaySize();
62 std::string getClipboardText();
63 std::string getPlatformType();
64
65 void displayFatalError(const std::string& message) override;
66 void showTextEditor(const std::string& title, const std::string& description, const std::string& text, int flags) override;
67
68 void handleCmd(int32_t cmd);
69 int handleInput(AInputEvent* event);
70 void updateSize();
71 void handleTextInput(std::string text);
72 void openUrl(std::string url);
73
74protected:
75 int internalLoadMouseCursor(const ImagePtr& image, const Point& hotSpot) override { return -1; };
76
77 JNIEnv* getJNIEnv()
78 {
79 return g_androidState->activity->env;
80 }
81 JavaVM* getJavaVM()
82 {
83 return g_androidState->activity->vm;
84 }
85 jobject getClazz()
86 {
87 return g_androidState->activity->clazz;
88 }
89
90private:
91 EGLConfig m_eglConfig;
92 EGLContext m_eglContext;
93 EGLDisplay m_eglDisplay;
94 EGLSurface m_eglSurface;
95 InputEvent m_multiInputEvent[3];
96};
97
98extern AndroidWindow g_androidWindow;;
99
100#endif
Top