Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51916 - in sandbox/guigl: boost/guigl boost/guigl/view/impl libs/guigl/build/vc8ide libs/guigl/example
From: andreytorba_at_[hidden]
Date: 2009-03-22 18:28:08


Author: andreo
Date: 2009-03-22 18:28:05 EDT (Sun, 22 Mar 2009)
New Revision: 51916
URL: http://svn.boost.org/trac/boost/changeset/51916

Log:
added color.hpp, added alpha channel
Added:
   sandbox/guigl/boost/guigl/color.hpp (contents, props changed)
Text files modified:
   sandbox/guigl/boost/guigl/parameters.hpp | 9 +++++----
   sandbox/guigl/boost/guigl/types.hpp | 4 ++--
   sandbox/guigl/boost/guigl/view/impl/active_colored.hpp | 4 ++--
   sandbox/guigl/boost/guigl/view/impl/colored.hpp | 4 ++--
   sandbox/guigl/boost/guigl/view/impl/solid_background.hpp | 8 ++++++--
   sandbox/guigl/libs/guigl/build/vc8ide/build.vcproj | 4 ++++
   sandbox/guigl/libs/guigl/example/two_buttons.hpp | 4 ++--
   sandbox/guigl/libs/guigl/example/window_example.cpp | 24 +++++++++++-------------
   8 files changed, 34 insertions(+), 27 deletions(-)

