forked from organicmaps/organicmaps
Transit mark realization.
This commit is contained in:
parent
cb0cd2e5a1
commit
2fc02876b4
12 changed files with 130 additions and 5 deletions
|
@ -241,6 +241,7 @@ void DrapeEngine::UpdateUserMarksGroup(MarkGroupID groupId, UserMarksProvider *
|
|||
renderInfo->m_pixelOffset = mark->GetPixelOffset();
|
||||
renderInfo->m_symbolName = mark->GetSymbolName();
|
||||
renderInfo->m_titleDecl = mark->GetTitleDecl();
|
||||
renderInfo->m_symbolSizes = mark->GetSymbolSizes();
|
||||
renderInfo->m_hasSymbolPriority = mark->HasSymbolPriority();
|
||||
renderInfo->m_hasTitlePriority = mark->HasTitlePriority();
|
||||
renderInfo->m_priority = mark->GetPriority();
|
||||
|
|
|
@ -1201,6 +1201,7 @@ void FrontendRenderer::RenderScene(ScreenBase const & modelView)
|
|||
{
|
||||
StencilWriterGuard guard(make_ref(m_postprocessRenderer));
|
||||
RenderUserMarksLayer(modelView, RenderState::UserMarkLayer);
|
||||
RenderUserMarksLayer(modelView, RenderState::TransitMarkLayer);
|
||||
RenderUserMarksLayer(modelView, RenderState::RoutingMarkLayer);
|
||||
}
|
||||
|
||||
|
@ -1324,6 +1325,7 @@ void FrontendRenderer::BuildOverlayTree(ScreenBase const & modelView)
|
|||
static std::vector<RenderState::DepthLayer> layers = {RenderState::OverlayLayer,
|
||||
RenderState::LocalAdsMarkLayer,
|
||||
RenderState::NavigationLayer,
|
||||
RenderState::TransitMarkLayer,
|
||||
RenderState::RoutingMarkLayer};
|
||||
BeginUpdateOverlayTree(modelView);
|
||||
for (auto const & layerId : layers)
|
||||
|
|
|
@ -164,6 +164,7 @@ bool RenderGroup::IsUserMark() const
|
|||
auto const depthLayer = GetDepthLayer(m_state);
|
||||
return depthLayer == RenderState::UserLineLayer ||
|
||||
depthLayer == RenderState::UserMarkLayer ||
|
||||
depthLayer == RenderState::TransitMarkLayer ||
|
||||
depthLayer == RenderState::RoutingMarkLayer ||
|
||||
depthLayer == RenderState::LocalAdsMarkLayer;
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ public:
|
|||
LocalAdsMarkLayer,
|
||||
UserMarkLayer,
|
||||
NavigationLayer,
|
||||
TransitMarkLayer,
|
||||
RoutingMarkLayer,
|
||||
GuiLayer,
|
||||
LayersCount
|
||||
|
|
|
@ -130,7 +130,7 @@ void CacheUserMarks(TileKey const & tileKey, ref_ptr<dp::TextureManager> texture
|
|||
PoiSymbolShape(renderInfo.m_pivot, params, tileKey,
|
||||
0 /* textIndex */).Draw(&batcher, textures);
|
||||
}
|
||||
else
|
||||
else if (!renderInfo.m_symbolName.empty())
|
||||
{
|
||||
buffer.reserve(vertexCount);
|
||||
|
||||
|
@ -180,9 +180,16 @@ void CacheUserMarks(TileKey const & tileKey, ref_ptr<dp::TextureManager> texture
|
|||
params.m_specialPriority = renderInfo.m_priority;
|
||||
}
|
||||
|
||||
dp::TextureManager::SymbolRegion region;
|
||||
textures->GetSymbolRegion(renderInfo.m_symbolName, region);
|
||||
m2::PointF const symbolSize = region.GetPixelSize();
|
||||
m2::PointF symbolSize;
|
||||
if (renderInfo.m_symbolSizes != nullptr)
|
||||
{
|
||||
symbolSize = renderInfo.m_symbolSizes->at(static_cast<size_t>(tileKey.m_zoomLevel)) * vs;
|
||||
}
|
||||
else
|
||||
{
|
||||
textures->GetSymbolRegion(renderInfo.m_symbolName, region);
|
||||
symbolSize = region.GetPixelSize();
|
||||
}
|
||||
|
||||
TextShape(renderInfo.m_pivot, params, tileKey, renderInfo.m_hasSymbolPriority /* hasPOI */,
|
||||
symbolSize, renderInfo.m_anchor, 0 /* textIndex */).Draw(&batcher, textures);
|
||||
|
|
|
@ -20,6 +20,7 @@ struct UserMarkRenderParams
|
|||
m2::PointD m_pixelOffset = m2::PointD(0.0, 0.0);
|
||||
std::string m_symbolName;
|
||||
dp::Anchor m_anchor = dp::Center;
|
||||
drape_ptr<std::vector<m2::PointF>> m_symbolSizes;
|
||||
drape_ptr<dp::TitleDecl> m_titleDecl;
|
||||
bool m_hasSymbolPriority = false;
|
||||
bool m_hasTitlePriority = false;
|
||||
|
|
|
@ -54,6 +54,7 @@ public:
|
|||
virtual RenderState::DepthLayer GetDepthLayer() const = 0;
|
||||
virtual bool IsVisible() const = 0;
|
||||
virtual drape_ptr<dp::TitleDecl> GetTitleDecl() const = 0;
|
||||
virtual drape_ptr<std::vector<m2::PointF>> GetSymbolSizes() const = 0;
|
||||
virtual uint16_t GetPriority() const = 0;
|
||||
virtual bool HasSymbolPriority() const = 0;
|
||||
virtual bool HasTitlePriority() const = 0;
|
||||
|
|
|
@ -38,6 +38,7 @@ using ApiUserMarkContainer = SpecifiedUserMarkContainer<ApiMarkPoint, UserMark::
|
|||
using DebugUserMarkContainer = SpecifiedUserMarkContainer<DebugMarkPoint, UserMark::Type::DEBUG_MARK>;
|
||||
using RouteUserMarkContainer = SpecifiedUserMarkContainer<RouteMarkPoint, UserMark::Type::ROUTING>;
|
||||
using LocalAdsMarkContainer = SpecifiedUserMarkContainer<LocalAdsMark, UserMark::Type::LOCAL_ADS>;
|
||||
using TransitMarkContainer = SpecifiedUserMarkContainer<TransitMark, UserMark::Type::TRANSIT>;
|
||||
using StaticUserMarkContainer = SpecifiedUserMarkContainer<SearchMarkPoint, UserMark::Type::STATIC>;
|
||||
|
||||
// Returns extension with a dot in a lower case.
|
||||
|
@ -69,12 +70,13 @@ BookmarkManager::BookmarkManager(GetStringsBundleFn && getStringsBundleFn)
|
|||
{
|
||||
ASSERT(m_getStringsBundle != nullptr, ());
|
||||
|
||||
m_userMarkLayers.reserve(6);
|
||||
m_userMarkLayers.reserve(7);
|
||||
m_userMarkLayers.emplace_back(my::make_unique<SearchUserMarkContainer>());
|
||||
m_userMarkLayers.emplace_back(my::make_unique<ApiUserMarkContainer>());
|
||||
m_userMarkLayers.emplace_back(my::make_unique<DebugUserMarkContainer>());
|
||||
m_userMarkLayers.emplace_back(my::make_unique<RouteUserMarkContainer>());
|
||||
m_userMarkLayers.emplace_back(my::make_unique<LocalAdsMarkContainer>());
|
||||
m_userMarkLayers.emplace_back(my::make_unique<TransitMarkContainer>());
|
||||
|
||||
auto staticMarksContainer = my::make_unique<StaticUserMarkContainer>();
|
||||
m_selectionMark = my::make_unique<StaticMarkPoint>(staticMarksContainer.get());
|
||||
|
|
|
@ -11,9 +11,14 @@ static std::string const kRouteMarkPrimaryTextOutline = "RouteMarkPrimaryTextOut
|
|||
static std::string const kRouteMarkSecondaryText = "RouteMarkSecondaryText";
|
||||
static std::string const kRouteMarkSecondaryTextOutline = "RouteMarkSecondaryTextOutline";
|
||||
|
||||
// TODO(@darina) Use separate colors.
|
||||
static std::string const kTransitMarkText = "RouteMarkPrimaryText";
|
||||
static std::string const kTransitMarkTextOutline = "RouteMarkPrimaryTextOutline";
|
||||
|
||||
float const kRouteMarkPrimaryTextSize = 11.0f;
|
||||
float const kRouteMarkSecondaryTextSize = 10.0f;
|
||||
float const kRouteMarkSecondaryOffsetY = 2.0f;
|
||||
float const kTransitMarkTextSize = 13.0f;
|
||||
} // namespace
|
||||
|
||||
RouteMarkPoint::RouteMarkPoint(m2::PointD const & ptOrg, UserMarkContainer * container)
|
||||
|
@ -367,3 +372,70 @@ void RoutePointsLayout::NotifyChanges()
|
|||
{
|
||||
m_routeMarks.NotifyChanges();
|
||||
}
|
||||
|
||||
TransitMark::TransitMark(m2::PointD const & ptOrg, UserMarkContainer * container)
|
||||
: UserMark(ptOrg, container)
|
||||
{
|
||||
m_titleDecl.m_anchor = dp::Center;
|
||||
m_titleDecl.m_primaryTextFont.m_color = df::GetColorConstant(kTransitMarkText);
|
||||
m_titleDecl.m_primaryTextFont.m_outlineColor = df::GetColorConstant(kTransitMarkTextOutline);
|
||||
m_titleDecl.m_primaryTextFont.m_size = kTransitMarkTextSize;
|
||||
m_titleDecl.m_secondaryTextFont.m_color = df::GetColorConstant(kTransitMarkText);
|
||||
m_titleDecl.m_secondaryTextFont.m_outlineColor = df::GetColorConstant(kTransitMarkTextOutline);
|
||||
m_titleDecl.m_secondaryTextFont.m_size = kTransitMarkTextSize;
|
||||
}
|
||||
|
||||
void TransitMark::SetMinZoom(int minZoom)
|
||||
{
|
||||
SetDirty();
|
||||
m_minZoom = minZoom;
|
||||
}
|
||||
|
||||
void TransitMark::SetSymbolSizes(std::vector<m2::PointF> const & symbolSizes)
|
||||
{
|
||||
SetDirty();
|
||||
m_symbolSizes = symbolSizes;
|
||||
}
|
||||
|
||||
void TransitMark::SetPrimaryText(std::string const & primary)
|
||||
{
|
||||
SetDirty();
|
||||
m_titleDecl.m_primaryText = primary;
|
||||
}
|
||||
|
||||
void TransitMark::SetSecondaryText(std::string const & secondary)
|
||||
{
|
||||
SetDirty();
|
||||
m_titleDecl.m_secondaryText = secondary;
|
||||
}
|
||||
|
||||
void TransitMark::SetTextPosition(dp::Anchor anchor,
|
||||
m2::PointF const & primaryOffset, m2::PointF const & secondaryOffset)
|
||||
{
|
||||
SetDirty();
|
||||
m_titleDecl.m_primaryOffset = primaryOffset;
|
||||
m_titleDecl.m_secondaryOffset = secondaryOffset;
|
||||
m_titleDecl.m_anchor = anchor;
|
||||
}
|
||||
|
||||
void TransitMark::SetPrimaryTextColor(dp::Color color)
|
||||
{
|
||||
SetDirty();
|
||||
m_titleDecl.m_primaryTextFont.m_color = color;
|
||||
}
|
||||
|
||||
void TransitMark::SetSecondaryTextColor(dp::Color color)
|
||||
{
|
||||
SetDirty();
|
||||
m_titleDecl.m_secondaryTextFont.m_color = color;
|
||||
}
|
||||
|
||||
drape_ptr<dp::TitleDecl> TransitMark::GetTitleDecl() const
|
||||
{
|
||||
return make_unique_dp<dp::TitleDecl>(m_titleDecl);
|
||||
}
|
||||
|
||||
drape_ptr<std::vector<m2::PointF>> TransitMark::GetSymbolSizes() const
|
||||
{
|
||||
return make_unique_dp<std::vector<m2::PointF>>(m_symbolSizes);
|
||||
}
|
||||
|
|
|
@ -100,3 +100,37 @@ private:
|
|||
|
||||
UserMarksController & m_routeMarks;
|
||||
};
|
||||
|
||||
class TransitMark : public UserMark
|
||||
{
|
||||
public:
|
||||
TransitMark(m2::PointD const & ptOrg, UserMarkContainer * container);
|
||||
virtual ~TransitMark() {}
|
||||
|
||||
dp::Anchor GetAnchor() const override { return dp::Center; }
|
||||
df::RenderState::DepthLayer GetDepthLayer() const override { return df::RenderState::TransitMarkLayer; }
|
||||
std::string GetSymbolName() const override { return ""; }
|
||||
UserMark::Type GetMarkType() const override { return Type::TRANSIT; }
|
||||
|
||||
bool HasSymbolPriority() const override { return false; }
|
||||
bool HasTitlePriority() const override { return true; }
|
||||
|
||||
void SetMinZoom(int minZoom);
|
||||
int GetMinZoom() const override { return m_minZoom; }
|
||||
|
||||
void SetSymbolSizes(std::vector<m2::PointF> const & symbolSizes);
|
||||
drape_ptr<std::vector<m2::PointF>> GetSymbolSizes() const override;
|
||||
|
||||
void SetPrimaryText(std::string const & primary);
|
||||
void SetSecondaryText(std::string const & secondary);
|
||||
void SetTextPosition(dp::Anchor anchor, m2::PointF const & primaryOffset = m2::PointF(0.0f, 0.0f),
|
||||
m2::PointF const & secondaryOffset = m2::PointF(0.0f, 0.0f));
|
||||
void SetPrimaryTextColor(dp::Color color);
|
||||
void SetSecondaryTextColor(dp::Color color);
|
||||
drape_ptr<dp::TitleDecl> GetTitleDecl() const override;
|
||||
|
||||
private:
|
||||
int m_minZoom = 1;
|
||||
dp::TitleDecl m_titleDecl;
|
||||
std::vector<m2::PointF> m_symbolSizes;
|
||||
};
|
||||
|
|
|
@ -86,5 +86,6 @@ string DebugPrint(UserMark::Type type)
|
|||
case UserMark::Type::DEBUG_MARK: return "DEBUG_MARK";
|
||||
case UserMark::Type::ROUTING: return "ROUTING";
|
||||
case UserMark::Type::LOCAL_ADS: return "LOCAL_ADS";
|
||||
case UserMark::Type::TRANSIT: return "TRANSIT";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ public:
|
|||
STATIC,
|
||||
BOOKMARK,
|
||||
ROUTING,
|
||||
TRANSIT,
|
||||
LOCAL_ADS,
|
||||
DEBUG_MARK
|
||||
};
|
||||
|
@ -43,6 +44,7 @@ public:
|
|||
float GetDepth() const override;
|
||||
df::RenderState::DepthLayer GetDepthLayer() const override;
|
||||
drape_ptr<dp::TitleDecl> GetTitleDecl() const override { return nullptr; }
|
||||
drape_ptr<std::vector<m2::PointF>> GetSymbolSizes() const override { return nullptr; }
|
||||
uint16_t GetPriority() const override { return kDefaultUserMarkPriority; }
|
||||
bool HasSymbolPriority() const override { return false; }
|
||||
bool HasTitlePriority() const override { return false; }
|
||||
|
|
Loading…
Add table
Reference in a new issue