]> Dogcows Code - chaz/yoink/blob - src/moof/view.hh
bugfix: win32 packaging script temp directories
[chaz/yoink] / src / moof / view.hh
1
2 /*] Copyright (c) 2009-2010, Charles McGarvey [**************************
3 **] All rights reserved.
4 *
5 * vi:ts=4 sw=4 tw=75
6 *
7 * Distributable under the terms and conditions of the 2-clause BSD license;
8 * see the file COPYING for a complete text of the license.
9 *
10 **************************************************************************/
11
12 #ifndef _MOOF_VIEW_HH_
13 #define _MOOF_VIEW_HH_
14
15 /**
16 * \file view.hh
17 * Fundamental architectural classes.
18 */
19
20 #include <list>
21 #include <string>
22
23 #include <boost/shared_ptr.hpp>
24
25 #include <moof/event.hh>
26 #include <moof/math.hh>
27
28
29 namespace moof {
30
31
32 class settings;
33 class video;
34
35 class view;
36 typedef boost::shared_ptr<view> view_ptr;
37
38
39 /**
40 * The core is essentially a stack of layers. While running, it updates
41 * each layer from the bottom up every timestep. It also draws each layer
42 * from the bottom up, adhering to the maximum frame-rate. Events are sent
43 * to each layer from the top down until a layer signals the event was
44 * handled. The core is also responsible for firing timers on time. The
45 * core will continue running as long as there are layers on the stack.
46 */
47 class view
48 {
49 public:
50
51 // loads settings: rngseed, timestep, framerate, showfps
52 view(moof::settings& settings, moof::video& video);
53 view();
54
55 virtual ~view() {}
56
57 virtual void did_add_to_view() {}
58 virtual void will_remove_from_view() {}
59
60 virtual void update(scalar t, scalar dt);
61 virtual void draw(scalar alpha) const;
62 virtual bool handle_event(const event& event);
63
64
65 void add_child(view_ptr view);
66 view_ptr remove_child(view* view);
67 view_ptr remove_child(view_ptr view);
68 void clear();
69
70 view& parent() const;
71 const std::list<view_ptr>& children() const;
72
73 // do not call these without adding the view to a hierarchy with a base
74 // view constructed with settings and a video context
75 moof::settings& settings() const;
76 moof::video& video() const;
77
78 // set this machine in motion
79 void run();
80 void stop();
81 bool is_running() const;
82
83
84 private:
85
86 class impl;
87 boost::shared_ptr<impl> impl_;
88 };
89
90
91 } // namespace moof
92
93 #endif // _MOOF_VIEW_HH_
94
This page took 0.03291 seconds and 4 git commands to generate.