|
@@ -81,6 +81,10 @@ Class AppInstance
|
|
If Not config config=New StringMap<String>
|
|
If Not config config=New StringMap<String>
|
|
|
|
|
|
_config=config
|
|
_config=config
|
|
|
|
+
|
|
|
|
+#if __TARGET__="android"
|
|
|
|
+ _touchMouse=True
|
|
|
|
+#endif
|
|
|
|
|
|
SDL_Init( SDL_INIT_EVERYTHING & ~SDL_INIT_AUDIO )
|
|
SDL_Init( SDL_INIT_EVERYTHING & ~SDL_INIT_AUDIO )
|
|
|
|
|
|
@@ -89,10 +93,16 @@ Class AppInstance
|
|
Mouse.Init()
|
|
Mouse.Init()
|
|
|
|
|
|
Audio.Init()
|
|
Audio.Init()
|
|
|
|
+
|
|
|
|
+#if __TARGET__="android"
|
|
|
|
|
|
-#If __TARGET__<>"emscripten"
|
|
|
|
-
|
|
|
|
-#If __HOSTOS__="windows"
|
|
|
|
|
|
+ SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION,2 )
|
|
|
|
+ SDL_GL_SetAttribute( SDL_GL_CONTEXT_MINOR_VERSION,0 )
|
|
|
|
+ SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK,SDL_GL_CONTEXT_PROFILE_ES )
|
|
|
|
+
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
+#if __TARGET__="desktop" and __HOSTOS__="windows"
|
|
|
|
|
|
Local gl_major:=Int( GetConfig( "GL_context_major_version",-1 ) )
|
|
Local gl_major:=Int( GetConfig( "GL_context_major_version",-1 ) )
|
|
Local gl_minor:=Int( GetConfig( "GL_context_major_version",-1 ) )
|
|
Local gl_minor:=Int( GetConfig( "GL_context_major_version",-1 ) )
|
|
@@ -117,6 +127,8 @@ Class AppInstance
|
|
|
|
|
|
#Endif
|
|
#Endif
|
|
|
|
|
|
|
|
+#if __TARGET__="desktop"
|
|
|
|
+
|
|
SDL_GL_SetAttribute( SDL_GL_SHARE_WITH_CURRENT_CONTEXT,1 )
|
|
SDL_GL_SetAttribute( SDL_GL_SHARE_WITH_CURRENT_CONTEXT,1 )
|
|
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER,1 )
|
|
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER,1 )
|
|
|
|
|
|
@@ -250,10 +262,6 @@ Class AppInstance
|
|
|
|
|
|
An app is active if any of its windows has system input focus.
|
|
An app is active if any of its windows has system input focus.
|
|
|
|
|
|
- If Active is true, then [[ActiveWindow]] will always be non-null.
|
|
|
|
-
|
|
|
|
- If Active is false, then [[ActiveWindow]] will always be null.
|
|
|
|
-
|
|
|
|
#end
|
|
#end
|
|
Property Active:Bool()
|
|
Property Active:Bool()
|
|
|
|
|
|
@@ -264,19 +272,13 @@ Class AppInstance
|
|
|
|
|
|
The active window is the window that has system input focus.
|
|
The active window is the window that has system input focus.
|
|
|
|
|
|
- If ActiveWindow is non-null, then [[Active]] will always be true.
|
|
|
|
-
|
|
|
|
- If ActiveWindow is null, then [[Active]] will always be false.
|
|
|
|
-
|
|
|
|
#end
|
|
#end
|
|
Property ActiveWindow:Window()
|
|
Property ActiveWindow:Window()
|
|
-
|
|
|
|
- #rem
|
|
|
|
|
|
+
|
|
If Not _activeWindow
|
|
If Not _activeWindow
|
|
Local windows:=Window.VisibleWindows()
|
|
Local windows:=Window.VisibleWindows()
|
|
If windows _activeWindow=windows[0]
|
|
If windows _activeWindow=windows[0]
|
|
Endif
|
|
Endif
|
|
- #end
|
|
|
|
|
|
|
|
Return _activeWindow
|
|
Return _activeWindow
|
|
End
|
|
End
|
|
@@ -313,6 +315,8 @@ Class AppInstance
|
|
Return _modalView
|
|
Return _modalView
|
|
End
|
|
End
|
|
|
|
|
|
|
|
+ #if __TARGET__="desktop"
|
|
|
|
+
|
|
#rem monkeydoc @hidden
|
|
#rem monkeydoc @hidden
|
|
#end
|
|
#end
|
|
Method WaitIdle()
|
|
Method WaitIdle()
|
|
@@ -325,6 +329,8 @@ Class AppInstance
|
|
future.Get()
|
|
future.Get()
|
|
End
|
|
End
|
|
|
|
|
|
|
|
+ #endif
|
|
|
|
+
|
|
#rem monkeydoc @hidden
|
|
#rem monkeydoc @hidden
|
|
#end
|
|
#end
|
|
Method GetConfig:String( name:String,defValue:String )
|
|
Method GetConfig:String( name:String,defValue:String )
|
|
@@ -392,7 +398,7 @@ Class AppInstance
|
|
SDL_WaitEvent( Null )
|
|
SDL_WaitEvent( Null )
|
|
|
|
|
|
Endif
|
|
Endif
|
|
-
|
|
|
|
|
|
+
|
|
UpdateEvents()
|
|
UpdateEvents()
|
|
|
|
|
|
UpdateWindows()
|
|
UpdateWindows()
|
|
@@ -440,7 +446,7 @@ Class AppInstance
|
|
_hoverView=Null
|
|
_hoverView=Null
|
|
Endif
|
|
Endif
|
|
|
|
|
|
- If Not _hoverView
|
|
|
|
|
|
+ If Not _hoverView And Not _touchMouse
|
|
_hoverView=ActiveViewAtMouseLocation()
|
|
_hoverView=ActiveViewAtMouseLocation()
|
|
If _mouseView And _hoverView<>_mouseView _hoverView=Null
|
|
If _mouseView And _hoverView<>_mouseView _hoverView=Null
|
|
If _hoverView SendMouseEvent( EventType.MouseEnter,_hoverView )
|
|
If _hoverView SendMouseEvent( EventType.MouseEnter,_hoverView )
|
|
@@ -461,8 +467,11 @@ Class AppInstance
|
|
#end
|
|
#end
|
|
Method Run()
|
|
Method Run()
|
|
|
|
|
|
|
|
+#if __TARGET__="desktop"
|
|
|
|
+
|
|
SDL_AddEventWatch( _EventFilter,Null )
|
|
SDL_AddEventWatch( _EventFilter,Null )
|
|
-
|
|
|
|
|
|
+
|
|
|
|
+#endif
|
|
RequestRender()
|
|
RequestRender()
|
|
|
|
|
|
#If __TARGET__="emscripten"
|
|
#If __TARGET__="emscripten"
|
|
@@ -483,6 +492,8 @@ Class AppInstance
|
|
|
|
|
|
Field _config:StringMap<String>
|
|
Field _config:StringMap<String>
|
|
|
|
|
|
|
|
+ Field _touchMouse:Bool=False 'mouse is really touch...
|
|
|
|
+
|
|
Field _defaultFont:Font
|
|
Field _defaultFont:Font
|
|
Field _theme:Theme
|
|
Field _theme:Theme
|
|
|
|
|
|
@@ -539,6 +550,10 @@ Class AppInstance
|
|
|
|
|
|
While SDL_PollEvent( Varptr event )
|
|
While SDL_PollEvent( Varptr event )
|
|
|
|
|
|
|
|
+ Keyboard.SendEvent( Varptr event )
|
|
|
|
+
|
|
|
|
+ Mouse.SendEvent( Varptr event )
|
|
|
|
+
|
|
DispatchEvent( Varptr event )
|
|
DispatchEvent( Varptr event )
|
|
|
|
|
|
Wend
|
|
Wend
|
|
@@ -609,7 +624,7 @@ Class AppInstance
|
|
End
|
|
End
|
|
|
|
|
|
Method DispatchEvent( event:SDL_Event Ptr )
|
|
Method DispatchEvent( event:SDL_Event Ptr )
|
|
-
|
|
|
|
|
|
+
|
|
Select event->type
|
|
Select event->type
|
|
|
|
|
|
Case SDL_KEYDOWN
|
|
Case SDL_KEYDOWN
|
|
@@ -658,7 +673,7 @@ Class AppInstance
|
|
_keyChar=String.FromChar( tevent->text[0] )
|
|
_keyChar=String.FromChar( tevent->text[0] )
|
|
|
|
|
|
SendKeyEvent( EventType.KeyChar )
|
|
SendKeyEvent( EventType.KeyChar )
|
|
-
|
|
|
|
|
|
+
|
|
Case SDL_MOUSEBUTTONDOWN
|
|
Case SDL_MOUSEBUTTONDOWN
|
|
|
|
|
|
Local mevent:=Cast<SDL_MouseButtonEvent Ptr>( event )
|
|
Local mevent:=Cast<SDL_MouseButtonEvent Ptr>( event )
|
|
@@ -674,20 +689,22 @@ Class AppInstance
|
|
Local view:=ActiveViewAtMouseLocation()
|
|
Local view:=ActiveViewAtMouseLocation()
|
|
|
|
|
|
If view
|
|
If view
|
|
-'#If __HOSTOS__<>"linux"
|
|
|
|
|
|
+
|
|
|
|
+ If _touchMouse
|
|
|
|
+ _hoverView=view
|
|
|
|
+ SendMouseEvent( EventType.MouseEnter,_hoverView )
|
|
|
|
+ Endif
|
|
|
|
+
|
|
SDL_CaptureMouse( SDL_TRUE )
|
|
SDL_CaptureMouse( SDL_TRUE )
|
|
-'#Endif
|
|
|
|
_mouseView=view
|
|
_mouseView=view
|
|
|
|
+
|
|
|
|
+ _mouseClicks=mevent->clicks
|
|
|
|
+
|
|
|
|
+ SendMouseEvent( EventType.MouseDown,_mouseView )
|
|
|
|
+
|
|
|
|
+ _mouseClicks=0
|
|
Endif
|
|
Endif
|
|
- Endif
|
|
|
|
-
|
|
|
|
- If _mouseView
|
|
|
|
-
|
|
|
|
- _mouseClicks=mevent->clicks
|
|
|
|
|
|
|
|
- SendMouseEvent( EventType.MouseDown,_mouseView )
|
|
|
|
-
|
|
|
|
- _mouseClicks=0
|
|
|
|
Endif
|
|
Endif
|
|
|
|
|
|
Case SDL_MOUSEBUTTONUP
|
|
Case SDL_MOUSEBUTTONUP
|
|
@@ -703,44 +720,85 @@ Class AppInstance
|
|
If _mouseView
|
|
If _mouseView
|
|
|
|
|
|
SendMouseEvent( EventType.MouseUp,_mouseView )
|
|
SendMouseEvent( EventType.MouseUp,_mouseView )
|
|
-'#If __HOSTOS__<>"linux"
|
|
|
|
|
|
+
|
|
SDL_CaptureMouse( SDL_FALSE )
|
|
SDL_CaptureMouse( SDL_FALSE )
|
|
-'#Endif
|
|
|
|
|
|
+
|
|
_mouseView=Null
|
|
_mouseView=Null
|
|
|
|
|
|
_mouseButton=Null
|
|
_mouseButton=Null
|
|
|
|
+
|
|
|
|
+ If _touchMouse
|
|
|
|
+ SendMouseEvent( EventType.MouseLeave,_hoverView )
|
|
|
|
+ _hoverView=Null
|
|
|
|
+ Endif
|
|
|
|
+
|
|
Endif
|
|
Endif
|
|
|
|
|
|
Case SDL_MOUSEMOTION
|
|
Case SDL_MOUSEMOTION
|
|
|
|
|
|
Local mevent:=Cast<SDL_MouseMotionEvent Ptr>( event )
|
|
Local mevent:=Cast<SDL_MouseMotionEvent Ptr>( event )
|
|
-
|
|
|
|
|
|
+
|
|
_window=Window.WindowForID( mevent->windowID )
|
|
_window=Window.WindowForID( mevent->windowID )
|
|
If Not _window Return
|
|
If Not _window Return
|
|
-
|
|
|
|
|
|
+
|
|
_mouseLocation=New Vec2i( mevent->x,mevent->y )
|
|
_mouseLocation=New Vec2i( mevent->x,mevent->y )
|
|
|
|
|
|
- Local view:=ActiveViewAtMouseLocation()
|
|
|
|
- If _mouseView And view<>_mouseView view=Null
|
|
|
|
|
|
+ If _mouseView
|
|
|
|
+
|
|
|
|
+ SendMouseEvent( EventType.MouseMove,_mouseView )
|
|
|
|
|
|
- If view<>_hoverView
|
|
|
|
|
|
+ Else If Not _touchMouse
|
|
|
|
|
|
- If _hoverView SendMouseEvent( EventType.MouseLeave,_hoverView )
|
|
|
|
|
|
+ Local view:=ActiveViewAtMouseLocation()
|
|
|
|
|
|
- _hoverView=view
|
|
|
|
|
|
+ If view<>_hoverView
|
|
|
|
+
|
|
|
|
+ If _hoverView SendMouseEvent( EventType.MouseLeave,_hoverView )
|
|
|
|
+
|
|
|
|
+ _hoverView=view
|
|
|
|
+
|
|
|
|
+ If _hoverView SendMouseEvent( EventType.MouseEnter,_hoverView )
|
|
|
|
+
|
|
|
|
+ Endif
|
|
|
|
|
|
- If _hoverView SendMouseEvent( EventType.MouseEnter,_hoverView )
|
|
|
|
|
|
+ If _hoverView SendMouseEvent( EventType.MouseMove,_hoverView )
|
|
|
|
+
|
|
Endif
|
|
Endif
|
|
|
|
|
|
- If _mouseView
|
|
|
|
-
|
|
|
|
- SendMouseEvent( EventType.MouseMove,_mouseView )
|
|
|
|
|
|
+ #rem
|
|
|
|
+ If Not _touchMouse Or _mouseView
|
|
|
|
+
|
|
|
|
+ Local mevent:=Cast<SDL_MouseMotionEvent Ptr>( event )
|
|
|
|
|
|
- Else If _hoverView
|
|
|
|
-
|
|
|
|
- SendMouseEvent( EventType.MouseMove,_hoverView )
|
|
|
|
|
|
+ _window=Window.WindowForID( mevent->windowID )
|
|
|
|
+ If Not _window Return
|
|
|
|
+
|
|
|
|
+ _mouseLocation=New Vec2i( mevent->x,mevent->y )
|
|
|
|
+
|
|
|
|
+ Local view:=ActiveViewAtMouseLocation()
|
|
|
|
+ If _mouseView And view<>_mouseView view=Null
|
|
|
|
+
|
|
|
|
+ If view<>_hoverView
|
|
|
|
+
|
|
|
|
+ If _hoverView SendMouseEvent( EventType.MouseLeave,_hoverView )
|
|
|
|
+
|
|
|
|
+ _hoverView=view
|
|
|
|
+
|
|
|
|
+ If _hoverView SendMouseEvent( EventType.MouseEnter,_hoverView )
|
|
|
|
+ Endif
|
|
|
|
+
|
|
|
|
+ If _mouseView
|
|
|
|
+
|
|
|
|
+ SendMouseEvent( EventType.MouseMove,_mouseView )
|
|
|
|
+
|
|
|
|
+ Else If _hoverView
|
|
|
|
+
|
|
|
|
+ SendMouseEvent( EventType.MouseMove,_hoverView )
|
|
|
|
+
|
|
|
|
+ Endif
|
|
|
|
|
|
Endif
|
|
Endif
|
|
|
|
+ #end
|
|
|
|
|
|
Case SDL_MOUSEWHEEL
|
|
Case SDL_MOUSEWHEEL
|
|
|
|
|
|
@@ -760,7 +818,7 @@ Class AppInstance
|
|
SendMouseEvent( EventType.MouseWheel,_hoverView )
|
|
SendMouseEvent( EventType.MouseWheel,_hoverView )
|
|
|
|
|
|
Endif
|
|
Endif
|
|
-
|
|
|
|
|
|
+
|
|
Case SDL_WINDOWEVENT
|
|
Case SDL_WINDOWEVENT
|
|
|
|
|
|
Local wevent:=Cast<SDL_WindowEvent Ptr>( event )
|
|
Local wevent:=Cast<SDL_WindowEvent Ptr>( event )
|
|
@@ -782,6 +840,8 @@ Class AppInstance
|
|
|
|
|
|
Case SDL_WINDOWEVENT_FOCUS_GAINED
|
|
Case SDL_WINDOWEVENT_FOCUS_GAINED
|
|
|
|
|
|
|
|
+ Print "SDL_WINDOWEVENT_FOCUS_GAINED"
|
|
|
|
+
|
|
Local active:=_active
|
|
Local active:=_active
|
|
_activeWindow=_window
|
|
_activeWindow=_window
|
|
_active=True
|
|
_active=True
|
|
@@ -792,8 +852,10 @@ Class AppInstance
|
|
|
|
|
|
Case SDL_WINDOWEVENT_FOCUS_LOST
|
|
Case SDL_WINDOWEVENT_FOCUS_LOST
|
|
|
|
|
|
|
|
+ Print "SDL_WINDOWEVENT_FOCUS_LOST"
|
|
|
|
+
|
|
Local active:=_active
|
|
Local active:=_active
|
|
- _activeWindow=Null
|
|
|
|
|
|
+' _activeWindow=Null 'too dangerous for now!
|
|
_active=False
|
|
_active=False
|
|
|
|
|
|
SendWindowEvent( EventType.WindowLostFocus )
|
|
SendWindowEvent( EventType.WindowLostFocus )
|
|
@@ -824,6 +886,18 @@ Class AppInstance
|
|
RemoveAsyncCallback( id )
|
|
RemoveAsyncCallback( id )
|
|
Endif
|
|
Endif
|
|
|
|
|
|
|
|
+ Case SDL_RENDER_TARGETS_RESET
|
|
|
|
+
|
|
|
|
+ Print "SDL_RENDER_TARGETS_RESET"
|
|
|
|
+
|
|
|
|
+ RequestRender()
|
|
|
|
+
|
|
|
|
+ Case SDL_RENDER_DEVICE_RESET
|
|
|
|
+
|
|
|
|
+ Print "SDL_RENDER_DEVICE_RESET"
|
|
|
|
+
|
|
|
|
+ mojo.graphics.glutil.glGraphicsSeq+=1
|
|
|
|
+
|
|
End
|
|
End
|
|
|
|
|
|
End
|
|
End
|