[new downloader] Fix problem with hiding download dialog on high scales

This commit is contained in:
Sergey Yershov 2016-03-10 15:04:24 +03:00
parent abca53c99c
commit 4dc5610cd4
2 changed files with 26 additions and 27 deletions

View file

@ -943,34 +943,34 @@ void Framework::ClearAllCaches()
m_searchEngine->ClearCaches();
}
void Framework::OnCheckUpdateCurrentCountry(m2::PointF const & pt, int zoomLevel)
{
if (zoomLevel <= scales::GetUpperWorldScale())
m_deferredCountryUpdate.Drop();
else
m_deferredCountryUpdate.RestartWith([this, pt, zoomLevel]
{
OnUpdateCurrentCountry(pt, zoomLevel);
});
}
void Framework::OnUpdateCurrentCountry(m2::PointF const & pt, int zoomLevel)
{
if (zoomLevel <= scales::GetUpperWorldScale())
return;
storage::TCountryId newCountryId = m_infoGetter->GetRegionCountryId(m2::PointD(pt));
if (newCountryId == m_lastReportedCountry)
return;
m_lastReportedCountry = newCountryId;
GetPlatform().RunOnGuiThread([this, newCountryId]()
auto action = [this](TCountryId const &countryId)
{
if (m_currentCountryChanged != nullptr)
m_currentCountryChanged(newCountryId);
});
if (countryId == m_lastReportedCountry)
return;
m_lastReportedCountry = countryId;
auto guiCallback = [this, countryId]
{
if (m_currentCountryChanged != nullptr)
m_currentCountryChanged(countryId);
};
GetPlatform().RunOnGuiThread(guiCallback);
};
if (zoomLevel <= scales::GetUpperWorldScale())
{
m_deferredCountryUpdate.Drop();
action(kInvalidCountryId);
}
else
{
m_deferredCountryUpdate.RestartWith([this, pt, action]
{
storage::TCountryId newCountryId = m_infoGetter->GetRegionCountryId(m2::PointD(pt));
action(newCountryId);
});
}
}
void Framework::SetCurrentCountryChangedListener(TCurrentCountryChanged const & listener)
@ -1364,7 +1364,7 @@ void Framework::CreateDrapeEngine(ref_ptr<dp::OGLContextFactory> contextFactory,
auto isCountryLoadedFn = bind(&Framework::IsCountryLoaded, this, _1);
auto isCountryLoadedByNameFn = bind(&Framework::IsCountryLoadedByName, this, _1);
auto updateCurrentCountryFn = bind(&Framework::OnCheckUpdateCurrentCountry, this, _1, _2);
auto updateCurrentCountryFn = bind(&Framework::OnUpdateCurrentCountry, this, _1, _2);
bool allow3d;
bool allow3dBuildings;

View file

@ -359,7 +359,6 @@ private:
void FillSearchResultsMarks(search::Results const & results);
void OnCheckUpdateCurrentCountry(m2::PointF const & pt, int zoomLevel);
void OnUpdateCurrentCountry(m2::PointF const & pt, int zoomLevel);
storage::TCountryId m_lastReportedCountry;