|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r51385 - in sandbox-branches/andreo/guigl: boost/guigl boost/guigl/view boost/guigl/view/impl boost/guigl/widget libs/guigl/build/vc8ide libs/guigl/build/xcodeide/guigl.xcodeproj libs/guigl/doc libs/guigl/example libs/guigl/platform libs/guigl/src
From: andreytorba_at_[hidden]
Date: 2009-02-22 04:52:58
Author: andreo
Date: 2009-02-22 04:52:57 EST (Sun, 22 Feb 2009)
New Revision: 51385
URL: http://svn.boost.org/trac/boost/changeset/51385
Log:
merging changes
Added:
sandbox-branches/andreo/guigl/boost/guigl/view/custom_event_processing.hpp
- copied unchanged from r51383, /sandbox/guigl/boost/guigl/view/custom_event_processing.hpp
sandbox-branches/andreo/guigl/libs/guigl/doc/usage.qbk
- copied unchanged from r51383, /sandbox/guigl/libs/guigl/doc/usage.qbk
sandbox-branches/andreo/guigl/libs/guigl/example/window_only_example.cpp
- copied unchanged from r51383, /sandbox/guigl/libs/guigl/example/window_only_example.cpp
sandbox-branches/andreo/guigl/libs/guigl/platform/
- copied from r51383, /sandbox/guigl/libs/guigl/platform/
Text files modified:
sandbox-branches/andreo/guigl/boost/guigl/event.hpp | 8 +++++++-
sandbox-branches/andreo/guigl/boost/guigl/parameters.hpp | 1 +
sandbox-branches/andreo/guigl/boost/guigl/view/custom_drawable.hpp | 10 ++++++++--
sandbox-branches/andreo/guigl/boost/guigl/view/impl/static_compound.hpp | 4 ++++
sandbox-branches/andreo/guigl/boost/guigl/widget/window.hpp | 11 +++++++----
sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/build.vcproj | 40 ++++++++++++++++++++++++----------------
sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/doc.vcproj | 12 ++++++++----
sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/example.vcproj | 20 ++++++++++++++------
sandbox-branches/andreo/guigl/libs/guigl/build/xcodeide/guigl.xcodeproj/project.pbxproj | 6 ++++++
sandbox-branches/andreo/guigl/libs/guigl/doc/guigl.qbk | 19 +++++++++++--------
sandbox-branches/andreo/guigl/libs/guigl/example/Jamfile | 18 ++++++++++++------
sandbox-branches/andreo/guigl/libs/guigl/example/custom_example.cpp | 18 ++++++++++++++++--
sandbox-branches/andreo/guigl/libs/guigl/example/two_spheres.cpp | 3 ++-
sandbox-branches/andreo/guigl/libs/guigl/example/window_example.cpp | 12 ++++++++++--
sandbox-branches/andreo/guigl/libs/guigl/src/window.cpp | 17 +++++++++++++++++
15 files changed, 147 insertions(+), 52 deletions(-)
Modified: sandbox-branches/andreo/guigl/boost/guigl/event.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/boost/guigl/event.hpp (original)
+++ sandbox-branches/andreo/guigl/boost/guigl/event.hpp 2009-02-22 04:52:57 EST (Sun, 22 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-branches/andreo/guigl/boost/guigl/parameters.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/boost/guigl/parameters.hpp (original)
+++ sandbox-branches/andreo/guigl/boost/guigl/parameters.hpp 2009-02-22 04:52:57 EST (Sun, 22 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-branches/andreo/guigl/boost/guigl/view/custom_drawable.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/boost/guigl/view/custom_drawable.hpp (original)
+++ sandbox-branches/andreo/guigl/boost/guigl/view/custom_drawable.hpp 2009-02-22 04:52:57 EST (Sun, 22 Feb 2009)
@@ -30,7 +30,13 @@
, m_draw_prologue(rhs.m_draw_prologue)
, m_draw_epilogue(rhs.m_draw_epilogue)
{}
-
+ template<typename T>
+ void set_draw_prologue(const T &t)
+ { m_draw_prologue = t; }
+ template<typename T>
+ void set_draw_epilogue(const T &t)
+ { m_draw_epilogue = t; }
+
protected:
void draw_prologue()
{
@@ -50,4 +56,4 @@
}}}
-#endif // BOOST__GUIGL__VIEW__CUSTOM_DRAW_HPP
+#endif // BOOST__GUIGL__VIEW__CUSTOM_DRAWABLE_HPP
Modified: sandbox-branches/andreo/guigl/boost/guigl/view/impl/static_compound.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/boost/guigl/view/impl/static_compound.hpp (original)
+++ sandbox-branches/andreo/guigl/boost/guigl/view/impl/static_compound.hpp 2009-02-22 04:52:57 EST (Sun, 22 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-branches/andreo/guigl/boost/guigl/widget/window.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/boost/guigl/widget/window.hpp (original)
+++ sandbox-branches/andreo/guigl/boost/guigl/widget/window.hpp 2009-02-22 04:52:57 EST (Sun, 22 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-branches/andreo/guigl/libs/guigl/build/vc8ide/build.vcproj
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/build.vcproj (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/build.vcproj 2009-02-22 04:52:57 EST (Sun, 22 Feb 2009)
@@ -156,67 +156,75 @@
Name="view"
>
<File
- RelativePath="..\..\..\../boost/guigl/view/active_colored.hpp"
+ RelativePath="..\..\..\..\boost\guigl\view\active_colored.hpp"
>
</File>
<File
- RelativePath="..\..\..\../boost/guigl/view/base.hpp"
+ RelativePath="..\..\..\..\boost\guigl\view\base.hpp"
>
</File>
<File
- RelativePath="..\..\..\../boost/guigl/view/clickable.hpp"
+ RelativePath="..\..\..\..\boost\guigl\view\clickable.hpp"
>
</File>
<File
- RelativePath="..\..\..\../boost/guigl/view/colored.hpp"
+ RelativePath="..\..\..\..\boost\guigl\view\colored.hpp"
>
</File>
<File
- RelativePath="..\..\..\../boost/guigl/view/compound.hpp"
+ RelativePath="..\..\..\..\boost\guigl\view\compound.hpp"
>
</File>
<File
- RelativePath="..\..\..\../boost/guigl/view/draggable.hpp"
+ RelativePath="..\..\..\..\boost\guigl\view\custom_drawable.hpp"
>
</File>
<File
- RelativePath="..\..\..\../boost/guigl/view/labeled.hpp"
+ RelativePath="..\..\..\..\boost\guigl\view\custom_event_processing.hpp"
>
</File>
<File
- RelativePath="..\..\..\../boost/guigl/view/mouse_tracking.hpp"
+ RelativePath="..\..\..\..\boost\guigl\view\draggable.hpp"
>
</File>
<File
- RelativePath="..\..\..\../boost/guigl/view/navigable.hpp"
+ RelativePath="..\..\..\..\boost\guigl\view\labeled.hpp"
>
</File>
<File
- RelativePath="..\..\..\../boost/guigl/view/periodic.hpp"
+ RelativePath="..\..\..\..\boost\guigl\view\mouse_tracking.hpp"
>
</File>
<File
- RelativePath="..\..\..\../boost/guigl/view/positioned.hpp"
+ RelativePath="..\..\..\..\boost\guigl\view\navigable.hpp"
>
</File>
<File
- RelativePath="..\..\..\../boost/guigl/view/solid_background.hpp"
+ RelativePath="..\..\..\..\boost\guigl\view\periodic.hpp"
>
</File>
<File
- RelativePath="..\..\..\../boost/guigl/view/static_base.hpp"
+ RelativePath="..\..\..\..\boost\guigl\view\positioned.hpp"
>
</File>
<File
- RelativePath="..\..\..\../boost/guigl/view/static_compound.hpp"
+ RelativePath="..\..\..\..\boost\guigl\view\solid_background.hpp"
>
</File>
<File
- RelativePath="..\..\..\../boost/guigl/view/three_dimensional.hpp"
+ RelativePath="..\..\..\..\boost\guigl\view\static_base.hpp"
>
</File>
<File
- RelativePath="..\..\..\../boost/guigl/view/window.hpp"
+ RelativePath="..\..\..\..\boost\guigl\view\static_compound.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\guigl\view\three_dimensional.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\..\..\boost\guigl\view\window.hpp"
>
</File>
<Filter
Modified: sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/doc.vcproj
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/doc.vcproj (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/doc.vcproj 2009-02-22 04:52:57 EST (Sun, 22 Feb 2009)
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="8.00"
+ Version="8,00"
Name="doc"
ProjectGUID="{9D6EDF83-2360-4267-8075-64934F754048}"
>
@@ -742,15 +742,19 @@
</Filter>
</Filter>
<File
- RelativePath="..\../doc/guigl.qbk"
+ RelativePath="..\../doc/guigl_doxygen.xml"
>
</File>
<File
- RelativePath="..\../doc/guigl_doxygen.xml"
+ RelativePath="..\..\doc\guigl.qbk"
+ >
+ </File>
+ <File
+ RelativePath="..\..\doc\Jamfile"
>
</File>
<File
- RelativePath="..\../doc/Jamfile"
+ RelativePath="..\..\doc\usage.qbk"
>
</File>
</Files>
Modified: sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/example.vcproj
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/example.vcproj (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/build/vc8ide/example.vcproj 2009-02-22 04:52:57 EST (Sun, 22 Feb 2009)
@@ -59,27 +59,35 @@
</References>
<Files>
<File
- RelativePath="..\../example/Jamfile"
+ RelativePath="..\..\example\custom_example.cpp"
>
</File>
<File
- RelativePath="..\../example/two_buttons.cpp"
+ RelativePath="..\..\example\Jamfile"
>
</File>
<File
- RelativePath="..\../example/two_buttons.hpp"
+ RelativePath="..\..\example\two_buttons.cpp"
>
</File>
<File
- RelativePath="..\../example/two_spheres.cpp"
+ RelativePath="..\..\example\two_buttons.hpp"
>
</File>
<File
- RelativePath="..\../example/two_spheres.hpp"
+ RelativePath="..\..\example\two_spheres.cpp"
>
</File>
<File
- RelativePath="..\../example/window_example.cpp"
+ RelativePath="..\..\example\two_spheres.hpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\example\window_example.cpp"
+ >
+ </File>
+ <File
+ RelativePath="..\..\example\window_only_example.cpp"
>
</File>
</Files>
Modified: sandbox-branches/andreo/guigl/libs/guigl/build/xcodeide/guigl.xcodeproj/project.pbxproj
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/build/xcodeide/guigl.xcodeproj/project.pbxproj (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/build/xcodeide/guigl.xcodeproj/project.pbxproj 2009-02-22 04:52:57 EST (Sun, 22 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-branches/andreo/guigl/libs/guigl/doc/guigl.qbk
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/doc/guigl.qbk (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/doc/guigl.qbk 2009-02-22 04:52:57 EST (Sun, 22 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.
Modified: sandbox-branches/andreo/guigl/libs/guigl/example/Jamfile
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/example/Jamfile (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/example/Jamfile 2009-02-22 04:52:57 EST (Sun, 22 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-branches/andreo/guigl/libs/guigl/example/custom_example.cpp
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/example/custom_example.cpp (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/example/custom_example.cpp 2009-02-22 04:52:57 EST (Sun, 22 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
@@ -25,14 +25,28 @@
rect(0.0, 0.0, 50.0, 50.0);
}
+void draw_stuff2()
+{
+ glColor3d(1.0, 0.0, 0.0);
+ glRectd(0.0, 0.0, 150.0, 150.0);
+}
+
int main()
{
window test_window1(( _label = "custom example", _size=size_type(300,300) ));
test_window1 << new widget::custom((
- _size=size_type(300,300),
+ _size=size_type(300,150),
_draw_prologue=draw_stuff
));
+ widget::custom *set = new widget::custom((
+ _size=size_type(300,150), _position=position_type(0, 150)
+ ));
+
+ set->set_draw_prologue(&draw_stuff2);
+
+ test_window1 << set;
+
application::run();
}
Modified: sandbox-branches/andreo/guigl/libs/guigl/example/two_spheres.cpp
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/example/two_spheres.cpp (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/example/two_spheres.cpp 2009-02-22 04:52:57 EST (Sun, 22 Feb 2009)
@@ -95,7 +95,8 @@
rotate_z(drag_origin().x);
rotate_x(drag_origin().y);
- material(GL_FRONT)
+ // polished gold
+ material(GL_FRONT)
.ambient(0.24725f, 0.1995f, 0.0745f, 1.0f)
.diffuse(0.75164f, 0.60648f, 0.22648f, 1.0f)
.specular(0.628281f, 0.555802f, 0.366065f, 1.0f)
Modified: sandbox-branches/andreo/guigl/libs/guigl/example/window_example.cpp
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/example/window_example.cpp (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/example/window_example.cpp 2009-02-22 04:52:57 EST (Sun, 22 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>
@@ -41,6 +40,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) ));
@@ -83,6 +89,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) ));
Modified: sandbox-branches/andreo/guigl/libs/guigl/src/window.cpp
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/src/window.cpp (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/src/window.cpp 2009-02-22 04:52:57 EST (Sun, 22 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);
+}
+
} }
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