Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50904 - in sandbox-branches/guigl-openGL-wrappers: boost/guigl boost/guigl/view/impl libs/guigl/example libs/guigl/src/widget
From: andreytorba_at_[hidden]
Date: 2009-01-30 10:53:00


Author: andreo
Date: 2009-01-30 10:52:58 EST (Fri, 30 Jan 2009)
New Revision: 50904
URL: http://svn.boost.org/trac/boost/changeset/50904

Log:
alpha chanel
Text files modified:
   sandbox-branches/guigl-openGL-wrappers/boost/guigl/draw.hpp | 23 ++++-------------------
   sandbox-branches/guigl-openGL-wrappers/boost/guigl/parameters.hpp | 6 +++---
   sandbox-branches/guigl-openGL-wrappers/boost/guigl/types.hpp | 33 ++++++++++++++++++++++++++++++++-
   sandbox-branches/guigl-openGL-wrappers/boost/guigl/view/impl/solid_background.hpp | 9 ---------
   sandbox-branches/guigl-openGL-wrappers/libs/guigl/example/two_buttons.cpp | 20 ++++++++++++++++++++
   sandbox-branches/guigl-openGL-wrappers/libs/guigl/example/two_buttons.hpp | 2 +-
   sandbox-branches/guigl-openGL-wrappers/libs/guigl/example/window_example.cpp | 35 ++++++++++++++++++++---------------
   sandbox-branches/guigl-openGL-wrappers/libs/guigl/src/widget/slider.cpp | 22 +++++++++++++++++++++-
   8 files changed, 101 insertions(+), 49 deletions(-)

Modified: sandbox-branches/guigl-openGL-wrappers/boost/guigl/draw.hpp
==============================================================================
--- sandbox-branches/guigl-openGL-wrappers/boost/guigl/draw.hpp (original)
+++ sandbox-branches/guigl-openGL-wrappers/boost/guigl/draw.hpp 2009-01-30 10:52:58 EST (Fri, 30 Jan 2009)
@@ -18,19 +18,9 @@
 
 namespace draw {
 
- inline color_type red()
- {
- return color_type(1, 0, 0);
- }
-
- inline color_type green()
- {
- return color_type(0, 1, 0);
- }
-
- inline color_type blue()
+ inline void color(const color_type &color)
     {
- return color_type(0, 0, 1);
+ glColor4f(color[0], color[1], color[2], color[3]);
     }
 
   class begin : boost::noncopyable
@@ -57,20 +47,15 @@
     vertex(position.x, position.y);
     }
 
- inline void color(const color_type &color)
- {
- glColor3d(color[0], color[1], color[2]);
- }
-
   struct vertex_creator : boost::noncopyable
     {
- inline vertex_creator& operator()(const position_type &position)
+ inline vertex_creator const& operator()(const position_type &position) const
       {
       vertex(position);
       return *this;
       }
 
- inline vertex_creator& operator()(double x, double y)
+ inline vertex_creator const& operator()(double x, double y) const
       {
       vertex(x, y);
       return *this;

Modified: sandbox-branches/guigl-openGL-wrappers/boost/guigl/parameters.hpp
==============================================================================
--- sandbox-branches/guigl-openGL-wrappers/boost/guigl/parameters.hpp (original)
+++ sandbox-branches/guigl-openGL-wrappers/boost/guigl/parameters.hpp 2009-01-30 10:52:58 EST (Fri, 30 Jan 2009)
@@ -19,9 +19,9 @@
     BOOST_PARAMETER_TYPED_NAME_WDEFAULT(label,const std::string,"")
     BOOST_PARAMETER_TYPED_NAME_WDEFAULT(size,const size_type,(size_type(200,200)))
     BOOST_PARAMETER_TYPED_NAME_WDEFAULT(position,const position_type,(size_type(0,0)))
- BOOST_PARAMETER_TYPED_NAME_WDEFAULT(background,const color_type,(color_type(0,0,0)))
- BOOST_PARAMETER_TYPED_NAME_WDEFAULT(color,const color_type,(color_type(1,1,1)))
- BOOST_PARAMETER_TYPED_NAME_WDEFAULT(active_color,const color_type,(color_type(1,0,0)))
+ BOOST_PARAMETER_TYPED_NAME_WDEFAULT(background,const color_type,(white()))
+ BOOST_PARAMETER_TYPED_NAME_WDEFAULT(color,const color_type,(black()))
+ BOOST_PARAMETER_TYPED_NAME_WDEFAULT(active_color,const color_type,(red()))
     BOOST_PARAMETER_TYPED_NAME_WDEFAULT(depth,const bool,false)
     BOOST_PARAMETER_TYPED_NAME_WDEFAULT(min,const double,0.0)
     BOOST_PARAMETER_TYPED_NAME_WDEFAULT(max,const double,1.0)

Modified: sandbox-branches/guigl-openGL-wrappers/boost/guigl/types.hpp
==============================================================================
--- sandbox-branches/guigl-openGL-wrappers/boost/guigl/types.hpp (original)
+++ sandbox-branches/guigl-openGL-wrappers/boost/guigl/types.hpp 2009-01-30 10:52:58 EST (Fri, 30 Jan 2009)
@@ -17,7 +17,38 @@
 
 typedef gil::point2<double> size_type;
 typedef gil::point2<double> position_type;
-typedef gil::rgb32f_pixel_t color_type;
+typedef gil::rgba32f_pixel_t color_type;
+
+// temporary place for color functions
+inline color_type red(float alpha = 1)
+ {
+ return color_type(1, 0, 0, alpha);
+ }
+
+inline color_type green(float alpha = 1)
+ {
+ return color_type(0, 1, 0, alpha);
+ }
+
+inline color_type blue(float alpha = 1)
+ {
+ return color_type(0, 0, 1, alpha);
+ }
+
+inline color_type yellow(float alpha = 1)
+ {
+ return color_type(1, 1, 0, alpha);
+ }
+
+inline color_type white(float alpha = 1)
+ {
+ return color_type(1, 1, 1, alpha);
+ }
+
+inline color_type black(float alpha = 1)
+ {
+ return color_type(0, 0, 0, alpha);
+ }
 
 }}
 

