From ba09d1e7c2e71397b609a983e368fa3a31b612ef Mon Sep 17 00:00:00 2001 From: "r.kuznetsov" Date: Mon, 18 May 2015 10:15:36 +0300 Subject: [PATCH] Review fixes --- drape_gui/compass.cpp | 4 ++-- drape_gui/compass.hpp | 1 - drape_gui/country_status.cpp | 8 ++++---- drape_gui/country_status.hpp | 1 - drape_gui/drape_gui.cpp | 4 ++-- drape_gui/drape_gui.hpp | 6 +++--- drape_gui/layer_render.cpp | 21 ++++++++++----------- drape_gui/shape.hpp | 1 + 8 files changed, 22 insertions(+), 24 deletions(-) diff --git a/drape_gui/compass.cpp b/drape_gui/compass.cpp index b9337acef7..181abf7f36 100644 --- a/drape_gui/compass.cpp +++ b/drape_gui/compass.cpp @@ -26,7 +26,7 @@ namespace class CompassHandle : public TappableHandle { public: - CompassHandle(m2::PointF const & pivot, m2::PointF const & size, Compass::TTapHandler const & tapHandler) + CompassHandle(m2::PointF const & pivot, m2::PointF const & size, Shape::TTapHandler const & tapHandler) : TappableHandle(dp::Center, pivot, size) , m_tapHandler(tapHandler) {} @@ -53,7 +53,7 @@ namespace } private: - Compass::TTapHandler m_tapHandler; + Shape::TTapHandler m_tapHandler; }; } diff --git a/drape_gui/compass.hpp b/drape_gui/compass.hpp index 33db8b7281..f178f0fba6 100644 --- a/drape_gui/compass.hpp +++ b/drape_gui/compass.hpp @@ -12,7 +12,6 @@ public: : Shape(position) {} - using TTapHandler = function; drape_ptr Draw(ref_ptr tex, TTapHandler const & tapHandler) const; }; diff --git a/drape_gui/country_status.cpp b/drape_gui/country_status.cpp index 9837e303af..b9e65c2f6f 100644 --- a/drape_gui/country_status.cpp +++ b/drape_gui/country_status.cpp @@ -20,7 +20,7 @@ class CountryStatusButtonHandle : public ButtonHandle public: CountryStatusButtonHandle(CountryStatusHelper::ECountryState const state, - CountryStatus::TTapHandler const & tapHandler, + Shape::TTapHandler const & tapHandler, dp::Anchor anchor, m2::PointF const & size) : TBase(anchor, size) , m_state(state) @@ -41,7 +41,7 @@ public: private: CountryStatusHelper::ECountryState m_state; - CountryStatus::TTapHandler m_tapHandler; + Shape::TTapHandler m_tapHandler; }; class CountryStatusLabelHandle : public Handle @@ -89,7 +89,7 @@ private: }; drape_ptr CreateButtonHandle(CountryStatusHelper::ECountryState const state, - CountryStatus::TTapHandler const & tapHandler, + Shape::TTapHandler const & tapHandler, dp::Anchor anchor, m2::PointF const & size) { return make_unique_dp(state, tapHandler, anchor, size); @@ -165,7 +165,7 @@ drape_ptr CountryStatus::Draw(ref_ptr tex, case CountryStatusHelper::CONTROL_TYPE_BUTTON: { TButtonHandlers::const_iterator buttonHandlerIt = buttonHandlers.find(control.m_buttonType); - CountryStatus::TTapHandler buttonHandler = (buttonHandlerIt != buttonHandlers.end() ? buttonHandlerIt->second : nullptr); + Shape::TTapHandler buttonHandler = (buttonHandlerIt != buttonHandlers.end() ? buttonHandlerIt->second : nullptr); Button::THandleCreator buttonHandleCreator = bind(&CreateButtonHandle, state, buttonHandler, _1, _2); Button::THandleCreator labelHandleCreator = bind(&CreateLabelHandle, state, _1, _2); diff --git a/drape_gui/country_status.hpp b/drape_gui/country_status.hpp index 1d2e085547..75604540f1 100644 --- a/drape_gui/country_status.hpp +++ b/drape_gui/country_status.hpp @@ -12,7 +12,6 @@ public: : Shape(position) {} - using TTapHandler = function; using TButtonHandlers = map; drape_ptr Draw(ref_ptr tex, diff --git a/drape_gui/drape_gui.cpp b/drape_gui/drape_gui.cpp index a1ae529736..d0ce482a0a 100644 --- a/drape_gui/drape_gui.cpp +++ b/drape_gui/drape_gui.cpp @@ -132,13 +132,13 @@ CountryStatusHelper & DrapeGui::GetCountryStatusHelperImpl() return m_impl->m_countryHelper; } -void DrapeGui::ConnectOnCompassTappedHandler(Compass::TTapHandler const & handler) +void DrapeGui::ConnectOnCompassTappedHandler(Shape::TTapHandler const & handler) { m_onCompassTappedHandler = handler; } void DrapeGui::ConnectOnButtonPressedHandler(CountryStatusHelper::EButtonType buttonType, - CountryStatus::TTapHandler const & handler) + Shape::TTapHandler const & handler) { m_buttonHandlers[buttonType] = handler; } diff --git a/drape_gui/drape_gui.hpp b/drape_gui/drape_gui.hpp index cba9dc07bf..0916a3b4e8 100644 --- a/drape_gui/drape_gui.hpp +++ b/drape_gui/drape_gui.hpp @@ -73,9 +73,9 @@ public: bool IsCopyrightActive() const { return m_isCopyrightActive; } void DeactivateCopyright() { m_isCopyrightActive = false; } - void ConnectOnCompassTappedHandler(Compass::TTapHandler const & handler); + void ConnectOnCompassTappedHandler(Shape::TTapHandler const & handler); void ConnectOnButtonPressedHandler(CountryStatusHelper::EButtonType buttonType, - CountryStatus::TTapHandler const & handler); + Shape::TTapHandler const & handler); void CallOnCompassTappedHandler(); void CallOnButtonPressedHandler(CountryStatusHelper::EButtonType buttonType); @@ -88,7 +88,7 @@ private: unique_ptr m_impl; bool m_isCopyrightActive = true; - Compass::TTapHandler m_onCompassTappedHandler; + Shape::TTapHandler m_onCompassTappedHandler; CountryStatus::TButtonHandlers m_buttonHandlers; }; diff --git a/drape_gui/layer_render.cpp b/drape_gui/layer_render.cpp index bf875a0c40..de2af37fe3 100644 --- a/drape_gui/layer_render.cpp +++ b/drape_gui/layer_render.cpp @@ -51,6 +51,13 @@ private: int m_scale; }; +void RegisterButtonHandler(CountryStatus::TButtonHandlers & handlers, + CountryStatusHelper::EButtonType buttonType) +{ + handlers[buttonType] = bind(&DrapeGui::CallOnButtonPressedHandler, + &DrapeGui::Instance(), buttonType); +} + } LayerCacher::LayerCacher(string const & deviceType) @@ -86,17 +93,9 @@ drape_ptr LayerCacher::Recache(Skin::ElementName names, CountryStatus countryStatus = CountryStatus(GetPos(Skin::CountryStatus)); CountryStatus::TButtonHandlers handlers; - handlers[CountryStatusHelper::BUTTON_TYPE_MAP] = bind(&DrapeGui::CallOnButtonPressedHandler, - &DrapeGui::Instance(), - CountryStatusHelper::BUTTON_TYPE_MAP); - - handlers[CountryStatusHelper::BUTTON_TYPE_MAP_ROUTING] = bind(&DrapeGui::CallOnButtonPressedHandler, - &DrapeGui::Instance(), - CountryStatusHelper::BUTTON_TYPE_MAP_ROUTING); - - handlers[CountryStatusHelper::BUTTON_TRY_AGAIN] = bind(&DrapeGui::CallOnButtonPressedHandler, - &DrapeGui::Instance(), - CountryStatusHelper::BUTTON_TRY_AGAIN); + RegisterButtonHandler(handlers, CountryStatusHelper::BUTTON_TYPE_MAP); + RegisterButtonHandler(handlers, CountryStatusHelper::BUTTON_TYPE_MAP_ROUTING); + RegisterButtonHandler(handlers, CountryStatusHelper::BUTTON_TRY_AGAIN); renderer->AddShapeRenderer(Skin::CountryStatus, countryStatus.Draw(textures, handlers)); } diff --git a/drape_gui/shape.hpp b/drape_gui/shape.hpp index 3d960ded7f..f1f27185cc 100644 --- a/drape_gui/shape.hpp +++ b/drape_gui/shape.hpp @@ -110,6 +110,7 @@ class Shape { public: Shape(gui::Position const & position) : m_position(position) {} + using TTapHandler = function; protected: gui::Position m_position;