$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r51373 - in sandbox/guigl: boost/guigl boost/guigl/view boost/guigl/view/impl boost/guigl/widget libs/guigl/build/xcodeide/guigl.xcodeproj libs/guigl/doc libs/guigl/example libs/guigl/platform libs/guigl/src
From: stipe_at_[hidden]
Date: 2009-02-21 15:12:35
Author: srajko
Date: 2009-02-21 15:12:33 EST (Sat, 21 Feb 2009)
New Revision: 51373
URL: http://svn.boost.org/trac/boost/changeset/51373
Log:
Added custom_event_processing, starting work on docs
Added:
   sandbox/guigl/boost/guigl/view/custom_event_processing.hpp   (contents, props changed)
   sandbox/guigl/libs/guigl/doc/usage.qbk   (contents, props changed)
   sandbox/guigl/libs/guigl/example/window_only_example.cpp   (contents, props changed)
   sandbox/guigl/libs/guigl/platform/
Text files modified: 
   sandbox/guigl/boost/guigl/event.hpp                                     |     8 +++++++-                                
   sandbox/guigl/boost/guigl/parameters.hpp                                |     1 +                                       
   sandbox/guigl/boost/guigl/view/custom_drawable.hpp                      |     2 +-                                      
   sandbox/guigl/boost/guigl/view/impl/static_compound.hpp                 |     4 ++++                                    
   sandbox/guigl/boost/guigl/widget/window.hpp                             |    11 +++++++----                             
   sandbox/guigl/libs/guigl/build/xcodeide/guigl.xcodeproj/project.pbxproj |     6 ++++++                                  
   sandbox/guigl/libs/guigl/doc/guigl.qbk                                  |    19 +++++++++++--------                     
   sandbox/guigl/libs/guigl/example/Jamfile                                |    18 ++++++++++++------                      
   sandbox/guigl/libs/guigl/example/custom_example.cpp                     |     2 +-                                      
   sandbox/guigl/libs/guigl/example/window_example.cpp                     |    12 ++++++++++--                            
   sandbox/guigl/libs/guigl/src/window.cpp                                 |    17 +++++++++++++++++                       
   11 files changed, 77 insertions(+), 23 deletions(-)
Modified: sandbox/guigl/boost/guigl/event.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/event.hpp	(original)
+++ sandbox/guigl/boost/guigl/event.hpp	2009-02-21 15:12:33 EST (Sat, 21 Feb 2009)
@@ -82,7 +82,13 @@
     direction::enum_type direction;
 };
 
-typedef boost::variant<button_event, movement_event, entry_exit_event> event_type;
+struct keyboard_event
+{
+    position_type position;
+    unsigned char key;
+};
+
+typedef boost::variant<button_event, movement_event, entry_exit_event, keyboard_event> event_type;
 
 }}
 
Modified: sandbox/guigl/boost/guigl/parameters.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/parameters.hpp	(original)
+++ sandbox/guigl/boost/guigl/parameters.hpp	2009-02-21 15:12:33 EST (Sat, 21 Feb 2009)
@@ -35,6 +35,7 @@
     BOOST_PARAMETER_UNTYPED_NAME(children)
     BOOST_PARAMETER_UNTYPED_NAME(draw_prologue)
     BOOST_PARAMETER_UNTYPED_NAME(draw_epilogue)
+    BOOST_PARAMETER_UNTYPED_NAME(on_event)
     
     typedef boost::parameter::aux::empty_typed_arg_list default_parameters;
 }
Modified: sandbox/guigl/boost/guigl/view/custom_drawable.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/view/custom_drawable.hpp	(original)
+++ sandbox/guigl/boost/guigl/view/custom_drawable.hpp	2009-02-21 15:12:33 EST (Sat, 21 Feb 2009)
@@ -50,4 +50,4 @@
 
 }}}
 
