cat_engine/window/
mod.rs

1#[macro_use]
2mod event_handlers; // макросы для обратки событий
3
4mod window_base;
5pub (crate) use window_base::WindowBase;
6
7pub use window_base::default_draw_parameters;
8
9mod window_page;
10pub use window_page::WindowPage;
11
12mod window;
13pub use window::Window;
14
15mod settings;
16pub use settings::*;
17
18mod mouse_cursor;
19pub use mouse_cursor::MouseCursor;
20
21use glium::glutin::event::{
22    ModifiersState,
23    MouseScrollDelta,
24    MouseButton,
25};
26
27#[cfg(feature="file_drop")]
28use std::path::PathBuf;
29
30/// Положение курсора мыши. The mouse cursor position.
31pub static mut mouse_cursor:MouseCursor=MouseCursor::new();
32
33/// Ширина окна. The window width.
34pub static mut window_width:f32=0f32;
35/// Высота окна. The window height.
36pub static mut window_height:f32=0f32;
37/// Центр окна. The window center. [x, y]
38pub static mut window_center:[f32;2]=[0f32;2];
39
40/// Счётчик кадров в секунду. A frame per seconds counter. `feature = "fps_counter"`
41/// 
42/// Обновляется раз в секунду. Updates once a second.
43#[cfg(feature="fps_counter")]
44pub static mut fps:u32=0;
45
46/// Счётчик обновлений в секунду. An update per seconds counter. `feature = "ups_counter"`
47/// 
48/// Обновляется раз в секунду. Updates once a second.
49#[cfg(feature="ups_counter")]
50pub static mut ups:u32=0;
51
52#[derive(PartialEq)]
53pub (crate) enum EventLoopState<O:PartialEq>{
54    Running,
55    CloseRequested,
56    Closed(O),
57}
58
59/// Внутренние события для управления окном.
60/// Inner events to operate the window.
61#[derive(Clone,Debug)]
62pub enum InnerWindowEvent{
63    /// Emitted with `stop_events()` function.
64    EventLoopCloseRequested,
65    Update,
66}
67
68/// Внешние события окна.
69/// Outer window events.
70#[derive(Clone,Debug)]
71pub enum WindowEvent{
72    /// feature != "lazy"
73    #[cfg(not(feature="lazy"))]
74    Update,
75
76    /// Кадр окна можно обновить.
77    /// 
78    /// The window should be redrawn.
79    RedrawRequested,
80
81    /// The window has been requested to close.
82    CloseRequested,
83
84    /// Event loop has been stopped,
85    /// means that a page (closure) will be closed.
86    EventLoopClosed,
87
88    /// Приложение приостановлено.
89    /// 
90    /// Emitted when the application has been suspended.
91    Suspended,
92    /// Приложение возобновлено.
93    /// 
94    /// Emitted when the application has been resumed.
95    Resumed,
96
97    /// Окно получило или потеряло фокус.
98    /// True - получило, false - потеряло.
99    /// 
100    /// The window gained or lost focus.
101    /// The parameter is true if the window has gained focus,
102    /// and false if it has lost focus.
103    Focused(bool),
104
105    /// Размера окна изменён.
106    /// Содержит новый размер.
107    /// 
108    /// The size of the window has changed.
109    /// Contains the client area's new dimensions.
110    Resized([u32;2]),
111
112    /// Окно сдвинуто.
113    /// Содержит новую позицию.
114    /// 
115    /// The position of the window has changed.
116    /// Contains the window's new position.
117    Moved([i32;2]),
118
119    /// Сдвиг мышки (сдвиг за пределы экрана игнорируется).
120    /// 
121    /// Mouse movement (moving beyond the window border is ignored).
122    MouseMovementDelta([f32;2]),
123
124    /// Describes a difference in the mouse scroll wheel state.
125    MouseWheelScroll(MouseScrollDelta),
126    MousePressed(MouseButton),
127    MouseReleased(MouseButton),
128
129    KeyboardPressed(KeyboardButton),
130    KeyboardReleased(KeyboardButton),
131    CharacterInput(char),
132
133    /// Состояние Shift, Ctrl, Alt или Logo изменено.
134    /// 
135    /// Shift, Ctrl, Alt or Logo state has been changed.
136    ModifiersChanged(ModifiersState),
137
138    /// A file has been dropped into the window.
139    /// When the user drops multiple files at once,
140    /// this event will be emitted for each file separately.
141    /// 
142    /// feature = "file_drop"
143    #[cfg(feature="file_drop")]
144    DroppedFile(PathBuf),
145    /// A file is being hovered over the window.
146    /// When the user hovers multiple files at once,
147    /// this event will be emitted for each file separately.
148    ///
149    /// feature = "file_drop"
150    #[cfg(feature="file_drop")]
151    HoveredFile(PathBuf),
152    /// A file was hovered, but has exited the window.
153    /// There will be a single HoveredFileCancelled event triggered even
154    /// if multiple files were hovered.
155    /// 
156    /// feature = "file_drop"
157    #[cfg(feature="file_drop")]
158    HoveredFileCancelled,
159}
160
161#[derive(Clone,PartialEq,Debug)]
162#[repr(u32)]
163pub enum KeyboardButton{
164    One,
165    Two,
166    Three,
167    Four,
168    Five,
169    Six,
170    Seven,
171    Eight,
172    Nine,
173    Zero,
174    A,
175    B,
176    C,
177    D,
178    E,
179    F,
180    G,
181    H,
182    I,
183    J,
184    K,
185    L,
186    M,
187    N,
188    O,
189    P,
190    Q,
191    R,
192    S,
193    T,
194    U,
195    V,
196    W,
197    X,
198    Y,
199    Z,
200    Escape,
201    F1,
202    F2,
203    F3,
204    F4,
205    F5,
206    F6,
207    F7,
208    F8,
209    F9,
210    F10,
211    F11,
212    F12,
213    F13,
214    F14,
215    F15,
216    F16,
217    F17,
218    F18,
219    F19,
220    F20,
221    F21,
222    F22,
223    F23,
224    F24,
225    Screenshot,
226    Scroll,
227    Pause,
228    Insert,
229    Home,
230    Delete,
231    End,
232    PageDown,
233    PageUp,
234    Left,
235    Up,
236    Right,
237    Down,
238    Backspace,
239    Enter,
240    Space,
241    Compose,
242    Caret,
243    Numlock,
244    Numpad0,
245    Numpad1,
246    Numpad2,
247    Numpad3,
248    Numpad4,
249    Numpad5,
250    Numpad6,
251    Numpad7,
252    Numpad8,
253    Numpad9,
254    AbntC1,
255    AbntC2,
256    Add,
257    Apostrophe,
258    Apps,
259    At,
260    Ax,
261    Backslash,
262    Calculator,
263    Capital,
264    Colon,
265    Comma,
266    Convert,
267    Decimal,
268    Divide,
269    Equals,
270    Grave,
271    Kana,
272    Kanji,
273    LeftAlt,
274    LeftBracket,
275    LeftControl,
276    LeftShift,
277    LeftWin,
278    Mail,
279    MediaSelect,
280    MediaStop,
281    Minus,
282    Multiply,
283    Mute,
284    MyComputer,
285    NavigateForward,
286    NavigateBackward,
287    NextTrack,
288    NoConvert,
289    NumpadComma,
290    NumpadEnter,
291    NumpadEquals,
292    OEM102,
293    Period,
294    PlayPause,
295    Power,
296    PrevTrack,
297    RightAlt,
298    RightBracket,
299    RightControl,
300    RightShift,
301    RightWin,
302    Semicolon,
303    Slash,
304    Sleep,
305    Stop,
306    Subtract,
307    Sysrq,
308    Tab,
309    Underline,
310    Unlabeled,
311    VolumeDown,
312    VolumeUp,
313    Wake,
314    WebBack,
315    WebFavorites,
316    WebForward,
317    WebHome,
318    WebRefresh,
319    WebSearch,
320    WebStop,
321    Yen,
322    Copy,
323    Paste,
324    Cut,
325    Unknown,
326}