- Sort gui elements by depth before select.
- Correct My position and Bookmark depth.
- Add ballon mode for show with bookmark padding and without.
This commit is contained in:
ExMix 2013-06-27 15:15:01 +03:00 committed by Alex Zolotarev
parent 56c2974f14
commit 366c57ac6a
7 changed files with 30 additions and 16 deletions

View file

@ -16,6 +16,7 @@ namespace graphics
static const int compassDepth = balloonBaseDepth - 10;
static const int locationDepth = compassDepth - 10;
static const int poiAndBookmarkDepth = locationDepth - 10;
static const int countryStatusDepth = locationDepth - 10;
static const int rulerDepth = countryStatusDepth;

View file

@ -43,11 +43,21 @@ namespace gui
}
}
namespace
{
bool DepthGreater(const shared_ptr<Element> & e1,
const shared_ptr<Element> & e2)
{
return e1->depth() > e2->depth();
}
}
bool Controller::OnTapStarted(m2::PointD const & pt)
{
elem_list_t l;
SelectElements(pt, l, true);
l.sort(DepthGreater);
/// selecting first hit-tested element from the list
if (!l.empty())

View file

@ -2,6 +2,7 @@
#include "../graphics/display_list.hpp"
#include "../graphics/glyph.hpp"
#include "../graphics/depth_constants.hpp"
namespace gui
{
@ -76,7 +77,7 @@ namespace gui
/// @todo do not cache depth in display list. use separate vertex shader and uniform constant
/// to specify it while rendering display list.
m_CacheScreen->drawSymbol(m2::PointD(0, 0), name, graphics::EPosAbove, graphics::maxDepth - 4);
m_CacheScreen->drawSymbol(m2::PointD(0, 0), name, graphics::EPosAbove, graphics::poiAndBookmarkDepth);
m_CacheScreen->setDisplayList(0);
m_CacheScreen->endFrame();

View file

@ -57,20 +57,20 @@ void BalloonManager::LocationChanged(location::GpsInfo const & info)
void BalloonManager::OnPositionClicked(m2::PointD const & pt)
{
Show(pt, m_f.GetStringsBundle().GetString("my_position"), "");
Show(pt, m_f.GetStringsBundle().GetString("my_position"), "", false);
m_balloon->setOnClickListener(bind(&BalloonManager::OnActivateMyPosition, this, _1));
m_updateForLocation = true;
}
void BalloonManager::Show(m2::PointD const & pt, string const & name, string const & type)
void BalloonManager::Show(m2::PointD const & pt, string const & name, string const & type, bool needPadding)
{
m_updateForLocation = false;
m_balloon->setGlbPivot(pt);
m_balloon->setBookmarkCaption(name, type);
m_balloon->showAnimated();
m_balloon->showAnimated(needPadding);
m_f.Invalidate();
}
@ -91,7 +91,7 @@ void BalloonManager::ShowAddress(m2::PointD const & pt, search::AddressInfo cons
if (name.empty() && type.empty())
name = m_f.GetStringsBundle().GetString("dropped_pin");
Show(pt, name, type);
Show(pt, name, type, false);
m_balloon->setOnClickListener(bind(&BalloonManager::OnActivatePOI, this, _1, info));
}
@ -100,14 +100,14 @@ void BalloonManager::ShowApiPoint(url_scheme::ApiPoint const & apiPoint)
{
Show(m2::PointD(MercatorBounds::LonToX(apiPoint.m_lon),
MercatorBounds::LatToY(apiPoint.m_lat)),
apiPoint.m_name, "");
apiPoint.m_name, "", true);
m_balloon->setOnClickListener(bind(&BalloonManager::OnActivateAPI, this, _1, apiPoint));
}
void BalloonManager::ShowBookmark(BookmarkAndCategory bmAndCat)
{
Bookmark const * pBM = m_f.GetBmCategory(bmAndCat.first)->GetBookmark(bmAndCat.second);
Show(pBM->GetOrg(), pBM->GetName(), "");
Show(pBM->GetOrg(), pBM->GetName(), "", true);
m_balloon->setOnClickListener(bind(&BalloonManager::OnActivateBookmark, this, _1, bmAndCat));
}
@ -118,7 +118,7 @@ void BalloonManager::OnClick(m2::PointD const & pxPoint, bool isLongTouch)
{
Show(m2::PointD(MercatorBounds::LonToX(apiPoint.m_lon),
MercatorBounds::LatToY(apiPoint.m_lat)),
apiPoint.m_name, "");
apiPoint.m_name, "", true);
m_balloon->setOnClickListener(bind(&BalloonManager::OnActivateAPI, this, _1, apiPoint));
}
else
@ -131,9 +131,7 @@ void BalloonManager::OnClick(m2::PointD const & pxPoint, bool isLongTouch)
{
case Framework::BOOKMARK:
{
Bookmark const * pBM = m_f.GetBmCategory(bmAndCat.first)->GetBookmark(bmAndCat.second);
Show(pBM->GetOrg(), pBM->GetName(), "");
m_balloon->setOnClickListener(bind(&BalloonManager::OnActivateBookmark, this, _1, bmAndCat));
ShowBookmark(bmAndCat);
return;
}

View file

@ -30,7 +30,7 @@ class BalloonManager
void OnActivateAPI(gui::Element *, url_scheme::ApiPoint const & apiPoint);
void OnActivateBookmark(gui::Element *, BookmarkAndCategory const & bmAndCat);
void Show(m2::PointD const & pt, string const & name, string const & type);
void Show(m2::PointD const & pt, string const & name, string const & type, bool needPadding);
public:
BalloonManager(Framework & f);

View file

@ -90,7 +90,8 @@ private:
BookmarkBalloon::BookmarkBalloon(Params const & p)
: Balloon(p),
m_framework(p.m_framework),
m_isPositionChecked(true)
m_isPositionChecked(true),
m_needPadding(false)
{
}
@ -169,7 +170,8 @@ void BookmarkBalloon::update()
if (isVisible())
{
m2::PointD newPivot(m_framework->GtoP(m_glbPivot));
newPivot.y -= PopupPadding * visualScale();
if (m_needPadding)
newPivot.y -= PopupPadding * visualScale();
setPivot(newPivot);
if (checkPosition())
@ -229,8 +231,9 @@ void BookmarkBalloon::cancelTask()
}
}
void BookmarkBalloon::showAnimated()
void BookmarkBalloon::showAnimated(bool needPadding)
{
m_needPadding = needPadding;
setPosition(graphics::EPosCenter);
setIsPositionChecked(false);

View file

@ -18,6 +18,7 @@ private:
string m_bmkName;
string m_bmkType;
bool m_isPositionChecked;
bool m_needPadding;
void setIsPositionChecked(bool isChecked);
bool isPositionChecked() const;
@ -42,7 +43,7 @@ public:
BookmarkBalloon(Params const & p);
void showAnimated();
void showAnimated(bool needPadding);
void hide();
void setGlbPivot(m2::PointD const & pivot);