-#endif // BOOST__GUIGL__VIEW__CUSTOM_DRAW_HPP
+#endif // BOOST__GUIGL__VIEW__CUSTOM_DRAWABLE_HPP
Added: sandbox/guigl/boost/guigl/view/custom_event_processing.hpp
==============================================================================
--- (empty file)
+++ sandbox/guigl/boost/guigl/view/custom_event_processing.hpp	2009-02-21 15:12:33 EST (Sat, 21 Feb 2009)
@@ -0,0 +1,54 @@
+/*=================================---------------------------------------------
+    Copyright 2008 Stjepan Rajko
+  
+    Distributed under the Boost Software License, Version 1.0.
+    (See accompanying file LICENSE_1_0.txt or copy at
+    http://www.boost.org/LICENSE_1_0.txt)
+-----------------------------------------------===============================*/
+
+#ifndef BOOST__GUIGL__VIEW__CUSTOM_EVENT_PROCESSING_HPP
+#define BOOST__GUIGL__VIEW__CUSTOM_EVENT_PROCESSING_HPP
+
+#include <boost/guigl/view/base.hpp>
+
+namespace boost { namespace guigl { namespace view {
+
+template<typename Callable, typename BaseView=base>
+class custom_event_processing : public BaseView
+{
+public:
+    typedef BaseView base_type;
+
+    template<typename ArgumentPack>
+    custom_event_processing(const ArgumentPack &args)
+        : base_type(args)
+        , m_on_event(args[_draw_prologue|Callable()])
+    {}
+    custom_event_processing(const custom_event_processing &rhs)
+        : base_type(static_cast<const base_type &>(rhs))
+        , m_on_event(rhs.m_on_event)
+    {}
+    Callable &event_handler()
+    {
+        return m_on_event;
+    }
+    const Callable &event_handler() const
+    {
+        return m_on_event;
+    }
+protected:
+    bool on_event(const event_type &event)
+    {
+        if(!base_type::on_event(event))
+            if(m_on_event)
+                return m_on_event(event);
+            else return false;
+        return true;
+    };
+private:
+    Callable m_on_event;
+};
+
+}}}
+
+#endif // BOOST__GUIGL__VIEW__CUSTOM_EVENT_PROCESSING_HPP
Modified: sandbox/guigl/boost/guigl/view/impl/static_compound.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/view/impl/static_compound.hpp	(original)
+++ sandbox/guigl/boost/guigl/view/impl/static_compound.hpp	2009-02-21 15:12:33 EST (Sat, 21 Feb 2009)
@@ -164,6 +164,10 @@
     {
         view.m_button_focus_child = &child;
     }
