diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index 61f5f3663a..0d21d19042 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -62,6 +62,7 @@ Framework::Framework() : m_lastCompass(0.0) , m_currentMode(location::MODE_UNKNOWN_POSITION) , m_isCurrentModeInitialized(false) + , m_isChoosePositionMode(false) , m_activeUserMark(nullptr) { ASSERT_EQUAL ( g_framework, 0, () ); @@ -121,6 +122,7 @@ bool Framework::CreateDrapeEngine(JNIEnv * env, jobject jSurface, int densityDpi p.m_visualScale = dp::VisualScale(densityDpi); p.m_hasMyPositionState = m_isCurrentModeInitialized; p.m_initialMyPositionState = m_currentMode; + p.m_isChoosePositionMode = m_isChoosePositionMode; ASSERT(!m_guiPositions.empty(), ("GUI elements must be set-up before engine is created")); p.m_widgetsInitInfo = m_guiPositions; @@ -206,6 +208,13 @@ void Framework::Get3dMode(bool & allow3d, bool & allow3dBuildings) m_work.Load3dMode(allow3d, allow3dBuildings); } +void Framework::SetChoosePositionMode(bool enable) +{ + m_isChoosePositionMode = enable; + m_work.BlockTapEvents(enable); + m_work.EnableChoosePositionMode(enable); +} + Storage & Framework::Storage() { return m_work.Storage(); diff --git a/android/jni/com/mapswithme/maps/Framework.hpp b/android/jni/com/mapswithme/maps/Framework.hpp index b75796d8d5..549421c603 100644 --- a/android/jni/com/mapswithme/maps/Framework.hpp +++ b/android/jni/com/mapswithme/maps/Framework.hpp @@ -56,6 +56,8 @@ namespace android location::EMyPositionMode m_currentMode; bool m_isCurrentModeInitialized; + bool m_isChoosePositionMode; + UserMark const * m_activeUserMark; public: @@ -155,6 +157,8 @@ namespace android void Set3dMode(bool allow3d, bool allow3dBuildings); void Get3dMode(bool & allow3d, bool & allow3dBuildings); + void SetChoosePositionMode(bool enable); + void SetupWidget(gui::EWidget widget, float x, float y, dp::Anchor anchor); void ApplyWidgets(); void CleanWidgets(); diff --git a/drape/shaders/shader_index.txt b/drape/shaders/shader_index.txt index 3e6d412bbc..e61169a770 100644 --- a/drape/shaders/shader_index.txt +++ b/drape/shaders/shader_index.txt @@ -8,7 +8,7 @@ LINE_PROGRAM line_vertex_shader.vsh line_fragment_shader.fsh CAP_JOIN_PROGRAM circle_shader.vsh circle_shader.fsh DASHED_LINE_PROGRAM dashed_vertex_shader.vsh dashed_fragment_shader.fsh PATH_SYMBOL_LINE path_symbol_vertex_shader.vsh texturing_fragment_shader.fsh -COMPASS_PROGRAM compass_vertex_shader.vsh texturing_fragment_shader.fsh +TEXTURING_GUI_PROGRAM texturing_gui_vertex_shader.vsh texturing_fragment_shader.fsh RULER_PROGRAM ruler_vertex_shader.vsh texturing_fragment_shader.fsh ACCURACY_PROGRAM position_accuracy3d_shader.vsh texturing_fragment_shader.fsh MY_POSITION_PROGRAM my_position_shader.vsh texturing_fragment_shader.fsh diff --git a/drape/shaders/compass_vertex_shader.vsh b/drape/shaders/texturing_gui_vertex_shader.vsh similarity index 100% rename from drape/shaders/compass_vertex_shader.vsh rename to drape/shaders/texturing_gui_vertex_shader.vsh diff --git a/drape_frontend/backend_renderer.cpp b/drape_frontend/backend_renderer.cpp index 83dd0ef3e5..416eca17f5 100644 --- a/drape_frontend/backend_renderer.cpp +++ b/drape_frontend/backend_renderer.cpp @@ -74,17 +74,25 @@ unique_ptr BackendRenderer::CreateRoutine() return make_unique(*this); } -void BackendRenderer::RecacheGui(gui::TWidgetsInitInfo const & initInfo, gui::TWidgetsSizeInfo & sizeInfo) +void BackendRenderer::RecacheGui(gui::TWidgetsInitInfo const & initInfo, gui::TWidgetsSizeInfo & sizeInfo, + bool needResetOldGui) { drape_ptr layerRenderer = m_guiCacher.RecacheWidgets(initInfo, sizeInfo, m_texMng); - drape_ptr outputMsg = make_unique_dp(move(layerRenderer)); + drape_ptr outputMsg = make_unique_dp(move(layerRenderer), needResetOldGui); m_commutator->PostMessage(ThreadsCommutator::RenderThread, move(outputMsg), MessagePriority::Normal); } void BackendRenderer::RecacheCountryStatus() { drape_ptr layerRenderer = m_guiCacher.RecacheCountryStatus(m_texMng); - drape_ptr outputMsg = make_unique_dp(move(layerRenderer)); + drape_ptr outputMsg = make_unique_dp(move(layerRenderer), false); + m_commutator->PostMessage(ThreadsCommutator::RenderThread, move(outputMsg), MessagePriority::Normal); +} + +void BackendRenderer::RecacheChoosePositionMark() +{ + drape_ptr layerRenderer = m_guiCacher.RecacheChoosePositionMark(m_texMng); + drape_ptr outputMsg = make_unique_dp(move(layerRenderer), false); m_commutator->PostMessage(ThreadsCommutator::RenderThread, move(outputMsg), MessagePriority::Normal); } @@ -124,10 +132,15 @@ void BackendRenderer::AcceptMessage(ref_ptr message) RecacheCountryStatus(); break; } + case Message::ShowChoosePositionMark: + { + RecacheChoosePositionMark(); + break; + } case Message::GuiRecache: { ref_ptr msg = message; - RecacheGui(msg->GetInitInfo(), msg->GetSizeInfoMap()); + RecacheGui(msg->GetInitInfo(), msg->GetSizeInfoMap(), msg->NeedResetOldGui()); break; } case Message::GuiLayerLayout: diff --git a/drape_frontend/backend_renderer.hpp b/drape_frontend/backend_renderer.hpp index 9d31892fdf..5f4eb3f3a1 100644 --- a/drape_frontend/backend_renderer.hpp +++ b/drape_frontend/backend_renderer.hpp @@ -54,8 +54,9 @@ protected: unique_ptr CreateRoutine() override; private: - void RecacheGui(gui::TWidgetsInitInfo const & initInfo, gui::TWidgetsSizeInfo & sizeInfo); + void RecacheGui(gui::TWidgetsInitInfo const & initInfo, gui::TWidgetsSizeInfo & sizeInfo, bool needResetOldGui); void RecacheCountryStatus(); + void RecacheChoosePositionMark(); void RecacheMyPosition(); void AcceptMessage(ref_ptr message) override; diff --git a/drape_frontend/drape_engine.cpp b/drape_frontend/drape_engine.cpp index 1d75e681e6..6b22f19ef7 100644 --- a/drape_frontend/drape_engine.cpp +++ b/drape_frontend/drape_engine.cpp @@ -62,7 +62,8 @@ DrapeEngine::DrapeEngine(Params && params) bind(&DrapeEngine::TapEvent, this, _1), bind(&DrapeEngine::UserPositionChanged, this, _1), bind(&DrapeEngine::MyPositionModeChanged, this, _1), - mode, make_ref(m_requestedTiles), params.m_allow3dBuildings); + mode, make_ref(m_requestedTiles), params.m_allow3dBuildings, + params.m_blockTapEvents); m_frontend = make_unique_dp(frParams); @@ -73,10 +74,10 @@ DrapeEngine::DrapeEngine(Params && params) m_widgetsInfo = move(params.m_info); - GuiRecacheMessage::Blocker blocker; - drape_ptr message(new GuiRecacheMessage(blocker, m_widgetsInfo, m_widgetSizes)); - m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread, move(message), MessagePriority::High); - blocker.Wait(); + RecacheGui(false); + + if (params.m_showChoosePositionMark) + EnableChoosePositionMode(true); ResizeImpl(m_viewport.GetWidth(), m_viewport.GetHeight()); } @@ -197,10 +198,7 @@ void DrapeEngine::UpdateMapStyle() // Recache gui after updating of style. { - GuiRecacheMessage::Blocker blocker; - drape_ptr message(new GuiRecacheMessage(blocker, m_widgetsInfo, m_widgetSizes)); - m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread, move(message), MessagePriority::High); - blocker.Wait(); + RecacheGui(false); m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread, make_unique_dp(m_widgetsLayout), @@ -208,6 +206,16 @@ void DrapeEngine::UpdateMapStyle() } } +void DrapeEngine::RecacheGui(bool needResetOldGui) +{ + GuiRecacheMessage::Blocker blocker; + m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread, + make_unique_dp(blocker, m_widgetsInfo, + m_widgetSizes, needResetOldGui), + MessagePriority::High); + blocker.Wait(); +} + void DrapeEngine::AddUserEvent(UserEvent const & e) { m_frontend->AddUserEvent(e); @@ -464,4 +472,25 @@ void DrapeEngine::ClearGpsTrackPoints() MessagePriority::Normal); } +void DrapeEngine::EnableChoosePositionMode(bool enable) +{ + if (enable) + { + m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread, + make_unique_dp(), + MessagePriority::High); + } + else + { + RecacheGui(true); + } +} + +void DrapeEngine::BlockTapEvents(bool block) +{ + m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread, + make_unique_dp(block), + MessagePriority::Normal); +} + } // namespace df diff --git a/drape_frontend/drape_engine.hpp b/drape_frontend/drape_engine.hpp index 4627cd5baf..3a8a7c8be9 100644 --- a/drape_frontend/drape_engine.hpp +++ b/drape_frontend/drape_engine.hpp @@ -41,7 +41,9 @@ public: double vs, gui::TWidgetsInitInfo && info, pair const & initialMyPositionMode, - bool allow3dBuildings) + bool allow3dBuildings, + bool blockTapEvents, + bool showChoosePositionMark) : m_factory(factory) , m_stringsBundle(stringBundle) , m_viewport(viewport) @@ -50,6 +52,8 @@ public: , m_info(move(info)) , m_initialMyPositionMode(initialMyPositionMode) , m_allow3dBuildings(allow3dBuildings) + , m_blockTapEvents(blockTapEvents) + , m_showChoosePositionMark(showChoosePositionMark) {} ref_ptr m_factory; @@ -60,6 +64,8 @@ public: gui::TWidgetsInitInfo m_info; pair m_initialMyPositionMode; bool m_allow3dBuildings; + bool m_blockTapEvents; + bool m_showChoosePositionMark; }; DrapeEngine(Params && params); @@ -125,6 +131,9 @@ public: void UpdateGpsTrackPoints(vector && toAdd, vector && toRemove); void ClearGpsTrackPoints(); + void EnableChoosePositionMode(bool enable); + void BlockTapEvents(bool block); + private: void AddUserEvent(UserEvent const & e); void ModelViewChanged(ScreenBase const & screen); @@ -135,6 +144,7 @@ private: void UserPositionChanged(m2::PointD const & position); void ResizeImpl(int w, int h); + void RecacheGui(bool needResetOldGui); private: drape_ptr m_frontend; diff --git a/drape_frontend/drape_frontend.pro b/drape_frontend/drape_frontend.pro index afc7359031..fe458d9d73 100755 --- a/drape_frontend/drape_frontend.pro +++ b/drape_frontend/drape_frontend.pro @@ -20,6 +20,7 @@ SOURCES += \ animation/perspective_animation.cpp \ animation/show_hide_animation.cpp \ gui/button.cpp \ + gui/choose_position_mark.cpp \ gui/compass.cpp \ gui/copyright_label.cpp \ gui/country_status.cpp \ @@ -105,6 +106,7 @@ HEADERS += \ animation/show_hide_animation.hpp \ animation/value_mapping.hpp \ gui/button.hpp \ + gui/choose_position_mark.hpp \ gui/compass.hpp \ gui/copyright_label.hpp \ gui/country_status.hpp \ diff --git a/drape_frontend/frontend_renderer.cpp b/drape_frontend/frontend_renderer.cpp index 6b46dd6e39..49b844da90 100755 --- a/drape_frontend/frontend_renderer.cpp +++ b/drape_frontend/frontend_renderer.cpp @@ -119,6 +119,7 @@ FrontendRenderer::FrontendRenderer(Params const & params) , m_enablePerspectiveInNavigation(false) , m_enable3dBuildings(params.m_allow3dBuildings) , m_isIsometry(false) + , m_blockTapEvents(params.m_blockTapEvents) , m_viewport(params.m_viewport) , m_userEventStream(params.m_isCountryLoadedFn) , m_modelViewChangedFn(params.m_modelViewChangedFn) @@ -294,6 +295,8 @@ void FrontendRenderer::AcceptMessage(ref_ptr message) ref_ptr msg = message; drape_ptr renderer = move(msg->AcceptRenderer()); renderer->Build(make_ref(m_gpuProgramManager)); + if (msg->NeedResetOldGui()) + m_guiRenderer.release(); if (m_guiRenderer == nullptr) m_guiRenderer = move(renderer); else @@ -638,6 +641,13 @@ void FrontendRenderer::AcceptMessage(ref_ptr message) break; } + case Message::BlockTapEvents: + { + ref_ptr msg = message; + m_blockTapEvents = msg->NeedBlock(); + break; + } + case Message::Invalidate: { // Do nothing here, new frame will be rendered because of this message processing. @@ -1158,6 +1168,9 @@ void FrontendRenderer::ResolveZoomLevel(ScreenBase const & screen) void FrontendRenderer::OnTap(m2::PointD const & pt, bool isLongTap) { + if (m_blockTapEvents) + return; + double halfSize = VisualParams::Instance().GetTouchRectRadius(); m2::PointD sizePoint(halfSize, halfSize); m2::RectD selectRect(pt - sizePoint, pt + sizePoint); diff --git a/drape_frontend/frontend_renderer.hpp b/drape_frontend/frontend_renderer.hpp index 899ccab2cc..aabfb46d5f 100755 --- a/drape_frontend/frontend_renderer.hpp +++ b/drape_frontend/frontend_renderer.hpp @@ -81,7 +81,8 @@ public: location::TMyPositionModeChanged myPositionModeCallback, location::EMyPositionMode initMode, ref_ptr requestedTiles, - bool allow3dBuildings) + bool allow3dBuildings, + bool blockTapEvents) : BaseRenderer::Params(commutator, factory, texMng) , m_viewport(viewport) , m_modelViewChangedFn(modelViewChangedFn) @@ -92,6 +93,7 @@ public: , m_initMyPositionMode(initMode) , m_requestedTiles(requestedTiles) , m_allow3dBuildings(allow3dBuildings) + , m_blockTapEvents(blockTapEvents) {} Viewport m_viewport; @@ -103,6 +105,7 @@ public: location::EMyPositionMode m_initMyPositionMode; ref_ptr m_requestedTiles; bool m_allow3dBuildings; + bool m_blockTapEvents; }; FrontendRenderer(Params const & params); @@ -264,6 +267,8 @@ private: bool m_enable3dBuildings; bool m_isIsometry; + bool m_blockTapEvents; + Viewport m_viewport; UserEventStream m_userEventStream; TModelViewChanged m_modelViewChangedFn; diff --git a/drape_frontend/gui/choose_position_mark.cpp b/drape_frontend/gui/choose_position_mark.cpp new file mode 100644 index 0000000000..3f33aa6239 --- /dev/null +++ b/drape_frontend/gui/choose_position_mark.cpp @@ -0,0 +1,98 @@ +#include "choose_position_mark.hpp" +#include "drape_gui.hpp" + +#include "drape/shader_def.hpp" + +#include "drape/utils/vertex_decl.hpp" + +#include "std/bind.hpp" + +namespace gui +{ + +namespace +{ + +struct ChoosePositionMarkVertex +{ + ChoosePositionMarkVertex(glsl::vec2 const & position, glsl::vec2 const & texCoord) + : m_position(position) + , m_texCoord(texCoord) + {} + + glsl::vec2 m_position; + glsl::vec2 m_texCoord; +}; + +class ChoosePositionMarkHandle : public Handle +{ + using TBase = Handle; + +public: + ChoosePositionMarkHandle(uint32_t id, m2::PointF const & pivot, m2::PointF const & size) + : Handle(id, dp::Center, pivot, size) + { + SetIsVisible(true); + } + + bool Update(ScreenBase const & screen) override + { + SetPivot(glsl::ToVec2(m2::PointF(screen.PixelRect().Center()))); + return TBase::Update(screen); + } +}; + +} + +drape_ptr ChoosePositionMark::Draw(ref_ptr tex) const +{ + dp::TextureManager::SymbolRegion region; + tex->GetSymbolRegion("cross_geoposition", region); + glsl::vec2 halfSize = glsl::ToVec2(m2::PointD(region.GetPixelSize()) * 0.5); + m2::RectF texRect = region.GetTexRect(); + + ASSERT_EQUAL(m_position.m_anchor, dp::Center, ()); + ChoosePositionMarkVertex vertexes[] = + { + ChoosePositionMarkVertex(glsl::vec2(-halfSize.x, halfSize.y), glsl::ToVec2(texRect.LeftTop())), + ChoosePositionMarkVertex(glsl::vec2(-halfSize.x, -halfSize.y), glsl::ToVec2(texRect.LeftBottom())), + ChoosePositionMarkVertex(glsl::vec2(halfSize.x, halfSize.y), glsl::ToVec2(texRect.RightTop())), + ChoosePositionMarkVertex(glsl::vec2(halfSize.x, -halfSize.y), glsl::ToVec2(texRect.RightBottom())) + }; + + dp::GLState state(gpu::TEXTURING_GUI_PROGRAM, dp::GLState::Gui); + state.SetColorTexture(region.GetTexture()); + + dp::AttributeProvider provider(1 /*streamCount*/, 4 /*vertexCount*/); + dp::BindingInfo info(2 /*count*/); + + dp::BindingDecl & posDecl = info.GetBindingDecl(0); + posDecl.m_attributeName = "a_position"; + posDecl.m_componentCount = 2; + posDecl.m_componentType = gl_const::GLFloatType; + posDecl.m_offset = 0; + posDecl.m_stride = sizeof(ChoosePositionMarkVertex); + + dp::BindingDecl & texDecl = info.GetBindingDecl(1); + texDecl.m_attributeName = "a_colorTexCoords"; + texDecl.m_componentCount = 2; + texDecl.m_componentType = gl_const::GLFloatType; + texDecl.m_offset = sizeof(glsl::vec2); + texDecl.m_stride = posDecl.m_stride; + + provider.InitStream(0, info, make_ref(&vertexes)); + + m2::PointF const markSize = region.GetPixelSize(); + drape_ptr handle = make_unique_dp(EGuiHandle::GuiHandleChoosePositionMark, + m_position.m_pixelPivot, + markSize); + + drape_ptr renderer = make_unique_dp(); + dp::Batcher batcher(dp::Batcher::IndexPerQuad, dp::Batcher::VertexPerQuad); + dp::SessionGuard guard(batcher, bind(&ShapeRenderer::AddShape, renderer.get(), _1, _2)); + batcher.InsertTriangleStrip(state, make_ref(&provider), move(handle)); + + return renderer; +} + +} // namespace gui diff --git a/drape_frontend/gui/choose_position_mark.hpp b/drape_frontend/gui/choose_position_mark.hpp new file mode 100644 index 0000000000..6696df7df0 --- /dev/null +++ b/drape_frontend/gui/choose_position_mark.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include "shape.hpp" + +namespace gui +{ + +class ChoosePositionMark : public Shape +{ +public: + ChoosePositionMark(gui::Position const & position) + : Shape(position) + {} + + drape_ptr Draw(ref_ptr tex) const; +}; + +} // namespace gui diff --git a/drape_frontend/gui/compass.cpp b/drape_frontend/gui/compass.cpp index 8accaae6ee..2ff4222656 100644 --- a/drape_frontend/gui/compass.cpp +++ b/drape_frontend/gui/compass.cpp @@ -104,7 +104,7 @@ drape_ptr Compass::Draw(m2::PointF & compassSize, ref_ptr LayerCacher::RecacheCountryStatus(ref_ptr renderer = make_unique_dp(); - CountryStatus countryStatus = CountryStatus(Position(surfSize * 0.5, dp::Center)); + CountryStatus countryStatus = CountryStatus(Position(surfSize * 0.5f, dp::Center)); CountryStatus::TButtonHandlers handlers; RegisterButtonHandler(handlers, CountryStatusHelper::BUTTON_TYPE_MAP); @@ -218,6 +219,21 @@ drape_ptr LayerCacher::RecacheCountryStatus(ref_ptr LayerCacher::RecacheChoosePositionMark(ref_ptr textures) +{ + m2::PointF surfSize = DrapeGui::Instance().GetSurfaceSize(); + drape_ptr renderer = make_unique_dp(); + + ChoosePositionMark positionMark = ChoosePositionMark(Position(surfSize * 0.5f, dp::Center)); + renderer->AddShapeRenderer(WIDGET_CHOOSE_POSITION_MARK, positionMark.Draw(textures)); + + // Flush gui geometry. + GLFunctions::glFlush(); + + return renderer; +} + + m2::PointF LayerCacher::CacheCompass(Position const & position, ref_ptr renderer, ref_ptr textures) { diff --git a/drape_frontend/gui/layer_render.hpp b/drape_frontend/gui/layer_render.hpp index 4126f77c2a..b3703be9b7 100644 --- a/drape_frontend/gui/layer_render.hpp +++ b/drape_frontend/gui/layer_render.hpp @@ -55,7 +55,8 @@ public: drape_ptr RecacheWidgets(TWidgetsInitInfo const & initInfo, TWidgetsSizeInfo & sizeInfo, ref_ptr textures); - drape_ptr RecacheCountryStatus(ref_ptr texMng); + drape_ptr RecacheCountryStatus(ref_ptr textures); + drape_ptr RecacheChoosePositionMark(ref_ptr textures); private: m2::PointF CacheCompass(Position const & position, ref_ptr renderer, ref_ptr textures); diff --git a/drape_frontend/gui/skin.hpp b/drape_frontend/gui/skin.hpp index b756863c95..60bf6750f4 100644 --- a/drape_frontend/gui/skin.hpp +++ b/drape_frontend/gui/skin.hpp @@ -16,7 +16,8 @@ enum EWidget WIDGET_COPYRIGHT = 0x4, WIDGET_SCALE_LABEL = 0x8, /// WIDGET_COUNTRY_STATUS - controlled by rendering kernel. Don't use it in platform code - WIDGET_COUNTRY_STATUS = 0x8000 + WIDGET_COUNTRY_STATUS = 0x8000, + WIDGET_CHOOSE_POSITION_MARK = 0x8001 }; enum EGuiHandle @@ -33,7 +34,8 @@ enum EGuiHandle GuiHandleRetryButton, GuiHandleRetryButtonLabel, GuiHandleCancelButton, - GuiHandleCancelButtonLabel + GuiHandleCancelButtonLabel, + GuiHandleChoosePositionMark }; struct Position diff --git a/drape_frontend/message.hpp b/drape_frontend/message.hpp index 7f67ff4a4d..8f3e459802 100644 --- a/drape_frontend/message.hpp +++ b/drape_frontend/message.hpp @@ -52,7 +52,9 @@ public: CacheGpsTrackPoints, FlushGpsTrackPoints, UpdateGpsTrackPoints, - ClearGpsTrackPoints + ClearGpsTrackPoints, + ShowChoosePositionMark, + BlockTapEvents }; virtual ~Message() {} diff --git a/drape_frontend/message_subclasses.hpp b/drape_frontend/message_subclasses.hpp index 336bef859f..9ceaaa3a89 100644 --- a/drape_frontend/message_subclasses.hpp +++ b/drape_frontend/message_subclasses.hpp @@ -258,34 +258,42 @@ private: class GuiLayerRecachedMessage : public Message { public: - GuiLayerRecachedMessage(drape_ptr && renderer) - : m_renderer(move(renderer)) {} + GuiLayerRecachedMessage(drape_ptr && renderer, bool needResetOldGui) + : m_renderer(move(renderer)) + , m_needResetOldGui(needResetOldGui) + {} Type GetType() const override { return Message::GuiLayerRecached; } drape_ptr && AcceptRenderer() { return move(m_renderer); } + bool NeedResetOldGui() const { return m_needResetOldGui; } private: drape_ptr m_renderer; + bool const m_needResetOldGui; }; class GuiRecacheMessage : public BaseBlockingMessage { public: - GuiRecacheMessage(Blocker & blocker, gui::TWidgetsInitInfo const & initInfo, gui::TWidgetsSizeInfo & resultInfo) + GuiRecacheMessage(Blocker & blocker, gui::TWidgetsInitInfo const & initInfo, gui::TWidgetsSizeInfo & resultInfo, + bool needResetOldGui) : BaseBlockingMessage(blocker) , m_initInfo(initInfo) , m_sizeInfo(resultInfo) - { - } + , m_needResetOldGui(needResetOldGui) + {} Type GetType() const override { return Message::GuiRecache;} + gui::TWidgetsInitInfo const & GetInitInfo() const { return m_initInfo; } gui::TWidgetsSizeInfo & GetSizeInfoMap() const { return m_sizeInfo; } + bool NeedResetOldGui() const { return m_needResetOldGui; } private: gui::TWidgetsInitInfo m_initInfo; gui::TWidgetsSizeInfo & m_sizeInfo; + bool const m_needResetOldGui; }; class GuiLayerLayoutMessage : public Message @@ -331,8 +339,30 @@ private: class CountryStatusRecacheMessage : public Message { public: - CountryStatusRecacheMessage() {} - Type GetType() const override { return Message::CountryStatusRecache ;} + CountryStatusRecacheMessage() = default; + Type GetType() const override { return Message::CountryStatusRecache; } +}; + +class ShowChoosePositionMarkMessage : public Message +{ +public: + ShowChoosePositionMarkMessage() = default; + Type GetType() const override { return Message::ShowChoosePositionMark; } +}; + +class BlockTapEventsMessage : public Message +{ +public: + BlockTapEventsMessage(bool block) + : m_needBlock(block) + {} + + Type GetType() const override { return Message::BlockTapEvents; } + + bool NeedBlock() const { return m_needBlock; } + +private: + bool const m_needBlock; }; class MyPositionShapeMessage : public Message diff --git a/map/framework.cpp b/map/framework.cpp index 652b90af5f..309dde5fb6 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -1463,7 +1463,7 @@ void Framework::CreateDrapeEngine(ref_ptr contextFactory, params.m_visualScale, move(params.m_widgetsInitInfo), make_pair(params.m_initialMyPositionState, params.m_hasMyPositionState), - allow3dBuildings); + allow3dBuildings, params.m_isChoosePositionMode, params.m_isChoosePositionMode); m_drapeEngine = make_unique_dp(move(p)); AddViewportListener([this](ScreenBase const & screen) @@ -2376,6 +2376,16 @@ void Framework::Load3dMode(bool & allow3d, bool & allow3dBuildings) allow3dBuildings = true; } +void Framework::EnableChoosePositionMode(bool enable) +{ + CallDrapeFunction(bind(&df::DrapeEngine::EnableChoosePositionMode, _1, enable)); +} + +void Framework::BlockTapEvents(bool block) +{ + CallDrapeFunction(bind(&df::DrapeEngine::BlockTapEvents, _1, block)); +} + namespace feature { string GetPrintableTypes(FeatureType const & ft) diff --git a/map/framework.hpp b/map/framework.hpp index fc85b35cd7..dbf865237a 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -286,6 +286,9 @@ public: void InvalidateRendering(); + void EnableChoosePositionMode(bool enable); + void BlockTapEvents(bool block); + private: /// UI callback is called when tap event is "restored" after Drape engine restart. void SimulateLastTapEventIfNeeded(); @@ -325,6 +328,8 @@ public: bool m_hasMyPositionState = false; location::EMyPositionMode m_initialMyPositionState = location::MODE_UNKNOWN_POSITION; + + bool m_isChoosePositionMode = false; }; void CreateDrapeEngine(ref_ptr contextFactory, DrapeCreationParams && params); diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp index cfb77e7b44..cdd00dca11 100644 --- a/qt/draw_widget.cpp +++ b/qt/draw_widget.cpp @@ -172,6 +172,18 @@ void DrawWidget::SliderReleased() m_enableScaleUpdate = true; } +void DrawWidget::ChoosePositionModeEnable() +{ + m_framework->BlockTapEvents(true); + m_framework->EnableChoosePositionMode(true); +} + +void DrawWidget::ChoosePositionModeDisable() +{ + m_framework->EnableChoosePositionMode(false); + m_framework->BlockTapEvents(false); +} + void DrawWidget::CreateEngine() { Framework::DrapeCreationParams p; diff --git a/qt/draw_widget.hpp b/qt/draw_widget.hpp index 55183bbcc6..1e250161ed 100644 --- a/qt/draw_widget.hpp +++ b/qt/draw_widget.hpp @@ -42,6 +42,8 @@ namespace qt void SliderPressed(); void SliderReleased(); + void ChoosePositionModeEnable(); + void ChoosePositionModeDisable(); public: DrawWidget(QWidget * parent); ~DrawWidget(); diff --git a/qt/mainwindow.cpp b/qt/mainwindow.cpp index 2b4e234e9a..fef22c2417 100644 --- a/qt/mainwindow.cpp +++ b/qt/mainwindow.cpp @@ -235,7 +235,9 @@ void MainWindow::CreateNavigationBar() { Qt::Key_Minus, SLOT(ScaleMinus()) }, { Qt::ALT + Qt::Key_Equal, SLOT(ScalePlusLight()) }, { Qt::ALT + Qt::Key_Minus, SLOT(ScaleMinusLight()) }, - { Qt::Key_A, SLOT(ShowAll()) } + { Qt::Key_A, SLOT(ShowAll()) }, + { Qt::Key_N, SLOT(ChoosePositionModeEnable()) }, + { Qt::Key_Escape, SLOT(ChoosePositionModeDisable()) } }; for (size_t i = 0; i < ARRAY_SIZE(arr); ++i)