Review fixes

This commit is contained in:
r.kuznetsov 2015-05-19 13:47:40 +03:00
parent fed6d45081
commit ae291c477e
12 changed files with 55 additions and 56 deletions

View file

@ -65,7 +65,7 @@ void BackendRenderer::AcceptMessage(ref_ptr<Message> message)
{
case Message::UpdateReadManager:
{
ref_ptr<UpdateReadManagerMessage> msg = static_cast<ref_ptr<UpdateReadManagerMessage>>(message);
ref_ptr<UpdateReadManagerMessage> msg = message;
ScreenBase const & screen = msg->GetScreen();
TTilesCollection const & tiles = msg->GetTiles();
m_readManager->UpdateCoverage(screen, tiles);
@ -80,7 +80,7 @@ void BackendRenderer::AcceptMessage(ref_ptr<Message> message)
}
case Message::Resize:
{
ref_ptr<ResizeMessage> msg = static_cast<ref_ptr<ResizeMessage>>(message);
ref_ptr<ResizeMessage> msg = message;
df::Viewport const & v = msg->GetViewport();
m_guiCacher.Resize(v.GetWidth(), v.GetHeight());
RecacheGui(gui::Skin::AllElements);
@ -88,7 +88,7 @@ void BackendRenderer::AcceptMessage(ref_ptr<Message> message)
}
case Message::InvalidateReadManagerRect:
{
ref_ptr<InvalidateReadManagerRectMessage> msg = static_cast<ref_ptr<InvalidateReadManagerRectMessage>>(message);
ref_ptr<InvalidateReadManagerRectMessage> msg = message;
m_readManager->Invalidate(msg->GetTilesForInvalidate());
break;
}
@ -102,13 +102,13 @@ void BackendRenderer::AcceptMessage(ref_ptr<Message> message)
}
case Message::TileReadEnded:
{
ref_ptr<TileReadEndMessage> msg = static_cast<ref_ptr<TileReadEndMessage>>(message);
ref_ptr<TileReadEndMessage> msg = message;
m_batchersPool->ReleaseBatcher(msg->GetKey());
break;
}
case Message::FinishReading:
{
ref_ptr<FinishReadingMessage> msg = static_cast<ref_ptr<FinishReadingMessage>>(message);
ref_ptr<FinishReadingMessage> msg = message;
m_commutator->PostMessage(ThreadsCommutator::RenderThread,
make_unique_dp<FinishReadingMessage>(move(msg->MoveTiles())),
MessagePriority::Normal);
@ -116,7 +116,7 @@ void BackendRenderer::AcceptMessage(ref_ptr<Message> message)
}
case Message::MapShapeReaded:
{
ref_ptr<MapShapeReadedMessage> msg = static_cast<ref_ptr<MapShapeReadedMessage>>(message);
ref_ptr<MapShapeReadedMessage> msg = message;
ref_ptr<dp::Batcher> batcher = m_batchersPool->GetTileBatcher(msg->GetKey());
for (drape_ptr<MapShape> const & shape : msg->GetShapes())
shape->Draw(batcher, m_texMng);
@ -124,7 +124,7 @@ void BackendRenderer::AcceptMessage(ref_ptr<Message> message)
}
case Message::UpdateUserMarkLayer:
{
ref_ptr<UpdateUserMarkLayerMessage> msg = static_cast<ref_ptr<UpdateUserMarkLayerMessage>>(message);
ref_ptr<UpdateUserMarkLayerMessage> msg = message;
TileKey const & key = msg->GetKey();
m_commutator->PostMessage(ThreadsCommutator::RenderThread,
@ -140,19 +140,19 @@ void BackendRenderer::AcceptMessage(ref_ptr<Message> message)
m_batchersPool->ReleaseBatcher(key);
break;
}
case Message::StorageInfoUpdated:
case Message::CountryInfoUpdate:
{
ref_ptr<StorageInfoUpdatedMessage> msg = static_cast<ref_ptr<StorageInfoUpdatedMessage>>(message);
ref_ptr<CountryInfoUpdateMessage> msg = message;
gui::CountryStatusHelper & helper = gui::DrapeGui::Instance().GetCountryStatusHelper();
if (msg->IsCurrentCountry())
{
helper.SetStorageInfo(msg->GetStorageInfo());
helper.SetCountryInfo(msg->GetCountryInfo());
}
else
{
// check if country is current
if (helper.GetCountryIndex() == msg->GetStorageInfo().m_countryIndex)
helper.SetStorageInfo(msg->GetStorageInfo());
if (helper.GetCountryIndex() == msg->GetCountryInfo().m_countryIndex)
helper.SetCountryInfo(msg->GetCountryInfo());
}
break;
}

View file

@ -3,6 +3,7 @@
#include "drape_frontend/message_subclasses.hpp"
#include "drape_frontend/visual_params.hpp"
#include "drape_gui/country_status_helper.hpp"
#include "drape_gui/drape_gui.hpp"
#include "drape/texture_manager.hpp"
@ -168,10 +169,10 @@ void DrapeEngine::ModelViewChangedGuiThread(ScreenBase const & screen)
p.second(screen);
}
void DrapeEngine::SetStorageInfo(gui::StorageInfo const & info, bool isCurrentCountry)
void DrapeEngine::SetCountryInfo(gui::CountryInfo const & info, bool isCurrentCountry)
{
m_threadCommutator->PostMessage(ThreadsCommutator::ResourceUploadThread,
make_unique_dp<StorageInfoUpdatedMessage>(info, isCurrentCountry),
make_unique_dp<CountryInfoUpdateMessage>(info, isCurrentCountry),
MessagePriority::Normal);
}

