Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r48692 - in sandbox/guigl: boost/guigl libs/guigl/example libs/guigl/src
From: stipe_at_[hidden]
Date: 2008-09-09 20:45:13


Author: srajko
Date: 2008-09-09 20:45:13 EDT (Tue, 09 Sep 2008)
New Revision: 48692
URL: http://svn.boost.org/trac/boost/changeset/48692

Log:
added idle support
Text files modified:
   sandbox/guigl/boost/guigl/application.hpp | 4 ++--
   sandbox/guigl/libs/guigl/example/window_example.cpp | 9 +++++++++
   sandbox/guigl/libs/guigl/src/application.cpp | 16 ++++++++++++++++
   3 files changed, 27 insertions(+), 2 deletions(-)

Modified: sandbox/guigl/boost/guigl/application.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/application.hpp (original)
+++ sandbox/guigl/boost/guigl/application.hpp 2008-09-09 20:45:13 EDT (Tue, 09 Sep 2008)
@@ -10,14 +10,14 @@
 #define BOOST__GUIGL__APPLICATION_HPP
 
 
-#include <GLUT/glut.h>
-
+#include <boost/signals.hpp>
 
 namespace boost { namespace guigl {
 
 class application {
 public:
     static void run();
+ static boost::signal<void()> &on_idle();
 };
 
 }}

Modified: sandbox/guigl/libs/guigl/example/window_example.cpp
==============================================================================
--- sandbox/guigl/libs/guigl/example/window_example.cpp (original)
+++ sandbox/guigl/libs/guigl/example/window_example.cpp 2008-09-09 20:45:13 EDT (Tue, 09 Sep 2008)
@@ -19,6 +19,9 @@
 
 #include "two_spheres.hpp"
 
+#include <iostream>
+
+
 using namespace boost::guigl;
 
 color_type make_grey(double value)
@@ -26,6 +29,11 @@
     return color_type(value, value, value);
 }
 
+void idle()
+{
+ std::cout << "Idle called once." << std::endl;
+ application::on_idle().disconnect_all_slots();
+}
 
 int main()
 {
@@ -70,5 +78,6 @@
     window test_window_3d(( _depth = true, _label="3D", _color=make_grey(1) ));
     test_window_3d << new two_spheres(default_parameters());
     
+ application::on_idle().connect(&idle);
     application::run();
 }
\ No newline at end of file

Modified: sandbox/guigl/libs/guigl/src/application.cpp
==============================================================================
--- sandbox/guigl/libs/guigl/src/application.cpp (original)
+++ sandbox/guigl/libs/guigl/src/application.cpp 2008-09-09 20:45:13 EDT (Tue, 09 Sep 2008)
@@ -8,12 +8,28 @@
 
 
 #include <boost/guigl/application.hpp>
+#include <boost/guigl/platform/glut.hpp>
+
 
 namespace boost { namespace guigl {
 
+namespace {
+ void idle_func()
+ {
+ application::on_idle()();
+ }
+}
+
 void application::run()
 {
+ glutIdleFunc(idle_func);
     glutMainLoop();
 }
 
+boost::signal<void()> &application::on_idle()
+{
+ static boost::signal<void()> signal;
+ return signal;
+}
+
 }}
\ No newline at end of file


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk