lib: move mnit::display|input out of mnit
[nit.git] / lib / mnit_input.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Copyright 2011-2013 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 # Defines abstract classes for user and general inputs to the application.
18 # Implemented independantly for each platforms and technologies.
19 module mnit_input
20
21 # Input to the App, propagated through `App::input`.
22 interface InputEvent
23 end
24
25 # Mouse and touch input events
26 interface PointerEvent
27 super InputEvent
28
29 # X position on screen (in pixels)
30 fun x: Float is abstract
31
32 # Y position on screen (in pixels)
33 fun y: Float is abstract
34
35 # Is down? either going down or already down
36 fun pressed: Bool is abstract
37 fun depressed: Bool is abstract
38 end
39
40 # Pointer motion event, mais concern many events
41 interface MotionEvent
42 super InputEvent
43
44 # A pointer just went down?
45 fun just_went_down: Bool is abstract
46
47 # Which pointer is down, if any
48 fun down_pointer: nullable PointerEvent is abstract
49 end
50
51 # Specific touch event
52 interface TouchEvent
53 super PointerEvent
54
55 # Pressure level of input
56 fun pressure: Float is abstract
57 end
58
59 # Keyboard or other keys event
60 interface KeyEvent
61 super InputEvent
62
63 # Key is currently down?
64 fun is_down: Bool is abstract
65
66 # Key is currently up?
67 fun is_up: Bool is abstract
68
69 # Key is the up arrow key?
70 fun is_arrow_up: Bool is abstract
71
72 # Key is the left arrow key?
73 fun is_arrow_left: Bool is abstract
74
75 # Key is the down arrow key?
76 fun is_arrow_down: Bool is abstract
77
78 # Key is the right arrow key?
79 fun is_arrow_right: Bool is abstract
80
81 # Key code, is plateform specific
82 fun code: Int is abstract
83
84 # Get Char value of key, if any
85 fun to_c: nullable Char is abstract
86 end
87
88 # Mobile hardware (or pseudo hardware) event
89 interface MobileKeyEvent
90 super KeyEvent
91
92 # Key is back button? (mostly for Android)
93 fun is_back_key: Bool is abstract
94
95 # Key is menu button? (mostly for Android)
96 fun is_menu_key: Bool is abstract
97
98 # Key is search button? (mostly for Android)
99 fun is_search_key: Bool is abstract
100
101 # Key is home button? (mostly for Android)
102 fun is_home_key: Bool is abstract
103 end
104
105 # Sensor events like accelerometer, gyroscope etc for mobile apps
106 interface SensorEvent
107 super InputEvent
108 end
109
110 # Quit event, used for window close button
111 interface QuitEvent
112 super InputEvent
113 end