]> Dogcows Code - chaz/yoink/blob - src/Moof/View.hh
tcp socket disconnecting by remote
[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 #include <list>
16 #include <string>
17
18 #include <boost/shared_ptr.hpp>
19
20 #include <Moof/Event.hh>
21 #include <Moof/Math.hh>
22
23
24 namespace Mf {
25
26
27 class Settings;
28 class Video;
29
30 class View;
31 typedef boost::shared_ptr<View> ViewP;
32
33 /**
34 * The core is essentially a stack of layers. While running, it updates
35 * each layer from the bottom up every timestep. It also draws each layer
36 * from the bottom up, adhering to the maximum frame-rate. Events are sent
37 * to each layer from the top down until a layer signals the event was
38 * handled. The core is also responsible for firing timers on time. The
39 * core will continue running as long as there are layers on the stack.
40 */
41
42 class View
43 {
44 public:
45
46 // loads settings: rngseed, timestep, framerate, showfps
47 View(Settings& settings, Video& video);
48 View();
49
50 virtual ~View() {}
51
52 virtual void didAddToView() {}
53 virtual void willRemoveFromView() {}
54
55 virtual void update(Scalar t, Scalar dt);
56 virtual void draw(Scalar alpha) const;
57 virtual bool handleEvent(const Event& event);
58
59
60 void addChild(ViewP view);
61 ViewP removeChild(View* view);
62 ViewP removeChild(ViewP view);
63 void clear();
64
65 View& parent() const;
66 const std::list<ViewP>& children() const;
67
68 // do not call these without adding the view to a hierarchy with a base
69 // view constructed with settings and a video context
70 Settings& settings() const;
71 Video& video() const;
72
73 // set this machine in motion
74 void run();
75 void stop();
76 bool isRunning() const;
77
78 private:
79
80 class Impl;
81 boost::shared_ptr<Impl> mImpl;
82 };
83
84
85 } // namespace Mf
86
87 #endif // _MOOF_VIEW_HH_
88
This page took 0.031572 seconds and 4 git commands to generate.