diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index bc5824c932..f9d3d34592 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -1017,7 +1017,7 @@ Java_com_mapswithme_maps_Framework_nativeSetMapObjectListener(JNIEnv * env, jcla "(Lcom/mapswithme/maps/bookmarks/data/MapObject;)V"); // void onDismiss(boolean switchFullScreenMode); jmethodID const dismissId = jni::GetMethodID(env, g_mapObjectListener, "onDismiss", "(Z)V"); - frm()->SetMapSelectionListeners([activatedId](place_page::Info const & info) + frm()->SetPlacePageListenners([activatedId](place_page::Info const & info) { JNIEnv * env = jni::GetEnv(); g_framework->SetPlacePageInfo(info); @@ -1028,7 +1028,8 @@ Java_com_mapswithme_maps_Framework_nativeSetMapObjectListener(JNIEnv * env, jcla JNIEnv * env = jni::GetEnv(); g_framework->SetPlacePageInfo({}); env->CallVoidMethod(g_mapObjectListener, dismissId, switchFullScreenMode); - }); + }, + {} /* onUpdate */); } JNIEXPORT void JNICALL @@ -1037,7 +1038,7 @@ Java_com_mapswithme_maps_Framework_nativeRemoveMapObjectListener(JNIEnv * env, j if (g_mapObjectListener == nullptr) return; - frm()->SetMapSelectionListeners({}, {}); + frm()->SetPlacePageListenners({} /* onOpen */, {} /* onClose */, {} /* onUpdate */); LOG(LINFO, ("Remove global map object listener")); env->DeleteGlobalRef(g_mapObjectListener); g_mapObjectListener = nullptr; diff --git a/iphone/Maps/Classes/MapViewController.mm b/iphone/Maps/Classes/MapViewController.mm index 4da16460b6..5130c19be4 100644 --- a/iphone/Maps/Classes/MapViewController.mm +++ b/iphone/Maps/Classes/MapViewController.mm @@ -392,9 +392,10 @@ NSString * const kHotelFacilitiesSegue = @"Map2FacilitiesSegue"; self.listeners = [NSHashTable> weakObjectsHashTable]; Framework & f = GetFramework(); // TODO: Review and improve this code. - f.SetMapSelectionListeners( + f.SetPlacePageListenners( [self](place_page::Info const & info) { [self onMapObjectSelected:info]; }, - [self](bool switchFullScreen) { [self onMapObjectDeselected:switchFullScreen]; }); + [self](bool switchFullScreen) { [self onMapObjectDeselected:switchFullScreen]; }, + {} /* onUpdate */); // TODO: Review and improve this code. f.SetMyPositionModeListener([self](location::EMyPositionMode mode, bool routingActive) { // TODO: Two global listeners are subscribed to the same event from the core. diff --git a/map/framework.cpp b/map/framework.cpp index 7a7763bfaa..051ba461f0 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -2396,11 +2396,13 @@ BookmarkManager const & Framework::GetBookmarkManager() const return *m_bmManager.get(); } -void Framework::SetMapSelectionListeners(TActivateMapSelectionFn const & activator, - TDeactivateMapSelectionFn const & deactivator) +void Framework::SetPlacePageListenners(PlacePageEvent::OnOpen const & onOpen, + PlacePageEvent::OnClose const & onClose, + PlacePageEvent::OnUpdate const & onUpdate) { - m_activateMapSelectionFn = activator; - m_deactivateMapSelectionFn = deactivator; + m_onPlacePageOpen = onOpen; + m_onPlacePageClose = onClose; + m_onPlacePageUpdate = onUpdate; } void Framework::ActivateMapSelection(bool needAnimation, df::SelectionShape::ESelectedObject selectionType, @@ -2420,10 +2422,10 @@ void Framework::ActivateMapSelection(bool needAnimation, df::SelectionShape::ESe SetDisplacementMode(DisplacementModeManager::SLOT_MAP_SELECTION, ftypes::IsHotelChecker::Instance()(info.GetTypes()) /* show */); - if (m_activateMapSelectionFn) - m_activateMapSelectionFn(info); + if (m_onPlacePageOpen) + m_onPlacePageOpen(info); else - LOG(LWARNING, ("m_activateMapSelectionFn has not been set up.")); + LOG(LWARNING, ("m_onPlacePageOpen has not been set up.")); } void Framework::DeactivateMapSelection(bool notifyUI) @@ -2431,8 +2433,8 @@ void Framework::DeactivateMapSelection(bool notifyUI) bool const somethingWasAlreadySelected = (m_lastTapEvent != nullptr); m_lastTapEvent.reset(); - if (notifyUI && m_deactivateMapSelectionFn) - m_deactivateMapSelectionFn(!somethingWasAlreadySelected); + if (notifyUI && m_onPlacePageClose) + m_onPlacePageClose(!somethingWasAlreadySelected); if (somethingWasAlreadySelected && m_drapeEngine != nullptr) m_drapeEngine->DeselectObject(); diff --git a/map/framework.hpp b/map/framework.hpp index 644c14fe3a..aaabb0ceee 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -412,15 +412,19 @@ public: void DrawMwmBorder(std::string const & mwmName, std::vector const & regions, bool withVertices); - /// Called to notify UI that object on a map was selected (UI should show Place Page, for example). - using TActivateMapSelectionFn = function; - /// Called to notify UI that object on a map was deselected (UI should hide Place Page). - /// If switchFullScreenMode is true, ui can [optionally] enter or exit full screen mode. - using TDeactivateMapSelectionFn = function; - void SetMapSelectionListeners(TActivateMapSelectionFn const & activator, - TDeactivateMapSelectionFn const & deactivator); + struct PlacePageEvent + { + /// Called to notify UI that object on a map was selected (UI should show Place Page, for example). + using OnOpen = function; + /// Called to notify UI that object on a map was deselected (UI should hide Place Page). + /// If switchFullScreenMode is true, ui can [optionally] enter or exit full screen mode. + using OnClose = function; + using OnUpdate = function; + }; - void ResetLastTapEvent(); + void SetPlacePageListenners(PlacePageEvent::OnOpen const & onOpen, + PlacePageEvent::OnClose const & onClose, + PlacePageEvent::OnUpdate const & onUpdate); void InvalidateRendering(); void EnableDebugRectRendering(bool enabled); @@ -478,8 +482,9 @@ private: int m_minBuildingsTapZoom; - TActivateMapSelectionFn m_activateMapSelectionFn; - TDeactivateMapSelectionFn m_deactivateMapSelectionFn; + PlacePageEvent::OnOpen m_onPlacePageOpen; + PlacePageEvent::OnClose m_onPlacePageClose; + PlacePageEvent::OnUpdate m_onPlacePageUpdate; /// Here we store last selected feature to get its polygons in case of adding organization. mutable FeatureID m_selectedFeature; diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp index 6ab50cd7bd..51242dab29 100644 --- a/qt/draw_widget.cpp +++ b/qt/draw_widget.cpp @@ -58,9 +58,8 @@ DrawWidget::DrawWidget(Framework & framework, bool apiOpenGLES3, std::unique_ptr , m_rubberBand(nullptr) , m_emulatingLocation(false) { - m_framework.SetMapSelectionListeners( - [this](place_page::Info const & info) { ShowPlacePage(info); }, - [](bool /* switchFullScreenMode */) {}); // Empty deactivation listener. + m_framework.SetPlacePageListenners([this](place_page::Info const & info) { ShowPlacePage(info); }, + {} /* onClose */, {} /* onUpdate */); m_framework.GetRoutingManager().SetRouteBuildingListener( [](routing::RouterResultCode, storage::CountriesSet const &) {}); diff --git a/search/search_quality/assessment_tool/main_view.cpp b/search/search_quality/assessment_tool/main_view.cpp index 72baed92dd..57acceefaa 100644 --- a/search/search_quality/assessment_tool/main_view.cpp +++ b/search/search_quality/assessment_tool/main_view.cpp @@ -58,7 +58,7 @@ MainView::MainView(Framework & framework) : m_framework(framework) InitDocks(); InitMenuBar(); - m_framework.SetMapSelectionListeners( + m_framework.SetPlacePageListenners( [this](place_page::Info const & info) { auto const & selectedFeature = info.GetID(); if (!selectedFeature.IsValid()) @@ -79,7 +79,8 @@ MainView::MainView(Framework & framework) : m_framework(framework) FeatureInfoDialog dialog(this /* parent */, mapObject, address, m_sampleLocale); dialog.exec(); }, - [this](bool /* switchFullScreenMode */) { m_selectedFeature = FeatureID(); }); + [this](bool /* switchFullScreenMode */) { m_selectedFeature = FeatureID(); }, + {} /* onUpdate */); } MainView::~MainView()