forked from organicmaps/organicmaps
[core] transfer UserMarkCopy for platform-specific code.
[core] transfer UserMarkCopy for platform-specific code.
This commit is contained in:
parent
fc7c42fd8b
commit
52ad88e431
5 changed files with 50 additions and 4 deletions
|
@ -28,7 +28,7 @@ void PinClickManager::OnClick(m2::PointD const & pxPoint, bool isLongTouch)
|
|||
{
|
||||
UserMark const * mark = m_f.GetUserMark(pxPoint, isLongTouch);
|
||||
if (mark != NULL)
|
||||
OnActivateUserMark(mark);
|
||||
OnActivateUserMark(mark->Copy());
|
||||
SetBalloonVisible(mark != NULL);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ void PinClickManager::ClearListeners()
|
|||
m_dismissListener.clear();
|
||||
}
|
||||
|
||||
void PinClickManager::OnActivateUserMark(UserMark const * mark)
|
||||
void PinClickManager::OnActivateUserMark(UserMarkCopy * mark)
|
||||
{
|
||||
m_userMarkListener(mark);
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class PinClickManager
|
|||
{
|
||||
Framework & m_f;
|
||||
|
||||
void OnActivateUserMark(UserMark const * mark);
|
||||
void OnActivateUserMark(UserMarkCopy * mark);
|
||||
void OnDismiss();
|
||||
|
||||
void SetBalloonVisible(bool isVisible);
|
||||
|
@ -41,7 +41,8 @@ public:
|
|||
private:
|
||||
/// @name Platform dependent listeners to show special activities.
|
||||
//@{
|
||||
function<void (UserMark const *)> m_userMarkListener;
|
||||
// Use must remove UserMarkCopy that transfer for you by this callback
|
||||
function<void (UserMarkCopy *)> m_userMarkListener;
|
||||
function<void (void)> m_dismissListener;
|
||||
|
||||
public:
|
||||
|
|
|
@ -26,6 +26,11 @@
|
|||
#include "../std/algorithm.hpp"
|
||||
#include "../std/auto_ptr.hpp"
|
||||
|
||||
UserMarkCopy *Bookmark::Copy() const
|
||||
{
|
||||
return new UserMarkCopy(this, false);
|
||||
}
|
||||
|
||||
graphics::DisplayList * Bookmark::GetDisplayList(UserMarkDLCache * cache) const
|
||||
{
|
||||
return cache->FindUserMark(UserMarkDLCache::Key(GetType(), graphics::EPosAbove, GetContainer()->GetDepth()));
|
||||
|
|
|
@ -108,6 +108,8 @@ public:
|
|||
double GetScale() const { return m_data.GetScale(); }
|
||||
void SetScale(double scale) { m_data.SetScale(scale); }
|
||||
|
||||
virtual UserMarkCopy * Copy() const;
|
||||
|
||||
virtual graphics::DisplayList * GetDisplayList(UserMarkDLCache * cache) const;
|
||||
virtual double GetAnimScaleFactor() const;
|
||||
virtual m2::PointD const & GetPixelOffset() const;
|
||||
|
|
|
@ -16,6 +16,8 @@ namespace graphics
|
|||
class DisplayList;
|
||||
}
|
||||
|
||||
class UserMarkCopy;
|
||||
|
||||
class UserMark : private noncopyable
|
||||
{
|
||||
public:
|
||||
|
@ -35,12 +37,35 @@ public:
|
|||
void GetLatLon(double & lat, double & lon) const;
|
||||
virtual bool IsCustomDrawable() const { return false;}
|
||||
virtual Type GetMarkType() const = 0;
|
||||
virtual UserMarkCopy * Copy() const = 0;
|
||||
|
||||
protected:
|
||||
m2::PointD m_ptOrg;
|
||||
mutable UserMarkContainer * m_container;
|
||||
};
|
||||
|
||||
class UserMarkCopy
|
||||
{
|
||||
public:
|
||||
UserMarkCopy(UserMark const * srcMark, bool needDestroy = true)
|
||||
: m_srcMark(srcMark)
|
||||
, m_needDestroy(needDestroy)
|
||||
{
|
||||
}
|
||||
|
||||
~UserMarkCopy()
|
||||
{
|
||||
if (m_needDestroy)
|
||||
delete m_srcMark;
|
||||
}
|
||||
|
||||
UserMark const * GetUserMark() const { return m_srcMark; }
|
||||
|
||||
private:
|
||||
UserMark const * m_srcMark;
|
||||
bool m_needDestroy;
|
||||
};
|
||||
|
||||
class ApiMarkPoint : public UserMark
|
||||
{
|
||||
public:
|
||||
|
@ -67,6 +92,11 @@ public:
|
|||
string const & GetID() const { return m_id; }
|
||||
void SetID(string const & id) { m_id = id; }
|
||||
|
||||
virtual UserMarkCopy * Copy() const
|
||||
{
|
||||
return new UserMarkCopy(new ApiMarkPoint(m_name, m_id, m_ptOrg, m_container));
|
||||
}
|
||||
|
||||
private:
|
||||
string m_name;
|
||||
string m_id;
|
||||
|
@ -92,6 +122,10 @@ public:
|
|||
|
||||
search::AddressInfo const & GetInfo() const { return m_info; }
|
||||
void SetInfo(search::AddressInfo const & info) { m_info = info; }
|
||||
virtual UserMarkCopy * Copy() const
|
||||
{
|
||||
return new UserMarkCopy(new SearchMarkPoint(m_info, m_ptOrg, m_container));
|
||||
}
|
||||
|
||||
private:
|
||||
search::AddressInfo m_info;
|
||||
|
@ -104,6 +138,10 @@ public:
|
|||
: SearchMarkPoint(m2::PointD(0.0, 0.0), container) {}
|
||||
|
||||
UserMark::Type GetMarkType() const { return POI; }
|
||||
virtual UserMarkCopy * Copy() const
|
||||
{
|
||||
return new UserMarkCopy(this, false);
|
||||
}
|
||||
|
||||
void SetPtOrg(m2::PointD const & ptOrg) { m_ptOrg = ptOrg; }
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue