[core] separate user mark for MyPosition

This commit is contained in:
ExMix 2014-06-23 15:53:56 +03:00 committed by Alex Zolotarev
parent 9f1ce5eafb
commit d7dd760035
5 changed files with 34 additions and 12 deletions

View file

@ -28,7 +28,7 @@ BookmarkManager::BookmarkManager(Framework & f)
m_userMarkLayers.reserve(2);
m_userMarkLayers.push_back(new SearchUserMarkContainer(graphics::activePinDepth, m_framework));
m_userMarkLayers.push_back(new ApiUserMarkContainer(graphics::activePinDepth, m_framework));
UserMarkContainer::InitPoiSelectionMark(FindUserMarksContainer(UserMarkContainer::SEARCH_MARK));
UserMarkContainer::InitStaticMarks(FindUserMarksContainer(UserMarkContainer::SEARCH_MARK));
}
BookmarkManager::~BookmarkManager()

View file

@ -1487,9 +1487,9 @@ void Framework::SetViewPortASync(m2::RectD const & r)
void Framework::UpdateSelectedMyPosition(m2::PointD const & pt)
{
PoiMarkPoint * poiMark = UserMarkContainer::UserMarkForPoi();
poiMark->SetPtOrg(pt);
ActivateUserMark(poiMark, false);
MyPositionMarkPoint * myPositionMark = UserMarkContainer::UserMarkForMyPostion();
myPositionMark->SetPtOrg(pt);
ActivateUserMark(myPositionMark, false);
}
void Framework::DisconnectMyPositionUpdate()
@ -1603,7 +1603,7 @@ shared_ptr<location::State> const & Framework::GetLocationState() const
void Framework::ActivateUserMark(UserMark const * mark, bool needAnim)
{
if (mark != UserMarkContainer::UserMarkForPoi())
if (mark != UserMarkContainer::UserMarkForMyPostion())
DisconnectMyPositionUpdate();
m_bmManager.ActivateMark(mark, needAnim);
}
@ -1627,11 +1627,11 @@ UserMark const * Framework::GetUserMark(m2::PointD const & pxPoint, bool isLongP
{
search::AddressInfo info;
info.m_name = m_stringsBundle.GetString("my_position");
PoiMarkPoint * poiMark = UserMarkContainer::UserMarkForPoi();
MyPositionMarkPoint * myPostition = UserMarkContainer::UserMarkForMyPostion();
m_locationChangedSlotID = locationState->AddPositionChangedListener(bind(&Framework::UpdateSelectedMyPosition, this, _1));
poiMark->SetPtOrg(glPivot);
poiMark->SetInfo(info);
return poiMark;
myPostition->SetPtOrg(glPivot);
myPostition->SetInfo(info);
return myPostition;
}
}

View file

@ -26,7 +26,8 @@ public:
API,
SEARCH,
POI,
BOOKMARK
BOOKMARK,
MY_POSITION
};
UserMark(m2::PointD const & ptOrg, UserMarkContainer * container);
@ -147,6 +148,16 @@ public:
void SetName(string const & name) { m_info.m_name = name; }
};
class MyPositionMarkPoint : public PoiMarkPoint
{
typedef PoiMarkPoint base_t;
public:
MyPositionMarkPoint(UserMarkContainer * container)
: base_t(container) {}
UserMark::Type GetMarkType() const { return MY_POSITION; }
};
class ICustomDrawable : public UserMark
{
public:

View file

@ -159,12 +159,16 @@ void UserMarkContainer::Clear()
namespace
{
static scoped_ptr<PoiMarkPoint> s_selectionUserMark;
static scoped_ptr<MyPositionMarkPoint> s_myPosition;
}
void UserMarkContainer::InitPoiSelectionMark(UserMarkContainer * container)
void UserMarkContainer::InitStaticMarks(UserMarkContainer * container)
{
if (s_selectionUserMark == NULL)
s_selectionUserMark.reset(new PoiMarkPoint(container));
if (s_myPosition == NULL)
s_myPosition.reset(new MyPositionMarkPoint(container));
}
PoiMarkPoint * UserMarkContainer::UserMarkForPoi()
@ -173,6 +177,12 @@ PoiMarkPoint * UserMarkContainer::UserMarkForPoi()
return s_selectionUserMark.get();
}
MyPositionMarkPoint * UserMarkContainer::UserMarkForMyPostion()
{
ASSERT(s_myPosition != NULL, ());
return s_myPosition.get();
}
UserMark * UserMarkContainer::CreateUserMark(m2::PointD const & ptOrg)
{
m_userMarks.push_back(AllocateUserMark(ptOrg));

View file

@ -74,8 +74,9 @@ public:
double GetDepth() const { return m_layerDepth; }
static void InitPoiSelectionMark(UserMarkContainer * container);
static void InitStaticMarks(UserMarkContainer * container);
static PoiMarkPoint * UserMarkForPoi();
static MyPositionMarkPoint * UserMarkForMyPostion();
Controller const & GetController() const { return m_controller; }
Controller & GetController() { return m_controller; }