+    bool operator()(const keyboard_event &event_info) const
+    {
+        return false;
+    }
     bool operator()(const button_event &event_info) const
     {
         if(view.m_button_focus_child && event_info.direction == direction::up)
Modified: sandbox/guigl/boost/guigl/widget/window.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/widget/window.hpp	(original)
+++ sandbox/guigl/boost/guigl/widget/window.hpp	2009-02-21 15:12:33 EST (Sat, 21 Feb 2009)
@@ -10,16 +10,19 @@
 #define BOOST__GUIGL__WIDGET__WINDOW_HPP
 
 #include <boost/guigl/export_symbols.hpp>
+#include <boost/guigl/view/custom_event_processing.hpp>
 #include <boost/guigl/view/compound.hpp>
 #include <boost/guigl/view/mouse_tracking.hpp>
 #include <boost/guigl/view/window.hpp>
+#include <boost/function.hpp>
 
 namespace boost { namespace guigl { namespace widget {
 
-typedef view::compound<
-            view::mouse_tracking<
-                view::window<>
-        >   > window_base_type;
+typedef view::custom_event_processing<boost::function<bool(const event_type &)>,
+            view::compound<
+                view::mouse_tracking<
+                    view::window<>
+        >   >   > window_base_type;
 
 class window
     : public window_base_type
Modified: sandbox/guigl/libs/guigl/build/xcodeide/guigl.xcodeproj/project.pbxproj
==============================================================================
--- sandbox/guigl/libs/guigl/build/xcodeide/guigl.xcodeproj/project.pbxproj	(original)
+++ sandbox/guigl/libs/guigl/build/xcodeide/guigl.xcodeproj/project.pbxproj	2009-02-21 15:12:33 EST (Sat, 21 Feb 2009)
@@ -149,6 +149,7 @@
                 089D83740E5A35D800325868 /* parameters.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = parameters.hpp; sourceTree = "<group>"; };
                 089D83780E5A3AA900325868 /* test_parameter_map_compilation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = test_parameter_map_compilation.cpp; sourceTree = "<group>"; };
                 089D83800E5A3C0B00325868 /* test_parameter_map_compilation.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = test_parameter_map_compilation.hpp; sourceTree = "<group>"; };
+		089DF5BC0F3CE2A600908438 /* custom_event_processing.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = custom_event_processing.hpp; sourceTree = "<group>"; };
                 089E06FB0E5D0F3500C425FE /* button.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = button.hpp; sourceTree = "<group>"; };
                 089E34A60E5BB90900D9AD51 /* typed_keyword.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = typed_keyword.hpp; sourceTree = "<group>"; };
                 089E34AB0E5C865400D9AD51 /* typed_name.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = typed_name.hpp; sourceTree = "<group>"; };
@@ -158,6 +159,8 @@
                 08A048C40E77A1B70034FD11 /* navigable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = navigable.hpp; sourceTree = "<group>"; };
                 08A048CF0E77A2E70034FD11 /* navigable.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = navigable.hpp; sourceTree = "<group>"; };
                 08A13C090E535040008C8A10 /* field_map.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = field_map.hpp; sourceTree = "<group>"; };
+		08A19AE10F3F728F0003AC68 /* usage.qbk */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = usage.qbk; sourceTree = "<group>"; };
+		08A19B410F3F7D930003AC68 /* window_only_example.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = window_only_example.cpp; sourceTree = "<group>"; };
                 08A61CEE0F37B50300F2DF50 /* Jamfile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.jam; path = Jamfile; sourceTree = "<group>"; };
                 08A6D3950E7B99C700BF2671 /* two_buttons.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = two_buttons.hpp; sourceTree = "<group>"; };
                 08A77AB30E4F91AA00B8793E /* Jamroot */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = Jamroot; path = ../../../../Jamroot; sourceTree = SOURCE_ROOT; };
@@ -226,6 +229,7 @@
                                 08A6D3950E7B99C700BF2671 /* two_buttons.hpp */,
                                 089C81F20E7D949400CE0901 /* two_buttons.cpp */,
                                 089D7E0E0F3B75C800590295 /* custom_example.cpp */,
+				08A19B410F3F7D930003AC68 /* window_only_example.cpp */,
                         );
                         name = example;
                         path = ../../example;
@@ -252,6 +256,7 @@
                                 08ADC1F90E7B62BD00D8CB9D /* static_compound.hpp */,
                                 089F14D60E7DC87700B91674 /* periodic.hpp */,
                                 089C8CFE0F3AC3650062EFEC /* custom_drawable.hpp */,
+				089DF5BC0F3CE2A600908438 /* custom_event_processing.hpp */,
                         );
                         path = view;
                         sourceTree = "<group>";
@@ -446,6 +451,7 @@
                         children = (
                                 088513240E689E650089DAD3 /* Jamfile */,
                                 0885132B0E68AEC70089DAD3 /* guigl.qbk */,
+				08A19AE10F3F728F0003AC68 /* usage.qbk */,
                         );
                         name = doc;
                         path = ../../doc;
