Introduce StyledPoint between Bookmark and ICustomDrawable.

Has "style" parameter.
This commit is contained in:
Keith Wansbrough 2015-10-19 21:44:37 +01:00
parent 72fc9dc304
commit 23ac0a8cf7
4 changed files with 57 additions and 5 deletions

View file

@ -2,6 +2,7 @@
#include "map/user_mark.hpp"
#include "map/user_mark_container.hpp"
#include "map/styled_point.hpp"
#include "coding/reader.hpp"
@ -65,14 +66,14 @@ private:
time_t m_timeStamp;
};
class Bookmark : public ICustomDrawable
class Bookmark : public StyledPoint
{
BookmarkData m_data;
double m_animScaleFactor;
public:
Bookmark(m2::PointD const & ptOrg, UserMarkContainer * container)
: ICustomDrawable(ptOrg, container)
: StyledPoint(ptOrg, container)
, m_animScaleFactor(1.0)
{
}
@ -80,13 +81,13 @@ public:
Bookmark(BookmarkData const & data,
m2::PointD const & ptOrg,
UserMarkContainer * container)
: ICustomDrawable(ptOrg, container)
: StyledPoint(data.GetType(), ptOrg, container)
, m_data(data)
, m_animScaleFactor(1.0)
{
}
void SetData(BookmarkData const & data) { m_data = data; }
void SetData(BookmarkData const & data) { m_data = data; SetStyle(m_data.GetType()); }
BookmarkData const & GetData() const { return m_data; }
virtual Type GetMarkType() const override { return UserMark::Type::BOOKMARK; }
@ -96,7 +97,7 @@ public:
void SetName(string const & name) { m_data.SetName(name); }
/// @return Now its a bookmark color - name of icon file
string const & GetType() const { return m_data.GetType(); }
void SetType(string const & type) { m_data.SetType(type); }
void SetType(string const & type) { m_data.SetType(type); SetStyle(type); }
m2::RectD GetViewport() const { return m2::RectD(GetOrg(), GetOrg()); }
string const & GetDescription() const { return m_data.GetDescription(); }

View file

@ -20,6 +20,7 @@ HEADERS += \
benchmark_engine.hpp \
ruler.hpp \
bookmark.hpp \
styled_point.hpp \
geourl_process.hpp \
country_status_display.hpp \
rotate_screen_task.hpp \
@ -53,6 +54,7 @@ SOURCES += \
address_finder.cpp \
geourl_process.cpp \
bookmark.cpp \
styled_point.cpp \
country_status_display.cpp \
rotate_screen_task.cpp \
compass_arrow.cpp \

9
map/styled_point.cpp Normal file
View file

@ -0,0 +1,9 @@
#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"

40
map/styled_point.hpp Normal file
View file

@ -0,0 +1,40 @@
#pragma once
#include "map/user_mark.hpp"
#include "map/user_mark_container.hpp"
#include "search/result.hpp"
#include "indexer/feature.hpp"
#include "geometry/point2d.hpp"
#include "std/string.hpp"
#include "std/unique_ptr.hpp"
#include "std/utility.hpp"
class StyledPoint : public ICustomDrawable
{
public:
StyledPoint(m2::PointD const & ptOrg, UserMarkContainer * container)
: ICustomDrawable(ptOrg, container)
{
}
StyledPoint(string const & style, m2::PointD const & ptOrg, UserMarkContainer * container)
: ICustomDrawable(ptOrg, container)
, m_style(style)
{
}
virtual graphics::DisplayList * GetDisplayList(UserMarkDLCache * cache) const = 0;
virtual double GetAnimScaleFactor() const = 0;
virtual m2::PointD const & GetPixelOffset() const = 0;
string const & GetStyle() const { return m_style; }
void SetStyle(const string & style) { m_style = style; }
private:
string m_style; ///< Point style (name of icon).
};