Modified: sandbox-branches/guigl-openGL-wrappers/boost/guigl/view/impl/solid_background.hpp
==============================================================================
--- sandbox-branches/guigl-openGL-wrappers/boost/guigl/view/impl/solid_background.hpp (original)
+++ sandbox-branches/guigl-openGL-wrappers/boost/guigl/view/impl/solid_background.hpp 2009-01-30 10:52:58 EST (Fri, 30 Jan 2009)
@@ -24,15 +24,6 @@
     BaseView::draw_prologue();
     glColor3d(m_background_color[0], m_background_color[1], m_background_color[2]);
     glRectd(0.0, 0.0, solid_background::size().x, solid_background::size().y);
-
- using namespace draw;
-
- color(blue());
- line_loop
- (0, 0)
- (0, solid_background::size().y)
- (solid_background::size().x, solid_background::size().y)
- (solid_background::size().x, 0);
 }
 
 }}}

Modified: sandbox-branches/guigl-openGL-wrappers/libs/guigl/example/two_buttons.cpp
==============================================================================
--- sandbox-branches/guigl-openGL-wrappers/libs/guigl/example/two_buttons.cpp (original)
+++ sandbox-branches/guigl-openGL-wrappers/libs/guigl/example/two_buttons.cpp 2009-01-30 10:52:58 EST (Fri, 30 Jan 2009)
@@ -10,11 +10,31 @@
 #include "two_buttons.hpp"
 #include <boost/guigl/view/impl/static_compound.hpp>
 #include <boost/guigl/view/impl/positioned.hpp>
+#include <boost/guigl/types.hpp>
+#include <boost/guigl/draw.hpp>
 
 
 void two_buttons::draw()
 {
     draw_prologue();
+
+ using namespace boost::guigl;
+ using namespace boost::guigl::draw;
+
+ color(black((float)0.3));
+
+ glLineWidth(2.5);
+ glEnable(GL_LINE_SMOOTH);
+ glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
+ glEnable (GL_BLEND);
+ glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
+ line_loop
+ (0, 0)
+ (size().x, 0)
+ (size().x, size().y)
+ (0, size().y);
+
     draw_epilogue();
 }
 