Modified: sandbox/guigl/libs/guigl/doc/guigl.qbk
==============================================================================
--- sandbox/guigl/libs/guigl/doc/guigl.qbk	(original)
+++ sandbox/guigl/libs/guigl/doc/guigl.qbk	2009-02-21 15:12:33 EST (Sat, 21 Feb 2009)
@@ -14,6 +14,8 @@
 [template guigl[] [^guigl]]
 [template boost[] [@http://www.boost.org boost]]
 
+[import ../example/window_only_example.cpp]
+
 [section Introduction]
 
 [guigl] is a modular GUI library tbat uses OpenGL.  It's development was
@@ -25,19 +27,20 @@
 * To maximally use the [boost] libraries for anything not directly reated to
   GUI functionality.
 
-In [guigl], GUI elements are referred to as /views/.  /views/ are
-implemented through a simple chaining of /behaviors/, where each behavior can
-change the way the view looks and/or change the way in which the view responds
+[guigl] provides a number of widgets and related functionality that can be used
+to create a user interface.  New widgets can be created by reusing and extending
+the functionality provided by atomic /view behaviors/.  Each /view behavior/ can
+change the way the widget looks and/or change the way in which the widget responds
 to user interaction.  Behaviors can also add member functions and variables
-to the view, which can be used by other view code or user code.
-
-[/For example, the [classref guigl::view::button button] widget is implemented
-by combining.]
-
+to the widget, which can be used by other view behavior code or user code.
 
+Currently, [guigl] uses OpenGL for drawing and GLUT (or any library that
+provides a GLUT compatibility layer) as its window manager.
 
 [endsect]
 
+[include usage.qbk]
+
 [section:license License]
 
 Copyright 2007 Stjepan Rajko.
Added: sandbox/guigl/libs/guigl/doc/usage.qbk
==============================================================================
--- (empty file)
+++ sandbox/guigl/libs/guigl/doc/usage.qbk	2009-02-21 15:12:33 EST (Sat, 21 Feb 2009)
@@ -0,0 +1,32 @@
+[section:usage Usage Tutorial]
+
+[section Creating a window and running the application]
+
+The first thing you will need to construct a GUI is a window.
+You will need the following include files to access a window, and later give
+control to the GUI:
+
+[window_only_example_includes]
+
+All [guigl] functionality is in the namespace `boost::guigl`.  This example
+uses the following `using` statement:
+
+[window_only_example_using]
+
+We can now instantiate a window.  We will pass a window label and size to the
+constructor as follows:
+
+[window_only_example_window]
+
+[guigl] objects use named parameters based on a tweaked version of the
+Boost.Parameter library.  When specifying more than one named parameter
+in the constructor, [guigl] currently requires you to use double parenthesis.
+
+With the window in place, we can give control to [guigl]:
+
+[window_only_example_application]
+
+
+[endsect]
+
+[endsect]
\ No newline at end of file
Modified: sandbox/guigl/libs/guigl/example/Jamfile
==============================================================================
--- sandbox/guigl/libs/guigl/example/Jamfile	(original)
+++ sandbox/guigl/libs/guigl/example/Jamfile	2009-02-21 15:12:33 EST (Sat, 21 Feb 2009)
@@ -16,13 +16,19 @@
         window_example.cpp two_spheres.cpp two_buttons.cpp
     ;
 
-exe custom_example
+exe window_example_static
     :
-        custom_example.cpp
+        window_example.cpp two_spheres.cpp two_buttons.cpp
+    :
+       <link>static
     ;
 
-install window_example_stage : window_example custom_example
-           : <install-dependencies>on <install-type>EXE
-             <install-type>LIB <location>$(TOP)/bin/stage/window_example
-           ;
+exe custom_example : custom_example.cpp ;
+exe window_only_example : window_only_example.cpp ;
+
+install window_example_stage
+    : window_example custom_example window_only_example
+    : <install-dependencies>on <install-type>EXE
+      <install-type>LIB <location>$(TOP)/bin/stage/window_example
+    ;
  
\ No newline at end of file
Modified: sandbox/guigl/libs/guigl/example/custom_example.cpp
==============================================================================
--- sandbox/guigl/libs/guigl/example/custom_example.cpp	(original)
+++ sandbox/guigl/libs/guigl/example/custom_example.cpp	2009-02-21 15:12:33 EST (Sat, 21 Feb 2009)
@@ -1,5 +1,5 @@
 /*=================================---------------------------------------------
-    Copyright 2007,2008 Stjepan Rajko
+    Copyright 2008 Stjepan Rajko
   
     Distributed under the Boost Software License, Version 1.0.
     (See accompanying file LICENSE_1_0.txt or copy at
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	2009-02-21 15:12:33 EST (Sat, 21 Feb 2009)
@@ -6,10 +6,9 @@
     http://www.boost.org/LICENSE_1_0.txt)
 -----------------------------------------------===============================*/
 
-
 #include <boost/guigl/application.hpp>
-#include <boost/guigl/layout/grid.hpp>
 #include <boost/guigl/window.hpp>
+#include <boost/guigl/layout/grid.hpp>
 #include <boost/guigl/widget/button.hpp>
 #include <boost/guigl/widget/label.hpp>
 #include <boost/guigl/widget/labeled_button.hpp>
@@ -42,6 +41,13 @@
     std::cout << "5 seconds have elapsed." << std::endl;
 }
 
+bool keyboard(const event_type &event_info)
+{
+    if(const keyboard_event *event = boost::get<const keyboard_event>(&event_info))
+        std::cout << "key pressed: " << event->key << std::endl;
+    return false;
+}
+
 int main()
 {
     window test_window1(( _label = "window example 1", _size=size_type(300,300) ));
@@ -84,6 +90,8 @@
             _size=size_type(100,50),
             _position=position_type(50, 5) ));
     
