lib/mnit: do not redef virtual types
[nit.git] / lib / mnit / android / android_app.nit
1 # This file is part of NIT (http://www.nitlanguage.org).
2 #
3 # Copyright 2012-2014 Alexis Laferrière <alexis.laf@xymus.net>
4 #
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
8 #
9 # http://www.apache.org/licenses/LICENSE-2.0
10 #
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.
16
17 # Impements the services of `mnit:app` using the API from the Android ndk
18 module android_app is android_manifest_activity """
19 android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
20 android:configChanges="orientation|keyboardHidden"
21 """
22
23 import mnit
24 import mnit::opengles1
25 import ::android
26 intrude import ::android::input_events
27
28 in "C" `{
29 #include <EGL/egl.h>
30
31 extern EGLDisplay mnit_display;
32 extern EGLSurface mnit_surface;
33 extern EGLContext mnit_context;
34 extern EGLConfig mnit_config;
35 extern int32_t mnit_width;
36 extern int32_t mnit_height;
37 `}
38
39 redef class App
40 redef fun init_window
41 do
42 display = new Opengles1Display
43
44 super
45 end
46
47 redef fun full_frame do if not paused then super
48
49 redef fun generate_input do poll_looper 0
50
51 redef fun native_input_key(event)
52 do
53 return input(event)
54 end
55
56 redef fun native_input_motion(event)
57 do
58 var ie = new AndroidMotionEvent(event)
59 var handled = input(ie)
60
61 if not handled then
62 input ie.acting_pointer
63 end
64
65 return handled
66 end
67 end