Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r49487 - in sandbox/guigl/boost/guigl: . view view/impl widget
From: stipe_at_[hidden]
Date: 2008-10-29 12:43:52


Author: srajko
Date: 2008-10-29 12:43:51 EDT (Wed, 29 Oct 2008)
New Revision: 49487
URL: http://svn.boost.org/trac/boost/changeset/49487

Log:
clickable and draggable are now for a specified button, moved base_type typedefs to public
Text files modified:
   sandbox/guigl/boost/guigl/event.hpp | 16 ++++++++++++++++
   sandbox/guigl/boost/guigl/parameters.hpp | 4 ++++
   sandbox/guigl/boost/guigl/view/active_colored.hpp | 3 ++-
   sandbox/guigl/boost/guigl/view/clickable.hpp | 13 ++++++++-----
   sandbox/guigl/boost/guigl/view/colored.hpp | 3 ++-
   sandbox/guigl/boost/guigl/view/draggable.hpp | 14 +++++++++++---
   sandbox/guigl/boost/guigl/view/impl/clickable.hpp | 18 ++++++++++--------
   sandbox/guigl/boost/guigl/view/impl/draggable.hpp | 14 ++++++++------
   sandbox/guigl/boost/guigl/view/labeled.hpp | 3 ++-
   sandbox/guigl/boost/guigl/view/navigable.hpp | 6 +++---
   sandbox/guigl/boost/guigl/view/positioned.hpp | 2 +-
   sandbox/guigl/boost/guigl/widget/button.hpp | 7 ++++---
   sandbox/guigl/boost/guigl/widget/label.hpp | 3 ++-
   sandbox/guigl/boost/guigl/widget/labeled_button.hpp | 3 ++-
   sandbox/guigl/boost/guigl/widget/slider.hpp | 4 ++--
   15 files changed, 77 insertions(+), 36 deletions(-)

Modified: sandbox/guigl/boost/guigl/event.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/event.hpp (original)
+++ sandbox/guigl/boost/guigl/event.hpp 2008-10-29 12:43:51 EDT (Wed, 29 Oct 2008)
@@ -23,6 +23,22 @@
     left, middle, right
 };
 
+struct left_type
+{
+ const static enum_type value = left;
+};
+
+struct middle_type
+{
+ const static enum_type value = middle;
+};
+
+struct right_type
+{
+ const static enum_type value = right;
+};
+
+
 }
 
 namespace direction {

Modified: sandbox/guigl/boost/guigl/parameters.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/parameters.hpp (original)
+++ sandbox/guigl/boost/guigl/parameters.hpp 2008-10-29 12:43:51 EDT (Wed, 29 Oct 2008)
@@ -26,6 +26,10 @@
     BOOST_PARAMETER_TYPED_NAME_WDEFAULT(max,const double,1.0)
     BOOST_PARAMETER_TYPED_NAME_WDEFAULT(step,const double,0.0)
     BOOST_PARAMETER_TYPED_NAME_WDEFAULT(period,const double,0.0)
+
+ BOOST_PARAMETER_TYPED_NAME_WDEFAULT(clickable_button,button::enum_type,button::left)
+ BOOST_PARAMETER_TYPED_NAME_WDEFAULT(draggable_button,button::enum_type,button::left)
+
     BOOST_PARAMETER_UNTYPED_NAME(value)
     BOOST_PARAMETER_UNTYPED_NAME(children)
     

Modified: sandbox/guigl/boost/guigl/view/active_colored.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/view/active_colored.hpp (original)
+++ sandbox/guigl/boost/guigl/view/active_colored.hpp 2008-10-29 12:43:51 EDT (Wed, 29 Oct 2008)
@@ -17,8 +17,9 @@
 template<typename BaseView=base>
 class active_colored : public BaseView
 {
- typedef BaseView base_type;
 public:
+ typedef BaseView base_type;
+
     /** Sets the active color to the _active_color named parameter. */
     template<typename ArgumentPack>
     active_colored(const ArgumentPack &args)

Modified: sandbox/guigl/boost/guigl/view/clickable.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/view/clickable.hpp (original)
+++ sandbox/guigl/boost/guigl/view/clickable.hpp 2008-10-29 12:43:51 EDT (Wed, 29 Oct 2008)
@@ -15,7 +15,7 @@
 
 namespace detail {
 
- template<typename Derived, typename BaseView>
+ template<typename Derived, typename Button, typename BaseView>
     struct clickable_static_visitor;
 
 }
@@ -25,11 +25,12 @@
     The Derived class must have the method clickable_on_click(), which
     will be called when the user completes a click in the view.
 */
-template<typename Derived, typename BaseView=base>
+template<typename Derived, typename Button, typename BaseView=base>
 class clickable : public BaseView
 {
- typedef BaseView base_type;
 public:
+ typedef BaseView base_type;
+
     template<typename ArgumentPack>
     clickable(const ArgumentPack &args)
         : base_type(args)
@@ -39,7 +40,8 @@
         : base_type(static_cast<const base_type &>(rhs))
         , m_button_down(false)
     {}
-
+ button::enum_type clickable_button()
+ { return Button::value; }
 protected:
     bool on_event(const event_type &event_info);
 
@@ -47,13 +49,14 @@
     { return m_button_down; }
 private:
     bool m_button_down;
+
     void button_down(bool state);
     void clickable_on_click()
     {
         static_cast<Derived *>(this)->clickable_on_click();
     }
 
- friend struct detail::clickable_static_visitor<Derived,BaseView>;
+ friend struct detail::clickable_static_visitor<Derived,Button,BaseView>;
 };
 
 }}}