View file

@ -7,8 +7,6 @@
#include "drape/pointers.hpp"
#include "drape/texture_manager.hpp"
#include "drape_gui/country_status_helper.hpp"
#include "geometry/screenbase.hpp"
#include "base/strings_bundle.hpp"
@ -17,6 +15,7 @@
#include "std/mutex.hpp"
namespace dp { class OGLContextFactory; }
namespace gui { struct CountryInfo; }
namespace df
{
@ -73,7 +72,7 @@ public:
void SetRenderingEnabled(bool const isEnabled);
void SetStorageInfo(gui::StorageInfo const & info, bool isCurrentCountry);
void SetCountryInfo(gui::CountryInfo const & info, bool isCurrentCountry);
private:
void AddUserEvent(UserEvent const & e);

View file

@ -24,7 +24,7 @@ public:
GuiLayerRecached,
GuiRecache,
MyPositionShape,
StorageInfoUpdated,
CountryInfoUpdate,
StopRendering
};

View file

@ -247,20 +247,20 @@ private:
gui::Skin::ElementName m_elements;
};
class StorageInfoUpdatedMessage : public Message
class CountryInfoUpdateMessage : public Message
{
public:
StorageInfoUpdatedMessage(gui::StorageInfo const & info, bool isCurrentCountry)
: m_storageInfo(info)
CountryInfoUpdateMessage(gui::CountryInfo const & info, bool isCurrentCountry)
: m_countryInfo(info)
, m_isCurrentCountry(isCurrentCountry)
{}
Type GetType() const override { return Message::StorageInfoUpdated;}
gui::StorageInfo const & GetStorageInfo() const { return m_storageInfo; }
Type GetType() const override { return Message::CountryInfoUpdate;}
gui::CountryInfo const & GetCountryInfo() const { return m_countryInfo; }
bool IsCurrentCountry() const { return m_isCurrentCountry; }
private:
gui::StorageInfo m_storageInfo;
gui::CountryInfo m_countryInfo;
bool m_isCurrentCountry;
};

View file

