forked from organicmaps/organicmaps
Simplified UserMark and Bookmark.
This commit is contained in:
parent
f0c7638eac
commit
7e4cc74bf9
5 changed files with 19 additions and 19 deletions
|
@ -28,14 +28,16 @@
|
|||
#include <map>
|
||||
#include <memory>
|
||||
|
||||
Bookmark::Bookmark(m2::PointD const & ptOrg, UserMarkManager * manager, size_t containerId)
|
||||
: Base(ptOrg, manager, containerId)
|
||||
Bookmark::Bookmark(m2::PointD const & ptOrg, UserMarkManager * manager, size_t categoryId)
|
||||
: Base(ptOrg, manager, UserMark::BOOKMARK)
|
||||
, m_categoryId(categoryId)
|
||||
{}
|
||||
|
||||
Bookmark::Bookmark(BookmarkData const & data, m2::PointD const & ptOrg,
|
||||
UserMarkManager * manager, size_t containerId)
|
||||
: Base(ptOrg, manager, containerId)
|
||||
UserMarkManager * manager, size_t categoryId)
|
||||
: Base(ptOrg, manager, UserMark::BOOKMARK)
|
||||
, m_data(data)
|
||||
, m_categoryId(categoryId)
|
||||
{}
|
||||
|
||||
void Bookmark::SetData(BookmarkData const & data)
|
||||
|
|
|
@ -74,10 +74,10 @@ class Bookmark : public UserMark
|
|||
{
|
||||
using Base = UserMark;
|
||||
public:
|
||||
Bookmark(m2::PointD const & ptOrg, UserMarkManager * manager, size_t containerId);
|
||||
Bookmark(m2::PointD const & ptOrg, UserMarkManager * manager, size_t categoryId);
|
||||
|
||||
Bookmark(BookmarkData const & data, m2::PointD const & ptOrg,
|
||||
UserMarkManager * manager, size_t containerId);
|
||||
UserMarkManager * manager, size_t categoryId);
|
||||
|
||||
void SetData(BookmarkData const & data);
|
||||
BookmarkData const & GetData() const;
|
||||
|
@ -103,8 +103,11 @@ public:
|
|||
double GetScale() const;
|
||||
void SetScale(double scale);
|
||||
|
||||
size_t GetCategoryId() const { return m_categoryId; }
|
||||
|
||||
private:
|
||||
BookmarkData m_data;
|
||||
size_t m_categoryId;
|
||||
};
|
||||
|
||||
class BookmarkCategory : public UserMarkContainer
|
||||
|
|
|
@ -2116,16 +2116,17 @@ BookmarkManager const & Framework::GetBookmarkManager() const
|
|||
|
||||
BookmarkAndCategory Framework::FindBookmark(UserMark const * mark) const
|
||||
{
|
||||
Bookmark const * bookmark = static_cast<Bookmark const *>(mark);
|
||||
BookmarkAndCategory empty;
|
||||
BookmarkAndCategory result;
|
||||
ASSERT_LESS_OR_EQUAL(GetBookmarkManager().GetBmCategoriesIds().size(), numeric_limits<int>::max(), ());
|
||||
result.m_categoryIndex = mark->GetCategoryId();
|
||||
result.m_categoryIndex = bookmark->GetCategoryId();
|
||||
ASSERT(result.m_categoryIndex != empty.m_categoryIndex, ());
|
||||
size_t const sz = GetBookmarkManager().GetUserMarkCount(result.m_categoryIndex);
|
||||
ASSERT_LESS_OR_EQUAL(sz, numeric_limits<int>::max(), ());
|
||||
for (size_t i = 0; i < sz; ++i)
|
||||
{
|
||||
if (mark == GetBookmarkManager().GetBookmark(result.m_categoryIndex, i))
|
||||
if (bookmark == GetBookmarkManager().GetBookmark(result.m_categoryIndex, i))
|
||||
{
|
||||
result.m_bookmarkIndex = static_cast<int>(i);
|
||||
break;
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
#include "base/string_utils.hpp"
|
||||
|
||||
UserMark::UserMark(m2::PointD const & ptOrg, UserMarkManager * manager, size_t type)
|
||||
: m_ptOrg(ptOrg), m_manager(manager), m_type(min((UserMark::Type)type, UserMark::BOOKMARK)), m_id(type)
|
||||
UserMark::UserMark(m2::PointD const & ptOrg, UserMarkManager * manager, UserMark::Type type)
|
||||
: m_ptOrg(ptOrg), m_manager(manager), m_type(type), m_id(type)
|
||||
{}
|
||||
|
||||
m2::PointD const & UserMark::GetPivot() const
|
||||
|
@ -26,11 +26,6 @@ dp::Anchor UserMark::GetAnchor() const
|
|||
return dp::Center;
|
||||
}
|
||||
|
||||
float UserMark::GetDepth() const
|
||||
{
|
||||
return m_manager->GetPointDepth(m_id);
|
||||
}
|
||||
|
||||
df::RenderState::DepthLayer UserMark::GetDepthLayer() const
|
||||
{
|
||||
return df::RenderState::UserMarkLayer;
|
||||
|
|
|
@ -45,7 +45,7 @@ public:
|
|||
PREDEFINED_COUNT = BOOKMARK
|
||||
};
|
||||
|
||||
UserMark(m2::PointD const & ptOrg, UserMarkManager * container, size_t type);
|
||||
UserMark(m2::PointD const & ptOrg, UserMarkManager * container, UserMark::Type type);
|
||||
|
||||
// df::UserPointMark overrides.
|
||||
bool IsDirty() const override { return m_isDirty; }
|
||||
|
@ -54,7 +54,7 @@ public:
|
|||
m2::PointD const & GetPivot() const override;
|
||||
m2::PointD GetPixelOffset() const override;
|
||||
dp::Anchor GetAnchor() const override;
|
||||
float GetDepth() const override;
|
||||
virtual float GetDepth() const override { return 0.0f; };
|
||||
df::RenderState::DepthLayer GetDepthLayer() const override;
|
||||
drape_ptr<TitlesInfo> GetTitleDecl() const override { return nullptr; }
|
||||
drape_ptr<ColoredSymbolZoomInfo> GetColoredSymbols() const override { return nullptr; }
|
||||
|
@ -70,9 +70,8 @@ public:
|
|||
bool HasCreationAnimation() const override { return false; }
|
||||
|
||||
ms::LatLon GetLatLon() const;
|
||||
virtual Type GetMarkType() const { return m_type; };
|
||||
virtual Type GetMarkType() const { return m_type; }
|
||||
virtual bool IsAvailableForSearch() const { return true; }
|
||||
size_t GetCategoryId() const { return m_id; }
|
||||
|
||||
protected:
|
||||
void SetDirty() { m_isDirty = true; }
|
||||
|
|
Loading…
Add table
Reference in a new issue