浏览代码

Added Window.OnCreateWindow virtual method.

Mark Sibly 7 年之前
父节点
当前提交
b132f2bd0d
共有 2 个文件被更改,包括 28 次插入0 次删除
  1. 2 0
      modules/mojo/app/app.monkey2
  2. 26 0
      modules/mojo/app/window.monkey2

+ 2 - 0
modules/mojo/app/app.monkey2

@@ -595,6 +595,8 @@ Class AppInstance
 		Local event:SDL_Event
 		Local event:SDL_Event
 
 
 		While SDL_PollEvent( Varptr event )
 		While SDL_PollEvent( Varptr event )
+			
+			Window.CreateNewWindows()
 		
 		
 			DispatchEvent( Varptr event )
 			DispatchEvent( Varptr event )
 			
 			

+ 26 - 0
modules/mojo/app/window.monkey2

@@ -292,6 +292,11 @@ Class Window Extends View
 	
 	
 	Protected
 	Protected
 	
 	
+	#rem monkeydoc Called once after a Window has been created.
+	#end
+	Method OnCreateWindow() Virtual
+	End
+	
 	#rem monkeydoc Theme changed handler.
 	#rem monkeydoc Theme changed handler.
 	
 	
 	Called when the App theme changes.
 	Called when the App theme changes.
@@ -337,6 +342,25 @@ Class Window Extends View
 	
 	
 		If _contentView _contentView.Frame=Rect
 		If _contentView _contentView.Frame=Rect
 	End
 	End
+
+	Internal
+	
+	Method CreateWindow()
+		
+		If _clearEnabled ClearWindow( _clearColor )
+			
+		OnCreateWindow()
+	End
+		
+	Function CreateNewWindows()
+		
+		For Local window:=Eachin _newWindows
+			
+			window.CreateWindow()
+		End
+		
+		_newWindows.Clear()
+	End
 	
 	
 	Private
 	Private
 	
 	
@@ -367,6 +391,7 @@ Class Window Extends View
 	Global _allWindows:=New Stack<Window>
 	Global _allWindows:=New Stack<Window>
 	Global _visibleWindows:=New Stack<Window>
 	Global _visibleWindows:=New Stack<Window>
 	Global _windowsByID:=New Map<UInt,Window>
 	Global _windowsByID:=New Map<UInt,Window>
+	Global _newWindows:=New Stack<Window>
 	
 	
 	Method SetMinSize( size:Vec2i )
 	Method SetMinSize( size:Vec2i )
 		size/=_mouseScale
 		size/=_mouseScale
@@ -552,6 +577,7 @@ Class Window Extends View
 		bbglInit()
 		bbglInit()
 		
 		
 		_allWindows.Push( Self )
 		_allWindows.Push( Self )
+		_newWindows.Push( Self )
 		_windowsByID[SDL_GetWindowID( _sdlWindow )]=Self
 		_windowsByID[SDL_GetWindowID( _sdlWindow )]=Self
 		If Not (flags & WindowFlags.Hidden) _visibleWindows.Push( Self )
 		If Not (flags & WindowFlags.Hidden) _visibleWindows.Push( Self )