1 /**
2  * Activity
3  */
4 module d2d.Activity;
5 
6 import std.algorithm;
7 import d2d;
8 
9 /**
10  * An object that represents an Activity or a Screen or a point in time of the display
11  * Draws itself to the screen, can handle events, and can contain components which do the same
12  * Adding components to an activity ensures that they will automatically get handled as long as the activity is active
13  */
14 abstract class Activity : EventHandler {
15 
16     Component[] components; ///All the components that the screen contains; components are handled separately from the screen
17     protected Display container; ///The display that contains this screen
18 
19     /**
20      * It may be useful for a screen to have access to it's containing display
21      */
22     this(Display container) {
23         this.container = container;
24     }
25 
26     /**
27      * How the screen should respond to events
28      * Is necessary because it is an event handler
29      */
30     void handleEvent(SDL_Event event) {
31     }
32 
33     /**
34      * How the screen should be drawn
35      * Drawing of screen components is handled after this method
36      */
37     void draw() {
38     }
39 
40     /**
41      * What the screen should do every screen update
42      * If the renderer is on VSync, update may be called more than once per actual frame
43      * Can be treated as the insides of a while(true) loop
44      */
45     void update() {
46     }
47 
48 }