[drape] add GetCurrentZoom()

- add to the drape_engine and framework `GetCurrentZoom`
- make GetCurrentZoom public in the frontend_renderer

Signed-off-by: Kiryl Kaveryn <kirylkaveryn@gmail.com>
This commit is contained in:
Kiryl Kaveryn 2024-07-06 15:39:28 +04:00 committed by Roman Tsisyk
parent edef4d2e7f
commit 37b493e503
6 changed files with 23 additions and 6 deletions

View file

@ -166,6 +166,11 @@ void DrapeEngine::SetVisibleViewport(m2::RectD const & rect) const
MessagePriority::Normal);
}
int DrapeEngine::GetCurrentZoomLevel() const
{
return m_frontend->GetCurrentZoom();
}
void DrapeEngine::Invalidate()
{
m_threadCommutator->PostMessage(ThreadsCommutator::RenderThread,

View file

@ -119,6 +119,8 @@ public:
void SetVisibleViewport(m2::RectD const & rect) const;
int GetCurrentZoomLevel() const;
void AddTouchEvent(TouchEvent const & event);
void Scale(double factor, m2::PointD const & pxPoint, bool isAnim);
void Move(double factorX, double factorY, bool isAnim);

View file

@ -2524,6 +2524,12 @@ void FrontendRenderer::ChangeModelView(double autoScale, m2::PointD const & user
AddUserEvent(make_unique_dp<FollowAndRotateEvent>(userPos, pxZero, azimuth, autoScale, parallelAnimCreator));
}
int FrontendRenderer::GetCurrentZoom() const
{
ASSERT(IsValidCurrentZoom(), ());
return m_currentZoomLevel;
}
void FrontendRenderer::OnEnterBackground()
{
m_myPositionController->OnEnterBackground();

View file

@ -145,6 +145,7 @@ public:
drape_ptr<ScenarioManager> const & GetScenarioManager() const { return m_scenarioManager; }
location::EMyPositionMode GetMyPositionMode() const { return m_myPositionController->GetCurrentMode(); }
int GetCurrentZoom() const;
void OnEnterBackground();
@ -351,12 +352,6 @@ private:
return m_currentZoomLevel >= 0;
}
int GetCurrentZoom() const
{
ASSERT(IsValidCurrentZoom(), ());
return m_currentZoomLevel;
}
int m_currentZoomLevel = -1;
ref_ptr<RequestedTiles> m_requestedTiles;

View file

@ -979,6 +979,13 @@ void Framework::SetVisibleViewport(m2::RectD const & rect)
m_drapeEngine->SetVisibleViewport(rect);
}
int Framework::GetCurrentZoomLevel() const
{
if (m_drapeEngine == nullptr)
return scales::GetUpperComfortScale();
return m_drapeEngine->GetCurrentZoomLevel();
}
void Framework::ShowRect(m2::RectD const & rect, int maxScale, bool animation, bool useVisibleViewport)
{
if (m_drapeEngine == nullptr)

View file

@ -505,6 +505,8 @@ public:
m2::RectD GetCurrentViewport() const;
void SetVisibleViewport(m2::RectD const & rect);
int GetCurrentZoomLevel() const;
/// - Check minimal visible scale according to downloaded countries.
void ShowRect(m2::RectD const & rect, int maxScale = -1, bool animation = true,
bool useVisibleViewport = false);