X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2FMoof%2FView.hh;fp=src%2FMoof%2FView.hh;h=9fae113025a34f7cb925ccf5edef65cef9ec3a52;hb=e0c0a3b5e7337cde55e520801d2e59e03dc97d9c;hp=0000000000000000000000000000000000000000;hpb=ed5fcf5f1357fc42749408f705e9ec55531ff006;p=chaz%2Fyoink diff --git a/src/Moof/View.hh b/src/Moof/View.hh new file mode 100644 index 0000000..9fae113 --- /dev/null +++ b/src/Moof/View.hh @@ -0,0 +1,88 @@ + +/*] 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_ + +#include +#include + +#include + +#include +#include + + +namespace Mf { + + +class Settings; +class Video; + +class View; +typedef boost::shared_ptr ViewP; + +/** + * 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(Settings& settings, Video& video); + View(); + + virtual ~View() {} + + virtual void didAddToView() {} + virtual void willRemoveFromView() {} + + virtual void update(Scalar t, Scalar dt); + virtual void draw(Scalar alpha) const; + virtual bool handleEvent(const Event& event); + + + void addChild(ViewP view); + ViewP removeChild(View* view); + ViewP removeChild(ViewP view); + void clear(); + + View& parent() const; + const std::list& children() const; + + // do not call these without adding the view to a hierarchy with a base + // view constructed with settings and a video context + Settings& settings() const; + Video& video() const; + + // set this machine in motion + void run(); + void stop(); + bool isRunning() const; + +private: + + class Impl; + boost::shared_ptr mImpl; +}; + + +} // namespace Mf + +#endif // _MOOF_VIEW_HH_ +