Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51857 - in sandbox-branches/andreo/guigl: boost/guigl/view libs/guigl/example
From: andreytorba_at_[hidden]
Date: 2009-03-19 13:11:59


Author: andreo
Date: 2009-03-19 13:11:58 EDT (Thu, 19 Mar 2009)
New Revision: 51857
URL: http://svn.boost.org/trac/boost/changeset/51857

Log:
sexy button development
Text files modified:
   sandbox-branches/andreo/guigl/boost/guigl/view/clickable.hpp | 1
   sandbox-branches/andreo/guigl/libs/guigl/example/sexy_button.cpp | 93 +++++++++++++++++++++++++++------------
   2 files changed, 65 insertions(+), 29 deletions(-)

Modified: sandbox-branches/andreo/guigl/boost/guigl/view/clickable.hpp
==============================================================================
--- sandbox-branches/andreo/guigl/boost/guigl/view/clickable.hpp (original)
+++ sandbox-branches/andreo/guigl/boost/guigl/view/clickable.hpp 2009-03-19 13:11:58 EDT (Thu, 19 Mar 2009)
@@ -53,6 +53,7 @@
     void button_down(bool state);
     void clickable_on_click()
     {
+ int i = 0;
         static_cast<Derived *>(this)->clickable_on_click();
     }
 

Modified: sandbox-branches/andreo/guigl/libs/guigl/example/sexy_button.cpp
==============================================================================
--- sandbox-branches/andreo/guigl/libs/guigl/example/sexy_button.cpp (original)
+++ sandbox-branches/andreo/guigl/libs/guigl/example/sexy_button.cpp 2009-03-19 13:11:58 EDT (Thu, 19 Mar 2009)
@@ -92,16 +92,11 @@
 typedef
 colored<sexy_button_color_map_type,
 view::mouse_tracking<
-//view::solid_background<
-//view::clickable<sexy_button,button::left_type,
+view::clickable<sexy_button,button::left_type,
 view::positioned<>
-/*>*/ > > button_base_type;
+> > > button_base_type;
 
 class sexy_button : public button_base_type {
-private:
- color_type m_bg_color;
- color_type m_highlight_color;
-
 public:
   typedef button_base_type base_type;
 
@@ -171,36 +166,75 @@
     glHint (GL_LINE_SMOOTH_HINT, GL_NICEST); //glEnable(GL_POLYGON_SMOOTH);
     //glHint (GL_POLYGON_SMOOTH_HINT, GL_NICEST); //glEnable(GL_POLYGON_SMOOTH);
 
- { // shadow
+ {
       gl::scoped_matrix m;
- gl::translate(2., 2.);
- gl::color(black(0.1));
+ double x_offset = button_down() ? (size().x*.1)/2 : 0.;
+ double y_offset = button_down() ? (size().y*.1)/2 : 0.;
+ gl::translate(x_offset, y_offset);
+ double scale_value = button_down() ? 0.9 : 1.;
+ gl::scale(scale_value, scale_value, scale_value);
+
+ { // shadow
+ gl::scoped_matrix m;
+ gl::translate(2., 2.);
+ gl::color(black(0.1));
+ glBegin(GL_POLYGON);
+ draw_rounded_rect();
+ glEnd();
+ }
+
+ if(mouse_state().inside)
+ use_color<highlight_color>();
+ else
+ use_color<bg_color>();
       glBegin(GL_POLYGON);
       draw_rounded_rect();
       glEnd();
- }
 
- if(mouse_state().inside)
- use_color<highlight_color>();
- else
- use_color<bg_color>();
- glBegin(GL_POLYGON);
- draw_rounded_rect();
- glEnd();
-
- glBegin(GL_LINE_LOOP);
- draw_rounded_rect();
- glEnd();
-
- glLineWidth(0.5);
- gl::color(black(mouse_state().inside ? 1.0 : 0.7));
- glBegin(GL_LINE_LOOP);
- draw_rounded_rect();
- glEnd();
+ glBegin(GL_LINE_LOOP);
+ draw_rounded_rect();
+ glEnd();
+
+
+ glLineWidth(0.5);
+ gl::color(black(mouse_state().inside ? 1.0 : 0.7));
+ glBegin(GL_LINE_LOOP);
+ draw_rounded_rect();
+ glEnd();
+
+ gl::color(black(0.1));
+ double radius = (std::min)(10., (std::min)(size().x, size().y)/2);
+ glBegin(GL_POLYGON);
+ draw_circle_segment(
+ circle2d_generator(position_type(radius, radius), radius),
+ 180,
+ 90);
+
+ draw_circle_segment(
+ circle2d_generator(position_type(size().x - radius, radius), radius),
+ 270,
+ 90);
+ glEnd();
+
+ }
 
     base_type::draw_epilogue();
     }
 
+ void clickable_on_click()
+ {
+ window::redraw(*this);
+ }
+
+ void clickable_button_down(bool state)
+ {
+ window::redraw(*this);
+ }
+
+ bool on_event(const event_type &event_info)
+ {
+ return base_type::on_event(event_info);
+ }
   };
 
 int main()
@@ -211,7 +245,8 @@
 
     window test_window1((
       _label = "custom example",
- _size = window_size
+ _size = window_size,
+ _background = black()
       ));
     
     sexy_button* btn1 = new sexy_button((


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