misc/vim: inform the user when no results are found
[nit.git] / lib / mnit_display.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 display classes
18 module mnit_display
19
20 import mnit_input
21
22 # Any class with a size
23 interface Sized
24 fun width: Int is abstract
25 fun height: Int is abstract
26 end
27
28 # General image class, will be specialized for each classes
29 interface Image
30 super Sized
31 fun destroy is abstract
32
33 #var scale: Float is abstract
34 # Scale this image when blit
35 fun scale: Float is abstract
36 fun scale=( v: Float ) is abstract
37
38 #var blended: Bool is abstract
39 # Use blending on this image?
40 fun blended: Bool is abstract
41 fun blended=( v: Bool ) is abstract
42
43 # Get another image from this one
44 fun subimage( x, y, w, h: Int ): Image is abstract
45 end
46
47 # General class for everything drawable to
48 # Is used by drawable images and display
49 interface Drawable
50 type I: Image
51
52 # Call to prepare for drawing
53 fun begin is abstract
54
55 # Call when drawing is finished
56 fun finish is abstract
57
58 # Set viewport for drawing
59 fun set_viewport( x, y, w, h: Int ) is abstract
60
61 # Draw image on self, for top left position
62 fun blit(image: I, x, y: Numeric) is abstract
63
64 # Draw image on self, for top left position but scaled
65 # the width and height of the target rectangle is specified
66 fun blit_scaled(image: Image, x, y, w, h: Numeric)
67 do
68 var fx = x.to_f
69 var fy = y.to_f
70 var fx2 = fx + w.to_f
71 var fy2 = fy + h.to_f
72 blit_stretched(image, fx, fy, fx, fy2, fx2, fy2, fx2, fy)
73 end
74
75 # Draw image, centered at position
76 fun blit_centered(image: I, x, y: Numeric) is abstract
77
78 # Draw image, centered at position but rotated
79 fun blit_rotated(image: I, x, y: Numeric, angle: Float) is abstract
80
81 # Draw image, centered, rotated and scaled
82 fun blit_rotated_scaled(image: I, x, y: Numeric, angle, scale: Float) is abstract
83
84 # Draw image by specifying the positon of each image corners
85 # Corners are in counter-clockwise order stating top left
86 # a is top left, b is bottom left, c is bottom right and d is top right
87 # ~~~raw
88 # a-d
89 # | |
90 # b-c
91 # ~~~
92 fun blit_stretched(image: I, ax, ay, bx, by, cx, cy, dx, dy: Numeric)
93 is abstract
94
95 # Clear entire window with given color
96 fun clear( r, g, b: Float ) is abstract
97 end
98
99 # General display class, is sized and drawable
100 interface Display
101 super Sized
102 super Drawable
103 end
104
105 # General drawable display image
106 interface DrawableImage
107 super Drawable
108 super Image
109 end