diff options
author | rachytski <siarhei.rachytski@gmail.com> | 2013-01-25 21:00:40 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:49:22 +0300 |
commit | 9ef29ad3d046e982be99c71d026748932e80632d (patch) | |
tree | bf7d502e3aef22dbf45a7b6ea006e999cdd41295 /gui | |
parent | 2bf7adf129911da7d2f6a41aca07ecefd006743b (diff) |
Ruler code cleanup and changes according to code review.
Diffstat (limited to 'gui')
-rw-r--r-- | gui/controller.cpp | 30 | ||||
-rw-r--r-- | gui/element.hpp | 15 |
2 files changed, 15 insertions, 30 deletions
diff --git a/gui/controller.cpp b/gui/controller.cpp index e1627aba6f..35f2a2aff2 100644 --- a/gui/controller.cpp +++ b/gui/controller.cpp @@ -166,10 +166,7 @@ namespace gui math::Matrix<double, 3, 3> m = math::Identity<double, 3>(); - for (elem_list_t::const_iterator it = m_Elements.begin(); - it != m_Elements.end(); - ++it) - (*it)->draw(screen, m); + for_each(m_Elements.begin(), m_Elements.end(), bind(&Element::draw, _1, screen, m)); screen->endFrame(); } @@ -188,11 +185,7 @@ namespace gui void Controller::SetStringsBundle(StringsBundle const * bundle) { m_bundle = bundle; - - for (elem_list_t::const_iterator it = m_Elements.begin(); - it != m_Elements.end(); - ++it) - (*it)->setIsDirtyLayout(true); + for_each(m_Elements.begin(), m_Elements.end(), bind(&Element::setIsDirtyLayout, _1, true)); } StringsBundle const * Controller::GetStringsBundle() const @@ -207,28 +200,17 @@ namespace gui void Controller::UpdateElements() { - for (elem_list_t::const_iterator it = m_Elements.begin(); - it != m_Elements.end(); - ++it) - (*it)->update(); + for_each(m_Elements.begin(), m_Elements.end(), bind(&Element::update, _1)); } void Controller::PurgeElements() { - for (elem_list_t::const_iterator it = m_Elements.begin(); - it != m_Elements.end(); - ++it) - { - (*it)->purge(); - (*it)->setIsDirtyLayout(true); - } + for_each(m_Elements.begin(), m_Elements.end(), bind(&Element::purge, _1)); + for_each(m_Elements.begin(), m_Elements.end(), bind(&Element::setIsDirtyLayout, _1, true)); } void Controller::LayoutElements() { - for (elem_list_t::const_iterator it = m_Elements.begin(); - it != m_Elements.end(); - ++it) - (*it)->checkDirtyLayout(); + for_each(m_Elements.begin(), m_Elements.end(), bind(&Element::checkDirtyLayout, _1)); } } diff --git a/gui/element.hpp b/gui/element.hpp index fdfee77d93..4d8adfd1ed 100644 --- a/gui/element.hpp +++ b/gui/element.hpp @@ -64,13 +64,11 @@ namespace gui virtual bool onTapEnded(m2::PointD const & pt); virtual bool onTapCancelled(m2::PointD const & pt); + /// invalidate the rendering system to redraw the gui elements. void invalidate(); + /// obtain @see VisualScale double visualScale() const; - graphics::OverlayElement * clone(math::Matrix<double, 3, 3> const & m) const; - void draw(graphics::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const; - double priority() const; - /// this method is called to cache visual appearance of gui::Element for fast rendering. /// it should be called when isDirtyDrawing is set to true(visual parameters of object is changed). virtual void cache(); @@ -83,9 +81,14 @@ namespace gui /// this method is called after gui::Controller::SetRenderParams to /// perform layout calculations which might depends on RenderParams. virtual void layout(); - + /// set the parent controller for this element. virtual void setController(Controller * controller); - + /// check if the layout of element is dirty and re-layout element if needed. void checkDirtyLayout() const; + + graphics::OverlayElement * clone(math::Matrix<double, 3, 3> const & m) const; + void draw(graphics::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const; + double priority() const; + }; } |