From 6ae72ea4624eb7bcae28a6dd40e75c6ee829f094 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Mon, 9 Jul 2018 15:31:55 -0700 Subject: [PATCH] Native cleanup, merge lime.ui.Mouse into Window --- .vscode/settings.json | 3 +- project/Build.xml | 4 +- project/include/text/TextLayout.h | 51 --- project/include/ui/Cursor.h | 31 ++ project/include/ui/Mouse.h | 30 -- project/include/ui/MouseCursor.h | 30 -- project/include/ui/Window.h | 9 +- project/include/ui/WindowEvent.h | 1 + project/src/ExternalInterface.cpp | 401 +++++------------- project/src/backend/sdl/SDLApplication.cpp | 2 + .../backend/sdl/{SDLMouse.h => SDLCursor.h} | 9 +- project/src/backend/sdl/SDLMouse.cpp | 203 --------- project/src/backend/sdl/SDLWindow.cpp | 240 ++++++++++- project/src/backend/sdl/SDLWindow.h | 10 +- project/src/text/TextLayout.cpp | 149 ------- .../_internal/backend/flash/FlashMouse.hx | 120 ------ .../_internal/backend/flash/FlashWindow.hx | 103 ++++- .../_internal/backend/html5/HTML5Mouse.hx | 115 ----- .../_internal/backend/html5/HTML5Window.hx | 226 +++++----- .../backend/native/NativeApplication.hx | 18 +- .../_internal/backend/native/NativeCFFI.hx | 72 ++-- .../_internal/backend/native/NativeMouse.hx | 168 -------- .../_internal/backend/native/NativeWindow.hx | 123 +++++- src/lime/ui/{MouseCursor.hx => Cursor.hx} | 2 +- src/lime/ui/Mouse.hx | 90 ---- src/lime/ui/Window.hx | 74 +++- 26 files changed, 811 insertions(+), 1473 deletions(-) delete mode 100644 project/include/text/TextLayout.h create mode 100644 project/include/ui/Cursor.h delete mode 100644 project/include/ui/Mouse.h delete mode 100644 project/include/ui/MouseCursor.h rename project/src/backend/sdl/{SDLMouse.h => SDLCursor.h} (76%) delete mode 100644 project/src/backend/sdl/SDLMouse.cpp delete mode 100644 project/src/text/TextLayout.cpp delete mode 100644 src/lime/_internal/backend/flash/FlashMouse.hx delete mode 100644 src/lime/_internal/backend/html5/HTML5Mouse.hx delete mode 100644 src/lime/_internal/backend/native/NativeMouse.hx rename src/lime/ui/{MouseCursor.hx => Cursor.hx} (88%) delete mode 100644 src/lime/ui/Mouse.hx diff --git a/.vscode/settings.json b/.vscode/settings.json index e89c82021..cbb89a340 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -40,6 +40,7 @@ "functional": "cpp", "tuple": "cpp", "utility": "cpp", - "sstream": "cpp" + "sstream": "cpp", + "mutex": "cpp" } } \ No newline at end of file diff --git a/project/Build.xml b/project/Build.xml index e1bca6ade..18dbfd8d2 100644 --- a/project/Build.xml +++ b/project/Build.xml @@ -120,7 +120,6 @@ - @@ -246,13 +245,12 @@ - - + diff --git a/project/include/text/TextLayout.h b/project/include/text/TextLayout.h deleted file mode 100644 index 8736e6495..000000000 --- a/project/include/text/TextLayout.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef LIME_TEXT_TEXT_LAYOUT_H -#define LIME_TEXT_TEXT_LAYOUT_H - - -#include -#include - - -namespace lime { - - - typedef struct { - - uint32_t codepoint; - uint32_t index; - float advanceX; - float advanceY; - float offsetX; - float offsetY; - - } GlyphPosition; - - class TextLayout { - - - public: - - TextLayout (int direction, const char *script, const char *language); - ~TextLayout (); - - void Position (Font *font, size_t size, const char *text, Bytes *bytes); - void SetDirection (int direction); - void SetLanguage (const char* language); - void SetScript (const char* script); - - private: - - Font *mFont; - void *mHBFont; - void *mBuffer; - int mDirection; - int mScript; - void *mLanguage; - - }; - - -} - - -#endif diff --git a/project/include/ui/Cursor.h b/project/include/ui/Cursor.h new file mode 100644 index 000000000..712a2974b --- /dev/null +++ b/project/include/ui/Cursor.h @@ -0,0 +1,31 @@ +#ifndef LIME_UI_CURSOR_H +#define LIME_UI_CURSOR_H + + +namespace lime { + + + enum Cursor { + + HIDDEN, + ARROW, + CROSSHAIR, + DEFAULT, + MOVE, + POINTER, + RESIZE_NESW, + RESIZE_NS, + RESIZE_NWSE, + RESIZE_WE, + TEXT, + WAIT, + WAIT_ARROW, + CUSTOM + + }; + + +} + + +#endif \ No newline at end of file diff --git a/project/include/ui/Mouse.h b/project/include/ui/Mouse.h deleted file mode 100644 index 5faf937b0..000000000 --- a/project/include/ui/Mouse.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef LIME_UI_MOUSE_H -#define LIME_UI_MOUSE_H - - -#include -#include - - -namespace lime { - - - class Mouse { - - public: - - static MouseCursor currentCursor; - - static void Hide (); - static void SetCursor (MouseCursor cursor); - static void SetLock (bool lock); - static void Show (); - static void Warp (int x, int y, Window* window); - - }; - - -} - - -#endif \ No newline at end of file diff --git a/project/include/ui/MouseCursor.h b/project/include/ui/MouseCursor.h deleted file mode 100644 index 5194f025d..000000000 --- a/project/include/ui/MouseCursor.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef LIME_UI_MOUSE_CURSOR_H -#define LIME_UI_MOUSE_CURSOR_H - - -namespace lime { - - - enum MouseCursor { - - ARROW, - CROSSHAIR, - DEFAULT, - MOVE, - POINTER, - RESIZE_NESW, - RESIZE_NS, - RESIZE_NWSE, - RESIZE_WE, - TEXT, - WAIT, - WAIT_ARROW, - CUSTOM - - }; - - -} - - -#endif \ No newline at end of file diff --git a/project/include/ui/Window.h b/project/include/ui/Window.h index 556882a78..055c39329 100644 --- a/project/include/ui/Window.h +++ b/project/include/ui/Window.h @@ -33,12 +33,14 @@ namespace lime { virtual void Focus () = 0; virtual void* GetContext () = 0; virtual const char* GetContextType () = 0; + // virtual Cursor GetCursor () = 0; virtual int GetDisplay () = 0; virtual void GetDisplayMode (DisplayMode* displayMode) = 0; - virtual bool GetEnableTextEvents () = 0; virtual int GetHeight () = 0; virtual uint32_t GetID () = 0; + virtual bool GetMouseLock () = 0; virtual double GetScale () = 0; + virtual bool GetTextInputEnabled () = 0; virtual int GetWidth () = 0; virtual int GetX () = 0; virtual int GetY () = 0; @@ -46,14 +48,17 @@ namespace lime { virtual void ReadPixels (ImageBuffer *buffer, Rectangle *rect) = 0; virtual void Resize (int width, int height) = 0; virtual bool SetBorderless (bool borderless) = 0; + virtual void SetCursor (Cursor cursor) = 0; virtual void SetDisplayMode (DisplayMode* displayMode) = 0; - virtual void SetEnableTextEvents (bool enable) = 0; virtual bool SetFullscreen (bool fullscreen) = 0; virtual void SetIcon (ImageBuffer *imageBuffer) = 0; virtual bool SetMaximized (bool minimized) = 0; virtual bool SetMinimized (bool minimized) = 0; + virtual void SetMouseLock (bool mouseLock) = 0; virtual bool SetResizable (bool resizable) = 0; + virtual void SetTextInputEnabled (bool enable) = 0; virtual const char* SetTitle (const char* title) = 0; + virtual void WarpMouse (int x, int y) = 0; Application* currentApplication; int flags; diff --git a/project/include/ui/WindowEvent.h b/project/include/ui/WindowEvent.h index 83ab56992..9371d5e36 100644 --- a/project/include/ui/WindowEvent.h +++ b/project/include/ui/WindowEvent.h @@ -20,6 +20,7 @@ namespace lime { WINDOW_FOCUS_IN, WINDOW_FOCUS_OUT, WINDOW_LEAVE, + WINDOW_MAXIMIZE, WINDOW_MINIMIZE, WINDOW_MOVE, WINDOW_RESIZE, diff --git a/project/src/ExternalInterface.cpp b/project/src/ExternalInterface.cpp index ce566efe6..553b01ab7 100644 --- a/project/src/ExternalInterface.cpp +++ b/project/src/ExternalInterface.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -39,8 +39,6 @@ #include #include #include -#include -#include #include #include #include @@ -112,26 +110,6 @@ namespace lime { } - void gc_text_layout (value handle) { - - #ifdef LIME_HARFBUZZ - TextLayout *text = (TextLayout*)val_data (handle); - delete text; - #endif - - } - - - void hl_gc_text_layout (HL_CFFIPointer* handle) { - - #ifdef LIME_HARFBUZZ - TextLayout* text = (TextLayout*)handle->ptr; - delete text; - #endif - - } - - void gc_window (value handle) { Window* window = (Window*)val_data (handle); @@ -2495,92 +2473,6 @@ namespace lime { } - void lime_mouse_hide () { - - Mouse::Hide (); - - } - - - HL_PRIM void hl_lime_mouse_hide () { - - Mouse::Hide (); - - } - - - void lime_mouse_set_cursor (int cursor) { - - Mouse::SetCursor ((MouseCursor)cursor); - - } - - - HL_PRIM void hl_lime_mouse_set_cursor (int cursor) { - - Mouse::SetCursor ((MouseCursor)cursor); - - } - - - void lime_mouse_set_lock (bool lock) { - - Mouse::SetLock (lock); - - } - - - HL_PRIM void hl_lime_mouse_set_lock (bool lock) { - - Mouse::SetLock (lock); - - } - - - void lime_mouse_show () { - - Mouse::Show (); - - } - - - HL_PRIM void hl_lime_mouse_show () { - - Mouse::Show (); - - } - - - void lime_mouse_warp (int x, int y, value window) { - - Window* windowRef = 0; - - if (window) { - - windowRef = (Window*)val_data (window); - - } - - Mouse::Warp (x, y, windowRef); - - } - - - HL_PRIM void hl_lime_mouse_warp (int x, int y, HL_CFFIPointer* window) { - - Window* windowRef = 0; - - if (window) { - - windowRef = (Window*)window->ptr; - - } - - Mouse::Warp (x, y, windowRef); - - } - - void lime_neko_execute (HxString module) { #ifdef LIME_NEKO @@ -3128,133 +3020,6 @@ namespace lime { } - value lime_text_layout_create (int direction, HxString script, HxString language) { - - #if defined (LIME_FREETYPE) && defined (LIME_HARFBUZZ) - - TextLayout *text = new TextLayout (direction, script.c_str (), language.c_str ()); - return CFFIPointer (text, gc_text_layout); - - #else - - return alloc_null (); - - #endif - - } - - - HL_PRIM HL_CFFIPointer* hl_lime_text_layout_create (int direction, hl_vstring* script, hl_vstring* language) { - - #if defined (LIME_FREETYPE) && defined (LIME_HARFBUZZ) - - TextLayout *text = new TextLayout (direction, script ? (char*)hl_to_utf8 ((const uchar*)script->bytes) : NULL, language ? (char*)hl_to_utf8 ((const uchar*)language->bytes) : NULL); - return HLCFFIPointer (text, (hl_finalizer)hl_gc_text_layout); - - #else - - return 0; - - #endif - - } - - - value lime_text_layout_position (value textHandle, value fontHandle, int size, HxString textString, value data) { - - #if defined (LIME_FREETYPE) && defined (LIME_HARFBUZZ) - - TextLayout *text = (TextLayout*)val_data (textHandle); - Font *font = (Font*)val_data (fontHandle); - Bytes bytes (data); - - text->Position (font, size, textString.c_str (), &bytes); - - return bytes.Value (data); - - #endif - - return alloc_null (); - - } - - - HL_PRIM Bytes* hl_lime_text_layout_position (HL_CFFIPointer* textHandle, HL_CFFIPointer* fontHandle, int size, hl_vstring* textString, Bytes* data) { - - #if defined(LIME_FREETYPE) && defined(LIME_HARFBUZZ) - - TextLayout* text = (TextLayout*)textHandle->ptr; - Font* font = (Font*)fontHandle->ptr; - text->Position (font, size, textString ? hl_to_utf8 ((const uchar*)textString->bytes) : NULL, data); - return data; - - #endif - - return 0; - - } - - - void lime_text_layout_set_direction (value textHandle, int direction) { - - #if defined (LIME_FREETYPE) && defined (LIME_HARFBUZZ) - TextLayout *text = (TextLayout*)val_data (textHandle); - text->SetDirection (direction); - #endif - - } - - - HL_PRIM void hl_lime_text_layout_set_direction (HL_CFFIPointer* textHandle, int direction) { - - #if defined (LIME_FREETYPE) && defined (LIME_HARFBUZZ) - TextLayout *text = (TextLayout*)textHandle->ptr; - text->SetDirection (direction); - #endif - - } - - - void lime_text_layout_set_language (value textHandle, HxString language) { - - #if defined (LIME_FREETYPE) && defined (LIME_HARFBUZZ) - TextLayout *text = (TextLayout*)val_data (textHandle); - text->SetLanguage (language.c_str ()); - #endif - - } - - - HL_PRIM void hl_lime_text_layout_set_language (HL_CFFIPointer* textHandle, hl_vstring* language) { - - #if defined (LIME_FREETYPE) && defined (LIME_HARFBUZZ) - TextLayout *text = (TextLayout*)textHandle->ptr; - text->SetLanguage ((char*)hl_to_utf8 ((const uchar*)language->bytes)); - #endif - - } - - - void lime_text_layout_set_script (value textHandle, HxString script) { - - #if defined (LIME_FREETYPE) && defined (LIME_HARFBUZZ) - TextLayout *text = (TextLayout*)val_data (textHandle); - text->SetScript (script.c_str ()); - #endif - - } - - - HL_PRIM void hl_lime_text_layout_set_script (HL_CFFIPointer* textHandle, hl_vstring* script) { - - #if defined (LIME_FREETYPE) && defined (LIME_HARFBUZZ) - TextLayout *text = (TextLayout*)textHandle->ptr; - text->SetScript ((char*)hl_to_utf8 ((const uchar*)script->bytes)); - #endif - - } - - void lime_touch_event_manager_register (value callback, value eventObject) { TouchEvent::callback = new ValuePointer (callback); @@ -3476,22 +3241,6 @@ namespace lime { } - bool lime_window_get_enable_text_events (value window) { - - Window* targetWindow = (Window*)val_data (window); - return targetWindow->GetEnableTextEvents (); - - } - - - HL_PRIM bool hl_lime_window_get_enable_text_events (HL_CFFIPointer* window) { - - Window* targetWindow = (Window*)window->ptr; - return targetWindow->GetEnableTextEvents (); - - } - - int lime_window_get_height (value window) { Window* targetWindow = (Window*)val_data (window); @@ -3524,6 +3273,22 @@ namespace lime { } + bool lime_window_get_mouse_lock (value window) { + + Window* targetWindow = (Window*)val_data (window); + return targetWindow->GetMouseLock (); + + } + + + HL_PRIM bool hl_lime_window_get_mouse_lock (HL_CFFIPointer* window) { + + Window* targetWindow = (Window*)window->ptr; + return targetWindow->GetMouseLock (); + + } + + double lime_window_get_scale (value window) { Window* targetWindow = (Window*)val_data (window); @@ -3540,6 +3305,22 @@ namespace lime { } + bool lime_window_get_text_input_enabled (value window) { + + Window* targetWindow = (Window*)val_data (window); + return targetWindow->GetTextInputEnabled (); + + } + + + HL_PRIM bool hl_lime_window_get_text_input_enabled (HL_CFFIPointer* window) { + + Window* targetWindow = (Window*)window->ptr; + return targetWindow->GetTextInputEnabled (); + + } + + int lime_window_get_width (value window) { Window* targetWindow = (Window*)val_data (window); @@ -3676,6 +3457,22 @@ namespace lime { } + void lime_window_set_cursor (value window, int cursor) { + + Window* targetWindow = (Window*)val_data (window); + targetWindow->SetCursor ((Cursor)cursor); + + } + + + HL_PRIM void hl_lime_window_set_cursor (HL_CFFIPointer* window, int cursor) { + + Window* targetWindow = (Window*)window->ptr; + targetWindow->SetCursor ((Cursor)cursor); + + } + + value lime_window_set_display_mode (value window, value displayMode) { Window* targetWindow = (Window*)val_data (window); @@ -3698,22 +3495,6 @@ namespace lime { } - void lime_window_set_enable_text_events (value window, bool enabled) { - - Window* targetWindow = (Window*)val_data (window); - targetWindow->SetEnableTextEvents (enabled); - - } - - - HL_PRIM void hl_lime_window_set_enable_text_events (HL_CFFIPointer* window, bool enabled) { - - Window* targetWindow = (Window*)window->ptr; - targetWindow->SetEnableTextEvents (enabled); - - } - - bool lime_window_set_fullscreen (value window, bool fullscreen) { Window* targetWindow = (Window*)val_data (window); @@ -3779,6 +3560,22 @@ namespace lime { } + void lime_window_set_mouse_lock (value window, bool mouseLock) { + + Window* targetWindow = (Window*)val_data (window); + targetWindow->SetMouseLock (mouseLock); + + } + + + HL_PRIM void hl_lime_window_set_mouse_lock (HL_CFFIPointer* window, bool mouseLock) { + + Window* targetWindow = (Window*)window->ptr; + targetWindow->SetMouseLock (mouseLock); + + } + + bool lime_window_set_resizable (value window, bool resizable) { Window* targetWindow = (Window*)val_data (window); @@ -3795,6 +3592,22 @@ namespace lime { } + void lime_window_set_text_input_enabled (value window, bool enabled) { + + Window* targetWindow = (Window*)val_data (window); + targetWindow->SetTextInputEnabled (enabled); + + } + + + HL_PRIM void hl_lime_window_set_text_input_enabled (HL_CFFIPointer* window, bool enabled) { + + Window* targetWindow = (Window*)window->ptr; + targetWindow->SetTextInputEnabled (enabled); + + } + + value lime_window_set_title (value window, HxString title) { Window* targetWindow = (Window*)val_data (window); @@ -3839,6 +3652,22 @@ namespace lime { } + void lime_window_warp_mouse (value window, int x, int y) { + + Window* targetWindow = (Window*)val_data (window); + targetWindow->WarpMouse (x, y); + + } + + + HL_PRIM void hl_lime_window_warp_mouse (HL_CFFIPointer* window, int x, int y) { + + Window* targetWindow = (Window*)window->ptr; + targetWindow->WarpMouse (x, y); + + } + + value lime_zlib_compress (value buffer, value bytes) { #ifdef LIME_ZLIB @@ -3985,11 +3814,6 @@ namespace lime { DEFINE_PRIME2 (lime_lzma_compress); DEFINE_PRIME2 (lime_lzma_decompress); DEFINE_PRIME2v (lime_mouse_event_manager_register); - DEFINE_PRIME0v (lime_mouse_hide); - DEFINE_PRIME1v (lime_mouse_set_cursor); - DEFINE_PRIME1v (lime_mouse_set_lock); - DEFINE_PRIME0v (lime_mouse_show); - DEFINE_PRIME3v (lime_mouse_warp); DEFINE_PRIME1v (lime_neko_execute); DEFINE_PRIME3 (lime_png_decode_bytes); DEFINE_PRIME3 (lime_png_decode_file); @@ -4012,11 +3836,6 @@ namespace lime { DEFINE_PRIME1 (lime_system_set_allow_screen_timeout); DEFINE_PRIME2 (lime_system_set_windows_console_mode); DEFINE_PRIME2v (lime_text_event_manager_register); - DEFINE_PRIME3 (lime_text_layout_create); - DEFINE_PRIME5 (lime_text_layout_position); - DEFINE_PRIME2v (lime_text_layout_set_direction); - DEFINE_PRIME2v (lime_text_layout_set_language); - DEFINE_PRIME2v (lime_text_layout_set_script); DEFINE_PRIME2v (lime_touch_event_manager_register); DEFINE_PRIME3v (lime_window_alert); DEFINE_PRIME1v (lime_window_close); @@ -4031,10 +3850,11 @@ namespace lime { DEFINE_PRIME1 (lime_window_get_context_type); DEFINE_PRIME1 (lime_window_get_display); DEFINE_PRIME1 (lime_window_get_display_mode); - DEFINE_PRIME1 (lime_window_get_enable_text_events); DEFINE_PRIME1 (lime_window_get_height); DEFINE_PRIME1 (lime_window_get_id); + DEFINE_PRIME1 (lime_window_get_mouse_lock); DEFINE_PRIME1 (lime_window_get_scale); + DEFINE_PRIME1 (lime_window_get_text_input_enabled); DEFINE_PRIME1 (lime_window_get_width); DEFINE_PRIME1 (lime_window_get_x); DEFINE_PRIME1 (lime_window_get_y); @@ -4042,14 +3862,17 @@ namespace lime { DEFINE_PRIME3 (lime_window_read_pixels); DEFINE_PRIME3v (lime_window_resize); DEFINE_PRIME2 (lime_window_set_borderless); + DEFINE_PRIME2v (lime_window_set_cursor); DEFINE_PRIME2 (lime_window_set_display_mode); - DEFINE_PRIME2v (lime_window_set_enable_text_events); DEFINE_PRIME2 (lime_window_set_fullscreen); DEFINE_PRIME2v (lime_window_set_icon); DEFINE_PRIME2 (lime_window_set_maximized); DEFINE_PRIME2 (lime_window_set_minimized); + DEFINE_PRIME2v (lime_window_set_mouse_lock); DEFINE_PRIME2 (lime_window_set_resizable); + DEFINE_PRIME2v (lime_window_set_text_input_enabled); DEFINE_PRIME2 (lime_window_set_title); + DEFINE_PRIME3v (lime_window_warp_mouse); DEFINE_PRIME2 (lime_zlib_compress); DEFINE_PRIME2 (lime_zlib_decompress); @@ -4174,11 +3997,6 @@ namespace lime { DEFINE_HL_PRIM (_TBYTES, lime_lzma_compress, _TBYTES _TBYTES); DEFINE_HL_PRIM (_TBYTES, lime_lzma_decompress, _TBYTES _TBYTES); DEFINE_HL_PRIM (_VOID, lime_mouse_event_manager_register, _FUN (_VOID, _NO_ARG) _TMOUSE_EVENT); - DEFINE_HL_PRIM (_VOID, lime_mouse_hide, _NO_ARG); - DEFINE_HL_PRIM (_VOID, lime_mouse_set_cursor, _I32); - DEFINE_HL_PRIM (_VOID, lime_mouse_set_lock, _BOOL); - DEFINE_HL_PRIM (_VOID, lime_mouse_show, _NO_ARG); - DEFINE_HL_PRIM (_VOID, lime_mouse_warp, _I32 _I32 _TCFFIPOINTER); // DEFINE_PRIME1v (lime_neko_execute); DEFINE_HL_PRIM (_TIMAGEBUFFER, lime_png_decode_bytes, _TBYTES _BOOL _TIMAGEBUFFER); DEFINE_HL_PRIM (_TIMAGEBUFFER, lime_png_decode_file, _STRING _BOOL _TIMAGEBUFFER); @@ -4201,11 +4019,6 @@ namespace lime { DEFINE_HL_PRIM (_BOOL, lime_system_set_allow_screen_timeout, _BOOL); DEFINE_HL_PRIM (_BOOL, lime_system_set_windows_console_mode, _I32 _I32); DEFINE_HL_PRIM (_VOID, lime_text_event_manager_register, _FUN (_VOID, _NO_ARG) _TTEXT_EVENT); - DEFINE_HL_PRIM (_TCFFIPOINTER, lime_text_layout_create, _I32 _STRING _STRING); - DEFINE_HL_PRIM (_TBYTES, lime_text_layout_position, _TCFFIPOINTER _TCFFIPOINTER _I32 _STRING _TBYTES); - DEFINE_HL_PRIM (_VOID, lime_text_layout_set_direction, _TCFFIPOINTER _I32); - DEFINE_HL_PRIM (_VOID, lime_text_layout_set_language, _TCFFIPOINTER _STRING); - DEFINE_HL_PRIM (_VOID, lime_text_layout_set_script, _TCFFIPOINTER _STRING); DEFINE_HL_PRIM (_VOID, lime_touch_event_manager_register, _FUN (_VOID, _NO_ARG) _TTOUCH_EVENT); DEFINE_HL_PRIM (_VOID, lime_window_alert, _TCFFIPOINTER _STRING _STRING); DEFINE_HL_PRIM (_VOID, lime_window_close, _TCFFIPOINTER); @@ -4220,10 +4033,11 @@ namespace lime { DEFINE_HL_PRIM (_BYTES, lime_window_get_context_type, _TCFFIPOINTER); DEFINE_HL_PRIM (_I32, lime_window_get_display, _TCFFIPOINTER); DEFINE_HL_PRIM (_DYN, lime_window_get_display_mode, _TCFFIPOINTER); - DEFINE_HL_PRIM (_BOOL, lime_window_get_enable_text_events, _TCFFIPOINTER); DEFINE_HL_PRIM (_I32, lime_window_get_height, _TCFFIPOINTER); DEFINE_HL_PRIM (_I32, lime_window_get_id, _TCFFIPOINTER); + DEFINE_HL_PRIM (_BOOL, lime_window_get_mouse_lock, _TCFFIPOINTER); DEFINE_HL_PRIM (_F64, lime_window_get_scale, _TCFFIPOINTER); + DEFINE_HL_PRIM (_BOOL, lime_window_get_text_input_enabled, _TCFFIPOINTER); DEFINE_HL_PRIM (_I32, lime_window_get_width, _TCFFIPOINTER); DEFINE_HL_PRIM (_I32, lime_window_get_x, _TCFFIPOINTER); DEFINE_HL_PRIM (_I32, lime_window_get_y, _TCFFIPOINTER); @@ -4231,14 +4045,17 @@ namespace lime { DEFINE_HL_PRIM (_DYN, lime_window_read_pixels, _TCFFIPOINTER _TRECTANGLE _TIMAGEBUFFER); DEFINE_HL_PRIM (_VOID, lime_window_resize, _TCFFIPOINTER _I32 _I32); DEFINE_HL_PRIM (_BOOL, lime_window_set_borderless, _TCFFIPOINTER _BOOL); + DEFINE_HL_PRIM (_VOID, lime_window_set_cursor, _TCFFIPOINTER _I32); DEFINE_HL_PRIM (_TDISPLAYMODE, lime_window_set_display_mode, _TCFFIPOINTER _TDISPLAYMODE); - DEFINE_HL_PRIM (_VOID, lime_window_set_enable_text_events, _TCFFIPOINTER _BOOL); DEFINE_HL_PRIM (_BOOL, lime_window_set_fullscreen, _TCFFIPOINTER _BOOL); DEFINE_HL_PRIM (_VOID, lime_window_set_icon, _TCFFIPOINTER _TIMAGEBUFFER); DEFINE_HL_PRIM (_BOOL, lime_window_set_maximized, _TCFFIPOINTER _BOOL); DEFINE_HL_PRIM (_BOOL, lime_window_set_minimized, _TCFFIPOINTER _BOOL); + DEFINE_HL_PRIM (_VOID, lime_window_set_mouse_lock, _TCFFIPOINTER _BOOL); DEFINE_HL_PRIM (_BOOL, lime_window_set_resizable, _TCFFIPOINTER _BOOL); + DEFINE_HL_PRIM (_VOID, lime_window_set_text_input_enabled, _TCFFIPOINTER _BOOL); DEFINE_HL_PRIM (_STRING, lime_window_set_title, _TCFFIPOINTER _STRING); + DEFINE_HL_PRIM (_VOID, lime_window_warp_mouse, _TCFFIPOINTER _I32 _I32); DEFINE_HL_PRIM (_TBYTES, lime_zlib_compress, _TBYTES _TBYTES); DEFINE_HL_PRIM (_TBYTES, lime_zlib_decompress, _TBYTES _TBYTES); diff --git a/project/src/backend/sdl/SDLApplication.cpp b/project/src/backend/sdl/SDLApplication.cpp index 64cc71430..17e8a0410 100644 --- a/project/src/backend/sdl/SDLApplication.cpp +++ b/project/src/backend/sdl/SDLApplication.cpp @@ -252,6 +252,7 @@ namespace lime { case SDL_WINDOWEVENT_HIDDEN: case SDL_WINDOWEVENT_FOCUS_GAINED: case SDL_WINDOWEVENT_FOCUS_LOST: + case SDL_WINDOWEVENT_MAXIMIZED: case SDL_WINDOWEVENT_MINIMIZED: case SDL_WINDOWEVENT_MOVED: case SDL_WINDOWEVENT_RESTORED: @@ -750,6 +751,7 @@ namespace lime { case SDL_WINDOWEVENT_FOCUS_GAINED: windowEvent.type = WINDOW_FOCUS_IN; break; case SDL_WINDOWEVENT_FOCUS_LOST: windowEvent.type = WINDOW_FOCUS_OUT; break; case SDL_WINDOWEVENT_LEAVE: windowEvent.type = WINDOW_LEAVE; break; + case SDL_WINDOWEVENT_MAXIMIZED: windowEvent.type = WINDOW_MAXIMIZE; break; case SDL_WINDOWEVENT_MINIMIZED: windowEvent.type = WINDOW_MINIMIZE; break; case SDL_WINDOWEVENT_EXPOSED: windowEvent.type = WINDOW_EXPOSE; break; diff --git a/project/src/backend/sdl/SDLMouse.h b/project/src/backend/sdl/SDLCursor.h similarity index 76% rename from project/src/backend/sdl/SDLMouse.h rename to project/src/backend/sdl/SDLCursor.h index d54618ba7..80e3b55b1 100644 --- a/project/src/backend/sdl/SDLMouse.h +++ b/project/src/backend/sdl/SDLCursor.h @@ -1,17 +1,14 @@ -#ifndef LIME_SDL_MOUSE_H -#define LIME_SDL_MOUSE_H +#ifndef LIME_SDL_CURSOR_H +#define LIME_SDL_CURSOR_H #include -#include -#include -#include namespace lime { - class SDLMouse { + class SDLCursor { public: diff --git a/project/src/backend/sdl/SDLMouse.cpp b/project/src/backend/sdl/SDLMouse.cpp deleted file mode 100644 index 52cbb97c1..000000000 --- a/project/src/backend/sdl/SDLMouse.cpp +++ /dev/null @@ -1,203 +0,0 @@ -#include "SDLMouse.h" -#include "SDLWindow.h" - - -namespace lime { - - - MouseCursor Mouse::currentCursor = DEFAULT; - - SDL_Cursor* SDLMouse::arrowCursor = 0; - SDL_Cursor* SDLMouse::crosshairCursor = 0; - SDL_Cursor* SDLMouse::moveCursor = 0; - SDL_Cursor* SDLMouse::pointerCursor = 0; - SDL_Cursor* SDLMouse::resizeNESWCursor = 0; - SDL_Cursor* SDLMouse::resizeNSCursor = 0; - SDL_Cursor* SDLMouse::resizeNWSECursor = 0; - SDL_Cursor* SDLMouse::resizeWECursor = 0; - SDL_Cursor* SDLMouse::textCursor = 0; - SDL_Cursor* SDLMouse::waitCursor = 0; - SDL_Cursor* SDLMouse::waitArrowCursor = 0; - - - void Mouse::Hide () { - - SDL_ShowCursor (SDL_DISABLE); - - } - - - void Mouse::SetCursor (MouseCursor cursor) { - - if (cursor != Mouse::currentCursor) { - - switch (cursor) { - - case CROSSHAIR: - - if (!SDLMouse::crosshairCursor) { - - SDLMouse::crosshairCursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_CROSSHAIR); - - } - - SDL_SetCursor (SDLMouse::crosshairCursor); - break; - - case MOVE: - - if (!SDLMouse::moveCursor) { - - SDLMouse::moveCursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_SIZEALL); - - } - - SDL_SetCursor (SDLMouse::moveCursor); - break; - - case POINTER: - - if (!SDLMouse::pointerCursor) { - - SDLMouse::pointerCursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_HAND); - - } - - SDL_SetCursor (SDLMouse::pointerCursor); - break; - - case RESIZE_NESW: - - if (!SDLMouse::resizeNESWCursor) { - - SDLMouse::resizeNESWCursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_SIZENESW); - - } - - SDL_SetCursor (SDLMouse::resizeNESWCursor); - break; - - case RESIZE_NS: - - if (!SDLMouse::resizeNSCursor) { - - SDLMouse::resizeNSCursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_SIZENS); - - } - - SDL_SetCursor (SDLMouse::resizeNSCursor); - break; - - case RESIZE_NWSE: - - if (!SDLMouse::resizeNWSECursor) { - - SDLMouse::resizeNWSECursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_SIZENWSE); - - } - - SDL_SetCursor (SDLMouse::resizeNWSECursor); - break; - - case RESIZE_WE: - - if (!SDLMouse::resizeWECursor) { - - SDLMouse::resizeWECursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_SIZEWE); - - } - - SDL_SetCursor (SDLMouse::resizeWECursor); - break; - - case TEXT: - - if (!SDLMouse::textCursor) { - - SDLMouse::textCursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_IBEAM); - - } - - SDL_SetCursor (SDLMouse::textCursor); - break; - - case WAIT: - - if (!SDLMouse::waitCursor) { - - SDLMouse::waitCursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_WAIT); - - } - - SDL_SetCursor (SDLMouse::waitCursor); - break; - - case WAIT_ARROW: - - if (!SDLMouse::waitArrowCursor) { - - SDLMouse::waitArrowCursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_WAITARROW); - - } - - SDL_SetCursor (SDLMouse::waitArrowCursor); - break; - - default: - - if (!SDLMouse::arrowCursor) { - - SDLMouse::arrowCursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_ARROW); - - } - - SDL_SetCursor (SDLMouse::arrowCursor); - break; - - } - - Mouse::currentCursor = cursor; - - } - - } - - - void Mouse::SetLock (bool lock) { - - if (lock) { - - SDL_SetRelativeMouseMode (SDL_TRUE); - - } else { - - SDL_SetRelativeMouseMode (SDL_FALSE); - - } - - } - - - void Mouse::Show () { - - SDL_ShowCursor (SDL_ENABLE); - - } - - - void Mouse::Warp (int x, int y, Window* window){ - - if (window) { - - SDL_WarpMouseInWindow (((SDLWindow*)window)->sdlWindow, x, y); - - } else { - - SDL_WarpMouseGlobal (x, y); - - } - - } - - -} \ No newline at end of file diff --git a/project/src/backend/sdl/SDLWindow.cpp b/project/src/backend/sdl/SDLWindow.cpp index 1e7b71ed5..49101173f 100644 --- a/project/src/backend/sdl/SDLWindow.cpp +++ b/project/src/backend/sdl/SDLWindow.cpp @@ -1,4 +1,5 @@ #include "SDLWindow.h" +#include "SDLCursor.h" #include "SDLApplication.h" #include "../../graphics/opengl/OpenGL.h" #include "../../graphics/opengl/OpenGLBindings.h" @@ -13,6 +14,20 @@ namespace lime { + static Cursor currentCursor = DEFAULT; + + SDL_Cursor* SDLCursor::arrowCursor = 0; + SDL_Cursor* SDLCursor::crosshairCursor = 0; + SDL_Cursor* SDLCursor::moveCursor = 0; + SDL_Cursor* SDLCursor::pointerCursor = 0; + SDL_Cursor* SDLCursor::resizeNESWCursor = 0; + SDL_Cursor* SDLCursor::resizeNSCursor = 0; + SDL_Cursor* SDLCursor::resizeNWSECursor = 0; + SDL_Cursor* SDLCursor::resizeWECursor = 0; + SDL_Cursor* SDLCursor::textCursor = 0; + SDL_Cursor* SDLCursor::waitCursor = 0; + SDL_Cursor* SDLCursor::waitArrowCursor = 0; + static bool displayModeSet = false; @@ -471,6 +486,9 @@ namespace lime { } + + + const char* SDLWindow::GetContextType () { if (context) { @@ -538,13 +556,6 @@ namespace lime { } - bool SDLWindow::GetEnableTextEvents () { - - return SDL_IsTextInputActive (); - - } - - int SDLWindow::GetHeight () { int width; @@ -564,6 +575,13 @@ namespace lime { } + bool SDLWindow::GetMouseLock () { + + return SDL_GetRelativeMouseMode (); + + } + + double SDLWindow::GetScale () { if (sdlRenderer) { @@ -603,6 +621,13 @@ namespace lime { } + bool SDLWindow::GetTextInputEnabled () { + + return SDL_IsTextInputActive (); + + } + + int SDLWindow::GetWidth () { int width; @@ -702,6 +727,152 @@ namespace lime { } + void SDLWindow::SetCursor (Cursor cursor) { + + if (cursor != currentCursor) { + + if (currentCursor == HIDDEN) { + + SDL_ShowCursor (SDL_ENABLE); + + } + + switch (cursor) { + + case HIDDEN: + + SDL_ShowCursor (SDL_DISABLE); + + case CROSSHAIR: + + if (!SDLCursor::crosshairCursor) { + + SDLCursor::crosshairCursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_CROSSHAIR); + + } + + SDL_SetCursor (SDLCursor::crosshairCursor); + break; + + case MOVE: + + if (!SDLCursor::moveCursor) { + + SDLCursor::moveCursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_SIZEALL); + + } + + SDL_SetCursor (SDLCursor::moveCursor); + break; + + case POINTER: + + if (!SDLCursor::pointerCursor) { + + SDLCursor::pointerCursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_HAND); + + } + + SDL_SetCursor (SDLCursor::pointerCursor); + break; + + case RESIZE_NESW: + + if (!SDLCursor::resizeNESWCursor) { + + SDLCursor::resizeNESWCursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_SIZENESW); + + } + + SDL_SetCursor (SDLCursor::resizeNESWCursor); + break; + + case RESIZE_NS: + + if (!SDLCursor::resizeNSCursor) { + + SDLCursor::resizeNSCursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_SIZENS); + + } + + SDL_SetCursor (SDLCursor::resizeNSCursor); + break; + + case RESIZE_NWSE: + + if (!SDLCursor::resizeNWSECursor) { + + SDLCursor::resizeNWSECursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_SIZENWSE); + + } + + SDL_SetCursor (SDLCursor::resizeNWSECursor); + break; + + case RESIZE_WE: + + if (!SDLCursor::resizeWECursor) { + + SDLCursor::resizeWECursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_SIZEWE); + + } + + SDL_SetCursor (SDLCursor::resizeWECursor); + break; + + case TEXT: + + if (!SDLCursor::textCursor) { + + SDLCursor::textCursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_IBEAM); + + } + + SDL_SetCursor (SDLCursor::textCursor); + break; + + case WAIT: + + if (!SDLCursor::waitCursor) { + + SDLCursor::waitCursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_WAIT); + + } + + SDL_SetCursor (SDLCursor::waitCursor); + break; + + case WAIT_ARROW: + + if (!SDLCursor::waitArrowCursor) { + + SDLCursor::waitArrowCursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_WAITARROW); + + } + + SDL_SetCursor (SDLCursor::waitArrowCursor); + break; + + default: + + if (!SDLCursor::arrowCursor) { + + SDLCursor::arrowCursor = SDL_CreateSystemCursor (SDL_SYSTEM_CURSOR_ARROW); + + } + + SDL_SetCursor (SDLCursor::arrowCursor); + break; + + } + + currentCursor = cursor; + + } + + } + + void SDLWindow::SetDisplayMode (DisplayMode* displayMode) { Uint32 pixelFormat = 0; @@ -741,21 +912,6 @@ namespace lime { } - void SDLWindow::SetEnableTextEvents (bool enabled) { - - if (enabled) { - - SDL_StartTextInput (); - - } else { - - SDL_StopTextInput (); - - } - - } - - bool SDLWindow::SetFullscreen (bool fullscreen) { if (fullscreen) { @@ -829,6 +985,21 @@ namespace lime { } + void SDLWindow::SetMouseLock (bool mouseLock) { + + if (mouseLock) { + + SDL_SetRelativeMouseMode (SDL_TRUE); + + } else { + + SDL_SetRelativeMouseMode (SDL_FALSE); + + } + + } + + bool SDLWindow::SetResizable (bool resizable) { #ifndef EMSCRIPTEN @@ -850,6 +1021,22 @@ namespace lime { return resizable; #endif + + } + + + void SDLWindow::SetTextInputEnabled (bool enabled) { + + if (enabled) { + + SDL_StartTextInput (); + + } else { + + SDL_StopTextInput (); + + } + } @@ -862,6 +1049,13 @@ namespace lime { } + void SDLWindow::WarpMouse (int x, int y){ + + SDL_WarpMouseInWindow (sdlWindow, x, y); + + } + + Window* CreateWindow (Application* application, int width, int height, int flags, const char* title) { return new SDLWindow (application, width, height, flags, title); @@ -869,4 +1063,4 @@ namespace lime { } -} +} \ No newline at end of file diff --git a/project/src/backend/sdl/SDLWindow.h b/project/src/backend/sdl/SDLWindow.h index 9df3bcba9..0b0f528d2 100644 --- a/project/src/backend/sdl/SDLWindow.h +++ b/project/src/backend/sdl/SDLWindow.h @@ -4,6 +4,7 @@ #include #include +#include #include @@ -26,12 +27,14 @@ namespace lime { virtual void Focus (); virtual void* GetContext (); virtual const char* GetContextType (); + // virtual Cursor GetCursor (); virtual int GetDisplay (); virtual void GetDisplayMode (DisplayMode* displayMode); - virtual bool GetEnableTextEvents (); virtual int GetHeight (); virtual uint32_t GetID (); + virtual bool GetMouseLock (); virtual double GetScale (); + virtual bool GetTextInputEnabled (); virtual int GetWidth (); virtual int GetX (); virtual int GetY (); @@ -39,14 +42,17 @@ namespace lime { virtual void ReadPixels (ImageBuffer *buffer, Rectangle *rect); virtual void Resize (int width, int height); virtual bool SetBorderless (bool borderless); + virtual void SetCursor (Cursor cursor); virtual void SetDisplayMode (DisplayMode* displayMode); - virtual void SetEnableTextEvents (bool enabled); virtual bool SetFullscreen (bool fullscreen); virtual void SetIcon (ImageBuffer *imageBuffer); virtual bool SetMaximized (bool maximized); virtual bool SetMinimized (bool minimized); + virtual void SetMouseLock (bool mouseLock); virtual bool SetResizable (bool resizable); + virtual void SetTextInputEnabled (bool enabled); virtual const char* SetTitle (const char* title); + virtual void WarpMouse (int x, int y); SDL_Renderer* sdlRenderer; SDL_Texture* sdlTexture; diff --git a/project/src/text/TextLayout.cpp b/project/src/text/TextLayout.cpp deleted file mode 100644 index 088bc7fb0..000000000 --- a/project/src/text/TextLayout.cpp +++ /dev/null @@ -1,149 +0,0 @@ -#include -#include - -#include -#include FT_FREETYPE_H -#include -#include -#include - - -namespace lime { - - - TextLayout::TextLayout (int direction, const char *script, const char *language) { - - if (strlen (script) != 4) return; - - mFont = 0; - mHBFont = 0; - mDirection = (hb_direction_t)direction; - mLanguage = (void *)hb_language_from_string (language, strlen (language)); - mScript = hb_script_from_string (script, -1); - - mBuffer = hb_buffer_create (); - hb_buffer_set_direction ((hb_buffer_t*)mBuffer, (hb_direction_t)mDirection); - hb_buffer_set_script ((hb_buffer_t*)mBuffer, (hb_script_t)mScript); - hb_buffer_set_language ((hb_buffer_t*)mBuffer, (hb_language_t)mLanguage); - - } - - - TextLayout::~TextLayout () { - - hb_buffer_destroy ((hb_buffer_t*)mBuffer); - hb_font_destroy ((hb_font_t*)mHBFont); - - } - - - void TextLayout::Position (Font *font, size_t size, const char *text, Bytes *bytes) { - - if (mFont != font) { - - mFont = font; - hb_font_destroy ((hb_font_t*)mHBFont); - font->SetSize (size); - mHBFont = hb_ft_font_create ((FT_Face)font->face, NULL); - // hb_ft_font_set_funcs ((hb_font_t*)mHBFont); - hb_ft_font_set_load_flags ((hb_font_t*)mHBFont, FT_LOAD_FORCE_AUTOHINT | FT_LOAD_TARGET_LIGHT); - - } else { - - font->SetSize (size); - - } - - // reset buffer - hb_buffer_reset ((hb_buffer_t*)mBuffer); - hb_buffer_set_direction ((hb_buffer_t*)mBuffer, (hb_direction_t)mDirection); - hb_buffer_set_script ((hb_buffer_t*)mBuffer, (hb_script_t)mScript); - hb_buffer_set_language ((hb_buffer_t*)mBuffer, (hb_language_t)mLanguage); - hb_buffer_set_cluster_level ((hb_buffer_t*)mBuffer, HB_BUFFER_CLUSTER_LEVEL_CHARACTERS); - - // layout the text - hb_buffer_add_utf8 ((hb_buffer_t*)mBuffer, text, strlen (text), 0, -1); - - // const hb_tag_t kerningTag = HB_TAG('k', 'e', 'r', 'n'); - // static hb_feature_t useKerning = { kerningTag, 1, 0, std::numeric_limits::max() }; - // std::vector features; - // features.push_back (useKerning); - - // hb_shape ((hb_font_t*)mHBFont, (hb_buffer_t*)mBuffer, &features[0], features.size()); - hb_shape ((hb_font_t*)mHBFont, (hb_buffer_t*)mBuffer, NULL, 0); - - uint32_t glyph_count; - hb_glyph_info_t *glyph_info = hb_buffer_get_glyph_infos ((hb_buffer_t*)mBuffer, &glyph_count); - hb_glyph_position_t *glyph_pos = hb_buffer_get_glyph_positions ((hb_buffer_t*)mBuffer, &glyph_count); - - //float hres = 100; - int posIndex = 0; - - int glyphSize = sizeof (GlyphPosition); - uint32_t dataSize = 5 + (glyph_count * glyphSize); - - if (bytes->length < dataSize) { - - bytes->Resize (dataSize); - - } - - unsigned char* bytesPosition = bytes->b; - - *(uint32_t *)(bytesPosition) = glyph_count; - bytesPosition += 4; - - hb_glyph_position_t pos; - hb_position_t kern; - GlyphPosition *data; - - for (int i = 0; i < glyph_count; i++) { - - pos = glyph_pos[i]; - - data = (GlyphPosition*)(bytesPosition); - - data->codepoint = glyph_info[i].codepoint; - data->index = glyph_info[i].cluster; - data->advanceX = (float)(pos.x_advance / (float)(64)); - data->advanceY = (float)(pos.y_advance / (float)64); - data->offsetX = (float)(pos.x_offset / (float)(64)); - data->offsetY = (float)(pos.y_offset / (float)64); - - // if (i < glyph_count - 1) { - - // Manually add kerning, hb_shape seems to ignore kern feature? - // kern = hb_font_get_glyph_h_kerning ((hb_font_t*)mHBFont, glyph_info[i].codepoint, glyph_info[i + 1].codepoint); - // data->advanceX += (float)(kern / (float)(64)); - - // } - - bytesPosition += glyphSize; - - } - - } - - - void TextLayout::SetDirection (int direction) { - - mDirection = (hb_direction_t)direction; - - } - - - void TextLayout::SetLanguage (const char* language) { - - mLanguage = (void *)hb_language_from_string (language, strlen (language)); - - } - - - void TextLayout::SetScript (const char* script) { - - mScript = hb_script_from_string (script, -1); - - } - - -} diff --git a/src/lime/_internal/backend/flash/FlashMouse.hx b/src/lime/_internal/backend/flash/FlashMouse.hx deleted file mode 100644 index 5051965a1..000000000 --- a/src/lime/_internal/backend/flash/FlashMouse.hx +++ /dev/null @@ -1,120 +0,0 @@ -package lime._internal.backend.flash; - - -import flash.ui.Mouse; -import flash.ui.MouseCursor in FlashMouseCursor; -import lime.ui.MouseCursor; -import lime.ui.Window; - - -class FlashMouse { - - - private static var __cursor:MouseCursor; - private static var __hidden:Bool; - - - public static function hide ():Void { - - if (!__hidden) { - - __hidden = true; - - Mouse.hide (); - - } - - } - - - public static function show ():Void { - - if (__hidden) { - - __hidden = false; - - Mouse.show (); - - } - - } - - - public static function warp (x:Int, y:Int, window:Window):Void { - - - - } - - - - - // Get & Set Methods - - - - - public static function get_cursor ():MouseCursor { - - if (__cursor == null) return DEFAULT; - return __cursor; - - } - - - public static function set_cursor (value:MouseCursor):MouseCursor { - - if (__cursor != value) { - - if (!__hidden) { - - Mouse.cursor = switch (value) { - - case ARROW: FlashMouseCursor.ARROW; - case CROSSHAIR: FlashMouseCursor.ARROW; - case MOVE: FlashMouseCursor.HAND; - case POINTER: FlashMouseCursor.BUTTON; - case RESIZE_NESW: FlashMouseCursor.HAND; - case RESIZE_NS: FlashMouseCursor.HAND; - case RESIZE_NWSE: FlashMouseCursor.HAND; - case RESIZE_WE: FlashMouseCursor.HAND; - case TEXT: FlashMouseCursor.IBEAM; - case WAIT: FlashMouseCursor.ARROW; - case WAIT_ARROW: FlashMouseCursor.ARROW; - default: FlashMouseCursor.AUTO; - - } - - } - - __cursor = value; - - } - - return __cursor; - - } - - - public static function get_lock ():Bool { - - return false; - - } - - - public static function set_lock (value:Bool):Bool { - - return value; - - } - - - public static function get_visible ():Bool { - - return !__hidden; - - } - - -} \ No newline at end of file diff --git a/src/lime/_internal/backend/flash/FlashWindow.hx b/src/lime/_internal/backend/flash/FlashWindow.hx index 579922f0b..d64f63007 100644 --- a/src/lime/_internal/backend/flash/FlashWindow.hx +++ b/src/lime/_internal/backend/flash/FlashWindow.hx @@ -12,12 +12,15 @@ import flash.events.MouseEvent; import flash.events.TouchEvent; import flash.geom.Matrix; import flash.system.Capabilities; +import flash.ui.Mouse; +import flash.ui.MouseCursor; import flash.Lib; import lime.app.Application; import lime.graphics.Image; import lime.graphics.RenderContext; import lime.graphics.RenderContextAttributes; import lime.math.Rectangle; +import lime.ui.Cursor; import lime.ui.KeyCode; import lime.ui.KeyModifier; import lime.ui.Touch; @@ -40,11 +43,12 @@ class FlashWindow { private var cacheMouseY:Float; private var cacheTime:Int; private var currentTouches = new Map (); - private var enableTextEvents:Bool; + private var cursor:Cursor; private var frameRate:Float; private var mouseLeft:Bool; private var parent:Window; private var stage:Stage; + private var textInputEnabled:Bool; private var unusedTouchesPool = new List (); @@ -54,6 +58,7 @@ class FlashWindow { cacheMouseX = 0; cacheMouseY = 0; + cursor = DEFAULT; create (); @@ -237,6 +242,13 @@ class FlashWindow { } + public function getCursor ():Cursor { + + return cursor; + + } + + public function getDisplay ():Display { return System.getDisplay (0); @@ -272,7 +284,7 @@ class FlashWindow { parent.onKeyDown.dispatch (keyCode, modifier); - if (parent.enableTextEvents) { + if (parent.textInputEnabled) { parent.onTextInput.dispatch (String.fromCharCode (event.charCode)); @@ -504,6 +516,50 @@ class FlashWindow { } + public function setCursor (value:Cursor):Cursor { + + if (cursor != value) { + + if (value == null) { + + Mouse.hide (); + + } else { + + if (cursor == null) { + + Mouse.show (); + + } + + Mouse.cursor = switch (value) { + + case ARROW: MouseCursor.ARROW; + case CROSSHAIR: MouseCursor.ARROW; + case MOVE: MouseCursor.HAND; + case POINTER: MouseCursor.BUTTON; + case RESIZE_NESW: MouseCursor.HAND; + case RESIZE_NS: MouseCursor.HAND; + case RESIZE_NWSE: MouseCursor.HAND; + case RESIZE_WE: MouseCursor.HAND; + case TEXT: MouseCursor.IBEAM; + case WAIT: MouseCursor.ARROW; + case WAIT_ARROW: MouseCursor.ARROW; + default: MouseCursor.AUTO; + + } + + } + + cursor = value; + + } + + return cursor; + + } + + public function setDisplayMode (value:DisplayMode):DisplayMode { return value; @@ -511,16 +567,23 @@ class FlashWindow { } - public function getEnableTextEvents ():Bool { + public function getFrameRate ():Float { - return enableTextEvents; + return frameRate; } - public function getFrameRate ():Float { + public function getMouseLock ():Bool { - return frameRate; + return false; + + } + + + public function getTextInputEnabled ():Bool { + + return textInputEnabled; } @@ -546,13 +609,6 @@ class FlashWindow { } - public function setEnableTextEvents (value:Bool):Bool { - - return enableTextEvents = value; - - } - - public function setFrameRate (value:Float):Float { frameRate = value; @@ -591,6 +647,13 @@ class FlashWindow { } + public function setMouseLock (value:Bool):Void { + + + + } + + public function setResizable (value:Bool):Bool { return value; @@ -598,6 +661,13 @@ class FlashWindow { } + public function setTextInputEnabled (value:Bool):Bool { + + return textInputEnabled = value; + + } + + public function setTitle (value:String):String { return value; @@ -605,4 +675,11 @@ class FlashWindow { } + public function warpMouse (x:Int, y:Int):Void { + + + + } + + } \ No newline at end of file diff --git a/src/lime/_internal/backend/html5/HTML5Mouse.hx b/src/lime/_internal/backend/html5/HTML5Mouse.hx deleted file mode 100644 index ce0d688e6..000000000 --- a/src/lime/_internal/backend/html5/HTML5Mouse.hx +++ /dev/null @@ -1,115 +0,0 @@ -package lime._internal.backend.html5; - - -import lime.app.Application; -import lime.ui.MouseCursor; -import lime.ui.Window; - -@:access(lime.app.Application) -@:access(lime.ui.Window) - - -class HTML5Mouse { - - - private static var __cursor:MouseCursor; - private static var __hidden:Bool; - - - public static function hide ():Void { - - if (!__hidden) { - - __hidden = true; - - for (window in Application.current.windows) { - - window.__backend.hideCursor (); - - } - - } - - } - - - public static function show ():Void { - - if (__hidden) { - - __hidden = false; - - for (window in Application.current.windows) { - - window.__backend.showCursor (); - - } - - } - - } - - - public static function warp (x:Int, y:Int, window:Window):Void { - - - - } - - - - - // Get & Set Methods - - - - - public static function get_cursor ():MouseCursor { - - if (__cursor == null) return DEFAULT; - return __cursor; - - } - - - public static function set_cursor (value:MouseCursor):MouseCursor { - - if (__cursor != value) { - - for (window in Application.current.windows) { - - window.__backend.setCursor (value); - - } - - __cursor = value; - - } - - return __cursor; - - } - - - public static function get_lock ():Bool { - - return false; - - } - - - public static function set_lock (value:Bool):Bool { - - return value; - - } - - - public static function get_visible ():Bool { - - return !__hidden; - - } - - -} \ No newline at end of file diff --git a/src/lime/_internal/backend/html5/HTML5Window.hx b/src/lime/_internal/backend/html5/HTML5Window.hx index 1d70c8bf2..912b032c0 100644 --- a/src/lime/_internal/backend/html5/HTML5Window.hx +++ b/src/lime/_internal/backend/html5/HTML5Window.hx @@ -27,9 +27,9 @@ import lime.system.Display; import lime.system.DisplayMode; import lime.system.System; import lime.system.Clipboard; +import lime.ui.Cursor; import lime.ui.Gamepad; import lime.ui.Joystick; -import lime.ui.MouseCursor; import lime.ui.Touch; import lime.ui.Window; @@ -63,10 +63,9 @@ class HTML5Window { private var cacheElementWidth:Float; private var cacheMouseX:Float; private var cacheMouseY:Float; - private var cursor:MouseCursor; + private var cursor:Cursor; private var cursorHidden:Bool; private var currentTouches = new Map (); - private var enableTextEvents:Bool; private var isFullscreen:Bool; private var parent:Window; private var primaryTouch:Touch; @@ -76,6 +75,7 @@ class HTML5Window { private var scale = 1.0; private var setHeight:Int; private var setWidth:Int; + private var textInputEnabled:Bool; private var unusedTouchesPool = new List (); @@ -369,6 +369,13 @@ class HTML5Window { } + public function getCursor ():Cursor { + + return cursor; + + } + + public function getDisplay ():Display { return System.getDisplay (0); @@ -404,28 +411,16 @@ class HTML5Window { } - public function hideCursor ():Void { + public function getMouseLock ():Bool { - if (!cursorHidden) { - - cursorHidden = true; - element.style.cursor = "none"; - - } + return false; } - public function setDisplayMode (value:DisplayMode):DisplayMode { + public function getTextInputEnabled ():Bool { - return value; - - } - - - public function getEnableTextEvents ():Bool { - - return enableTextEvents; + return textInputEnabled; } @@ -484,13 +479,13 @@ class HTML5Window { private function handleFocusEvent (event:FocusEvent):Void { - if (enableTextEvents) { + if (textInputEnabled) { if (event.relatedTarget == null || isDescendent (cast event.relatedTarget)) { Timer.delay (function () { - if (enableTextEvents) textInput.focus (); + if (textInputEnabled) textInput.focus (); }, 20); @@ -732,7 +727,7 @@ class HTML5Window { var text = event.clipboardData.getData ("text/plain"); Clipboard.text = text; - if (enableTextEvents) { + if (textInputEnabled) { parent.onTextInput.dispatch (text); @@ -999,9 +994,9 @@ class HTML5Window { public function setClipboard (value:String):Void { - var inputEnabled = enableTextEvents; + var inputEnabled = textInputEnabled; - setEnableTextEvents (true); // create textInput if necessary + setTextInputEnabled (true); // create textInput if necessary var cacheText = textInput.value; textInput.value = value; @@ -1015,16 +1010,20 @@ class HTML5Window { textInput.value = cacheText; - setEnableTextEvents (inputEnabled); + setTextInputEnabled (inputEnabled); } - public function setCursor (value:MouseCursor):Void { + public function setCursor (value:Cursor):Cursor { if (cursor != value) { - if (!cursorHidden) { + if (value == null) { + + element.style.cursor = null; + + } else { element.style.cursor = switch (value) { @@ -1049,85 +1048,14 @@ class HTML5Window { } + return cursor; + } - public function setEnableTextEvents (value:Bool):Bool { + public function setDisplayMode (value:DisplayMode):DisplayMode { - if (value) { - - if (textInput == null) { - - textInput = cast Browser.document.createElement ('input'); - textInput.type = 'text'; - textInput.style.position = 'absolute'; - textInput.style.opacity = "0"; - textInput.style.color = "transparent"; - textInput.value = dummyCharacter; // See: handleInputEvent() - - untyped textInput.autocapitalize = "off"; - untyped textInput.autocorrect = "off"; - textInput.autocomplete = "off"; - - // TODO: Position for mobile browsers better - - textInput.style.left = "0px"; - textInput.style.top = "50%"; - - if (~/(iPad|iPhone|iPod).*OS 8_/gi.match (Browser.window.navigator.userAgent)) { - - textInput.style.fontSize = "0px"; - textInput.style.width = '0px'; - textInput.style.height = '0px'; - - } else { - - textInput.style.width = '1px'; - textInput.style.height = '1px'; - - } - - untyped (textInput.style).pointerEvents = 'none'; - textInput.style.zIndex = "-10000000"; - - } - - if (textInput.parentNode == null) { - - element.appendChild (textInput); - - } - - if (!enableTextEvents) { - - textInput.addEventListener ('input', handleInputEvent, true); - textInput.addEventListener ('blur', handleFocusEvent, true); - textInput.addEventListener ('cut', handleCutOrCopyEvent, true); - textInput.addEventListener ('copy', handleCutOrCopyEvent, true); - textInput.addEventListener ('paste', handlePasteEvent, true); - - } - - textInput.focus (); - textInput.select (); - - } else { - - if (textInput != null) { - - textInput.removeEventListener ('input', handleInputEvent, true); - textInput.removeEventListener ('blur', handleFocusEvent, true); - textInput.removeEventListener ('cut', handleCutOrCopyEvent, true); - textInput.removeEventListener ('copy', handleCutOrCopyEvent, true); - textInput.removeEventListener ('paste', handlePasteEvent, true); - - textInput.blur (); - - } - - } - - return enableTextEvents = value; + return value; } @@ -1263,6 +1191,13 @@ class HTML5Window { } + public function setMouseLock (value:Bool):Void { + + + + } + + public function setResizable (value:Bool):Bool { return value; @@ -1270,6 +1205,86 @@ class HTML5Window { } + public function setTextInputEnabled (value:Bool):Bool { + + if (value) { + + if (textInput == null) { + + textInput = cast Browser.document.createElement ('input'); + textInput.type = 'text'; + textInput.style.position = 'absolute'; + textInput.style.opacity = "0"; + textInput.style.color = "transparent"; + textInput.value = dummyCharacter; // See: handleInputEvent() + + untyped textInput.autocapitalize = "off"; + untyped textInput.autocorrect = "off"; + textInput.autocomplete = "off"; + + // TODO: Position for mobile browsers better + + textInput.style.left = "0px"; + textInput.style.top = "50%"; + + if (~/(iPad|iPhone|iPod).*OS 8_/gi.match (Browser.window.navigator.userAgent)) { + + textInput.style.fontSize = "0px"; + textInput.style.width = '0px'; + textInput.style.height = '0px'; + + } else { + + textInput.style.width = '1px'; + textInput.style.height = '1px'; + + } + + untyped (textInput.style).pointerEvents = 'none'; + textInput.style.zIndex = "-10000000"; + + } + + if (textInput.parentNode == null) { + + element.appendChild (textInput); + + } + + if (!textInputEnabled) { + + textInput.addEventListener ('input', handleInputEvent, true); + textInput.addEventListener ('blur', handleFocusEvent, true); + textInput.addEventListener ('cut', handleCutOrCopyEvent, true); + textInput.addEventListener ('copy', handleCutOrCopyEvent, true); + textInput.addEventListener ('paste', handlePasteEvent, true); + + } + + textInput.focus (); + textInput.select (); + + } else { + + if (textInput != null) { + + textInput.removeEventListener ('input', handleInputEvent, true); + textInput.removeEventListener ('blur', handleFocusEvent, true); + textInput.removeEventListener ('cut', handleCutOrCopyEvent, true); + textInput.removeEventListener ('copy', handleCutOrCopyEvent, true); + textInput.removeEventListener ('paste', handlePasteEvent, true); + + textInput.blur (); + + } + + } + + return textInputEnabled = value; + + } + + public function setTitle (value:String):String { if (value != null) { @@ -1406,4 +1421,11 @@ class HTML5Window { } + public function warpMouse (x:Int, y:Int):Void { + + + + } + + } \ No newline at end of file diff --git a/src/lime/_internal/backend/native/NativeApplication.hx b/src/lime/_internal/backend/native/NativeApplication.hx index 19fa0c794..dd0c9a93c 100644 --- a/src/lime/_internal/backend/native/NativeApplication.hx +++ b/src/lime/_internal/backend/native/NativeApplication.hx @@ -631,9 +631,18 @@ class NativeApplication { window.onLeave.dispatch (); + case WINDOW_MAXIMIZE: + + window.__maximized = true; + window.__fullscreen = false; + window.__minimized = false; + window.onMaximize.dispatch (); + case WINDOW_MINIMIZE: window.__minimized = true; + window.__maximized = false; + window.__fullscreen = false; window.onMinimize.dispatch (); case WINDOW_MOVE: @@ -1173,9 +1182,10 @@ class NativeApplication { var WINDOW_FOCUS_IN = 5; var WINDOW_FOCUS_OUT = 6; var WINDOW_LEAVE = 7; - var WINDOW_MINIMIZE = 8; - var WINDOW_MOVE = 9; - var WINDOW_RESIZE = 10; - var WINDOW_RESTORE = 11; + var WINDOW_MAXIMIZE = 8; + var WINDOW_MINIMIZE = 9; + var WINDOW_MOVE = 10; + var WINDOW_RESIZE = 11; + var WINDOW_RESTORE = 12; } diff --git a/src/lime/_internal/backend/native/NativeCFFI.hx b/src/lime/_internal/backend/native/NativeCFFI.hx index 404a070a3..4deed42ed 100644 --- a/src/lime/_internal/backend/native/NativeCFFI.hx +++ b/src/lime/_internal/backend/native/NativeCFFI.hx @@ -142,11 +142,6 @@ class NativeCFFI { @:cffi private static function lime_key_event_manager_register (callback:Dynamic, eventObject:Dynamic):Void; @:cffi private static function lime_lzma_compress (data:Dynamic, bytes:Dynamic):Dynamic; @:cffi private static function lime_lzma_decompress (data:Dynamic, bytes:Dynamic):Dynamic; - @:cffi private static function lime_mouse_hide ():Void; - @:cffi private static function lime_mouse_set_cursor (cursor:Int):Void; - @:cffi private static function lime_mouse_set_lock (lock:Bool):Void; - @:cffi private static function lime_mouse_show ():Void; - @:cffi private static function lime_mouse_warp (x:Int, y:Int, window:Dynamic):Void; @:cffi private static function lime_mouse_event_manager_register (callback:Dynamic, eventObject:Dynamic):Void; @:cffi private static function lime_neko_execute (module:String):Void; @:cffi private static function lime_png_decode_bytes (data:Dynamic, decodeData:Bool, buffer:Dynamic):Dynamic; @@ -168,11 +163,6 @@ class NativeCFFI { @:cffi private static function lime_system_open_file (path:String):Void; @:cffi private static function lime_system_open_url (url:String, target:String):Void; @:cffi private static function lime_text_event_manager_register (callback:Dynamic, eventObject:Dynamic):Void; - @:cffi private static function lime_text_layout_create (direction:Int, script:String, language:String):Dynamic; - @:cffi private static function lime_text_layout_position (textHandle:Dynamic, fontHandle:Dynamic, size:Int, textString:String, data:Dynamic):Dynamic; - @:cffi private static function lime_text_layout_set_direction (textHandle:Dynamic, direction:Int):Void; - @:cffi private static function lime_text_layout_set_language (textHandle:Dynamic, language:String):Void; - @:cffi private static function lime_text_layout_set_script (textHandle:Dynamic, script:String):Void; @:cffi private static function lime_touch_event_manager_register (callback:Dynamic, eventObject:Dynamic):Void; @:cffi private static function lime_window_alert (handle:Dynamic, message:String, title:String):Void; @:cffi private static function lime_window_close (handle:Dynamic):Void; @@ -186,10 +176,11 @@ class NativeCFFI { @:cffi private static function lime_window_get_context_type (handle:Dynamic):Dynamic; @:cffi private static function lime_window_get_display (handle:Dynamic):Int; @:cffi private static function lime_window_get_display_mode (handle:Dynamic):Dynamic; - @:cffi private static function lime_window_get_enable_text_events (handle:Dynamic):Bool; @:cffi private static function lime_window_get_height (handle:Dynamic):Int; @:cffi private static function lime_window_get_id (handle:Dynamic):Int; + @:cffi private static function lime_window_get_mouse_lock (handle:Dynamic):Bool; @:cffi private static function lime_window_get_scale (handle:Dynamic):Float; + @:cffi private static function lime_window_get_text_input_enabled (handle:Dynamic):Bool; @:cffi private static function lime_window_get_width (handle:Dynamic):Int; @:cffi private static function lime_window_get_x (handle:Dynamic):Int; @:cffi private static function lime_window_get_y (handle:Dynamic):Int; @@ -197,14 +188,17 @@ class NativeCFFI { @:cffi private static function lime_window_read_pixels (handle:Dynamic, rect:Dynamic, imageBuffer:Dynamic):Dynamic; @:cffi private static function lime_window_resize (handle:Dynamic, width:Int, height:Int):Void; @:cffi private static function lime_window_set_borderless (handle:Dynamic, borderless:Bool):Bool; + @:cffi private static function lime_window_set_cursor (handle:Dynamic, cursor:Int):Void; @:cffi private static function lime_window_set_display_mode (handle:Dynamic, displayMode:Dynamic):Dynamic; - @:cffi private static function lime_window_set_enable_text_events (handle:Dynamic, enabled:Bool):Void; @:cffi private static function lime_window_set_fullscreen (handle:Dynamic, fullscreen:Bool):Bool; @:cffi private static function lime_window_set_icon (handle:Dynamic, buffer:Dynamic):Void; @:cffi private static function lime_window_set_maximized (handle:Dynamic, maximized:Bool):Bool; @:cffi private static function lime_window_set_minimized (handle:Dynamic, minimized:Bool):Bool; + @:cffi private static function lime_window_set_mouse_lock (handle:Dynamic, mouseLock:Bool):Void; @:cffi private static function lime_window_set_resizable (handle:Dynamic, resizable:Bool):Bool; + @:cffi private static function lime_window_set_text_input_enabled (handle:Dynamic, enabled:Bool):Void; @:cffi private static function lime_window_set_title (handle:Dynamic, title:String):Dynamic; + @:cffi private static function lime_window_warp_mouse (handle:Dynamic, x:Int, y:Int):Void; @:cffi private static function lime_window_event_manager_register (callback:Dynamic, eventObject:Dynamic):Void; @:cffi private static function lime_zlib_compress (data:Dynamic, bytes:Dynamic):Dynamic; @:cffi private static function lime_zlib_decompress (data:Dynamic, bytes:Dynamic):Dynamic; @@ -295,11 +289,6 @@ class NativeCFFI { private static var lime_key_event_manager_register = new cpp.Callablecpp.Object->cpp.Void> (cpp.Prime._loadPrime ("lime", "lime_key_event_manager_register", "oov", false)); private static var lime_lzma_compress = new cpp.Callablecpp.Object->cpp.Object> (cpp.Prime._loadPrime ("lime", "lime_lzma_compress", "ooo", false)); private static var lime_lzma_decompress = new cpp.Callablecpp.Object->cpp.Object> (cpp.Prime._loadPrime ("lime", "lime_lzma_decompress", "ooo", false)); - private static var lime_mouse_hide = new cpp.Callablecpp.Void> (cpp.Prime._loadPrime ("lime", "lime_mouse_hide", "v", false)); - private static var lime_mouse_set_cursor = new cpp.Callablecpp.Void> (cpp.Prime._loadPrime ("lime", "lime_mouse_set_cursor", "iv", false)); - private static var lime_mouse_set_lock = new cpp.Callablecpp.Void> (cpp.Prime._loadPrime ("lime", "lime_mouse_set_lock", "bv", false)); - private static var lime_mouse_show = new cpp.Callablecpp.Void> (cpp.Prime._loadPrime ("lime", "lime_mouse_show", "v", false)); - private static var lime_mouse_warp = new cpp.CallableInt->cpp.Object->cpp.Void> (cpp.Prime._loadPrime ("lime", "lime_mouse_warp", "iiov", false)); private static var lime_mouse_event_manager_register = new cpp.Callablecpp.Object->cpp.Void> (cpp.Prime._loadPrime ("lime", "lime_mouse_event_manager_register", "oov", false)); private static var lime_neko_execute = new cpp.Callablecpp.Void> (cpp.Prime._loadPrime ("lime", "lime_neko_execute", "sv", false)); private static var lime_png_decode_bytes = new cpp.CallableBool->cpp.Object->cpp.Object> (cpp.Prime._loadPrime ("lime", "lime_png_decode_bytes", "oboo", false)); @@ -321,11 +310,6 @@ class NativeCFFI { private static var lime_system_open_file = new cpp.Callablecpp.Void> (cpp.Prime._loadPrime ("lime", "lime_system_open_file", "sv", false)); private static var lime_system_open_url = new cpp.CallableString->cpp.Void> (cpp.Prime._loadPrime ("lime", "lime_system_open_url", "ssv", false)); private static var lime_text_event_manager_register = new cpp.Callablecpp.Object->cpp.Void> (cpp.Prime._loadPrime ("lime", "lime_text_event_manager_register", "oov", false)); - private static var lime_text_layout_create = new cpp.CallableString->String->cpp.Object> (cpp.Prime._loadPrime ("lime", "lime_text_layout_create", "isso", false)); - private static var lime_text_layout_position = new cpp.Callablecpp.Object->Int->String->cpp.Object->cpp.Object> (cpp.Prime._loadPrime ("lime", "lime_text_layout_position", "ooisoo", false)); - private static var lime_text_layout_set_direction = new cpp.CallableInt->cpp.Void> (cpp.Prime._loadPrime ("lime", "lime_text_layout_set_direction", "oiv", false)); - private static var lime_text_layout_set_language = new cpp.CallableString->cpp.Void> (cpp.Prime._loadPrime ("lime", "lime_text_layout_set_language", "osv", false)); - private static var lime_text_layout_set_script = new cpp.CallableString->cpp.Void> (cpp.Prime._loadPrime ("lime", "lime_text_layout_set_script", "osv", false)); private static var lime_touch_event_manager_register = new cpp.Callablecpp.Object->cpp.Void> (cpp.Prime._loadPrime ("lime", "lime_touch_event_manager_register", "oov", false)); private static var lime_window_alert = new cpp.CallableString->String->cpp.Void> (cpp.Prime._loadPrime ("lime", "lime_window_alert", "ossv", false)); private static var lime_window_close = new cpp.Callablecpp.Void> (cpp.Prime._loadPrime ("lime", "lime_window_close", "ov", false)); @@ -339,10 +323,11 @@ class NativeCFFI { private static var lime_window_get_context_type = new cpp.Callablecpp.Object> (cpp.Prime._loadPrime ("lime", "lime_window_get_context_type", "oo", false)); private static var lime_window_get_display = new cpp.CallableInt> (cpp.Prime._loadPrime ("lime", "lime_window_get_display", "oi", false)); private static var lime_window_get_display_mode = new cpp.Callablecpp.Object> (cpp.Prime._loadPrime ("lime", "lime_window_get_display_mode", "oo", false)); - private static var lime_window_get_enable_text_events = new cpp.CallableBool> (cpp.Prime._loadPrime ("lime", "lime_window_get_enable_text_events", "ob", false)); private static var lime_window_get_height = new cpp.CallableInt> (cpp.Prime._loadPrime ("lime", "lime_window_get_height", "oi", false)); private static var lime_window_get_id = new cpp.CallableInt> (cpp.Prime._loadPrime ("lime", "lime_window_get_id", "oi", false)); + private static var lime_window_get_mouse_lock = new cpp.Callablecpp.Void> (cpp.Prime._loadPrime ("lime", "lime_window_get_mouse_lock", "ov", false)); private static var lime_window_get_scale = new cpp.CallableFloat> (cpp.Prime._loadPrime ("lime", "lime_window_get_scale", "od", false)); + private static var lime_window_get_text_input_enabled = new cpp.CallableBool> (cpp.Prime._loadPrime ("lime", "lime_window_get_text_input_enabled", "ob", false)); private static var lime_window_get_width = new cpp.CallableInt> (cpp.Prime._loadPrime ("lime", "lime_window_get_width", "oi", false)); private static var lime_window_get_x = new cpp.CallableInt> (cpp.Prime._loadPrime ("lime", "lime_window_get_x", "oi", false)); private static var lime_window_get_y = new cpp.CallableInt> (cpp.Prime._loadPrime ("lime", "lime_window_get_y", "oi", false)); @@ -350,14 +335,17 @@ class NativeCFFI { private static var lime_window_read_pixels = new cpp.Callablecpp.Object->cpp.Object->cpp.Object> (cpp.Prime._loadPrime ("lime", "lime_window_read_pixels", "oooo", false)); private static var lime_window_resize = new cpp.CallableInt->Int->cpp.Void> (cpp.Prime._loadPrime ("lime", "lime_window_resize", "oiiv", false)); private static var lime_window_set_borderless = new cpp.CallableBool->Bool> (cpp.Prime._loadPrime ("lime", "lime_window_set_borderless", "obb", false)); + private static var lime_window_set_cursor = new cpp.CallableInt->cpp.Void> (cpp.Prime._loadPrime ("lime", "lime_window_set_cursor", "oiv", false)); private static var lime_window_set_display_mode = new cpp.Callablecpp.Object->cpp.Object> (cpp.Prime._loadPrime ("lime", "lime_window_set_display_mode", "ooo", false)); - private static var lime_window_set_enable_text_events = new cpp.CallableBool->cpp.Void> (cpp.Prime._loadPrime ("lime", "lime_window_set_enable_text_events", "obv", false)); private static var lime_window_set_fullscreen = new cpp.CallableBool->Bool> (cpp.Prime._loadPrime ("lime", "lime_window_set_fullscreen", "obb", false)); private static var lime_window_set_icon = new cpp.Callablecpp.Object->cpp.Void> (cpp.Prime._loadPrime ("lime", "lime_window_set_icon", "oov", false)); private static var lime_window_set_maximized = new cpp.CallableBool->Bool> (cpp.Prime._loadPrime ("lime", "lime_window_set_maximized", "obb", false)); private static var lime_window_set_minimized = new cpp.CallableBool->Bool> (cpp.Prime._loadPrime ("lime", "lime_window_set_minimized", "obb", false)); + private static var lime_window_set_mouse_lock = new cpp.CallableBool->cpp.Void> (cpp.Prime._loadPrime ("lime", "lime_window_set_mouse_lock", "obv", false)); private static var lime_window_set_resizable = new cpp.CallableBool->Bool> (cpp.Prime._loadPrime ("lime", "lime_window_set_resizable", "obb", false)); + private static var lime_window_set_text_input_enabled = new cpp.CallableBool->cpp.Void> (cpp.Prime._loadPrime ("lime", "lime_window_set_text_input_enabled", "obv", false)); private static var lime_window_set_title = new cpp.CallableString->cpp.Object> (cpp.Prime._loadPrime ("lime", "lime_window_set_title", "oso", false)); + private static var lime_window_warp_mouse = new cpp.CallableInt->Int->cpp.Object> (cpp.Prime._loadPrime ("lime", "lime_window_warp_mouse", "oiiv", false)); private static var lime_window_event_manager_register = new cpp.Callablecpp.Object->cpp.Void> (cpp.Prime._loadPrime ("lime", "lime_window_event_manager_register", "oov", false)); private static var lime_zlib_compress = new cpp.Callablecpp.Object->cpp.Object> (cpp.Prime._loadPrime ("lime", "lime_zlib_compress", "ooo", false)); private static var lime_zlib_decompress = new cpp.Callablecpp.Object->cpp.Object> (cpp.Prime._loadPrime ("lime", "lime_zlib_decompress", "ooo", false)); @@ -451,11 +439,6 @@ class NativeCFFI { private static var lime_key_event_manager_register = CFFI.load ("lime", "lime_key_event_manager_register", 2); private static var lime_lzma_compress = CFFI.load ("lime", "lime_lzma_compress", 2); private static var lime_lzma_decompress = CFFI.load ("lime", "lime_lzma_decompress", 2); - private static var lime_mouse_hide = CFFI.load ("lime", "lime_mouse_hide", 0); - private static var lime_mouse_set_cursor = CFFI.load ("lime", "lime_mouse_set_cursor", 1); - private static var lime_mouse_set_lock = CFFI.load ("lime", "lime_mouse_set_lock", 1); - private static var lime_mouse_show = CFFI.load ("lime", "lime_mouse_show", 0); - private static var lime_mouse_warp = CFFI.load ("lime", "lime_mouse_warp", 3); private static var lime_mouse_event_manager_register = CFFI.load ("lime", "lime_mouse_event_manager_register", 2); private static var lime_neko_execute = CFFI.load ("lime", "lime_neko_execute", 1); private static var lime_png_decode_bytes = CFFI.load ("lime", "lime_png_decode_bytes", 3); @@ -477,11 +460,6 @@ class NativeCFFI { private static var lime_system_open_file = CFFI.load ("lime", "lime_system_open_file", 1); private static var lime_system_open_url = CFFI.load ("lime", "lime_system_open_url", 2); private static var lime_text_event_manager_register = CFFI.load ("lime", "lime_text_event_manager_register", 2); - private static var lime_text_layout_create = CFFI.load ("lime", "lime_text_layout_create", 3); - private static var lime_text_layout_position = CFFI.load ("lime", "lime_text_layout_position", 5); - private static var lime_text_layout_set_direction = CFFI.load ("lime", "lime_text_layout_set_direction", 2); - private static var lime_text_layout_set_language = CFFI.load ("lime", "lime_text_layout_set_language", 2); - private static var lime_text_layout_set_script = CFFI.load ("lime", "lime_text_layout_set_script", 2); private static var lime_touch_event_manager_register = CFFI.load ("lime", "lime_touch_event_manager_register", 2); private static var lime_window_alert = CFFI.load ("lime", "lime_window_alert", 3); private static var lime_window_close = CFFI.load ("lime", "lime_window_close", 1); @@ -495,10 +473,11 @@ class NativeCFFI { private static var lime_window_get_context_type = CFFI.load ("lime", "lime_window_get_context_type", 1); private static var lime_window_get_display = CFFI.load ("lime", "lime_window_get_display", 1); private static var lime_window_get_display_mode = CFFI.load ("lime", "lime_window_get_display_mode", 1); - private static var lime_window_get_enable_text_events = CFFI.load ("lime", "lime_window_get_enable_text_events", 1); private static var lime_window_get_height = CFFI.load ("lime", "lime_window_get_height", 1); private static var lime_window_get_id = CFFI.load ("lime", "lime_window_get_id", 1); + private static var lime_window_get_mouse_lock = CFFI.load ("lime", "lime_window_get_mouse_lock", 1); private static var lime_window_get_scale = CFFI.load ("lime", "lime_window_get_scale", 1); + private static var lime_window_get_text_input_enabled = CFFI.load ("lime", "lime_window_get_text_input_enabled", 1); private static var lime_window_get_width = CFFI.load ("lime", "lime_window_get_width", 1); private static var lime_window_get_x = CFFI.load ("lime", "lime_window_get_x", 1); private static var lime_window_get_y = CFFI.load ("lime", "lime_window_get_y", 1); @@ -506,14 +485,17 @@ class NativeCFFI { private static var lime_window_read_pixels = CFFI.load ("lime", "lime_window_read_pixels", 3); private static var lime_window_resize = CFFI.load ("lime", "lime_window_resize", 3); private static var lime_window_set_borderless = CFFI.load ("lime", "lime_window_set_borderless", 2); + private static var lime_window_set_cursor = CFFI.load ("lime", "lime_window_set_cursor", 2); private static var lime_window_set_display_mode = CFFI.load ("lime", "lime_window_set_display_mode", 2); - private static var lime_window_set_enable_text_events = CFFI.load ("lime", "lime_window_set_enable_text_events", 2); private static var lime_window_set_fullscreen = CFFI.load ("lime", "lime_window_set_fullscreen", 2); private static var lime_window_set_icon = CFFI.load ("lime", "lime_window_set_icon", 2); private static var lime_window_set_maximized = CFFI.load ("lime", "lime_window_set_maximized", 2); private static var lime_window_set_minimized = CFFI.load ("lime", "lime_window_set_minimized", 2); + private static var lime_window_set_mouse_lock = CFFI.load ("lime", "lime_window_set_mouse_lock", 2); private static var lime_window_set_resizable = CFFI.load ("lime", "lime_window_set_resizable", 2); + private static var lime_window_set_text_input_enabled = CFFI.load ("lime", "lime_window_set_text_input_enabled", 2); private static var lime_window_set_title = CFFI.load ("lime", "lime_window_set_title", 2); + private static var lime_window_warp_mouse = CFFI.load ("lime", "lime_window_warp_mouse", 3); private static var lime_window_event_manager_register = CFFI.load ("lime", "lime_window_event_manager_register", 2); private static var lime_zlib_compress = CFFI.load ("lime", "lime_zlib_compress", 2); private static var lime_zlib_decompress = CFFI.load ("lime", "lime_zlib_decompress", 2); @@ -611,11 +593,6 @@ class NativeCFFI { @:hlNative("lime", "lime_key_event_manager_register") private static function lime_key_event_manager_register (callback:Void->Void, eventObject:KeyEventInfo):Void {} @:hlNative("lime", "lime_lzma_compress") private static function lime_lzma_compress (data:Bytes, bytes:Bytes):Bytes { return null; } @:hlNative("lime", "lime_lzma_decompress") private static function lime_lzma_decompress (data:Bytes, bytes:Bytes):Bytes { return null; } - @:hlNative("lime", "lime_mouse_hide") private static function lime_mouse_hide ():Void {} - @:hlNative("lime", "lime_mouse_set_cursor") private static function lime_mouse_set_cursor (cursor:Int):Void {} - @:hlNative("lime", "lime_mouse_set_lock") private static function lime_mouse_set_lock (lock:Bool):Void {} - @:hlNative("lime", "lime_mouse_show") private static function lime_mouse_show ():Void {} - @:hlNative("lime", "lime_mouse_warp") private static function lime_mouse_warp (x:Int, y:Int, window:CFFIPointer):Void {} @:hlNative("lime", "lime_mouse_event_manager_register") private static function lime_mouse_event_manager_register (callback:Void->Void, eventObject:MouseEventInfo):Void {} // @:cffi private static function lime_neko_execute (module:String):Void; @:hlNative("lime", "lime_png_decode_bytes") private static function lime_png_decode_bytes (data:Bytes, decodeData:Bool, buffer:ImageBuffer):ImageBuffer { return null; } @@ -637,11 +614,6 @@ class NativeCFFI { @:hlNative("lime", "lime_system_open_file") private static function lime_system_open_file (path:String):Void {} @:hlNative("lime", "lime_system_open_url") private static function lime_system_open_url (url:String, target:String):Void {} @:hlNative("lime", "lime_text_event_manager_register") private static function lime_text_event_manager_register (callback:Void->Void, eventObject:TextEventInfo):Void {} - @:hlNative("lime", "lime_text_layout_create") private static function lime_text_layout_create (direction:Int, script:String, language:String):CFFIPointer { return null; } - @:hlNative("lime", "lime_text_layout_position") private static function lime_text_layout_position (textHandle:CFFIPointer, fontHandle:CFFIPointer, size:Int, textString:String, data:Bytes):Bytes { return null; } - @:hlNative("lime", "lime_text_layout_set_direction") private static function lime_text_layout_set_direction (textHandle:CFFIPointer, direction:Int):Void {} - @:hlNative("lime", "lime_text_layout_set_language") private static function lime_text_layout_set_language (textHandle:CFFIPointer, language:String):Void {} - @:hlNative("lime", "lime_text_layout_set_script") private static function lime_text_layout_set_script (textHandle:CFFIPointer, script:String):Void {} @:hlNative("lime", "lime_touch_event_manager_register") private static function lime_touch_event_manager_register (callback:Void->Void, eventObject:TouchEventInfo):Void {} @:hlNative("lime", "lime_window_alert") private static function lime_window_alert (handle:CFFIPointer, message:String, title:String):Void {} @:hlNative("lime", "lime_window_close") private static function lime_window_close (handle:CFFIPointer):Void {} @@ -655,10 +627,11 @@ class NativeCFFI { @:hlNative("lime", "lime_window_get_context_type") private static function lime_window_get_context_type (handle:CFFIPointer):hl.Bytes { return null; } @:hlNative("lime", "lime_window_get_display") private static function lime_window_get_display (handle:CFFIPointer):Int { return 0; } @:hlNative("lime", "lime_window_get_display_mode") private static function lime_window_get_display_mode (handle:CFFIPointer):Dynamic { return null; } - @:hlNative("lime", "lime_window_get_enable_text_events") private static function lime_window_get_enable_text_events (handle:CFFIPointer):Bool { return false; } @:hlNative("lime", "lime_window_get_height") private static function lime_window_get_height (handle:CFFIPointer):Int { return 0; } @:hlNative("lime", "lime_window_get_id") private static function lime_window_get_id (handle:CFFIPointer):Int { return 0; } + @:hlNative("lime", "lime_window_get_mouse_lock") private static function lime_window_get_mouse_lock (handle:CFFIPointer):Bool { return false; } @:hlNative("lime", "lime_window_get_scale") private static function lime_window_get_scale (handle:CFFIPointer):Float { return 0; } + @:hlNative("lime", "lime_window_get_text_input_enabled") private static function lime_window_get_text_input_enabled (handle:CFFIPointer):Bool { return false; } @:hlNative("lime", "lime_window_get_width") private static function lime_window_get_width (handle:CFFIPointer):Int { return 0; } @:hlNative("lime", "lime_window_get_x") private static function lime_window_get_x (handle:CFFIPointer):Int { return 0; } @:hlNative("lime", "lime_window_get_y") private static function lime_window_get_y (handle:CFFIPointer):Int { return 0; } @@ -666,14 +639,17 @@ class NativeCFFI { @:hlNative("lime", "lime_window_read_pixels") private static function lime_window_read_pixels (handle:CFFIPointer, rect:Rectangle, imageBuffer:ImageBuffer):Dynamic { return null; } @:hlNative("lime", "lime_window_resize") private static function lime_window_resize (handle:CFFIPointer, width:Int, height:Int):Void {} @:hlNative("lime", "lime_window_set_borderless") private static function lime_window_set_borderless (handle:CFFIPointer, borderless:Bool):Bool { return false; } + @:hlNative("lime", "lime_window_set_cursor") private static function lime_window_set_cursor (handle:CFFIPointer, cursor:Int):Void {} @:hlNative("lime", "lime_window_set_display_mode") private static function lime_window_set_display_mode (handle:CFFIPointer, displayMode:DisplayMode):DisplayMode { return null; } - @:hlNative("lime", "lime_window_set_enable_text_events") private static function lime_window_set_enable_text_events (handle:CFFIPointer, enabled:Bool):Void {} @:hlNative("lime", "lime_window_set_fullscreen") private static function lime_window_set_fullscreen (handle:CFFIPointer, fullscreen:Bool):Bool { return false; } @:hlNative("lime", "lime_window_set_icon") private static function lime_window_set_icon (handle:CFFIPointer, buffer:ImageBuffer):Void {} @:hlNative("lime", "lime_window_set_maximized") private static function lime_window_set_maximized (handle:CFFIPointer, maximized:Bool):Bool { return false; } @:hlNative("lime", "lime_window_set_minimized") private static function lime_window_set_minimized (handle:CFFIPointer, minimized:Bool):Bool { return false; } + @:hlNative("lime", "lime_window_set_mouse_lock") private static function lime_window_set_mouse_lock (handle:CFFIPointer, mouseLock:Bool):Void {} @:hlNative("lime", "lime_window_set_resizable") private static function lime_window_set_resizable (handle:CFFIPointer, resizable:Bool):Bool { return false; } + @:hlNative("lime", "lime_window_set_text_input_enabled") private static function lime_window_set_text_input_enabled (handle:CFFIPointer, enabled:Bool):Void {} @:hlNative("lime", "lime_window_set_title") private static function lime_window_set_title (handle:CFFIPointer, title:String):String { return null; } + @:hlNative("lime", "lime_window_warp_mouse") private static function lime_window_warp_mouse (handle:CFFIPointer, x:Int, y:Int):Void {} @:hlNative("lime", "lime_window_event_manager_register") private static function lime_window_event_manager_register (callback:Void->Void, eventObject:WindowEventInfo):Void {} @:hlNative("lime", "lime_zlib_compress") private static function lime_zlib_compress (data:Bytes, bytes:Bytes):Bytes { return null; } @:hlNative("lime", "lime_zlib_decompress") private static function lime_zlib_decompress (data:Bytes, bytes:Bytes):Bytes { return null; } diff --git a/src/lime/_internal/backend/native/NativeMouse.hx b/src/lime/_internal/backend/native/NativeMouse.hx deleted file mode 100644 index f81227bb5..000000000 --- a/src/lime/_internal/backend/native/NativeMouse.hx +++ /dev/null @@ -1,168 +0,0 @@ -package lime._internal.backend.native; - - -import lime._internal.backend.native.NativeCFFI; -import lime.ui.MouseCursor; -import lime.ui.Window; - -#if !lime_debug -@:fileXml('tags="haxe,release"') -@:noDebug -#end - -@:access(lime._internal.backend.native.NativeCFFI) -@:access(lime.ui.Window) - - -class NativeMouse { - - - private static var __cursor:MouseCursor; - private static var __hidden:Bool; - private static var __lock:Bool; - - - public static function hide ():Void { - - if (!__hidden) { - - __hidden = true; - - #if (!macro && lime_cffi) - NativeCFFI.lime_mouse_hide (); - #end - - } - - } - - - public static function show ():Void { - - if (__hidden) { - - __hidden = false; - - #if (!macro && lime_cffi) - NativeCFFI.lime_mouse_show (); - #end - - } - - } - - - public static function warp (x:Int, y:Int, window:Window):Void { - - #if (!macro && lime_cffi) - NativeCFFI.lime_mouse_warp (x, y, window == null ? 0 : window.__backend.handle); - #end - - } - - - - - // Get & Set Methods - - - - - public static function get_cursor ():MouseCursor { - - if (__cursor == null) return DEFAULT; - return __cursor; - - } - - - public static function set_cursor (value:MouseCursor):MouseCursor { - - if (__cursor != value) { - - if (!__hidden) { - - var type:MouseCursorType = switch (value) { - - case ARROW: ARROW; - case CROSSHAIR: CROSSHAIR; - case MOVE: MOVE; - case POINTER: POINTER; - case RESIZE_NESW: RESIZE_NESW; - case RESIZE_NS: RESIZE_NS; - case RESIZE_NWSE: RESIZE_NWSE; - case RESIZE_WE: RESIZE_WE; - case TEXT: TEXT; - case WAIT: WAIT; - case WAIT_ARROW: WAIT_ARROW; - default: DEFAULT; - - } - - #if (!macro && lime_cffi) - NativeCFFI.lime_mouse_set_cursor (type); - #end - - } - - __cursor = value; - - } - - return __cursor; - - } - - - public static function get_lock ():Bool { - - return __lock; - - } - - - public static function set_lock (value:Bool):Bool { - - if (__lock != value) { - - #if (!macro && lime_cffi) - NativeCFFI.lime_mouse_set_lock (value); - #end - - __hidden = value; - __lock = value; - - } - - return __lock; - - } - - - public static function get_visible ():Bool { - - // TODO: Use SDL_ShowCursor (SDL_QUERY) to poll state instead? - return !__hidden; - - } - - -} - - -@:enum private abstract MouseCursorType(Int) from Int to Int { - - var ARROW = 0; - var CROSSHAIR = 1; - var DEFAULT = 2; - var MOVE = 3; - var POINTER = 4; - var RESIZE_NESW = 5; - var RESIZE_NS = 6; - var RESIZE_NWSE = 7; - var RESIZE_WE = 8; - var TEXT = 9; - var WAIT = 10; - var WAIT_ARROW = 11; - -} \ No newline at end of file diff --git a/src/lime/_internal/backend/native/NativeWindow.hx b/src/lime/_internal/backend/native/NativeWindow.hx index 6018a4dd8..c3e39fb8b 100644 --- a/src/lime/_internal/backend/native/NativeWindow.hx +++ b/src/lime/_internal/backend/native/NativeWindow.hx @@ -20,6 +20,7 @@ import lime.system.Display; import lime.system.DisplayMode; import lime.system.JNI; import lime.system.System; +import lime.ui.Cursor; import lime.ui.Window; import lime.utils.UInt8Array; @@ -46,8 +47,10 @@ class NativeWindow { public var handle:Dynamic; private var closing:Bool; + private var cursor:Cursor; private var displayMode:DisplayMode; private var frameRate:Float; + private var mouseLock:Bool; private var parent:Window; private var useHardware:Bool; @@ -62,6 +65,7 @@ class NativeWindow { this.parent = parent; + cursor = DEFAULT; displayMode = new DisplayMode (0, 0, 0, 0); var attributes = parent.__attributes; @@ -269,6 +273,13 @@ class NativeWindow { } + public function getCursor ():Cursor { + + return cursor; + + } + + public function getDisplay ():Display { if (handle != null) { @@ -316,12 +327,27 @@ class NativeWindow { } - public function getEnableTextEvents ():Bool { + public function getMouseLock ():Bool { if (handle != null) { #if (!macro && lime_cffi) - return NativeCFFI.lime_window_get_enable_text_events (handle); + return NativeCFFI.lime_window_get_mouse_lock (handle); + #end + + } + + return mouseLock; + + } + + + public function getTextInputEnabled ():Bool { + + if (handle != null) { + + #if (!macro && lime_cffi) + return NativeCFFI.lime_window_get_text_input_enabled (handle); #end } @@ -502,6 +528,50 @@ class NativeWindow { } + public function setCursor (value:Cursor):Cursor { + + if (cursor != value) { + + if (value == null) { + + #if (!macro && lime_cffi) + NativeCFFI.lime_window_set_cursor (0); + #end + + } else { + + var type:CursorType = switch (value) { + + case ARROW: ARROW; + case CROSSHAIR: CROSSHAIR; + case MOVE: MOVE; + case POINTER: POINTER; + case RESIZE_NESW: RESIZE_NESW; + case RESIZE_NS: RESIZE_NS; + case RESIZE_NWSE: RESIZE_NWSE; + case RESIZE_WE: RESIZE_WE; + case TEXT: TEXT; + case WAIT: WAIT; + case WAIT_ARROW: WAIT_ARROW; + default: DEFAULT; + + } + + #if (!macro && lime_cffi) + NativeCFFI.lime_window_set_cursor (type); + #end + + } + + cursor = value; + + } + + return cursor; + + } + + public function setDisplayMode (value:DisplayMode):DisplayMode { if (handle != null) { @@ -521,12 +591,29 @@ class NativeWindow { } - public function setEnableTextEvents (value:Bool):Bool { + public function setMouseLock (value:Bool):Bool { + + if (mouseLock != value) { + + #if (!macro && lime_cffi) + NativeCFFI.lime_window_set_mouse_lock (value); + #end + + mouseLock = value; + + } + + return mouseLock; + + } + + + public function setTextInputEnabled (value:Bool):Bool { if (handle != null) { #if (!macro && lime_cffi) - NativeCFFI.lime_window_set_enable_text_events (handle, value); + NativeCFFI.lime_window_set_text_input_enabled (handle, value); #end #if android @@ -667,6 +754,34 @@ class NativeWindow { } + public function warpMouse (x:Int, y:Int):Void { + + #if (!macro && lime_cffi) + NativeCFFI.lime_window_warp_mouse (handle, x, y); + #end + + } + + +} + + +@:enum private abstract CursorType(Int) from Int to Int { + + var HIDDEN = 0; + var ARROW = 1; + var CROSSHAIR = 2; + var DEFAULT = 3; + var MOVE = 4; + var POINTER = 5; + var RESIZE_NESW = 6; + var RESIZE_NS = 7; + var RESIZE_NWSE = 8; + var RESIZE_WE = 9; + var TEXT = 10; + var WAIT = 11; + var WAIT_ARROW = 12; + } diff --git a/src/lime/ui/MouseCursor.hx b/src/lime/ui/Cursor.hx similarity index 88% rename from src/lime/ui/MouseCursor.hx rename to src/lime/ui/Cursor.hx index 8d07f8803..a5ccf69e0 100644 --- a/src/lime/ui/MouseCursor.hx +++ b/src/lime/ui/Cursor.hx @@ -1,7 +1,7 @@ package lime.ui; -enum MouseCursor { +enum Cursor { ARROW; CROSSHAIR; diff --git a/src/lime/ui/Mouse.hx b/src/lime/ui/Mouse.hx deleted file mode 100644 index 60224cc22..000000000 --- a/src/lime/ui/Mouse.hx +++ /dev/null @@ -1,90 +0,0 @@ -package lime.ui; - - -#if !lime_debug -@:fileXml('tags="haxe,release"') -@:noDebug -#end - - -class Mouse { - - - public static var cursor (get, set):MouseCursor; - public static var lock (get, set):Bool; - public static var visible (get, never):Bool; - - - public static function hide ():Void { - - MouseBackend.hide (); - - } - - - public static function show ():Void { - - MouseBackend.show (); - - } - - - public static function warp (x:Int, y:Int, window:Window = null):Void { - - MouseBackend.warp (x, y, window); - - } - - - - - // Get & Set Methods - - - - - private static function get_cursor ():MouseCursor { - - return MouseBackend.get_cursor (); - - } - - - private static function set_cursor (value:MouseCursor):MouseCursor { - - return MouseBackend.set_cursor (value); - - } - - - private static function get_lock ():Bool { - - return MouseBackend.get_lock (); - - } - - - private static function set_lock (value:Bool):Bool { - - return MouseBackend.set_lock (value); - - } - - - private static function get_visible ():Bool { - - return MouseBackend.get_visible (); - - } - - -} - - -#if flash -@:noCompletion private typedef MouseBackend = lime._internal.backend.flash.FlashMouse; -#elseif (js && html5) -@:noCompletion private typedef MouseBackend = lime._internal.backend.html5.HTML5Mouse; -#else -@:noCompletion private typedef MouseBackend = lime._internal.backend.native.NativeMouse; -#end \ No newline at end of file diff --git a/src/lime/ui/Window.hx b/src/lime/ui/Window.hx index 5a0e95842..1bf354c98 100644 --- a/src/lime/ui/Window.hx +++ b/src/lime/ui/Window.hx @@ -34,9 +34,9 @@ class Window { public var application (default, null):Application; public var borderless (get, set):Bool; public var context (default, null):RenderContext; + public var cursor (get, set):Cursor; public var display (get, null):Display; public var displayMode (get, set):DisplayMode; - public var enableTextEvents (get, set):Bool; /** * The current frame rate (measured in frames-per-second) of the window. @@ -52,6 +52,7 @@ class Window { public var id (default, null):Int; public var maximized (get, set):Bool; public var minimized (get, set):Bool; + public var mouseLock (get, set):Bool; public var onActivate (default, null) = new EventVoid> (); public var onClose (default, null) = new EventVoid> (); public var onDeactivate (default, null) = new EventVoid> (); @@ -64,6 +65,7 @@ class Window { public var onKeyDown (default, null) = new EventKeyModifier->Void> (); public var onKeyUp (default, null) = new EventKeyModifier->Void> (); public var onLeave (default, null) = new EventVoid> (); + public var onMaximize (default, null) = new EventVoid> (); public var onMinimize (default, null) = new EventVoid> (); public var onMouseDown (default, null) = new EventFloat->Int->Void> (); public var onMouseMove (default, null) = new EventFloat->Void> (); @@ -82,6 +84,7 @@ class Window { public var resizable (get, set):Bool; public var scale (get, null):Float; // public var stage:Stage; + public var textInputEnabled (get, set):Bool; public var title (get, set):String; public var width (get, set):Int; public var x (get, set):Int; @@ -109,15 +112,18 @@ class Window { var p = untyped Window.prototype; untyped Object.defineProperties (p, { "borderless": { get: p.get_borderless, set: p.set_borderless }, + "cursor": { get: p.get_cursor, set: p.set_cursor }, "display": { get: p.get_display }, "displayMode": { get: p.get_displayMode, set: p.set_displayMode }, - "enableTextEvents": { get: p.get_enableTextEvents, set: p.set_enableTextEvents }, "frameRate": { get: p.get_frameRate, set: p.set_frameRate }, "fullscreen": { get: p.get_fullscreen, set: p.set_fullscreen }, "height": { get: p.get_height, set: p.set_height }, "maximized": { get: p.get_maximized, set: p.set_maximized }, + "minimized": { get: p.get_minimized, set: p.set_minimized }, + "mouseLock": { get: p.get_mouseLock, set: p.set_mouseLock }, "resizable": { get: p.get_resizable, set: p.set_resizable }, "scale": { get: p.get_scale }, + "textInputEnabled": { get: p.get_textInputEnabled, set: p.set_textInputEnabled }, "title": { get: p.get_title, set: p.set_title }, "width": { get: p.get_width, set: p.set_width }, "x": { get: p.get_x, set: p.set_y }, @@ -427,6 +433,13 @@ class Window { } + public function warpMouse (x:Int, y:Int):Void { + + __backend.warpMouse (x, y); + + } + + // Get & Set Methods @@ -434,6 +447,20 @@ class Window { + @:noCompletion private function get_cursor ():Cursor { + + return __backend.getCursor (); + + } + + + @:noCompletion private function set_cursor (value:Cursor):Cursor { + + return __backend.setCursor (value); + + } + + @:noCompletion private function get_display ():Display { return __backend.getDisplay (); @@ -469,20 +496,6 @@ class Window { } - @:noCompletion private inline function get_enableTextEvents ():Bool { - - return __backend.getEnableTextEvents (); - - } - - - @:noCompletion private inline function set_enableTextEvents (value:Bool):Bool { - - return __backend.setEnableTextEvents (value); - - } - - @:noCompletion private inline function get_frameRate ():Float { return __backend.getFrameRate (); @@ -563,6 +576,21 @@ class Window { } + @:noCompletion private function get_mouseLock ():Bool { + + return __backend.getMouseLock (); + + } + + + @:noCompletion private function set_mouseLock (value:Bool):Bool { + + __backend.setMouseLock (value); + return value; + + } + + @:noCompletion private inline function get_resizable ():Bool { return __resizable; @@ -585,6 +613,20 @@ class Window { } + @:noCompletion private inline function get_textInputEnabled ():Bool { + + return __backend.getTextInputEnabled (); + + } + + + @:noCompletion private inline function set_textInputEnabled (value:Bool):Bool { + + return __backend.setTextInputEnabled (value); + + } + + @:noCompletion private inline function get_title ():String { return __title;