Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50614 - in sandbox/guigl/boost/guigl: . layout view view/impl
From: stipe_at_[hidden]
Date: 2009-01-15 17:32:14


Author: srajko
Date: 2009-01-15 17:32:13 EST (Thu, 15 Jan 2009)
New Revision: 50614
URL: http://svn.boost.org/trac/boost/changeset/50614

Log:
fixed grid calculation
Text files modified:
   sandbox/guigl/boost/guigl/geometry.hpp | 6 ++++++
   sandbox/guigl/boost/guigl/layout/grid.hpp | 20 ++++++++++++--------
   sandbox/guigl/boost/guigl/view/impl/static_compound.hpp | 3 +--
   sandbox/guigl/boost/guigl/view/positioned.hpp | 32 ++++++++++++++++++++++++++++++--
   4 files changed, 49 insertions(+), 12 deletions(-)

Modified: sandbox/guigl/boost/guigl/geometry.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/geometry.hpp (original)
+++ sandbox/guigl/boost/guigl/geometry.hpp 2009-01-15 17:32:13 EST (Thu, 15 Jan 2009)
@@ -23,6 +23,12 @@
     return view.position() + view.size() / 2;
 }
 
+template<typename View>
+position_type root_midpoint(const View &view)
+{
+ return root_position(view) + view.size() / 2;
+}
+
 }
 
 }}

Modified: sandbox/guigl/boost/guigl/layout/grid.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/layout/grid.hpp (original)
+++ sandbox/guigl/boost/guigl/layout/grid.hpp 2009-01-15 17:32:13 EST (Thu, 15 Jan 2009)
@@ -50,8 +50,9 @@
         template<typename View>
         void operator()(View &view) const
         {
- view.set_position(layout.next_position());
- view.set_size(layout.next_size());
+ view.set_position(layout.position());
+ view.set_size(layout.size());
+ layout.next();
         }
         Layout &layout;
     };
@@ -70,17 +71,19 @@
         m_dimensions[1] = args[_vertical];
         m_next[0] = m_next[1] = 0;
     }
- position_type next_position()
+ void next()
     {
- position_type result(m_element_size.x * m_next[0], m_element_size.y * m_next[1]);
         if(++m_next[m_direction] >= m_dimensions[m_direction])
         {
             m_next[m_direction] = 0;
             m_next[!m_direction]++;
         }
- return result;
     }
- const size_type &next_size()
+ position_type position()
+ {
+ return position_type(m_element_size.x * m_next[0], m_element_size.y * m_next[1]);
+ }
+ const size_type &size()
     {
         return m_element_size;
     }
@@ -95,9 +98,10 @@
     {
         T *element(new T((
             args,
- _size = next_size(),
- _position = next_position()
+ _size = size(),
+ _position = position()
         )) );
+ next();
         return element;
     }
 private:

Modified: sandbox/guigl/boost/guigl/view/impl/static_compound.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/view/impl/static_compound.hpp (original)
+++ sandbox/guigl/boost/guigl/view/impl/static_compound.hpp 2009-01-15 17:32:13 EST (Thu, 15 Jan 2009)
@@ -178,8 +178,7 @@
     
     bool operator()(const movement_event &event_info) const
     {
- detail::accumulate(view.children(), false, propagate_movement_event<static_compound_event_visitor>(*this, event_info));
- return true;
+ return detail::accumulate(view.children(), false, propagate_movement_event<static_compound_event_visitor>(*this, event_info));
     }
 
     bool operator()(const entry_exit_event &event_info) const

Modified: sandbox/guigl/boost/guigl/view/positioned.hpp
==============================================================================
--- sandbox/guigl/boost/guigl/view/positioned.hpp (original)
+++ sandbox/guigl/boost/guigl/view/positioned.hpp 2009-01-15 17:32:13 EST (Thu, 15 Jan 2009)
@@ -63,7 +63,10 @@
             root = p_view->m_parent;
         return root;
     }
-
+ const base &parent() const
+ {
+ return *m_parent;
+ }
 protected:
     void draw_prologue();
     void draw_epilogue();
@@ -81,7 +84,32 @@
 struct is_positioned<positioned<BaseView> > : public mpl::true_
 {};
 
+/** Returns the topmost ancestor, as defined by following the parent pointer
+as long as the parent is also a positioned<> view. */
+template<typename View>
+inline const base *root(const positioned<View> &view)
+{
+ const base *root = view;
+ const positioned<> *p_view;
+ while((p_view = dynamic_cast<const positioned<> *>(root)))
+ root = p_view->parent();
+ return root;
+}
+
+/** Returns the position relative to topmost ancestor,
+ as defined by following the parent pointer
+ as long as the parent is also a positioned<> view. */
+inline position_type root_position(const positioned<> &view)
+{
+ const positioned<> *p_view = &view;
+ position_type position = view.position();
+ while((p_view = dynamic_cast<const positioned<> *>(&p_view->parent())))
+ position += p_view->position();
+ return position;
+}
+
+} // namespace view
 
-}}}
+}}
 
 #endif // BOOST__GUIGL__VIEW__POSITIONED_HPP


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