@ -68,12 +68,12 @@ CountryStatusHelper::CountryStatusHelper()
{
}
void CountryStatusHelper::SetStorageInfo(StorageInfo const & storageInfo)
void CountryStatusHelper::SetCountryInfo(CountryInfo const & countryInfo)
{
m_storageInfo = storageInfo;
m_countryInfo = countryInfo;
CountryStatusHelper::ECountryState state = CountryStatusHelper::COUNTRY_STATE_LOADED;
switch(m_storageInfo.m_countryStatus)
switch(m_countryInfo.m_countryStatus)
{
case storage::TStatus::ENotDownloaded:
state = CountryStatusHelper::COUNTRY_STATE_EMPTY;
@ -97,13 +97,13 @@ void CountryStatusHelper::SetStorageInfo(StorageInfo const & storageInfo)
void CountryStatusHelper::Clear()
{
m_storageInfo = StorageInfo();
m_countryInfo = CountryInfo();
SetState(COUNTRY_STATE_LOADED);
}
storage::TIndex CountryStatusHelper::GetCountryIndex() const
{
return m_storageInfo.m_countryIndex;
return m_countryInfo.m_countryIndex;
}
void CountryStatusHelper::SetState(ECountryState state)
@ -143,7 +143,7 @@ void CountryStatusHelper::GetProgressInfo(string & alphabet, size_t & maxLength)
string CountryStatusHelper::GetProgressValue() const
{
return strings::to_string(m_storageInfo.m_downloadProgress) + "%";
return strings::to_string(m_countryInfo.m_downloadProgress) + "%";
}
void CountryStatusHelper::FillControlsForState()
@ -172,7 +172,7 @@ void CountryStatusHelper::FillControlsForState()
void CountryStatusHelper::FillControlsForEmpty()
{
ASSERT(m_controls.empty(), ());
m_controls.push_back(MakeLabel(m_storageInfo.m_currentCountryName));
m_controls.push_back(MakeLabel(m_countryInfo.m_currentCountryName));
m_controls.push_back(MakeButton(FormatDownloadMap(), BUTTON_TYPE_MAP));
m_controls.push_back(MakeButton(FormatDownloadMapRouting(), BUTTON_TYPE_MAP_ROUTING));
}
@ -193,7 +193,7 @@ void CountryStatusHelper::FillControlsForLoading()
m_controls.push_back(MakeLabel(firstLabel));
}
m_controls.push_back(MakeLabel(m_storageInfo.m_currentCountryName));
m_controls.push_back(MakeLabel(m_countryInfo.m_currentCountryName));
m_controls.push_back(MakeProgress());
if (secondPos + 1 < text.size())
@ -221,7 +221,7 @@ string CountryStatusHelper::FormatDownloadMap()
{
size_t size;
string units;
FormatMapSize(m_storageInfo.m_mapSize, units, size);
FormatMapSize(m_countryInfo.m_mapSize, units, size);
return strings::Format(GetLocalizedString(DownloadMapButtonID), size, units);
}
@ -229,18 +229,18 @@ string CountryStatusHelper::FormatDownloadMapRouting()
{
size_t size;
string units;
FormatMapSize(m_storageInfo.m_mapSize + m_storageInfo.m_routingSize, units, size);
FormatMapSize(m_countryInfo.m_mapSize + m_countryInfo.m_routingSize, units, size);
return strings::Format(GetLocalizedString(DownloadMapRoutingButtonID), size, units);
}
string CountryStatusHelper::FormatInQueueMap()
{
return strings::Format(GetLocalizedString(InQueueID), m_storageInfo.m_currentCountryName);
return strings::Format(GetLocalizedString(InQueueID), m_countryInfo.m_currentCountryName);
}
string CountryStatusHelper::FormatFailed()
{
return strings::Format(GetLocalizedString(DownloadingFailedID), m_storageInfo.m_currentCountryName);
return strings::Format(GetLocalizedString(DownloadingFailedID), m_countryInfo.m_currentCountryName);
}
string CountryStatusHelper::FormatTryAgain()

View file

@ -13,7 +13,7 @@
namespace gui
{
struct StorageInfo
struct CountryInfo
{
storage::TIndex m_countryIndex = storage::TIndex::INVALID;
storage::TStatus m_countryStatus = storage::TStatus::EUnknown;
@ -59,7 +59,7 @@ public:
CountryStatusHelper();
void SetStorageInfo(StorageInfo const & storageInfo);
void SetCountryInfo(CountryInfo const & countryInfo);
void Clear();
storage::TIndex GetCountryIndex() const;
@ -94,7 +94,7 @@ private:
ECountryState m_state;
buffer_vector<Control, 4> m_controls;
StorageInfo m_storageInfo;
CountryInfo m_countryInfo;
};
} // namespace gui

View file

@ -1,6 +1,6 @@
# Head project for drape develop and debuging
ROOT_DIR = ..
DEPENDENCIES = map drape_frontend drape_gui anim drape indexer storage platform geometry coding base \
DEPENDENCIES = map drape_frontend drape_gui drape indexer storage platform geometry coding base \
freetype expat protobuf jansson fribidi tomcrypt
include($$ROOT_DIR/common.pri)

View file

@ -180,7 +180,7 @@ Framework::Framework()
{
m_activeMaps.reset(new ActiveMapsLayout(*this));
m_globalCntTree = storage::CountryTree(m_activeMaps);
m_storageBridge = make_unique_dp<StorageBridge>(m_activeMaps, bind(&Framework::UpdateStorageInfo, this, _1, _2));
m_storageBridge = make_unique_dp<StorageBridge>(m_activeMaps, bind(&Framework::UpdateCountryInfo, this, _1, false));
// Restore map style before classificator loading
int mapStyle = MapStyleLight;
@ -876,28 +876,28 @@ void Framework::OnUpdateCountryIndex(storage::TIndex const & currentIndex, m2::P
{
storage::TIndex newCountryIndex = GetCountryIndex(m2::PointD(pt));
if (currentIndex != newCountryIndex)
UpdateStorageInfo(newCountryIndex, true /* isCurrentCountry */);
UpdateCountryInfo(newCountryIndex, true /* isCurrentCountry */);
}
void Framework::UpdateStorageInfo(storage::TIndex const & countryIndex, bool isCurrentCountry)
void Framework::UpdateCountryInfo(storage::TIndex const & countryIndex, bool isCurrentCountry)
{
ASSERT(m_activeMaps != nullptr, ());
ASSERT(m_drapeEngine != nullptr, ());
gui::StorageInfo storageInfo;
gui::CountryInfo countryInfo;
storageInfo.m_countryIndex = countryIndex;
storageInfo.m_currentCountryName = m_activeMaps->GetFormatedCountryName(countryIndex);
storageInfo.m_mapSize = m_activeMaps->GetRemoteCountrySizes(countryIndex).first;
storageInfo.m_routingSize = m_activeMaps->GetRemoteCountrySizes(countryIndex).second;
storageInfo.m_countryStatus = m_activeMaps->GetCountryStatus(countryIndex);
if (storageInfo.m_countryStatus == storage::TStatus::EDownloading)
countryInfo.m_countryIndex = countryIndex;
countryInfo.m_currentCountryName = m_activeMaps->GetFormatedCountryName(countryIndex);
countryInfo.m_mapSize = m_activeMaps->GetRemoteCountrySizes(countryIndex).first;
countryInfo.m_routingSize = m_activeMaps->GetRemoteCountrySizes(countryIndex).second;
countryInfo.m_countryStatus = m_activeMaps->GetCountryStatus(countryIndex);
if (countryInfo.m_countryStatus == storage::TStatus::EDownloading)
{
storage::LocalAndRemoteSizeT progress = m_activeMaps->GetDownloadableCountrySize(countryIndex);
storageInfo.m_downloadProgress = progress.first * 100 / progress.second;
countryInfo.m_downloadProgress = progress.first * 100 / progress.second;
}
m_drapeEngine->SetStorageInfo(storageInfo, isCurrentCountry);
m_drapeEngine->SetCountryInfo(countryInfo, isCurrentCountry);
}
void Framework::MemoryWarning()

View file

@ -300,7 +300,7 @@ private:
void OnDownloadRetryCallback(storage::TIndex const & countryIndex);
void OnUpdateCountryIndex(storage::TIndex const & currentIndex, m2::PointF const & pt);
void UpdateStorageInfo(storage::TIndex const & countryIndex, bool isCurrentCountry);
void UpdateCountryInfo(storage::TIndex const & countryIndex, bool isCurrentCountry);
public:
using TSearchRequest = search::QuerySaver::TSearchRequest;

View file

@ -52,7 +52,6 @@ void StorageBridge::ReportChanges(ActiveMapsLayout::TGroup const & group, int po
{
storage::TIndex countryIndex = m_activeMaps->GetCoreIndex(group, position);
// here we can not be sure if the country is current, so let check it later
if (m_handler != nullptr)
m_handler(countryIndex, false /* isCurrentCountry */);
m_handler(countryIndex);
}

View file

@ -10,7 +10,7 @@
class StorageBridge : public storage::ActiveMapsLayout::ActiveMapsListener
{
public:
using TOnChangedHandler = function<void(storage::TIndex const & /*countryIndex*/, bool /*isCurrentCountry*/)>;
using TOnChangedHandler = function<void(storage::TIndex const & /*countryIndex*/)>;
StorageBridge(shared_ptr<storage::ActiveMapsLayout> activeMaps, TOnChangedHandler const & handler);
~StorageBridge() override;