fdb94093e995d9bad8aa920b78d36b61b2cc456e
1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Copyright 2011-2013 Alexis Laferrière <alexis.laf@xymus.net>
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # General Mnit application structure
22 # An App instance serves as base to every Mnit projects.
24 # This class is redefed by plateforme modules and so
25 # App can be specialized directly in the user app.
31 # Display to use by apps
32 # Is null if the display is not available or not yet ready
33 var display
: nullable D
protected writable = null
36 var quit
: Bool writable = false
40 # App is visible? (vs minimized or in background)
41 fun visible
: Bool is abstract
43 # Invoqued at each frame
44 # Usually you want to redef frame_core instead of this
47 var display
= self.display
48 if display
!= null then
55 # Main frame method to redef
56 # Is called between readying display and flipping it
57 fun frame_core
( display
: D
) is abstract
63 # Called when asked by the system (mainly for Android)
66 # Called when asked by the system (mainly for Android)
69 # Called when asked by the system (mainly for Android)
73 fun gained_focus
do end
78 # Main init method for graphical stuff
79 # Is called when display is ready so graphical assets
80 # can be loaded at this time.
81 fun init_window
do end
83 # Called before destroying the window
84 fun term_window
do end
86 # Helper function for logging
87 fun log_error
( msg
: String ) do print
"#nit error: {msg}"
89 # Helper function for logging
90 fun log_warning
( msg
: String ) do print
"#nit warn: {msg}"
92 # Helper function for logging
93 fun log_info
( msg
: String ) do print
"#nit info: {msg}"
95 # Receive and deal with all inputs
96 fun input
( event
: InputEvent ): Bool
101 # Internal method to generate inputs
102 protected fun generate_input
is abstract
105 # Usually you want to redef framw_core instead of this