1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
#[macro_use]
mod event_handlers; // макросы для обратки событий

mod window_base;
pub use window_base::WindowBase;

mod window;
pub use window::{Window,WindowPage};

mod paged_window;
pub use paged_window::PagedWindow;

mod dynamic_window;
pub use dynamic_window::{DynamicWindow,PageRef};

mod settings;
pub use settings::*;

mod mouse_cursor;
pub use mouse_cursor::MouseCursor;

use glium::glutin::event::{
    ModifiersState,
    MouseScrollDelta,
    MouseButton,
};

use std::path::PathBuf;

/// Положение курсора мыши. The mouse cursor position.
pub static mut mouse_cursor:MouseCursor=MouseCursor::new();

/// Ширина окна. The window width.
pub static mut window_width:f32=0f32;
/// Высота окна. The window height.
pub static mut window_height:f32=0f32;
/// Центр окна. The window center. [x, y]
pub static mut window_center:[f32;2]=[0f32;2];

/// Счётчик кадров в секунду. A frame per seconds counter. feature = "fps_counter"
/// 
/// Обновляется раз в секунду. Updates once a second.
#[cfg(feature="fps_counter")]
pub static mut fps:u32=0;

#[derive(PartialEq)]
pub (crate) enum EventLoopState<O:PartialEq>{
    Running,
    CloseRequested,
    Closed(O),
}

/// Внутренние события для управления окном.
/// Inner events to operate the window.
#[derive(Clone,Debug)]
pub enum InnerWindowEvent{
    /// Emitted with `stop_events()` function.
    EventLoopCloseRequested,
    Update,
}

/// Внешние события окна.
/// Outer window events.
#[derive(Clone,Debug)]
pub enum WindowEvent{
    /// feature != "lazy"
    #[cfg(not(feature="lazy"))]
    Update,

    /// Кадр окна можно обновить.
    /// 
    /// The window should be redrawn.
    RedrawRequested,

    /// The window has been requested to close.
    CloseRequested,

    /// Event loop has been stopped,
    /// means that a page (closure) will be closed.
    EventLoopClosed,

    /// Приложение приостановлено.
    /// 
    /// Emitted when the application has been suspended.
    Suspended,
    /// Приложение возобновлено.
    /// 
    /// Emitted when the application has been resumed.
    Resumed,

    /// Окно получило или потеряло фокус.
    /// True - получило, false - потеряло.
    /// 
    /// The window gained or lost focus.
    /// The parameter is true if the window has gained focus,
    /// and false if it has lost focus.
    Focused(bool),

    /// Размера окна изменён.
    /// Содержит новый размер.
    /// 
    /// The size of the window has changed.
    /// Contains the client area's new dimensions.
    Resized([u32;2]),

    /// Окно сдвинуто.
    /// Содержит новую позицию.
    /// 
    /// The position of the window has changed.
    /// Contains the window's new position.
    Moved([i32;2]),

    /// Сдвиг мышки (сдвиг за пределы экрана игнорируется).
    /// 
    /// Mouse movement (moving beyond the window border is ignored).
    MouseMovementDelta([f32;2]),
    /// Describes a difference in the mouse scroll wheel state.
    MouseWheelScroll(MouseScrollDelta),
    MousePressed(MouseButton),
    MouseReleased(MouseButton),

    KeyboardPressed(KeyboardButton),
    KeyboardReleased(KeyboardButton),
    CharacterInput(char),

    /// Состояние Shift, Ctrl, Alt или Logo изменено.
    /// 
    /// Shift, Ctrl, Alt or Logo state has been changed.
    ModifiersChanged(ModifiersState),

    /// A file has been dropped into the window.
    /// When the user drops multiple files at once,
    /// this event will be emitted for each file separately.
    /// 
    /// feature = "file_drop"
    #[cfg(feature="file_drop")]
    DroppedFile(PathBuf),
    /// A file is being hovered over the window.
    /// When the user hovers multiple files at once,
    /// this event will be emitted for each file separately.
    ///
    /// feature = "file_drop"
    #[cfg(feature="file_drop")]
    HoveredFile(PathBuf),
    /// A file was hovered, but has exited the window.
    /// There will be a single HoveredFileCancelled event triggered even
    /// if multiple files were hovered.
    /// 
    /// feature = "file_drop"
    #[cfg(feature="file_drop")]
    HoveredFileCancelled,
}

#[derive(Clone,PartialEq,Debug)]
#[repr(u32)]
pub enum KeyboardButton{
    One,
    Two,
    Three,
    Four,
    Five,
    Six,
    Seven,
    Eight,
    Nine,
    Zero,
    A,
    B,
    C,
    D,
    E,
    F,
    G,
    H,
    I,
    J,
    K,
    L,
    M,
    N,
    O,
    P,
    Q,
    R,
    S,
    T,
    U,
    V,
    W,
    X,
    Y,
    Z,
    Escape,
    F1,
    F2,
    F3,
    F4,
    F5,
    F6,
    F7,
    F8,
    F9,
    F10,
    F11,
    F12,
    F13,
    F14,
    F15,
    F16,
    F17,
    F18,
    F19,
    F20,
    F21,
    F22,
    F23,
    F24,
    Screenshot,
    Scroll,
    Pause,
    Insert,
    Home,
    Delete,
    End,
    PageDown,
    PageUp,
    Left,
    Up,
    Right,
    Down,
    Backspace,
    Enter,
    Space,
    Compose,
    Caret,
    Numlock,
    Numpad0,
    Numpad1,
    Numpad2,
    Numpad3,
    Numpad4,
    Numpad5,
    Numpad6,
    Numpad7,
    Numpad8,
    Numpad9,
    AbntC1,
    AbntC2,
    Add,
    Apostrophe,
    Apps,
    At,
    Ax,
    Backslash,
    Calculator,
    Capital,
    Colon,
    Comma,
    Convert,
    Decimal,
    Divide,
    Equals,
    Grave,
    Kana,
    Kanji,
    LeftAlt,
    LeftBracket,
    LeftControl,
    LeftShift,
    LeftWin,
    Mail,
    MediaSelect,
    MediaStop,
    Minus,
    Multiply,
    Mute,
    MyComputer,
    NavigateForward,
    NavigateBackward,
    NextTrack,
    NoConvert,
    NumpadComma,
    NumpadEnter,
    NumpadEquals,
    OEM102,
    Period,
    PlayPause,
    Power,
    PrevTrack,
    RightAlt,
    RightBracket,
    RightControl,
    RightShift,
    RightWin,
    Semicolon,
    Slash,
    Sleep,
    Stop,
    Subtract,
    Sysrq,
    Tab,
    Underline,
    Unlabeled,
    VolumeDown,
    VolumeUp,
    Wake,
    WebBack,
    WebFavorites,
    WebForward,
    WebHome,
    WebRefresh,
    WebSearch,
    WebStop,
    Yen,
    Copy,
    Paste,
    Cut,
    Unknown,
}