Modified: sandbox/guigl/boost/guigl/view/colored.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/view/colored.hpp (original)
+++ sandbox/guigl/boost/guigl/view/colored.hpp 2008-10-29 12:43:51 EDT (Wed, 29 Oct 2008)
@@ -16,8 +16,9 @@
 template<typename BaseView=base>
 class colored : public BaseView
 {
- typedef BaseView base_type;
 public:
+ typedef BaseView base_type;
+
     template<typename ArgumentPack>
     colored(const ArgumentPack &args)
         : base_type(args)

Modified: sandbox/guigl/boost/guigl/view/draggable.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/view/draggable.hpp (original)
+++ sandbox/guigl/boost/guigl/view/draggable.hpp 2008-10-29 12:43:51 EDT (Wed, 29 Oct 2008)
@@ -16,7 +16,7 @@
 
 namespace detail {
 
- template<typename Derived, typename BaseView>
+ template<typename Derived, typename Button, typename BaseView>
     struct draggable_static_visitor;
 
 }
@@ -25,7 +25,7 @@
 /** Behavior capturing dragging (moving the mouse over the view with the button
     held down).
 */
-template<typename Derived, typename BaseView=base>
+template<typename Derived, typename Button, typename BaseView=base>
 class draggable : public mouse_tracking<BaseView>
 {
 public:
@@ -41,6 +41,14 @@
         , m_dragging(false)
     {}
 
+ void draggable_on_drag(const position_type &position)
+ {}
+ void draggable_on_end_drag(const position_type &position)
+ {}
+
+ button::enum_type draggable_button() const
+ { return Button::value; }
+
 protected:
     bool on_event(const event_type &event_info);
     const position_type &drag_origin() const
@@ -58,7 +66,7 @@
         static_cast<Derived *>(this)->draggable_on_end_drag(position);
     }
 
- friend struct detail::draggable_static_visitor<Derived,BaseView>;
+ friend struct detail::draggable_static_visitor<Derived,Button,BaseView>;
     
     position_type m_drag_origin;
     bool m_dragging;

Modified: sandbox/guigl/boost/guigl/view/impl/clickable.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/view/impl/clickable.hpp (original)
+++ sandbox/guigl/boost/guigl/view/impl/clickable.hpp 2008-10-29 12:43:51 EDT (Wed, 29 Oct 2008)
@@ -15,8 +15,8 @@
 
 namespace boost { namespace guigl { namespace view {
 
-template<typename Derived, typename BaseView>
-inline void clickable<Derived, BaseView>::button_down(bool state)
+template<typename Derived, typename Button, typename BaseView>
+inline void clickable<Derived, Button, BaseView>::button_down(bool state)
 {
     m_button_down = state;
     static_cast<Derived *>(this)->clickable_button_down(state);
@@ -24,12 +24,12 @@
 
 namespace detail {
 
- template<typename Derived, typename BaseView>
+ template<typename Derived, typename Button, typename BaseView>
     struct clickable_static_visitor
         : public boost::static_visitor<>
     {
     public:
- clickable_static_visitor(clickable<Derived, BaseView> &c)
+ clickable_static_visitor(clickable<Derived, Button, BaseView> &c)
             : m_clickable(c)
         {}
         
@@ -43,6 +43,8 @@
         
         bool operator()(const button_event &event_info) const
         {
+ if(event_info.button != m_clickable.clickable_button())
+ return false;
             if(event_info.direction == direction::down)
             {
                 m_clickable.button_down(true);
@@ -64,18 +66,18 @@
             return true;
         }
 
- clickable<Derived, BaseView> &m_clickable;
+ clickable<Derived, Button, BaseView> &m_clickable;
     };
 
 }
 
-template<typename Derived, typename BaseView>
-inline bool clickable<Derived, BaseView>::on_event(const event_type &event_info)
+template<typename Derived, typename Button, typename BaseView>
+inline bool clickable<Derived, Button, BaseView>::on_event(const event_type &event_info)
 {
     if(base_type::on_event(event_info))
         return true;
     else
- return boost::apply_visitor(detail::clickable_static_visitor<Derived,BaseView>(*this), event_info);
+ return boost::apply_visitor(detail::clickable_static_visitor<Derived,Button,BaseView>(*this), event_info);
 }
 
 

Modified: sandbox/guigl/boost/guigl/view/impl/draggable.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/view/impl/draggable.hpp (original)
+++ sandbox/guigl/boost/guigl/view/impl/draggable.hpp 2008-10-29 12:43:51 EDT (Wed, 29 Oct 2008)
@@ -18,12 +18,12 @@
 
 namespace detail {
 
- template<typename Derived, typename BaseView>
+ template<typename Derived, typename Button, typename BaseView>
     struct draggable_static_visitor
         : public boost::static_visitor<>
     {
     public:
- draggable_static_visitor(draggable<Derived, BaseView> &c)
+ draggable_static_visitor(draggable<Derived, Button, BaseView> &c)
             : m_draggable(c)
         {}
         
@@ -37,6 +37,8 @@
 
         bool operator()(const button_event &event_info) const
         {
+ if(event_info.button != m_draggable.draggable_button())
+ return false;
             if(event_info.direction == direction::down)
             {
                 m_draggable.m_drag_origin = m_draggable.mouse_state().position;
@@ -58,18 +60,18 @@
             return true;
         }
         
- draggable<Derived, BaseView> &m_draggable;
+ draggable<Derived, Button, BaseView> &m_draggable;
     };
 
 }
 
-template<typename Derived, typename BaseView>
-inline bool draggable<Derived, BaseView>::on_event(const event_type &event_info)
+template<typename Derived, typename Button, typename BaseView>
+inline bool draggable<Derived, Button, BaseView>::on_event(const event_type &event_info)
 {
     if(base_type::on_event(event_info))
         return true;
     else
- return boost::apply_visitor(detail::draggable_static_visitor<Derived,BaseView>(*this), event_info);
+ return boost::apply_visitor(detail::draggable_static_visitor<Derived,Button,BaseView>(*this), event_info);
 }
 
 

Modified: sandbox/guigl/boost/guigl/view/labeled.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/view/labeled.hpp (original)
+++ sandbox/guigl/boost/guigl/view/labeled.hpp 2008-10-29 12:43:51 EDT (Wed, 29 Oct 2008)
@@ -17,8 +17,9 @@
 template<typename BaseView=base>
 class labeled : public BaseView
 {
- typedef BaseView base_type;
 public:
+ typedef BaseView base_type;
+
     template<typename ArgumentPack>
     labeled(const ArgumentPack &args)
         : base_type(args)

Modified: sandbox/guigl/boost/guigl/view/navigable.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/view/navigable.hpp (original)
+++ sandbox/guigl/boost/guigl/view/navigable.hpp 2008-10-29 12:43:51 EDT (Wed, 29 Oct 2008)
@@ -16,10 +16,10 @@
 namespace boost { namespace guigl { namespace view {
 
 template<typename BaseView=base>
-class navigable : public draggable<navigable<BaseView>, BaseView>
+class navigable : public draggable<navigable<BaseView>, guigl::button::left_type, BaseView>
 {
 public:
- typedef draggable<navigable<BaseView>, BaseView> base_type;
+ typedef draggable<navigable<BaseView>, guigl::button::left_type, BaseView> base_type;
 
     template<typename ArgumentPack>
     navigable(const ArgumentPack &args)
@@ -48,7 +48,7 @@
     void draggable_on_drag(const position_type &position);
     void draggable_on_end_drag(const position_type &position) {};
 
- friend class draggable<navigable<BaseView>, BaseView>;
+ friend class draggable<navigable<BaseView>, guigl::button::left_type, BaseView>;
 
 private:
     position_type m_angle;

Modified: sandbox/guigl/boost/guigl/view/positioned.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/view/positioned.hpp (original)
+++ sandbox/guigl/boost/guigl/view/positioned.hpp 2008-10-29 12:43:51 EDT (Wed, 29 Oct 2008)
@@ -49,7 +49,7 @@
     const position_type &position() const
     { return m_position; }
 
- /** Returns the position */
+ /** Sets the position */
     void set_position(const position_type &position)
     { m_position = position; }
 

Modified: sandbox/guigl/boost/guigl/widget/button.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/widget/button.hpp (original)
+++ sandbox/guigl/boost/guigl/widget/button.hpp 2008-10-29 12:43:51 EDT (Wed, 29 Oct 2008)
@@ -22,15 +22,16 @@
 typedef
     view::active_colored<
         view::solid_background<
- view::clickable<button,
+ view::clickable<button,guigl::button::left_type,
                 view::positioned<>
> > > button_base_type;
 
 /// A button which sends a signal when clicked.
 class button : public button_base_type
 {
- typedef button_base_type base_type;
 public:
+ typedef button_base_type base_type;
+
     template<typename ArgumentPack>
     button(const ArgumentPack &args)
         : button_base_type(args)
@@ -54,7 +55,7 @@
     void clickable_on_click()
     { on_click(); }
     
- friend class view::clickable<button, view::positioned<> >;
+ friend class view::clickable<button, guigl::button::left_type, view::positioned<> >;
 };
 
 }}}

Modified: sandbox/guigl/boost/guigl/widget/label.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/widget/label.hpp (original)
+++ sandbox/guigl/boost/guigl/widget/label.hpp 2008-10-29 12:43:51 EDT (Wed, 29 Oct 2008)
@@ -24,8 +24,9 @@
 
 class label : public label_base_type
 {
- typedef label_base_type base_type;
 public:
+ typedef label_base_type base_type;
+
     template<typename ArgumentPack>
     label(const ArgumentPack &args)
         : base_type(args)

Modified: sandbox/guigl/boost/guigl/widget/labeled_button.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/widget/labeled_button.hpp (original)
+++ sandbox/guigl/boost/guigl/widget/labeled_button.hpp 2008-10-29 12:43:51 EDT (Wed, 29 Oct 2008)
@@ -22,8 +22,9 @@
 
 class labeled_button : public labeled_button_base_type
 {
- typedef labeled_button_base_type base_type;
 public:
+ typedef labeled_button_base_type base_type;
+
     template<typename ArgumentPack>
     labeled_button(const ArgumentPack &args)
         : base_type(args)

Modified: sandbox/guigl/boost/guigl/widget/slider.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/widget/slider.hpp (original)
+++ sandbox/guigl/boost/guigl/widget/slider.hpp 2008-10-29 12:43:51 EDT (Wed, 29 Oct 2008)
@@ -21,7 +21,7 @@
 
 typedef
     view::active_colored<
- view::draggable<slider,
+ view::draggable<slider,guigl::button::left_type,
             view::solid_background<
                 view::positioned<>
> > > slider_base_type;
@@ -58,7 +58,7 @@
     void draggable_on_drag(const position_type &position);
     void draggable_on_end_drag(const position_type &position) {};
     
- friend class view::draggable<slider,
+ friend class view::draggable<slider,guigl::button::left_type,
         view::solid_background<
             view::positioned<>
> >;


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