Apply markups.

- If style is empty string, render using previous unstyled point (violet circle). Otherwise use a placemark icon. Ensure offset is correct.
- Default mark cache key is now returned by GetDefaultKey().
- GetSupportedStyle now takes a default to apply for unrecognized styles. For bookmarks it's the default placemark; for URLs it's the original (unstyled) point.
- Remove unnecessary comment line, and unused includes.
This commit is contained in:
Keith Wansbrough 2015-11-04 19:35:25 +00:00
parent 7b6e7d3f36
commit 8b16282360
7 changed files with 30 additions and 22 deletions

View file

@ -3,8 +3,6 @@
#include "framework.hpp"
////////////////////////////////////////////////////////////////////////
ApiUserMarkContainer::ApiUserMarkContainer(double layerDepth, Framework & framework)
: UserMarkContainer(layerDepth, framework)
@ -25,5 +23,3 @@ UserMark * ApiUserMarkContainer::AllocateUserMark(const m2::PointD & ptOrg)
{
return new ApiMarkPoint(ptOrg, this);
}

View file

@ -202,7 +202,7 @@ namespace
{
// Remove leading '#' symbol
string const result = s.substr(1);
return style::GetSupportedStyle(result, m_name);
return style::GetSupportedStyle(result, m_name, style::GetDefaultStyle());
}
BookmarkCategory & m_category;

View file

@ -70,7 +70,7 @@ bool ParsedMapApi::Parse(Uri const & uri)
ApiMarkPoint * mark = static_cast<ApiMarkPoint *>(m_controller->CreateUserMark(glPoint));
mark->SetName(p.m_name);
mark->SetID(p.m_id);
mark->SetStyle(style::GetSupportedStyle(p.m_style, p.m_name));
mark->SetStyle(style::GetSupportedStyle(p.m_style, p.m_name, ""));
}
return true;

View file

@ -1,27 +1,29 @@
#include "map/styled_point.hpp"
#include "base/stl_add.hpp"
#include "base/string_utils.hpp"
#include "std/fstream.hpp"
#include "std/algorithm.hpp"
#include "std/auto_ptr.hpp"
graphics::DisplayList * StyledPoint::GetDisplayList(UserMarkDLCache * cache) const
{
return cache->FindUserMark(UserMarkDLCache::Key(GetStyle(), graphics::EPosAbove, GetContainer()->GetDepth()));
UserMarkDLCache::Key key = GetStyle().empty() ? GetContainer()->GetDefaultKey()
: UserMarkDLCache::Key(GetStyle(),
graphics::EPosAbove,
GetContainer()->GetDepth());
return cache->FindUserMark(key);
}
double StyledPoint::GetAnimScaleFactor() const
{
// Matches the behaviour for non-custom drawables. The only caller
// of ::DrawUserMark is UserMarkContainer::Draw and it always passes
// this value.
return 1.0;
}
m2::PointD const & StyledPoint::GetPixelOffset() const
{
static m2::PointD s_offset(0.0, 3.0);
return s_offset;
static m2::PointD const s_centre(0.0, 0.0);
static m2::PointD const s_offset(0.0, 3.0);
return GetStyle().empty() ? s_centre : s_offset;
}
static char const * s_arrSupportedColors[] =
@ -32,10 +34,10 @@ static char const * s_arrSupportedColors[] =
namespace style
{
string GetSupportedStyle(string const & s, string const & context)
string GetSupportedStyle(string const & s, string const & context, string const & fallback)
{
if (s.empty())
return s_arrSupportedColors[0];
return fallback;
for (size_t i = 0; i < ARRAY_SIZE(s_arrSupportedColors); ++i)
if (s == s_arrSupportedColors[i])
@ -43,7 +45,7 @@ namespace style
// Not recognized symbols are replaced with default one
LOG(LWARNING, ("Icon", s, "for point", context, "is not supported"));
return s_arrSupportedColors[0];
return fallback;
}
string GetDefaultStyle()

View file

@ -16,8 +16,9 @@
namespace style
{
// Fixes icons which are not supported by MapsWithMe
string GetSupportedStyle(string const & s, string const & context);
// Fixes icons which are not supported by MapsWithMe.
string GetSupportedStyle(string const & s, string const & context, string const & fallback);
// Default icon.
string GetDefaultStyle();
} // namespace style
@ -45,6 +46,6 @@ public:
void SetStyle(const string & style) { m_style = style; }
private:
string m_style; ///< Point style (name of icon).
string m_style; ///< Point style (name of icon), or empty string for plain circle.
};

View file

@ -177,6 +177,13 @@ namespace
static unique_ptr<MyPositionMarkPoint> s_myPosition;
}
UserMarkDLCache::Key UserMarkContainer::GetDefaultKey() const
{
return UserMarkDLCache::Key(GetTypeName(),
graphics::EPosCenter,
GetDepth());
}
void UserMarkContainer::InitStaticMarks(UserMarkContainer * container)
{
if (s_selectionUserMark == NULL)

View file

@ -84,6 +84,8 @@ public:
double GetDepth() const { return m_layerDepth; }
virtual UserMarkDLCache::Key GetDefaultKey() const;
static void InitStaticMarks(UserMarkContainer * container);
static PoiMarkPoint * UserMarkForPoi();
static MyPositionMarkPoint * UserMarkForMyPostion();