+    test_window2.event_handler() = keyboard;
+
     layout::grid grid_layout(( _grid_size=test_window3.size(), _horizontal=3, _vertical=3 ));
     for(int i=1; i<=9; i++)
         test_window3 << grid_layout.create<widget::button>(( _background=color_type(1.0f/i,1.0f/i,1.0f/i) ));
Added: sandbox/guigl/libs/guigl/example/window_only_example.cpp
==============================================================================
--- (empty file)
+++ sandbox/guigl/libs/guigl/example/window_only_example.cpp	2009-02-21 15:12:33 EST (Sat, 21 Feb 2009)
@@ -0,0 +1,30 @@
+/*=================================---------------------------------------------
+    Copyright 2007,2008 Stjepan Rajko
+  
+    Distributed under the Boost Software License, Version 1.0.
+    (See accompanying file LICENSE_1_0.txt or copy at
+    http://www.boost.org/LICENSE_1_0.txt)
+-----------------------------------------------===============================*/
+
+
+//[ window_only_example_includes
+#include <boost/guigl/application.hpp>
+#include <boost/guigl/window.hpp>
+//]
+
+//[ window_only_example_using
+    using namespace boost::guigl;
+//]
+
+//[ window_only_example_window
+window test_window1(( _label = "window example 1", _size=size_type(300,300) ));
+//]
+
+//[ window_only_example_application
+int main()
+{
+    application::run();
+
+    return 0;
+}
+//]
Modified: sandbox/guigl/libs/guigl/src/window.cpp
==============================================================================
--- sandbox/guigl/libs/guigl/src/window.cpp	(original)
+++ sandbox/guigl/libs/guigl/src/window.cpp	2009-02-21 15:12:33 EST (Sat, 21 Feb 2009)
@@ -44,6 +44,7 @@
         glutPassiveMotionFunc(movement);
         glutMotionFunc(movement);
         glutEntryFunc(entry);
+        glutKeyboardFunc(keyboard);
                 
         return id;
     }
@@ -58,6 +59,7 @@
     static void mouse(int button, int state, int x, int y);
     static void movement(int x, int y);
     static void entry(int state);
+    static void keyboard(unsigned char key, int x, int y);
     std::map<int, window::impl *> m_windows;
 };
 
@@ -112,6 +114,13 @@
         event_info.region = state == GLUT_ENTERED ? region::entry : region::exit;
         m_window->on_event(event_info);
     }
+    void keyboard(unsigned char key, int x, int y)
+    {
+        keyboard_event event_info;
+        event_info.position = position_type(x, y);
+        event_info.key = key;
+        m_window->on_event(event_info);        
+    }
     ~impl()
     {
         s_glut->destroy_window(m_id);
@@ -180,5 +189,13 @@
     window::impl::s_glut->m_windows[id]->entry_exit(state);
 }
 
+void glut::keyboard(unsigned char key, int x, int y)
+{
+    int id = glutGetWindow();
+    if(window::impl::s_glut->m_windows.find(id)==window::impl::s_glut->m_windows.end())
+        return;
+    window::impl::s_glut->m_windows[id]->keyboard(key, x, y);
 
+}
+    
 } }