Modified: sandbox-branches/guigl-openGL-wrappers/libs/guigl/example/two_buttons.hpp
==============================================================================
--- sandbox-branches/guigl-openGL-wrappers/libs/guigl/example/two_buttons.hpp (original)
+++ sandbox-branches/guigl-openGL-wrappers/libs/guigl/example/two_buttons.hpp 2009-01-30 10:52:58 EST (Fri, 30 Jan 2009)
@@ -30,7 +30,7 @@
     template<typename Args>
     two_buttons(const Args &args)
         : base_type((args, boost::guigl::_children=boost::fusion::make_vector(
- boost::guigl::widget::labeled_button((boost::guigl::_label = "top button", boost::guigl::_background = boost::guigl::color_type(0.5,0.5,0.5))),
+ boost::guigl::widget::labeled_button((boost::guigl::_label = "top button", boost::guigl::_background = boost::guigl::color_type(0.5,0.5,0.5, 1))),
             boost::guigl::widget::labeled_button(boost::guigl::_label = "bottom button")
         ) ))
     {

Modified: sandbox-branches/guigl-openGL-wrappers/libs/guigl/example/window_example.cpp
==============================================================================
--- sandbox-branches/guigl-openGL-wrappers/libs/guigl/example/window_example.cpp (original)
+++ sandbox-branches/guigl-openGL-wrappers/libs/guigl/example/window_example.cpp 2009-01-30 10:52:58 EST (Fri, 30 Jan 2009)
@@ -26,10 +26,15 @@
 
 using namespace boost::guigl;
 
-color_type make_grey(float value)
-{
- return color_type(value, value, value);
-}
+//color_type make_grey(float value)
+//{
+// return color_type(value, value, value);
+//}
+
+color_type make_grey(double value)
+ {
+ return color_type((float)value, (float)value, (float)value, (float)value);
+ }
 
 void idle()
 {
@@ -51,15 +56,15 @@
     test_window1 << new widget::label((
         _label = "Label",
         _size=size_type(100,30),
- _background=color_type(1,1,1),
- _color=color_type(0,0,0) ));
+ _background=blue(),
+ _color=black() ));
 
     widget::labeled_button *b1 = new widget::labeled_button((
         _size=size_type(100,30),
         _position=position_type(50, 50),
- _background=color_type(1,1,1),
- _active_color=color_type(1,0,0),
- _color=color_type(0,0,0),
+ _background=color_type(1,1,1,1),
+ _active_color=color_type(1,0,0,1),
+ _color=color_type(0,0,0,1),
         _label="Button"));
     test_window1 << b1;
     
@@ -67,10 +72,10 @@
         _label="Slider",
         _size=size_type(100,30),
         _position=position_type(50,80),
- _background=color_type(0.5,0.5,0.5),
- _active_color=color_type(0,1,0),
+ _background=color_type(0.5,0.5,0.5,1),
+ _active_color=color_type(0,1,0,1),
         _min=0.1,_max=0.9,_value=0.5,
- _step=0.1 ));
+ _step=0.02 ));
     test_window1 << s;
     
 
@@ -86,10 +91,10 @@
     
     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) ));
+ test_window3 << grid_layout.create<widget::button>(( _background=color_type(1.0f/i,1.0f/i,1.0f/i,1) ));
     
- window test_window_3d(( _depth = true, _label="3D", _color=make_grey(1) ));
- test_window_3d << new two_spheres(_period = 0.01);
+ //window test_window_3d(( _depth = true, _label="3D", _color=make_grey(1) ));
+ //test_window_3d << new two_spheres(_period = 0.01);
     
     application::on_idle().connect(&idle);
     application::timeout(&timer, 5000);

Modified: sandbox-branches/guigl-openGL-wrappers/libs/guigl/src/widget/slider.cpp
==============================================================================
--- sandbox-branches/guigl-openGL-wrappers/libs/guigl/src/widget/slider.cpp (original)
+++ sandbox-branches/guigl-openGL-wrappers/libs/guigl/src/widget/slider.cpp 2009-01-30 10:52:58 EST (Fri, 30 Jan 2009)
@@ -25,7 +25,27 @@
     base_type::draw_prologue();
 
     use_active_color();
- glRectd(0,0,(m_value-m_min) * size().x / (m_max-m_min), size().y);
+
+ double position = (m_value-m_min) * size().x / (m_max-m_min);
+ glRectd(0,0,position, size().y);
+
+ glLineWidth(2.5);
+ glEnable(GL_LINE_SMOOTH);
+ glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
+ glEnable (GL_BLEND);
+ glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
+
+ draw::color(black(0.3f));
+ draw::line(
+ position_type(position, 0),
+ position_type(position, size().y));
+
+ draw::line_loop
+ (0, 0)
+ (0, size().y)
+ (size().x, size().y)
+ (size().x, 0);
 }
 
 void slider::draw_epilogue()


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