Added: sandbox/guigl/boost/guigl/color.hpp
==============================================================================
--- (empty file)
+++ sandbox/guigl/boost/guigl/color.hpp 2009-03-22 18:28:05 EDT (Sun, 22 Mar 2009)
@@ -0,0 +1,88 @@
+/*=================================---------------------------------------------
+Copyright 2009 Andrey Torba
+
+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__COLOR_HPP
+#define BOOST__GUIGL__COLOR_HPP
+
+#include <boost/guigl/types.hpp>
+
+namespace boost { namespace guigl {
+
+ template<class T>
+ color_type make_color(T r, T g, T b, T a);
+
+ template<>
+ inline color_type make_color<float>(float r, float g, float b, float a)
+ {
+ return color_type(r, g, b, a);
+ }
+
+ template<>
+ inline color_type make_color<double>(double r, double g, double b, double a)
+ {
+ return make_color(
+ static_cast<float>(r),
+ static_cast<float>(g),
+ static_cast<float>(b),
+ static_cast<float>(a));
+ }
+
+ template<>
+ inline color_type make_color<int>(int r, int g, int b, int a)
+ {
+ return make_color(
+ static_cast<float>(r)/255,
+ static_cast<float>(g)/255,
+ static_cast<float>(b)/255,
+ static_cast<float>(a)/255);
+ }
+
+ template<class T>
+ color_type make_color(T r, T g, T b);
+
+ template<>
+ inline color_type make_color<float>(float r, float g, float b)
+ {
+ return make_color(r, g, b, 1.0f);
+ }
+
+ template<>
+ inline color_type make_color<double>(double r, double g, double b)
+ {
+ return make_color(r, g, b, 1.0);
+ }
+
+ template<>
+ inline color_type make_color<int>(int r, int g, int b)
+ {
+ return make_color(r, g, b, 255);
+ }
+
+#define BOOST_GUIGL_COLOR(name, red, green, blue) \
+ inline color_type name(float alpha = 1.0f) \
+ { \
+ return make_color(red, green, blue, alpha); \
+ }
+
+ BOOST_GUIGL_COLOR(red, 1.0f, 0.0f, 0.0f);
+ BOOST_GUIGL_COLOR(green, 0.0f, 1.0f, 0.0f);
+ BOOST_GUIGL_COLOR(blue, 0.0f, 0.0f, 1.0f);
+ BOOST_GUIGL_COLOR(black, 0.0f, 0.0f, 0.0f);
+ BOOST_GUIGL_COLOR(white, 1.0f, 1.0f, 1.0f);
+ BOOST_GUIGL_COLOR(yellow, 1.0f, 1.0f, 0.0f);
+
+ inline color_type grey(float brightness = 0.5f, float alpha = 1.0f)
+ {
+ return make_color(brightness, brightness, brightness, alpha);
+ }
+
+#undef BOOST_GUIGL_COLOR
+
+}}
+
+#endif BOOST__GUIGL__COLOR_HPP

Modified: sandbox/guigl/boost/guigl/parameters.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/parameters.hpp (original)
+++ sandbox/guigl/boost/guigl/parameters.hpp 2009-03-22 18:28:05 EDT (Sun, 22 Mar 2009)
@@ -1,5 +1,5 @@
 /*=================================---------------------------------------------
- Copyright 2008 Stjepan Rajko
+ Copyright 2008,2009 Stjepan Rajko, Andrey Torba
   
     Distributed under the Boost Software License, Version 1.0.
     (See accompanying file LICENSE_1_0.txt or copy at
@@ -12,6 +12,7 @@
 #include <boost/guigl/event.hpp>
 #include <boost/guigl/types.hpp>
 #include <boost/parameter/typed_name.hpp>
+#include <boost/guigl/color.hpp>
 
 namespace boost { namespace guigl {
 
@@ -19,9 +20,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,(black()))
+ BOOST_PARAMETER_TYPED_NAME_WDEFAULT(color,const color_type,(white()))
+ 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/guigl/boost/guigl/types.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/types.hpp (original)
+++ sandbox/guigl/boost/guigl/types.hpp 2009-03-22 18:28:05 EDT (Sun, 22 Mar 2009)
@@ -1,5 +1,5 @@
 /*=================================---------------------------------------------
- Copyright 2008 Stjepan Rajko
+ Copyright 2008,2009 Stjepan Rajko, Andrey Torba
   
     Distributed under the Boost Software License, Version 1.0.
     (See accompanying file LICENSE_1_0.txt or copy at
@@ -17,7 +17,7 @@
 
 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;
 
 }}
 

Modified: sandbox/guigl/boost/guigl/view/impl/active_colored.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/view/impl/active_colored.hpp (original)
+++ sandbox/guigl/boost/guigl/view/impl/active_colored.hpp 2009-03-22 18:28:05 EDT (Sun, 22 Mar 2009)
@@ -1,5 +1,5 @@
 /*=================================---------------------------------------------
- Copyright 2008 Stjepan Rajko
+ Copyright 2008,2009 Stjepan Rajko, Andrey Torba
   
     Distributed under the Boost Software License, Version 1.0.
     (See accompanying file LICENSE_1_0.txt or copy at
@@ -17,7 +17,7 @@
 template<typename BaseView>
 void active_colored<BaseView>::use_active_color()
 {
- glColor3d(m_active_color[0],m_active_color[1],m_active_color[2]);
+ glColor4f(m_active_color[0], m_active_color[1], m_active_color[2], m_active_color[3]);
 }
 
 }}}

Modified: sandbox/guigl/boost/guigl/view/impl/colored.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/view/impl/colored.hpp (original)
+++ sandbox/guigl/boost/guigl/view/impl/colored.hpp 2009-03-22 18:28:05 EDT (Sun, 22 Mar 2009)
@@ -1,5 +1,5 @@
 /*=================================---------------------------------------------
- Copyright 2008 Stjepan Rajko
+ Copyright 2008,2009 Stjepan Rajko, Andrey Torba
   
     Distributed under the Boost Software License, Version 1.0.
     (See accompanying file LICENSE_1_0.txt or copy at
@@ -19,7 +19,7 @@
 inline void colored<BaseView>::draw_prologue()
 {
     BaseView::draw_prologue();
- glColor3d(m_color[0], m_color[1], m_color[2]);
+ glColor4f(m_color[0], m_color[1], m_color[2], m_color[3]);
 }
 
 }}}

Modified: sandbox/guigl/boost/guigl/view/impl/solid_background.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/view/impl/solid_background.hpp (original)
+++ sandbox/guigl/boost/guigl/view/impl/solid_background.hpp 2009-03-22 18:28:05 EDT (Sun, 22 Mar 2009)
@@ -1,5 +1,5 @@
 /*=================================---------------------------------------------
- Copyright 2008 Stjepan Rajko
+ Copyright 2008,2009 Stjepan Rajko, Andrey Torba
   
     Distributed under the Boost Software License, Version 1.0.
     (See accompanying file LICENSE_1_0.txt or copy at
@@ -21,7 +21,11 @@
 inline void solid_background<BaseView>::draw_prologue()
 {
     BaseView::draw_prologue();
- glColor3d(m_background_color[0], m_background_color[1], m_background_color[2]);
+ glColor4f(
+ m_background_color[0],
+ m_background_color[1],
+ m_background_color[2],
+ m_background_color[3]);
     glRectd(0.0, 0.0, solid_background::size().x, solid_background::size().y);
 }
 

Modified: sandbox/guigl/libs/guigl/build/vc8ide/build.vcproj
==============================================================================
--- sandbox/guigl/libs/guigl/build/vc8ide/build.vcproj (original)
+++ sandbox/guigl/libs/guigl/build/vc8ide/build.vcproj 2009-03-22 18:28:05 EDT (Sun, 22 Mar 2009)
@@ -85,6 +85,10 @@
>
                         </File>
                         <File
+ RelativePath="..\..\..\..\boost\guigl\color.hpp"
+ >
+ </File>
+ <File
                                 RelativePath="..\..\..\..\boost\guigl\export_symbols.hpp"
>
                         </File>

Modified: sandbox/guigl/libs/guigl/example/two_buttons.hpp
==============================================================================
--- sandbox/guigl/libs/guigl/example/two_buttons.hpp (original)
+++ sandbox/guigl/libs/guigl/example/two_buttons.hpp 2009-03-22 18:28:05 EDT (Sun, 22 Mar 2009)
@@ -1,5 +1,5 @@
 /*=================================---------------------------------------------
- Copyright 2008 Stjepan Rajko
+ Copyright 2008,2009 Stjepan Rajko, Andrey Torba
   
     Distributed under the Boost Software License, Version 1.0.
     (See accompanying file LICENSE_1_0.txt or copy at
@@ -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::grey())),
             boost::guigl::widget::labeled_button(boost::guigl::_label = "bottom button")
         ) ))
     {

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-03-22 18:28:05 EDT (Sun, 22 Mar 2009)
@@ -1,5 +1,5 @@
 /*=================================---------------------------------------------
- Copyright 2007,2008 Stjepan Rajko
+ Copyright 2007,2008,2009 Stjepan Rajko, Andrey Torba
   
     Distributed under the Boost Software License, Version 1.0.
     (See accompanying file LICENSE_1_0.txt or copy at
@@ -13,6 +13,7 @@
 #include <boost/guigl/widget/label.hpp>
 #include <boost/guigl/widget/labeled_button.hpp>
 #include <boost/guigl/widget/labeled_slider.hpp>
+#include <boost/guigl/color.hpp>
 
 #include <boost/bind.hpp>
 #include <boost/bind/placeholders.hpp>
@@ -27,10 +28,7 @@
 
 color_type make_grey(double value)
 {
- return color_type(
- static_cast<float>(value),
- static_cast<float>(value),
- static_cast<float>(value));
+ return grey(static_cast<float>(value));
 }
 
 void idle()
@@ -60,15 +58,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 = white(),
+ _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 = white(),
+ _active_color = red(),
+ _color = black(),
         _label="Button"));
     test_window1 << b1;
     
@@ -76,8 +74,8 @@
         _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 = grey(),
+ _active_color = green(),
         _min=0.1,_max=0.9,_value=0.5,
         _step=0.1 ));
     test_window1 << s;
@@ -97,7 +95,7 @@
 
     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 = make_color(1.0f/i, 1.0f/i, 1.0f/i, 1.0f) ));
     
     window test_window_3d(( _depth = true, _label="3D", _color=make_grey(1) ));
     test_window_3d << new two_spheres(_period = 0.01);


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