1 /**
2  * ae.ui.shell.shell
3  *
4  * License:
5  *   This Source Code Form is subject to the terms of
6  *   the Mozilla Public License, v. 2.0. If a copy of
7  *   the MPL was not distributed with this file, You
8  *   can obtain one at http://mozilla.org/MPL/2.0/.
9  *
10  * Authors:
11  *   Vladimir Panteleev <ae@cy.md>
12  */
13 
14 module ae.ui.shell.shell;
15 
16 import ae.ui.video.video;
17 import ae.ui.audio.audio;
18 
19 /// A "shell" handles OS window management, input handling, and various other platform-dependent tasks.
20 class Shell
21 {
22 	/// Run the main loop.
23 	abstract void run();
24 
25 	/// Set window title.
26 	abstract void setCaption(string caption);
27 
28 	/// Request the event loop to stop.
29 	/// May be called from another thread.
30 	void quit()
31 	{
32 		if (!quitting)
33 		{
34 			quitting = true;
35 			prod();
36 		}
37 	}
38 
39 	/// Wake event thread with a no-op event.
40 	abstract void prod();
41 
42 	Video video; /// `Video` implementation.
43 	Audio audio; /// `Audio` implementation.
44 
45 protected:
46 	bool quitting;
47 }
48 
49 /// Specifies the window / screen mode.
50 enum ScreenMode
51 {
52 	windowed          , ///
53 	maximized         , ///
54 	fullscreen        , ///
55 	windowedFullscreen, ///
56 }
57 
58 /// The default / remembered screen settings.
59 struct ShellSettings
60 {
61 	uint fullScreenX = 1024; /// Full-screen resolution.
62 	uint fullScreenY =  768; /// ditto
63 	uint windowSizeX =  800; /// Window size.
64 	uint windowSizeY =  600; /// ditto
65 	int windowPosX   = int.min; /// Windows position. `int.min` means unset.
66 	int windowPosY   = int.min; /// ditto
67 	ScreenMode screenMode = ScreenMode.windowed; /// Window / screen mode.
68 }