forked from organicmaps/organicmaps-tmp
[android] Add gui::BookmarkBalloon to android::Framework.
This commit is contained in:
parent
7c8634e74f
commit
e1bb2b713b
8 changed files with 61 additions and 50 deletions
|
@ -57,8 +57,6 @@ namespace android
|
|||
size_t const measurementsCount = 5;
|
||||
m_sensors[0].SetCount(measurementsCount);
|
||||
m_sensors[1].SetCount(measurementsCount);
|
||||
|
||||
m_work.GetBookmarkBalloon()->setOnClickListener(bind(&Framework::OnBalloonClick, this, _1));
|
||||
}
|
||||
|
||||
Framework::~Framework()
|
||||
|
@ -603,6 +601,7 @@ namespace android
|
|||
ActivatePopupWithAddressInfo(m_work.PtoG(point), adInfo);
|
||||
}
|
||||
|
||||
/*
|
||||
void Framework::ToCamelCase(string & s)
|
||||
{
|
||||
if (s.length() > 0)
|
||||
|
@ -618,6 +617,7 @@ namespace android
|
|||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
void Framework::ActivatePopupWithAddressInfo(m2::PointD const & bmkPosition, ::Framework::AddressInfo const & adInfo)
|
||||
{
|
||||
|
@ -654,7 +654,8 @@ namespace android
|
|||
|
||||
void Framework::ActivatePopup(m2::PointD const & bmkPosition, string const & name)
|
||||
{
|
||||
gui::BookmarkBalloon * b = m_work.GetBookmarkBalloon();
|
||||
gui::BookmarkBalloon * b = GetBookmarkBalloon();
|
||||
|
||||
m_work.DisablePlacemark();
|
||||
b->setBookmarkPivot(bmkPosition);
|
||||
b->setBookmarkName(name);
|
||||
|
@ -664,7 +665,7 @@ namespace android
|
|||
|
||||
void Framework::DeactivatePopup()
|
||||
{
|
||||
gui::BookmarkBalloon * b = m_work.GetBookmarkBalloon();
|
||||
gui::BookmarkBalloon * b = GetBookmarkBalloon();
|
||||
b->setIsVisible(false);
|
||||
m_work.DisablePlacemark();
|
||||
m_work.Invalidate();
|
||||
|
@ -672,7 +673,8 @@ namespace android
|
|||
|
||||
void Framework::OnBalloonClick(gui::Element * e)
|
||||
{
|
||||
gui::BookmarkBalloon * balloon = static_cast<gui::BookmarkBalloon *>(e);
|
||||
gui::BookmarkBalloon * balloon = GetBookmarkBalloon();
|
||||
|
||||
BookmarkAndCategory bac = m_work.GetBookmark(m_work.GtoP(balloon->getBookmarkPivot()));
|
||||
if (ValidateBookmarkAndCategory(bac))
|
||||
{
|
||||
|
@ -706,8 +708,36 @@ namespace android
|
|||
{
|
||||
m_balloonClickListener = l;
|
||||
}
|
||||
|
||||
void Framework::RemoveBalloonClickListener()
|
||||
{
|
||||
m_balloonClickListener.clear();
|
||||
}
|
||||
|
||||
void Framework::CreateBookmarkBalloon()
|
||||
{
|
||||
CHECK(m_work.GetGuiController(), ());
|
||||
CHECK(m_work.GetRenderPolicy(), ());
|
||||
|
||||
gui::Balloon::Params bp;
|
||||
|
||||
bp.m_position = graphics::EPosAbove;
|
||||
bp.m_depth = graphics::maxDepth;
|
||||
bp.m_pivot = m2::PointD(0, 0);
|
||||
bp.m_imageMarginBottom = 10;
|
||||
bp.m_imageMarginLeft = 10;
|
||||
bp.m_imageMarginRight = 10;
|
||||
bp.m_imageMarginTop = 10;
|
||||
bp.m_textMarginBottom = 10;
|
||||
bp.m_textMarginLeft = 10;
|
||||
bp.m_textMarginRight = 10;
|
||||
bp.m_textMarginTop = 10;
|
||||
bp.m_image = graphics::Image::Info("arrow.png", m_work.GetRenderPolicy()->Density());
|
||||
bp.m_text = "Bookmark";
|
||||
|
||||
m_bmBaloon.reset(new gui::BookmarkBalloon(bp, &m_work));
|
||||
m_bmBaloon->setIsVisible(false);
|
||||
m_bmBaloon->setOnClickListener(bind(&Framework::OnBalloonClick, this, _1));
|
||||
m_work.GetGuiController()->AddElement(m_bmBaloon);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
#include <jni.h>
|
||||
|
||||
#include "../../../../../map/framework.hpp"
|
||||
#include "../../../../../map/drawer.hpp"
|
||||
#include "../../../../../map/window_handle.hpp"
|
||||
#include "../../../../../map/feature_vec_model.hpp"
|
||||
#include "../../../../../map/bookmark_balloon.hpp"
|
||||
|
||||
#include "../../../../../search/result.hpp"
|
||||
|
||||
#include "../../../../../geometry/avg_vector.hpp"
|
||||
|
||||
|
@ -13,10 +13,11 @@
|
|||
#include "../../../../../base/scheduled_task.hpp"
|
||||
#include "../../../../../base/strings_bundle.hpp"
|
||||
|
||||
#include "../../../../../search/result.hpp"
|
||||
#include "../../../../../std/shared_ptr.hpp"
|
||||
|
||||
#include "../../../nv_event/nv_event.hpp"
|
||||
|
||||
|
||||
class CountryStatusDisplay;
|
||||
|
||||
namespace android
|
||||
|
@ -31,7 +32,7 @@ namespace android
|
|||
void CallRepaint();
|
||||
|
||||
TOnBalloonClickListener m_balloonClickListener;
|
||||
boost::shared_ptr<ScheduledTask> m_scheduledTask;
|
||||
shared_ptr<ScheduledTask> m_scheduledTask;
|
||||
|
||||
int m_onClickFnsHandler;
|
||||
NVMultiTouchEventType m_eventType; //< multitouch action
|
||||
|
@ -66,12 +67,23 @@ namespace android
|
|||
bool AdditionalHandlingForLongClick(double x, double y);
|
||||
void ActivatePopup(m2::PointD const & bmkPosition, string const & name);
|
||||
void ActivatePopupWithAddressInfo(m2::PointD const & bmkPosition, ::Framework::AddressInfo const & adInfo);
|
||||
void OnBalloonClick(gui::Element * e);
|
||||
|
||||
void ToCamelCase(string & c);
|
||||
|
||||
inline bool ValidateBookmarkAndCategory(BookmarkAndCategory const & bac)
|
||||
static inline bool ValidateBookmarkAndCategory(BookmarkAndCategory const & bac)
|
||||
{
|
||||
return bac.first > -1 && bac.second > -1;
|
||||
return (bac.first > -1 && bac.second > -1);
|
||||
}
|
||||
|
||||
shared_ptr<gui::BookmarkBalloon> m_bmBaloon;
|
||||
|
||||
void OnBalloonClick(gui::Element * e);
|
||||
void CreateBookmarkBalloon();
|
||||
inline gui::BookmarkBalloon * GetBookmarkBalloon()
|
||||
{
|
||||
if (!m_bmBaloon)
|
||||
CreateBookmarkBalloon();
|
||||
return m_bmBaloon.get();
|
||||
}
|
||||
|
||||
public:
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
namespace gui
|
||||
{
|
||||
BookmarkBalloon::BookmarkBalloon(Params const & p, Framework * framework)
|
||||
BookmarkBalloon::BookmarkBalloon(Params const & p, Framework const * framework)
|
||||
: Balloon(p),
|
||||
m_framework(framework)
|
||||
{
|
||||
|
|
|
@ -11,10 +11,12 @@ namespace gui
|
|||
private:
|
||||
void update();
|
||||
m2::PointD m_bookmarkPivot;
|
||||
Framework * m_framework;
|
||||
Framework const * m_framework;
|
||||
std::string m_bookmarkName;
|
||||
|
||||
public:
|
||||
BookmarkBalloon(Params const & p, Framework * framework);
|
||||
BookmarkBalloon(Params const & p, Framework const * framework);
|
||||
|
||||
void setBookmarkPivot(m2::PointD const & pivot);
|
||||
m2::PointD const getBookmarkPivot();
|
||||
void setBookmarkName(std::string const & name);
|
||||
|
|
|
@ -156,11 +156,6 @@ CountryStatusDisplay * Framework::GetCountryStatusDisplay() const
|
|||
return m_informationDisplay.countryStatusDisplay().get();
|
||||
}
|
||||
|
||||
gui::BookmarkBalloon * Framework::GetBookmarkBalloon() const
|
||||
{
|
||||
return m_informationDisplay.bookmarkBalloon().get();
|
||||
}
|
||||
|
||||
static void GetResourcesMaps(vector<string> & outMaps)
|
||||
{
|
||||
Platform & pl = GetPlatform();
|
||||
|
|
|
@ -239,7 +239,6 @@ public:
|
|||
|
||||
InformationDisplay & GetInformationDisplay();
|
||||
CountryStatusDisplay * GetCountryStatusDisplay() const;
|
||||
gui::BookmarkBalloon * GetBookmarkBalloon() const;
|
||||
|
||||
void PrepareToShutdown();
|
||||
|
||||
|
|
|
@ -75,25 +75,6 @@ InformationDisplay::InformationDisplay(Framework * framework)
|
|||
|
||||
m_locationState.reset(new location::State(lsp));
|
||||
|
||||
gui::Balloon::Params bp;
|
||||
|
||||
bp.m_position = graphics::EPosAbove;
|
||||
bp.m_depth = graphics::maxDepth;
|
||||
bp.m_pivot = m2::PointD(0, 0);
|
||||
bp.m_imageMarginBottom = 10;
|
||||
bp.m_imageMarginLeft = 10;
|
||||
bp.m_imageMarginRight = 10;
|
||||
bp.m_imageMarginTop = 10;
|
||||
bp.m_textMarginBottom = 10;
|
||||
bp.m_textMarginLeft = 10;
|
||||
bp.m_textMarginRight = 10;
|
||||
bp.m_textMarginTop = 10;
|
||||
bp.m_image = graphics::Image::Info("arrow.png");
|
||||
bp.m_text = "Bookmark";
|
||||
|
||||
m_bookmarkBalloon.reset(new gui::BookmarkBalloon(bp, framework));
|
||||
m_bookmarkBalloon->setIsVisible(false);
|
||||
|
||||
enableDebugPoints(false);
|
||||
enableRuler(false);
|
||||
enableCenter(false);
|
||||
|
@ -116,7 +97,6 @@ void InformationDisplay::setController(gui::Controller *controller)
|
|||
m_controller->AddElement(m_compassArrow);
|
||||
m_controller->AddElement(m_locationState);
|
||||
m_controller->AddElement(m_ruler);
|
||||
m_controller->AddElement(m_bookmarkBalloon);
|
||||
}
|
||||
|
||||
void InformationDisplay::setScreen(ScreenBase const & screen)
|
||||
|
@ -499,11 +479,6 @@ shared_ptr<CountryStatusDisplay> const & InformationDisplay::countryStatusDispla
|
|||
return m_countryStatusDisplay;
|
||||
}
|
||||
|
||||
shared_ptr<gui::BookmarkBalloon> const & InformationDisplay::bookmarkBalloon() const
|
||||
{
|
||||
return m_bookmarkBalloon;
|
||||
}
|
||||
|
||||
shared_ptr<location::State> const & InformationDisplay::locationState() const
|
||||
{
|
||||
return m_locationState;
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include "../storage/index.hpp"
|
||||
|
||||
#include "../gui/button.hpp"
|
||||
#include "../map/bookmark_balloon.hpp"
|
||||
|
||||
#include "../geometry/point2d.hpp"
|
||||
#include "../geometry/rect2d.hpp"
|
||||
|
@ -90,7 +89,6 @@ private:
|
|||
shared_ptr<CountryStatusDisplay> m_countryStatusDisplay;
|
||||
shared_ptr<CompassArrow> m_compassArrow;
|
||||
shared_ptr<location::State> m_locationState;
|
||||
shared_ptr<gui::BookmarkBalloon> m_bookmarkBalloon;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -144,7 +142,7 @@ public:
|
|||
void setEmptyCountryIndex(storage::TIndex const & idx);
|
||||
|
||||
shared_ptr<CountryStatusDisplay> const & countryStatusDisplay() const;
|
||||
shared_ptr<gui::BookmarkBalloon> const & bookmarkBalloon() const;
|
||||
shared_ptr<gui::BookmarkBalloon> const & bookmarkBalloon(Framework const * p) const;
|
||||
shared_ptr<Ruler> const & ruler() const;
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue