]> Dogcows Code - chaz/yoink/blobdiff - src/moof/view.hh
the massive refactoring effort
[chaz/yoink] / src / moof / view.hh
diff --git a/src/moof/view.hh b/src/moof/view.hh
new file mode 100644 (file)
index 0000000..406c8ae
--- /dev/null
@@ -0,0 +1,94 @@
+
+/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+**]  All rights reserved.
+*
+* vi:ts=4 sw=4 tw=75
+*
+* Distributable under the terms and conditions of the 2-clause BSD license;
+* see the file COPYING for a complete text of the license.
+*
+**************************************************************************/
+
+#ifndef _MOOF_VIEW_HH_
+#define _MOOF_VIEW_HH_
+
+/**
+ * \file view.hh
+ * Fundamental architectural classes.
+ */
+
+#include <list>
+#include <string>
+
+#include <boost/shared_ptr.hpp>
+
+#include <moof/event.hh>
+#include <moof/math.hh>
+
+
+namespace moof {
+
+       
+class settings;
+class video;
+
+class view;
+typedef boost::shared_ptr<view> view_ptr;
+
+
+/**
+ * The core is essentially a stack of layers.  While running, it updates
+ * each layer from the bottom up every timestep.  It also draws each layer
+ * from the bottom up, adhering to the maximum frame-rate.  Events are sent
+ * to each layer from the top down until a layer signals the event was
+ * handled.  The core is also responsible for firing timers on time.  The
+ * core will continue running as long as there are layers on the stack.
+ */
+class view
+{
+public:
+
+       // loads settings: rngseed, timestep, framerate, showfps
+       view(moof::settings& settings, moof::video& video);
+       view();
+
+       virtual ~view() {}
+
+       virtual void did_add_to_view() {}
+       virtual void will_remove_from_view() {}
+
+       virtual void update(scalar t, scalar dt);
+       virtual void draw(scalar alpha) const;
+       virtual bool handle_event(const event& event);
+
+
+       void add_child(view_ptr view);
+       view_ptr remove_child(view* view);
+       view_ptr remove_child(view_ptr view);
+       void clear();
+
+       view& parent() const;
+       const std::list<view_ptr>& children() const;
+
+       // do not call these without adding the view to a hierarchy with a base
+       // view constructed with settings and a video context
+       moof::settings& settings() const;
+       moof::video& video() const;
+
+       // set this machine in motion
+       void run();
+       void stop();
+       bool is_running() const;
+
+
+private:
+
+       class impl;
+       boost::shared_ptr<impl> impl_;
+};
+
+
+} // namespace moof
+
+#endif // _MOOF_VIEW_HH_
+
This page took 0.023051 seconds and 4 git commands to generate.