Fixed bookmark creation animation

This commit is contained in:
r.kuznetsov 2017-07-03 11:50:53 +03:00 committed by Daria Volvenkova
parent d6195ab269
commit e427204379
14 changed files with 55 additions and 36 deletions

View file

@ -220,7 +220,7 @@ void DrapeEngine::UpdateUserMarksLayer(size_t layerId, UserMarksProvider * provi
renderInfo.m_isVisible = mark->IsVisible();
renderInfo.m_pivot = mark->GetPivot();
renderInfo.m_pixelOffset = mark->GetPixelOffset();
renderInfo.m_runCreationAnim = mark->RunCreationAnim();
renderInfo.m_runCreationAnim = mark->HasCreationAnimation();
renderInfo.m_symbolName = mark->GetSymbolName();
marksRenderCollection->emplace_back(std::move(renderInfo));
}
@ -233,7 +233,7 @@ void DrapeEngine::UpdateUserMarksLayer(size_t layerId, UserMarksProvider * provi
UserLineRenderParams renderInfo;
renderInfo.m_spline = m2::SharedSpline(mark->GetPoints());
renderInfo.m_layers.reserve(mark->GetLayerCount());
for (size_t layerIndex = 0, sz = mark->GetLayerCount(); layerIndex < sz; ++layerIndex)
for (size_t layerIndex = 0, layersCount = mark->GetLayerCount(); layerIndex < layersCount; ++layerIndex)
{
renderInfo.m_layers.emplace_back(mark->GetColor(layerIndex),
mark->GetWidth(layerIndex),

View file

@ -217,7 +217,7 @@ UserMarkRenderGroup::~UserMarkRenderGroup()
void UserMarkRenderGroup::UpdateAnimation()
{
BaseRenderGroup::UpdateAnimation();
float t = 1.0;
float t = 1.0f;
if (m_animation)
t = static_cast<float>(m_animation->GetOpacity());

View file

@ -162,9 +162,8 @@ void UserMarkGenerator::SetGroupVisibility(GroupID groupId, bool isVisible)
void UserMarkGenerator::GenerateUserMarksGeometry(TileKey const & tileKey, ref_ptr<dp::TextureManager> textures)
{
MarksIndex::const_iterator itTile = m_marksIndex.find(TileKey(tileKey.m_x,
tileKey.m_y,
min(tileKey.m_zoomLevel, scales::GetUpperScale())));
auto const itTile = m_marksIndex.find(TileKey(tileKey.m_x, tileKey.m_y, std::min(tileKey.m_zoomLevel,
scales::GetUpperScale())));
if (itTile == m_marksIndex.end())
return;
@ -186,8 +185,8 @@ void UserMarkGenerator::GenerateUserMarksGeometry(TileKey const & tileKey, ref_p
if (m_groupsVisibility.find(groupId) == m_groupsVisibility.end())
continue;
CacheUserMarks(tileKey, textures, *m_marks[groupId], groupPair.second->m_markIndexes, batcher);
CacheUserLines(tileKey, textures, *m_lines[groupId], groupPair.second->m_lineIndexes, batcher);
CacheUserMarks(tileKey, textures, groupPair.second->m_markIndexes, *m_marks[groupId], batcher);
CacheUserLines(tileKey, textures, groupPair.second->m_lineIndexes, *m_lines[groupId], batcher);
}
}
m_flushFn(std::move(renderData));

View file

@ -57,7 +57,7 @@ struct UserPointVertex : gpu::BaseVertex
: m_position(pos)
, m_normal(normal)
, m_texCoord(texCoord)
, m_isAnim(isAnim ? 1.0 : -1.0)
, m_isAnim(isAnim ? 1.0f : -1.0f)
{}
static dp::BindingInfo GetBinding()
@ -81,7 +81,7 @@ struct UserPointVertex : gpu::BaseVertex
} // namespace
void CacheUserMarks(TileKey const & tileKey, ref_ptr<dp::TextureManager> textures,
UserMarksRenderCollection const & renderParams, MarkIndexesCollection const & indexes,
MarkIndexesCollection const & indexes, UserMarksRenderCollection & renderParams,
dp::Batcher & batcher)
{
using UPV = UserPointVertex;
@ -92,16 +92,18 @@ void CacheUserMarks(TileKey const & tileKey, ref_ptr<dp::TextureManager> texture
dp::TextureManager::SymbolRegion region;
for (auto const markIndex : indexes)
{
UserMarkRenderParams const & renderInfo = renderParams[markIndex];
UserMarkRenderParams & renderInfo = renderParams[markIndex];
if (!renderInfo.m_isVisible)
continue;
textures->GetSymbolRegion(renderInfo.m_symbolName, region);
m2::RectF const & texRect = region.GetTexRect();
m2::PointF const pxSize = region.GetPixelSize();
dp::Anchor const anchor = renderInfo.m_anchor;
m2::PointD const pt = MapShape::ConvertToLocal(renderInfo.m_pivot, tileKey.GetGlobalRect().Center(), kShapeCoordScalar);
m2::PointD const pt = MapShape::ConvertToLocal(renderInfo.m_pivot, tileKey.GetGlobalRect().Center(),
kShapeCoordScalar);
glsl::vec3 const pos = glsl::vec3(glsl::ToVec2(pt), renderInfo.m_depth);
bool const runAnim = renderInfo.m_runCreationAnim;
renderInfo.m_runCreationAnim = false;
glsl::vec2 left, right, up, down;
AlignHorizontal(pxSize.x * 0.5f, anchor, left, right);
@ -128,15 +130,15 @@ void CacheUserMarks(TileKey const & tileKey, ref_ptr<dp::TextureManager> texture
}
void CacheUserLines(TileKey const & tileKey, ref_ptr<dp::TextureManager> textures,
UserLinesRenderCollection const & renderParams, LineIndexesCollection const & indexes,
LineIndexesCollection const & indexes, UserLinesRenderCollection & renderParams,
dp::Batcher & batcher)
{
float const vs = static_cast<float>(df::VisualParams::Instance().GetVisualScale());
for (auto lineIndex : indexes)
{
UserLineRenderParams const & renderInfo = renderParams[lineIndex];
UserLineRenderParams & renderInfo = renderParams[lineIndex];
std::vector<m2::SharedSpline> const splines = m2::ClipSplineByRect(tileKey.GetGlobalRect(), renderInfo.m_spline);
auto const splines = m2::ClipSplineByRect(tileKey.GetGlobalRect(), renderInfo.m_spline);
for (auto const & spline : splines)
{
for (auto const & layer : renderInfo.m_layers)

View file

@ -11,7 +11,6 @@
namespace df
{
struct UserMarkRenderParams
{
int m_minZoom = 1;
@ -67,11 +66,10 @@ struct UserMarkRenderData
using TUserMarksRenderData = std::vector<UserMarkRenderData>;
void CacheUserMarks(TileKey const & tileKey, ref_ptr<dp::TextureManager> textures,
UserMarksRenderCollection const & renderParams, MarkIndexesCollection const & indexes,
MarkIndexesCollection const & indexes, UserMarksRenderCollection & renderParams,
dp::Batcher & batcher);
void CacheUserLines(TileKey const & tileKey, ref_ptr<dp::TextureManager> textures,
UserLinesRenderCollection const & renderParams, LineIndexesCollection const & indexes,
LineIndexesCollection const & indexes, UserLinesRenderCollection & renderParams,
dp::Batcher & batcher);
} // namespace df
} // namespace df

View file

@ -21,7 +21,7 @@ public:
virtual std::string GetSymbolName() const = 0;
virtual dp::Anchor GetAnchor() const = 0;
virtual float GetDepth() const = 0;
virtual bool RunCreationAnim() const = 0;
virtual bool HasCreationAnimation() const = 0;
virtual bool IsVisible() const { return true; }
};

View file

@ -348,7 +348,7 @@ using namespace place_page;
NSAssert(category, @"Category can't be nullptr!");
{
BookmarkCategory::Guard guard(*category);
auto bookmark = static_cast<Bookmark *>(guard.m_controller.GetUserMarkForEdit(bookmarkIndex));
auto bookmark = static_cast<Bookmark const *>(guard.m_controller.GetUserMark(bookmarkIndex));
f.FillBookmarkInfo(*bookmark, {bookmarkIndex, categoryIndex}, m_info);
}
m_sections.insert(m_sections.begin() + 1, Sections::Bookmark);

View file

@ -29,14 +29,14 @@
Bookmark::Bookmark(m2::PointD const & ptOrg, UserMarkContainer * container)
: TBase(ptOrg, container)
, m_runCreationAnim(true)
, m_hasCreationAnimation(false)
{
}
Bookmark::Bookmark(BookmarkData const & data, m2::PointD const & ptOrg, UserMarkContainer * container)
: TBase(ptOrg, container)
, m_data(data)
, m_runCreationAnim(true)
, m_hasCreationAnimation(false)
{
}
@ -65,13 +65,18 @@ UserMark::Type Bookmark::GetMarkType() const
return UserMark::Type::BOOKMARK;
}
bool Bookmark::RunCreationAnim() const
bool Bookmark::HasCreationAnimation() const
{
bool result = m_runCreationAnim;
m_runCreationAnim = false;
bool const result = m_hasCreationAnimation;
m_hasCreationAnimation = false;
return result;
}
void Bookmark::SetCreationAnimationShown(bool shown)
{
m_hasCreationAnimation = !shown;
}
string const & Bookmark::GetName() const
{
return m_data.GetName();
@ -408,7 +413,6 @@ namespace
{
Bookmark * bm = static_cast<Bookmark *>(m_controller.CreateUserMark(m_org));
bm->SetData(BookmarkData(m_name, m_type, m_description, m_scale, m_timeStamp));
bm->RunCreationAnim();
}
else if (GEOMETRY_TYPE_LINE == m_geometryType)
{

View file

@ -81,7 +81,8 @@ public:
string GetSymbolName() const override;
Type GetMarkType() const override;
bool RunCreationAnim() const override;
bool HasCreationAnimation() const override;
void SetCreationAnimationShown(bool shown);
string const & GetName() const;
void SetName(string const & name);
@ -102,7 +103,7 @@ public:
private:
BookmarkData m_data;
mutable bool m_runCreationAnim;
mutable bool m_hasCreationAnimation;
};
class BookmarkCategory : public UserMarkContainer

View file

@ -99,7 +99,9 @@ size_t BookmarkManager::AddBookmark(size_t categoryIndex, m2::PointD const & ptO
BookmarkCategory * pCat = m_categories[categoryIndex];
BookmarkCategory::Guard guard(*pCat);
static_cast<Bookmark *>(guard.m_controller.CreateUserMark(ptOrg))->SetData(bm);
Bookmark * bookmark = static_cast<Bookmark *>(guard.m_controller.CreateUserMark(ptOrg));
bookmark->SetData(bm);
bookmark->SetCreationAnimationShown(false);
guard.m_controller.SetIsVisible(true);
pCat->SaveToKMLFile();

View file

@ -32,7 +32,7 @@ float UserMark::GetDepth() const
return GetContainer()->GetPointDepth();
}
bool UserMark::RunCreationAnim() const
bool UserMark::HasCreationAnimation() const
{
return false;
}

View file

@ -40,7 +40,7 @@ public:
m2::PointD GetPixelOffset() const override;
dp::Anchor GetAnchor() const override;
float GetDepth() const override;
bool RunCreationAnim() const override;
bool HasCreationAnimation() const override;
UserMarkContainer const * GetContainer() const;
ms::LatLon GetLatLon() const;

View file

@ -170,7 +170,11 @@ void DrawWidget::mousePressEvent(QMouseEvent * e)
}
else if (IsRightButton(e))
{
if (!m_selectionMode || IsCommandModifier(e))
if (IsAltModifier(e))
{
SubmitBookmark(pt);
}
else if (!m_selectionMode || IsCommandModifier(e))
{
ShowInfoPopup(e, pt);
}
@ -361,6 +365,16 @@ void DrawWidget::SubmitRoutingPoint(m2::PointD const & pt)
routingManager.BuildRoute(0 /* timeoutSec */);
}
void DrawWidget::SubmitBookmark(m2::PointD const & pt)
{
size_t categoryIndex = 0;
auto category = m_framework.GetBookmarkManager().GetBmCategory(categoryIndex);
if (category == nullptr)
categoryIndex = m_framework.GetBookmarkManager().CreateBmCategory("Desktop_bookmarks");
BookmarkData data("", "placemark-red");
m_framework.GetBookmarkManager().AddBookmark(categoryIndex, m_framework.P3dtoG(pt), data);
}
void DrawWidget::FollowRoute()
{
auto & routingManager = m_framework.GetRoutingManager();

View file

@ -94,6 +94,7 @@ protected:
private:
void SubmitFakeLocationPoint(m2::PointD const & pt);
void SubmitRoutingPoint(m2::PointD const & pt);
void SubmitBookmark(m2::PointD const & pt);
void ShowInfoPopup(QMouseEvent * e, m2::PointD const & pt);
void ShowPlacePage(place_page::Info const & info);
@ -104,8 +105,6 @@ private:
bool m_emulatingLocation;
void InitRenderPolicy();
TCurrentCountryChanged m_currentCountryChanged;
storage::TCountryId m_countryId;