forked from organicmaps/organicmaps
[refactoring] Cross platform balloon everywhere.
This commit is contained in:
parent
593cb1723b
commit
2a34b742e4
25 changed files with 589 additions and 1054 deletions
|
@ -16,7 +16,6 @@
|
|||
|
||||
#include "../../../../../graphics/opengl/framebuffer.hpp"
|
||||
#include "../../../../../graphics/opengl/opengl.hpp"
|
||||
#include "../../../../../graphics/depth_constants.hpp"
|
||||
|
||||
#include "../../../../../platform/platform.hpp"
|
||||
#include "../../../../../platform/location.hpp"
|
||||
|
@ -43,8 +42,7 @@ namespace android
|
|||
: m_mask(0),
|
||||
m_isCleanSingleClick(false),
|
||||
m_doLoadState(true),
|
||||
m_wasLongClick(false),
|
||||
m_doUpdateBalloonPositionFromLocation(false)
|
||||
m_wasLongClick(false)
|
||||
{
|
||||
ASSERT_EQUAL ( g_framework, 0, () );
|
||||
g_framework = this;
|
||||
|
@ -53,11 +51,6 @@ namespace android
|
|||
size_t const measurementsCount = 5;
|
||||
m_sensors[0].SetCount(measurementsCount);
|
||||
m_sensors[1].SetCount(measurementsCount);
|
||||
|
||||
m_bmType = "placemark-red";
|
||||
|
||||
shared_ptr<location::State> locState = NativeFramework()->GetLocationState();
|
||||
locState->AddOnPositionClickListener(bind(&Framework::OnPositionClicked, this, _1));
|
||||
}
|
||||
|
||||
Framework::~Framework()
|
||||
|
@ -65,15 +58,6 @@ namespace android
|
|||
delete m_videoTimer;
|
||||
}
|
||||
|
||||
void Framework::OnPositionClicked(m2::PointD const & point)
|
||||
{
|
||||
string name = NativeFramework()->GetStringsBundle().GetString("my_position");
|
||||
ActivatePopup(point, name, "", IMAGE_ARROW);
|
||||
m_bmBaloon.get()->setOnClickListener(bind(&Framework::OnActivateMyPosition, this, _1));
|
||||
m_doUpdateBalloonPositionFromLocation = true;
|
||||
//TODO add listener to ballon for Java code
|
||||
}
|
||||
|
||||
void Framework::OnLocationError(int errorCode)
|
||||
{
|
||||
m_work.OnLocationError(static_cast<location::TLocationError>(errorCode));
|
||||
|
@ -87,14 +71,6 @@ namespace android
|
|||
info.m_longitude = lon;
|
||||
info.m_horizontalAccuracy = accuracy;
|
||||
|
||||
/// @todo don't forget to make cross-platform when we have our sexy-cross-platform balloons
|
||||
if (m_doUpdateBalloonPositionFromLocation)
|
||||
{
|
||||
GetBookmarkBalloon()->setGlbPivot(m2::PointD(MercatorBounds::LonToX(lon),
|
||||
MercatorBounds::LatToY(lat)));
|
||||
m_work.Invalidate();
|
||||
}
|
||||
|
||||
m_work.OnLocationUpdate(info);
|
||||
}
|
||||
|
||||
|
@ -105,6 +81,7 @@ namespace android
|
|||
info.m_magneticHeading = magneticNorth;
|
||||
info.m_trueHeading = trueNorth;
|
||||
info.m_accuracy = accuracy;
|
||||
|
||||
m_work.OnCompassUpdate(info);
|
||||
}
|
||||
|
||||
|
@ -190,12 +167,9 @@ namespace android
|
|||
return false;
|
||||
}
|
||||
|
||||
graphics::EDensity const density = m_work.GetRenderPolicy()->Density();
|
||||
m_images[IMAGE_ARROW] = ImageT("arrow.png", density);
|
||||
|
||||
m_work.SetUpdatesEnabled(true);
|
||||
m_work.EnterForeground();
|
||||
UpdateBalloonSize();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -229,7 +203,6 @@ namespace android
|
|||
void Framework::Resize(int w, int h)
|
||||
{
|
||||
m_work.OnSize(w, h);
|
||||
UpdateBalloonSize();
|
||||
}
|
||||
|
||||
void Framework::DrawFrame()
|
||||
|
@ -461,13 +434,6 @@ namespace android
|
|||
{
|
||||
m_doLoadState = false;
|
||||
|
||||
::Framework::AddressInfo info;
|
||||
info.MakeFrom(r);
|
||||
ActivatePopupWithAddressInfo(r.GetFeatureCenter(), info);
|
||||
|
||||
m2:: PointD globalPoint = r.GetFeatureCenter();
|
||||
m_bmBaloon.get()->setOnClickListener(bind(&Framework::OnActivatePoi, this, _1, info, globalPoint));
|
||||
|
||||
m_work.ShowSearchResult(r);
|
||||
}
|
||||
|
||||
|
@ -587,137 +553,8 @@ namespace android
|
|||
|
||||
void Framework::OnProcessTouchTask(double x, double y, unsigned ms)
|
||||
{
|
||||
// stop updating balloon position
|
||||
m_doUpdateBalloonPositionFromLocation = false;
|
||||
|
||||
m2::PointD pt(x, y);
|
||||
::Framework::AddressInfo addrInfo;
|
||||
m2::PointD pxPivot;
|
||||
BookmarkAndCategory bmAndCat;
|
||||
|
||||
url_scheme::ApiPoint apiPoint;
|
||||
bool const apiPointActivated = NativeFramework()->GetMapApiPoint(pt, apiPoint);
|
||||
if (apiPointActivated)
|
||||
{
|
||||
m2::PointD pivot(MercatorBounds::LonToX(apiPoint.m_lon),
|
||||
MercatorBounds::LatToY(apiPoint.m_lat));
|
||||
ActivatePopup(pivot, apiPoint.m_name, "", IMAGE_ARROW);
|
||||
m_bmBaloon.get()->setOnClickListener(bind(&Framework::OnActivateApiPoint, this, _1, apiPoint));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (m_work.GetBookmarkOrPoi(pt, pxPivot, addrInfo, bmAndCat))
|
||||
{
|
||||
case ::Framework::BOOKMARK:
|
||||
{
|
||||
Bookmark const * pBM = m_work.GetBmCategory(bmAndCat.first)->GetBookmark(bmAndCat.second);
|
||||
ActivatePopup(pBM->GetOrg(), pBM->GetName(), "", IMAGE_ARROW);
|
||||
m_bmBaloon.get()->setOnClickListener(bind(&Framework::OnActivateBookmark, this, _1, bmAndCat));
|
||||
return;
|
||||
}
|
||||
case ::Framework::POI:
|
||||
if (!GetBookmarkBalloon()->isVisible())
|
||||
{
|
||||
const m2::PointD globalPoint = m_work.PtoG(pxPivot);
|
||||
ActivatePopupWithAddressInfo(globalPoint, addrInfo);
|
||||
m_bmBaloon.get()->setOnClickListener(bind(&Framework::OnActivatePoi, this, _1, addrInfo, globalPoint));
|
||||
if (ms == LONG_TOUCH_MS)
|
||||
m_wasLongClick = true;
|
||||
return;
|
||||
}
|
||||
/* no break*/
|
||||
default:
|
||||
if (ms == LONG_TOUCH_MS)
|
||||
{
|
||||
m_work.GetAddressInfo(pt, addrInfo);
|
||||
const m2::PointD globalPoint = m_work.PtoG(pt);
|
||||
ActivatePopupWithAddressInfo(globalPoint, addrInfo);
|
||||
m_bmBaloon.get()->setOnClickListener(bind(&Framework::OnActivatePoi, this, _1, addrInfo, globalPoint));
|
||||
m_wasLongClick = true;
|
||||
return;
|
||||
}
|
||||
/* no break*/
|
||||
}
|
||||
}
|
||||
|
||||
DeactivatePopup();
|
||||
}
|
||||
|
||||
void Framework::ActivatePopupWithAddressInfo(m2::PointD const & pos, ::Framework::AddressInfo const & addrInfo)
|
||||
{
|
||||
string name = addrInfo.GetPinName();
|
||||
string type = addrInfo.GetPinType();
|
||||
if (name.empty() && type.empty())
|
||||
name = m_work.GetStringsBundle().GetString("dropped_pin");
|
||||
|
||||
ActivatePopup(pos, name, type, IMAGE_ARROW);
|
||||
|
||||
m_work.DrawPlacemark(pos);
|
||||
m_work.Invalidate();
|
||||
}
|
||||
|
||||
void Framework::ActivatePopup(m2::PointD const & pos, string const & name, string const & type, PopupImageIndexT index)
|
||||
{
|
||||
// stop updating balloon position
|
||||
m_doUpdateBalloonPositionFromLocation = false;
|
||||
|
||||
BookmarkBalloon * b = GetBookmarkBalloon();
|
||||
|
||||
m_work.DisablePlacemark();
|
||||
|
||||
b->setImage(m_images[index]);
|
||||
b->setGlbPivot(pos);
|
||||
b->setBookmarkCaption(name, type);
|
||||
b->showAnimated();
|
||||
|
||||
m_work.Invalidate();
|
||||
}
|
||||
|
||||
void Framework::DeactivatePopup()
|
||||
{
|
||||
m_doUpdateBalloonPositionFromLocation = false;
|
||||
|
||||
BookmarkBalloon * b = GetBookmarkBalloon();
|
||||
b->hide();
|
||||
|
||||
m_work.DisablePlacemark();
|
||||
m_work.Invalidate();
|
||||
}
|
||||
|
||||
void Framework::CreateBookmarkBalloon()
|
||||
{
|
||||
CHECK(m_work.GetGuiController(), ());
|
||||
|
||||
BookmarkBalloon::Params bp;
|
||||
bp.m_position = graphics::EPosAbove;
|
||||
bp.m_depth = graphics::balloonBaseDepth;
|
||||
bp.m_pivot = m2::PointD(0, 0);
|
||||
bp.m_mainText = "Bookmark";
|
||||
bp.m_framework = &m_work;
|
||||
|
||||
m_bmBaloon.reset(new BookmarkBalloon(bp));
|
||||
m_bmBaloon->setIsVisible(false);
|
||||
|
||||
m_work.GetGuiController()->AddElement(m_bmBaloon);
|
||||
|
||||
UpdateBalloonSize();
|
||||
}
|
||||
|
||||
void Framework::UpdateBalloonSize()
|
||||
{
|
||||
if (m_bmBaloon == NULL)
|
||||
return;
|
||||
|
||||
ScreenBase const & screen = m_work.GetNavigator().Screen();
|
||||
m_bmBaloon->onScreenSize(screen.GetWidth(), screen.GetHeight());
|
||||
}
|
||||
|
||||
BookmarkBalloon * Framework::GetBookmarkBalloon()
|
||||
{
|
||||
if (!m_bmBaloon)
|
||||
CreateBookmarkBalloon();
|
||||
return m_bmBaloon.get();
|
||||
m_wasLongClick = (ms == LONG_TOUCH_MS);
|
||||
GetBalloonManager().OnClick(m2::PointD(x, y), m_wasLongClick);
|
||||
}
|
||||
|
||||
BookmarkAndCategory Framework::AddBookmark(size_t cat, Bookmark & bm)
|
||||
|
@ -733,8 +570,6 @@ namespace android
|
|||
|
||||
void Framework::ReplaceBookmark(BookmarkAndCategory const & ind, Bookmark & bm)
|
||||
{
|
||||
m_bmType = bm.GetType();
|
||||
|
||||
BookmarkCategory * pCat = m_work.GetBmCategory(ind.first);
|
||||
pCat->ReplaceBookmark(ind.second, bm);
|
||||
pCat->SaveToKMLFile();
|
||||
|
@ -765,91 +600,16 @@ namespace android
|
|||
url_scheme::ApiPoint apiPoint;
|
||||
if (m_work.SetViewportByURL(url, apiPoint))
|
||||
{
|
||||
// we need it only for one-point-call
|
||||
m2::PointD const globalPoint(MercatorBounds::LonToX(apiPoint.m_lon), MercatorBounds::LatToY(apiPoint.m_lat));
|
||||
ActivatePopup(globalPoint, apiPoint.m_name, "", IMAGE_ARROW);
|
||||
|
||||
// For geo and ge0 draw placemark
|
||||
if (!strings::StartsWith(url, "mapswithme"))
|
||||
{
|
||||
m_work.DrawPlacemark(globalPoint);
|
||||
m_work.Invalidate();
|
||||
}
|
||||
|
||||
m_bmBaloon.get()->setOnClickListener(bind(&Framework::OnActivateApiPoint, this, _1, apiPoint));
|
||||
|
||||
GetBalloonManager().ShowApiPoint(apiPoint);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Framework::OnActivatePoi(gui::Element * e, ::Framework::AddressInfo const & addrInfo, m2::PointD const & globalPoint)
|
||||
void Framework::DeactivatePopup()
|
||||
{
|
||||
m_poiActivatedListener(addrInfo, globalPoint);
|
||||
GetBalloonManager().Hide();
|
||||
}
|
||||
|
||||
|
||||
void Framework::OnActivateBookmark(gui::Element * e, BookmarkAndCategory const & bmkAndCat)
|
||||
{
|
||||
m_bookmarkActivatedListener(bmkAndCat);
|
||||
}
|
||||
|
||||
void Framework::OnActivateApiPoint(gui::Element * e, url_scheme::ApiPoint const & apiPoint)
|
||||
{
|
||||
m_apiPointActivatedListener(apiPoint);
|
||||
}
|
||||
|
||||
void Framework::OnActivateMyPosition(gui::Element * e)
|
||||
{
|
||||
m2::PointD const & glbPoint = GetBookmarkBalloon()->glbPivot();
|
||||
const double lat = MercatorBounds::YToLat(glbPoint.y);
|
||||
const double lon = MercatorBounds::XToLon(glbPoint.x);
|
||||
m_myPositionActivatedListener(lat, lon);
|
||||
}
|
||||
|
||||
// POI
|
||||
void Framework::SetPoiActivatedListener(TOnPoiActivatedListener const & l)
|
||||
{
|
||||
m_poiActivatedListener = l;
|
||||
}
|
||||
|
||||
void Framework::ClearPoiActivatedListener()
|
||||
{
|
||||
m_poiActivatedListener.clear();
|
||||
}
|
||||
|
||||
// BOOKMARK
|
||||
void Framework::SetBookmarkActivatedListener(TOnBookmarkActivatedListener const & l)
|
||||
{
|
||||
m_bookmarkActivatedListener = l;
|
||||
}
|
||||
|
||||
void Framework::ClearBookmarkActivatedListener()
|
||||
{
|
||||
m_bookmarkActivatedListener.clear();
|
||||
}
|
||||
|
||||
// API point
|
||||
void Framework::SetApiPointActivatedListener(TOnApiPointActivatedListener const & l)
|
||||
{
|
||||
m_apiPointActivatedListener = l;
|
||||
}
|
||||
void Framework::ClearApiPointActivatedListener()
|
||||
{
|
||||
m_apiPointActivatedListener.clear();
|
||||
}
|
||||
|
||||
// My Position
|
||||
void Framework::SetOnMyPositionActivatedListener(TOnMyPositionActivatedListener const & l)
|
||||
{
|
||||
m_myPositionActivatedListener = l;
|
||||
}
|
||||
void Framework::ClearOnMyPositionActivatedListener()
|
||||
{
|
||||
m_myPositionActivatedListener.clear();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//============ GLUE CODE for com.mapswithme.maps.Framework class =============//
|
||||
|
@ -863,7 +623,6 @@ namespace android
|
|||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
// API
|
||||
void CallOnApiPointActivatedListener(shared_ptr<jobject> obj, url_scheme::ApiPoint const & apiPoint)
|
||||
{
|
||||
|
@ -879,7 +638,7 @@ extern "C"
|
|||
}
|
||||
|
||||
// POI
|
||||
void CallOnPoiActivatedListener(shared_ptr<jobject> obj, ::Framework::AddressInfo const & addrInfo, m2::PointD const & globalPoint)
|
||||
void CallOnPoiActivatedListener(shared_ptr<jobject> obj, m2::PointD const & globalPoint, search::AddressInfo const & addrInfo)
|
||||
{
|
||||
JNIEnv * jniEnv = jni::GetEnv();
|
||||
|
||||
|
@ -913,84 +672,35 @@ extern "C"
|
|||
jniEnv->CallVoidMethod(*obj.get(), methodId, lat, lon);
|
||||
}
|
||||
|
||||
// JNI EXPORTS
|
||||
//!!!!!!!!!!!!
|
||||
//!!!!!!!!!!!!
|
||||
//////////////
|
||||
/// @name JNI EXPORTS
|
||||
//@{
|
||||
JNIEXPORT jstring JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeGetNameAndAddress4Point(JNIEnv * env, jclass clazz, jdouble lat, jdouble lon)
|
||||
{
|
||||
search::AddressInfo info;
|
||||
|
||||
g_framework->NativeFramework()->GetAddressInfoForGlobalPoint(
|
||||
m2::PointD(MercatorBounds::LonToX(lon), MercatorBounds::LatToY(lat)), info);
|
||||
|
||||
m2::PointD point = m2::PointD( MercatorBounds::LonToX(lon),
|
||||
MercatorBounds::LatToY(lat));
|
||||
|
||||
::Framework * nativeFramework = g_framework->NativeFramework();
|
||||
return jni::ToJavaString(env, nativeFramework->GetNameAndAddressAtGlobalPoint(point));
|
||||
}
|
||||
|
||||
//API
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeSetApiPointActivatedListener(JNIEnv * env, jclass clazz, jobject l)
|
||||
{
|
||||
g_framework->SetApiPointActivatedListener(
|
||||
bind(&CallOnApiPointActivatedListener, jni::make_global_ref(l), _1));
|
||||
return jni::ToJavaString(env, info.FormatNameAndAddress());
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeClearApiPointActivatedListener(JNIEnv * env, jclass clazz, jobject l)
|
||||
Java_com_mapswithme_maps_Framework_nativeConnectBalloonListeners(JNIEnv * env, jclass clazz, jobject l)
|
||||
{
|
||||
g_framework->ClearApiPointActivatedListener();
|
||||
}
|
||||
BalloonManager & manager = g_framework->GetBalloonManager();
|
||||
shared_ptr<jobject> obj = jni::make_global_ref(l);
|
||||
|
||||
|
||||
// POI
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeSetOnPoiActivatedListener(JNIEnv * env, jclass clazz, jobject l)
|
||||
{
|
||||
g_framework->SetPoiActivatedListener(
|
||||
bind(&CallOnPoiActivatedListener, jni::make_global_ref(l), _1, _2));
|
||||
manager.ConnectApiListener(bind(&CallOnApiPointActivatedListener, obj, _1));
|
||||
manager.ConnectPoiListener(bind(&CallOnPoiActivatedListener, obj, _1, _2));
|
||||
manager.ConnectBookmarkListener(bind(&CallOnBookmarkActivatedListener, obj, _1));
|
||||
manager.ConnectPositionListener(bind(&CallOnMyPositionActivatedListener, obj, _1, _2));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeClearOnPoiActivatedListener(JNIEnv * env, jclass clazz)
|
||||
Java_com_mapswithme_maps_Framework_nativeClearBalloonListeners(JNIEnv * env, jobject thiz)
|
||||
{
|
||||
g_framework->ClearPoiActivatedListener();
|
||||
}
|
||||
|
||||
|
||||
// Bookmark
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeSetOnBookmarkActivatedListener(JNIEnv * env, jclass clazz, jobject l)
|
||||
{
|
||||
g_framework->SetBookmarkActivatedListener(
|
||||
bind(&CallOnBookmarkActivatedListener, jni::make_global_ref(l), _1));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeClearOnBookmarkActivatedListener(JNIEnv * env, jclass clazz)
|
||||
{
|
||||
g_framework->ClearBookmarkActivatedListener();
|
||||
}
|
||||
|
||||
// My Position
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeSetOnMyPositionActivatedListener(JNIEnv * env, jclass clazz, jobject l)
|
||||
{
|
||||
g_framework->SetOnMyPositionActivatedListener(
|
||||
bind(&CallOnMyPositionActivatedListener, jni::make_global_ref(l), _1, _2));
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeClearOnMyPositionActivatedListener(JNIEnv * env, jclass clazz)
|
||||
{
|
||||
g_framework->ClearOnMyPositionActivatedListener();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_mapswithme_maps_Framework_nativeClearApiPoints(JNIEnv * env, jobject thiz)
|
||||
{
|
||||
g_framework->NativeFramework()->ClearMapApiPoints();
|
||||
g_framework->GetBalloonManager().ClearListeners();
|
||||
}
|
||||
|
||||
JNIEXPORT jstring JNICALL
|
||||
|
|
|
@ -30,24 +30,6 @@ namespace android
|
|||
|
||||
void CallRepaint();
|
||||
|
||||
/* Balloon */
|
||||
// POI
|
||||
typedef function<void (::Framework::AddressInfo const &, m2::PointD const &)> TOnPoiActivatedListener;
|
||||
TOnPoiActivatedListener m_poiActivatedListener;
|
||||
// Bookmark
|
||||
typedef function<void (BookmarkAndCategory const &)> TOnBookmarkActivatedListener;
|
||||
TOnBookmarkActivatedListener m_bookmarkActivatedListener;
|
||||
// API point
|
||||
typedef function<void (url_scheme::ApiPoint const &)> TOnApiPointActivatedListener;
|
||||
TOnApiPointActivatedListener m_apiPointActivatedListener;
|
||||
// My Position
|
||||
typedef function<void (double, double)> TOnMyPositionActivatedListener;
|
||||
TOnMyPositionActivatedListener m_myPositionActivatedListener;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
double m_x1;
|
||||
double m_y1;
|
||||
double m_x2;
|
||||
|
@ -56,7 +38,6 @@ namespace android
|
|||
|
||||
bool m_doLoadState;
|
||||
|
||||
|
||||
/// @name Single click processing parameters.
|
||||
//@{
|
||||
my::Timer m_doubleClickTimer;
|
||||
|
@ -74,30 +55,6 @@ namespace android
|
|||
void KillTouchTask();
|
||||
void OnProcessTouchTask(double x, double y, unsigned ms);
|
||||
|
||||
typedef graphics::Image::Info ImageT;
|
||||
ImageT m_images[1];
|
||||
enum PopupImageIndexT {IMAGE_ARROW = 0};
|
||||
|
||||
void ActivatePopup(m2::PointD const & pos, string const & name, string const & type, PopupImageIndexT index);
|
||||
void ActivatePopupWithAddressInfo(m2::PointD const & pos, ::Framework::AddressInfo const & addrInfo);
|
||||
|
||||
void UpdateBalloonSize();
|
||||
|
||||
shared_ptr<BookmarkBalloon> m_bmBaloon;
|
||||
string m_bmType;
|
||||
|
||||
// Balloon click callbacks
|
||||
void OnActivatePoi(gui::Element * e, ::Framework::AddressInfo const & addrInfo, m2::PointD const & globalPoint);
|
||||
void OnActivateBookmark(gui::Element * e, BookmarkAndCategory const & bmkAndCat);
|
||||
void OnActivateApiPoint(gui::Element * e, url_scheme::ApiPoint const & apiPoint);
|
||||
void OnActivateMyPosition(gui::Element * e);
|
||||
|
||||
|
||||
void CreateBookmarkBalloon();
|
||||
BookmarkBalloon * GetBookmarkBalloon();
|
||||
void OnPositionClicked(m2::PointD const & point);
|
||||
bool m_doUpdateBalloonPositionFromLocation;
|
||||
|
||||
string m_searchQuery;
|
||||
|
||||
void SetBestDensity(int densityDpi, RenderPolicy::Params & params);
|
||||
|
@ -164,31 +121,13 @@ namespace android
|
|||
size_t ChangeBookmarkCategory(BookmarkAndCategory const & ind, size_t newCat);
|
||||
|
||||
::Framework * NativeFramework();
|
||||
BalloonManager & GetBalloonManager() { return m_work.GetBalloonManager(); }
|
||||
|
||||
bool IsDownloadingActive();
|
||||
|
||||
bool SetViewportByUrl(string const & ulr);
|
||||
|
||||
void DeactivatePopup();
|
||||
|
||||
/*
|
||||
* There glue code listeners started
|
||||
* to show their ugly (inter)faces!
|
||||
*/
|
||||
|
||||
// POI
|
||||
void SetPoiActivatedListener(TOnPoiActivatedListener const & l);
|
||||
void ClearPoiActivatedListener();
|
||||
// BOOKMARK
|
||||
void SetBookmarkActivatedListener(TOnBookmarkActivatedListener const & l);
|
||||
void ClearBookmarkActivatedListener();
|
||||
// API point
|
||||
void SetApiPointActivatedListener(TOnApiPointActivatedListener const & l);
|
||||
void ClearApiPointActivatedListener();
|
||||
// My Position
|
||||
void SetOnMyPositionActivatedListener(TOnMyPositionActivatedListener const & l);
|
||||
void ClearOnMyPositionActivatedListener();
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -8,35 +8,14 @@ import com.mapswithme.maps.bookmarks.data.DistanceAndAzimut;
|
|||
*/
|
||||
public class Framework
|
||||
{
|
||||
|
||||
// API
|
||||
public interface OnApiPointActivatedListener
|
||||
public interface OnBalloonListener
|
||||
{
|
||||
public void onApiPointActivated(double lat, double lon, String name, String id);
|
||||
}
|
||||
|
||||
|
||||
// POI
|
||||
public interface OnPoiActivatedListener
|
||||
{
|
||||
public void onPoiActivated(String name, String type, String address, double lat, double lon);
|
||||
}
|
||||
|
||||
|
||||
// Bookmark
|
||||
public interface OnBookmarkActivatedListener
|
||||
{
|
||||
public void onBookmarkActivated(int category, int bookmarkIndex);
|
||||
}
|
||||
|
||||
//My Position
|
||||
public interface OnMyPositionActivatedListener
|
||||
{
|
||||
public void onMyPositionActivated(double lat, double lon);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Interface
|
||||
|
||||
public static String getGe0Url(double lat, double lon, double zoomLevel, String name)
|
||||
|
@ -54,49 +33,14 @@ public class Framework
|
|||
return nativeGetNameAndAddress4Point(lat, lon);
|
||||
}
|
||||
|
||||
// API
|
||||
public static void setOnApiPointActivatedListener(OnApiPointActivatedListener listener)
|
||||
public static void connectBalloonListeners(OnBalloonListener listener)
|
||||
{
|
||||
nativeSetApiPointActivatedListener(listener);
|
||||
nativeConnectBalloonListeners(listener);
|
||||
}
|
||||
|
||||
public static void clearOnApiPointActivatedListener()
|
||||
public static void clearBalloonListeners()
|
||||
{
|
||||
nativeClearApiPointActivatedListener();
|
||||
}
|
||||
|
||||
|
||||
// POI
|
||||
public static void setOnPoiActivatedListener(OnApiPointActivatedListener listener)
|
||||
{
|
||||
nativeSetOnPoiActivatedListener(listener);
|
||||
}
|
||||
|
||||
public static void clearOnPoiActivatedListener()
|
||||
{
|
||||
nativeClearOnPoiActivatedListener();
|
||||
}
|
||||
|
||||
// Bookmark
|
||||
public static void setOnBookmarkActivatedListener(OnBookmarkActivatedListener listener)
|
||||
{
|
||||
nativeSetOnBookmarkActivatedListener(listener);
|
||||
}
|
||||
|
||||
public static void clearOnBookmarkActivatedListener()
|
||||
{
|
||||
nativeClearOnBookmarkActivatedListener();
|
||||
}
|
||||
|
||||
// My Position
|
||||
public static void setOnMyPositionActivatedListener(OnMyPositionActivatedListener listener)
|
||||
{
|
||||
nativeSetOnMyPositionActivatedListener(listener);
|
||||
}
|
||||
|
||||
public static void clearOnMyPositionActivatedListener()
|
||||
{
|
||||
nativeClearOnMyPositionActivatedListener();
|
||||
nativeClearBalloonListeners();
|
||||
}
|
||||
|
||||
public static void clearApiPoints()
|
||||
|
@ -130,18 +74,8 @@ public class Framework
|
|||
private native static String nativeGetGe0Url(double lat, double lon, double zoomLevel, String name);
|
||||
private native static String nativeGetNameAndAddress4Point(double lat, double lon);
|
||||
|
||||
// API point
|
||||
private native static void nativeSetApiPointActivatedListener(OnApiPointActivatedListener listener);
|
||||
private native static void nativeClearApiPointActivatedListener();
|
||||
// POI
|
||||
private native static void nativeSetOnPoiActivatedListener(OnApiPointActivatedListener listener);
|
||||
private native static void nativeClearOnPoiActivatedListener();
|
||||
// Bookmark
|
||||
private native static void nativeSetOnBookmarkActivatedListener(OnBookmarkActivatedListener listener);
|
||||
private native static void nativeClearOnBookmarkActivatedListener();
|
||||
// My Position
|
||||
private native static void nativeSetOnMyPositionActivatedListener(OnMyPositionActivatedListener listener);
|
||||
private native static void nativeClearOnMyPositionActivatedListener();
|
||||
private native static void nativeConnectBalloonListeners(OnBalloonListener listener);
|
||||
private native static void nativeClearBalloonListeners();
|
||||
|
||||
private native static void nativeClearApiPoints();
|
||||
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
package com.mapswithme.maps;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Locale;
|
||||
import java.util.Stack;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
|
@ -31,10 +35,7 @@ import android.widget.LinearLayout;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.mapswithme.maps.Framework.OnApiPointActivatedListener;
|
||||
import com.mapswithme.maps.Framework.OnBookmarkActivatedListener;
|
||||
import com.mapswithme.maps.Framework.OnMyPositionActivatedListener;
|
||||
import com.mapswithme.maps.Framework.OnPoiActivatedListener;
|
||||
import com.mapswithme.maps.Framework.OnBalloonListener;
|
||||
import com.mapswithme.maps.api.MWMRequest;
|
||||
import com.mapswithme.maps.bookmarks.BookmarkCategoriesActivity;
|
||||
import com.mapswithme.maps.location.LocationService;
|
||||
|
@ -46,16 +47,10 @@ import com.mapswithme.util.ConnectionState;
|
|||
import com.mapswithme.util.Utils;
|
||||
import com.nvidia.devtech.NvEventQueueActivity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Locale;
|
||||
import java.util.Stack;
|
||||
|
||||
public class MWMActivity extends NvEventQueueActivity
|
||||
implements LocationService.Listener, OnApiPointActivatedListener,
|
||||
OnBookmarkActivatedListener, OnPoiActivatedListener, OnMyPositionActivatedListener
|
||||
public class MWMActivity extends NvEventQueueActivity implements LocationService.Listener, OnBalloonListener
|
||||
{
|
||||
public static final String EXTRA_TASK = "map_task";
|
||||
|
||||
|
||||
private static final int PRO_VERSION_DIALOG = 110001;
|
||||
private static final String PRO_VERSION_DIALOG_MSG = "pro_version_dialog_msg";
|
||||
private static final int PROMO_DIALOG = 110002;
|
||||
|
@ -75,7 +70,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
private TextView mAppTitle;
|
||||
// Map tasks that we run AFTER rendering initialized
|
||||
private Stack<MapTask> mTasks = new Stack<MWMActivity.MapTask>();
|
||||
|
||||
|
||||
|
||||
|
||||
//showDialog(int, Bundle) available only form API 8
|
||||
|
@ -190,9 +185,9 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
checkBuyProDialog();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Task are not UI-thread bounded,
|
||||
// if any task need UI-thread it should implicitly
|
||||
// if any task need UI-thread it should implicitly
|
||||
// use Activity.runOnUiThread().
|
||||
while (!mTasks.isEmpty())
|
||||
mTasks.pop().run(this);
|
||||
|
@ -580,28 +575,22 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
|
||||
alignZoomButtons();
|
||||
|
||||
Framework.setOnBookmarkActivatedListener(this);
|
||||
Framework.setOnPoiActivatedListener(this);
|
||||
Framework.setOnMyPositionActivatedListener(this);
|
||||
Framework.setOnApiPointActivatedListener(this);
|
||||
|
||||
Framework.connectBalloonListeners(this);
|
||||
|
||||
Intent intent = getIntent();
|
||||
// We need check for tasks both in onCreate and onNewIntent
|
||||
// because of bug in OS: https://code.google.com/p/android/issues/detail?id=38629
|
||||
addTask(intent);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onDestroy()
|
||||
{
|
||||
Framework.clearOnBookmarkActivatedListener();
|
||||
Framework.clearOnPoiActivatedListener();
|
||||
Framework.clearOnMyPositionActivatedListener();
|
||||
Framework.clearOnApiPointActivatedListener();
|
||||
|
||||
Framework.clearBalloonListeners();
|
||||
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent)
|
||||
{
|
||||
|
@ -611,7 +600,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
|
||||
private void addTask(Intent intent)
|
||||
{
|
||||
if (intent != null
|
||||
if (intent != null
|
||||
&& intent.hasExtra(EXTRA_TASK)
|
||||
&& ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0))
|
||||
{
|
||||
|
@ -621,7 +610,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
}
|
||||
setIntent(null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onStop()
|
||||
{
|
||||
|
@ -822,7 +811,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
mTitleBar.setVisibility(View.VISIBLE);
|
||||
|
||||
marginTopForMap = (int) getResources().getDimension(R.dimen.abs__action_bar_default_height);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// hide title
|
||||
|
@ -1033,27 +1022,27 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
m_externalStorageReceiver = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
////
|
||||
// Map TASKS
|
||||
////
|
||||
|
||||
public interface MapTask extends Serializable
|
||||
|
||||
public interface MapTask extends Serializable
|
||||
{
|
||||
public boolean run(MWMActivity target);
|
||||
}
|
||||
|
||||
|
||||
public static class OpenUrlTask implements MapTask
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final String mUrl;
|
||||
|
||||
public OpenUrlTask(String url)
|
||||
|
||||
public OpenUrlTask(String url)
|
||||
{
|
||||
Utils.checkNotNull(url);
|
||||
mUrl = url;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean run(MWMActivity target)
|
||||
{
|
||||
|
@ -1061,29 +1050,29 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
////
|
||||
// NATIVE callbacks and methods
|
||||
////
|
||||
|
||||
|
||||
@Override
|
||||
public void onApiPointActivated(final double lat, final double lon, final String name, final String id)
|
||||
{
|
||||
if (MWMRequest.hasRequest())
|
||||
MWMRequest.getCurrentRequest().setPointData(lat, lon, name, id);
|
||||
// This is case for "mwm" scheme,
|
||||
// if point is from "geo" or "ge0" - this is wrong. So we check here.
|
||||
|
||||
runOnUiThread(new Runnable()
|
||||
if (MWMRequest.hasRequest())
|
||||
MWMRequest.getCurrentRequest().setPointData(lat, lon, name, id);
|
||||
// This is case for "mwm" scheme,
|
||||
// if point is from "geo" or "ge0" - this is wrong. So we check here.
|
||||
|
||||
runOnUiThread(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
MapObjectActivity.startWithApiPoint(getActivity(), name, null, null, lat, lon);
|
||||
}
|
||||
});
|
||||
MapObjectActivity.startWithApiPoint(getActivity(), name, null, null, lat, lon);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onPoiActivated(final String name, final String type, final String address, final double lat, final double lon)
|
||||
{
|
||||
|
@ -1096,7 +1085,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBookmarkActivated(final int category, final int bookmarkIndex)
|
||||
{
|
||||
|
@ -1109,7 +1098,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onMyPositionActivated(final double lat, final double lon)
|
||||
{
|
||||
|
@ -1122,7 +1111,7 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private native void nativeStorageConnected();
|
||||
private native void nativeStorageDisconnected();
|
||||
|
||||
|
@ -1136,6 +1125,6 @@ public class MWMActivity extends NvEventQueueActivity
|
|||
private native void nativeCompassUpdated(long time, double magneticNorth, double trueNorth, double accuracy);
|
||||
|
||||
private native boolean nativeIsInChina(double lat, double lon);
|
||||
|
||||
|
||||
private native boolean setViewPortByUrl(String url);
|
||||
}
|
||||
|
|
|
@ -142,7 +142,7 @@ HEADERS += \
|
|||
vertex_stream.hpp \
|
||||
path_view.hpp \
|
||||
path.hpp \
|
||||
depth_constants.hpp
|
||||
depth_constants.hpp \
|
||||
|
||||
win32* {
|
||||
SOURCES += opengl/opengl_win32.cpp
|
||||
|
|
|
@ -23,11 +23,8 @@
|
|||
@property(nonatomic, retain) NSString * setName;
|
||||
|
||||
|
||||
- (id) initWithTarget:(id)target andSelector:(SEL)selector;
|
||||
- (void) showInView;
|
||||
- (void) hide;
|
||||
- (id) initWithTarget:(id)target;
|
||||
- (void) clear;
|
||||
- (BOOL) isDisplayed;
|
||||
|
||||
// Kosher method to add bookmark into the Framework.
|
||||
// It automatically "edits" bookmark if it's already exists
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
@synthesize setName;
|
||||
|
||||
|
||||
- (id) initWithTarget:(id)target andSelector:(SEL)selector;
|
||||
- (id) initWithTarget:(id)target
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
|
@ -31,29 +31,6 @@
|
|||
// default bookmark name.
|
||||
self.title = [NSString stringWithUTF8String:f.GetBmCategory(f.LastEditedCategory())->GetName().c_str()];
|
||||
|
||||
// Init balloon.
|
||||
BookmarkBalloon::Params bp;
|
||||
bp.m_position = graphics::EPosAbove;
|
||||
bp.m_depth = graphics::balloonBaseDepth;
|
||||
bp.m_pivot = m2::PointD(0, 0);
|
||||
bp.m_mainText = "Bookmark";
|
||||
bp.m_framework = &f;
|
||||
|
||||
m_balloon.reset(new BookmarkBalloon(bp));
|
||||
m_balloon->setIsVisible(false);
|
||||
|
||||
typedef void (*fireBalloonFnT)(id, SEL);
|
||||
fireBalloonFnT fn = (fireBalloonFnT)[target methodForSelector:selector];
|
||||
m_balloon->setOnClickListener(bind(fn, target, selector));
|
||||
|
||||
f.GetGuiController()->AddElement(m_balloon);
|
||||
|
||||
graphics::EDensity const density = graphics::EDensityMDPI;//f.GetRenderPolicy()->Density();
|
||||
m_images[0] = graphics::Image::Info("plus.png", density);
|
||||
m_images[1] = graphics::Image::Info("arrow.png", density);
|
||||
|
||||
[self updateBalloonSize];
|
||||
|
||||
// load bookmarks from kml files
|
||||
f.LoadBookmarks();
|
||||
|
||||
|
@ -62,12 +39,6 @@
|
|||
return self;
|
||||
}
|
||||
|
||||
- (void) updateBalloonSize
|
||||
{
|
||||
ScreenBase const & s = GetFramework().GetNavigator().Screen();
|
||||
m_balloon->onScreenSize(s.GetWidth(), s.GetHeight());
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
self.color = nil;
|
||||
|
@ -77,32 +48,12 @@
|
|||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) showInView
|
||||
{
|
||||
m_balloon->setImage(m_images[0]);
|
||||
m_balloon->setBookmarkCaption([title UTF8String], "");
|
||||
m_balloon->setGlbPivot(m2::PointD(globalPosition.x, globalPosition.y));
|
||||
|
||||
[self updateBalloonSize];
|
||||
m_balloon->showAnimated();
|
||||
}
|
||||
|
||||
- (void) hide
|
||||
{
|
||||
m_balloon->hide();
|
||||
}
|
||||
|
||||
-(void)clear
|
||||
{
|
||||
self.notes = nil;
|
||||
self.editedBookmark = MakeEmptyBookmarkAndCategory();
|
||||
}
|
||||
|
||||
- (BOOL) isDisplayed
|
||||
{
|
||||
return m_balloon->isVisible();
|
||||
}
|
||||
|
||||
- (void) addOrEditBookmark
|
||||
{
|
||||
if (IsValid(self.editedBookmark))
|
||||
|
|
|
@ -6,6 +6,10 @@
|
|||
#import "MapsAppDelegate.h"
|
||||
#import "MapViewController.h"
|
||||
|
||||
#include "Framework.h"
|
||||
#include "../../search/result.hpp"
|
||||
|
||||
|
||||
@interface PinPickerView : UIView
|
||||
|
||||
- (id)initWithImage:(UIImage *)image;
|
||||
|
@ -424,8 +428,10 @@ static NSString * const g_colors [] =
|
|||
|
||||
if ([textFieldText isEqualToString:NSLocalizedString(@"my_position", nil)])
|
||||
{
|
||||
search::AddressInfo info;
|
||||
m2::PointD pt = m2::PointD(m_balloon.globalPosition.x, m_balloon.globalPosition.y);
|
||||
NSString * nameAndAddress = [NSString stringWithUTF8String:GetFramework().GetNameAndAddressAtGlobalPoint(pt).c_str()];
|
||||
GetFramework().GetAddressInfoForGlobalPoint(pt, info);
|
||||
NSString * nameAndAddress = [NSString stringWithUTF8String:info.FormatNameAndAddress().c_str()];
|
||||
[mailVC setMessageBody:[NSString stringWithFormat:NSLocalizedString(@"my_position_share_email", nil), nameAndAddress, shortUrl, httpGe0Url] isHTML:NO];
|
||||
[mailVC setSubject:NSLocalizedString(@"my_position_share_email_subject", nil)];
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "../../std/shared_ptr.hpp"
|
||||
|
||||
@class BalloonView;
|
||||
|
||||
class VideoTimer;
|
||||
class RenderPolicy;
|
||||
|
@ -36,8 +35,6 @@ namespace graphics
|
|||
CGRect lastViewSize;
|
||||
}
|
||||
|
||||
@property(nonatomic, retain) BalloonView * balloonView;
|
||||
|
||||
- (void) initRenderPolicy;
|
||||
- (CGPoint) viewPoint2GlobalPoint:(CGPoint)pt;
|
||||
- (CGPoint) globalPoint2ViewPoint:(CGPoint)pt;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
#import <OpenGLES/EAGLDrawable.h>
|
||||
|
||||
#import "EAGLView.h"
|
||||
#import "BalloonView.h"
|
||||
|
||||
#include "RenderBuffer.hpp"
|
||||
#include "RenderContext.hpp"
|
||||
|
@ -19,9 +18,9 @@
|
|||
|
||||
#include "../../std/bind.hpp"
|
||||
|
||||
|
||||
@implementation EAGLView
|
||||
|
||||
@synthesize balloonView;
|
||||
|
||||
// You must implement this method
|
||||
+ (Class)layerClass
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
#include "../../geometry/point2d.hpp"
|
||||
#include "../../geometry/rect2d.hpp"
|
||||
|
||||
#include "Framework.h"
|
||||
|
||||
namespace search { struct AddressInfo; }
|
||||
@class BalloonView;
|
||||
|
||||
@interface MapViewController : UIViewController <LocationObserver, UIAlertViewDelegate, UIPopoverControllerDelegate>
|
||||
|
@ -20,7 +20,7 @@
|
|||
bool m_isSticking;
|
||||
size_t m_StickyThreshold;
|
||||
m2::PointD m_Pt1, m_Pt2;
|
||||
|
||||
|
||||
BalloonView * m_balloonView;
|
||||
/// Temporary solution to improve long touch detection.
|
||||
m2::PointD m_touchDownPoint;
|
||||
|
@ -39,9 +39,8 @@
|
|||
- (IBAction)OnSearchClicked:(id)sender;
|
||||
- (IBAction)OnBookmarksClicked:(id)sender;
|
||||
|
||||
- (void)showSearchResultAsBookmarkAtMercatorPoint:(m2::PointD const &)pt withInfo:(Framework::AddressInfo const &)info;
|
||||
- (void)showBalloonWithCategoryIndex:(int)index andBookmarkIndex:(int)bmIndex;
|
||||
- (void)showBalloonWithText:(NSString *)text andGlobalPoint:(m2::PointD) point;
|
||||
- (void)showSearchResultAsBookmarkAtMercatorPoint:(m2::PointD const &)pt withInfo:(search::AddressInfo const &)info;
|
||||
- (void)showBalloonWithCategoryIndex:(int)cat andBookmarkIndex:(int)bm;
|
||||
|
||||
- (void)dismissPopoverAndSaveBookmark:(BOOL)save;
|
||||
- (void)prepareForApi;
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
|
||||
#import "../../Common/CustomAlertView.h"
|
||||
|
||||
#include "Framework.h"
|
||||
#include "RenderContext.hpp"
|
||||
|
||||
#include "../../../anim/controller.hpp"
|
||||
|
||||
#include "../../../gui/controller.hpp"
|
||||
|
@ -19,10 +22,9 @@
|
|||
|
||||
#include "../Statistics/Statistics.h"
|
||||
|
||||
#include "RenderContext.hpp"
|
||||
|
||||
#include "../../../map/dialog_settings.hpp"
|
||||
|
||||
|
||||
#define FACEBOOK_ALERT_VIEW 1
|
||||
#define APPSTORE_ALERT_VIEW 2
|
||||
#define BALLOON_PROPOSAL_ALERT_VIEW 11
|
||||
|
@ -122,26 +124,6 @@ const long long LITE_IDL = 431183278L;
|
|||
}
|
||||
}
|
||||
|
||||
//fires when user taps on dot or arrow on the screen
|
||||
-(void) onMyPosionClick:(m2::PointD const &) point
|
||||
{
|
||||
Framework &f = GetFramework();
|
||||
BookmarkAndCategory const bmAndCat = f.GetBookmark(f.GtoP(point));
|
||||
if (IsValid(bmAndCat))
|
||||
{
|
||||
if (f.GetBmCategory(bmAndCat.first)->IsVisible())
|
||||
{
|
||||
[self onBookmarkClickWithBookmarkAndCategory:bmAndCat];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[m_balloonView clear];
|
||||
[m_balloonView setTitle:NSLocalizedString(@"my_position", nil)];
|
||||
m_balloonView.globalPosition = CGPointMake(point.x, point.y);
|
||||
[m_balloonView showInView];
|
||||
}
|
||||
|
||||
//********************************************************************************************
|
||||
//********************************************************************************************
|
||||
|
||||
|
@ -240,7 +222,7 @@ const long long LITE_IDL = 431183278L;
|
|||
[navC release];
|
||||
}
|
||||
|
||||
- (void) onBalloonClicked
|
||||
- (void) onBalloonClicked:(m2::PointD const &)pt withInfo:(search::AddressInfo const &)info
|
||||
{
|
||||
// Disable bookmarks for free version
|
||||
if (!GetPlatform().IsPro())
|
||||
|
@ -283,7 +265,7 @@ const long long LITE_IDL = 431183278L;
|
|||
int categoryPos = f.LastEditedCategory();
|
||||
[m_balloonView addBookmarkToCategory:categoryPos];
|
||||
}
|
||||
[m_balloonView hide];
|
||||
|
||||
[placePageVC release];
|
||||
}
|
||||
}
|
||||
|
@ -296,76 +278,9 @@ const long long LITE_IDL = 431183278L;
|
|||
[self Invalidate];
|
||||
}
|
||||
|
||||
- (void) updatePinTexts:(Framework::AddressInfo const &)info
|
||||
{
|
||||
NSString * res = [NSString stringWithUTF8String:info.m_name.c_str()];
|
||||
|
||||
char const * cType = info.GetBestType();
|
||||
if (cType)
|
||||
{
|
||||
NSString * type = [NSString stringWithUTF8String:cType];
|
||||
|
||||
if (res.length == 0)
|
||||
res = [type capitalizedString];
|
||||
else
|
||||
res = [NSString stringWithFormat:@"%@ (%@)", res, type];
|
||||
}
|
||||
|
||||
if (res.length == 0)
|
||||
res = NSLocalizedString(@"dropped_pin", nil);
|
||||
|
||||
// Reset description BEFORE title, as title's setter also takes it into an account for Balloon text generation
|
||||
m_balloonView.notes = nil;
|
||||
m_balloonView.title = res;
|
||||
//m_balloonView.notes = [NSString stringWithUTF8String:info.FormatAddress().c_str()];
|
||||
//m_balloonView.type = [NSString stringWithUTF8String:info.FormatTypes().c_str()];
|
||||
}
|
||||
|
||||
|
||||
- (void) processMapClickAtPoint:(CGPoint)point longClick:(BOOL)isLongClick
|
||||
{
|
||||
BOOL wasBalloonDisplayed;
|
||||
if ([m_balloonView isDisplayed])
|
||||
{
|
||||
[m_balloonView hide];
|
||||
[m_balloonView clear];
|
||||
wasBalloonDisplayed = YES;
|
||||
}
|
||||
else
|
||||
wasBalloonDisplayed = NO;
|
||||
|
||||
// Try to check if we've clicked on bookmark
|
||||
Framework & f = GetFramework();
|
||||
CGFloat const scaleFactor = self.view.contentScaleFactor;
|
||||
|
||||
m2::PointD pxClicked(point.x * scaleFactor, point.y * scaleFactor);
|
||||
Framework::AddressInfo addrInfo;
|
||||
m2::PointD pxPivot;
|
||||
BookmarkAndCategory bmAndCat;
|
||||
switch (f.GetBookmarkOrPoi(pxClicked, pxPivot, addrInfo, bmAndCat))
|
||||
{
|
||||
case Framework::BOOKMARK:
|
||||
[self onBookmarkClickWithBookmarkAndCategory:bmAndCat];
|
||||
break;
|
||||
case Framework::POI:
|
||||
if (!wasBalloonDisplayed && f.GetVisiblePOI(pxClicked, pxPivot, addrInfo))
|
||||
{
|
||||
m2::PointD const gPivot = f.PtoG(pxPivot);
|
||||
m_balloonView.globalPosition = CGPointMake(gPivot.x, gPivot.y);
|
||||
[self updatePinTexts:addrInfo];
|
||||
[m_balloonView showInView];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (isLongClick)
|
||||
{
|
||||
f.GetAddressInfo(pxClicked, addrInfo);
|
||||
m_balloonView.globalPosition = [(EAGLView *)self.view viewPoint2GlobalPoint:point];
|
||||
[self updatePinTexts:addrInfo];
|
||||
[m_balloonView showInView];
|
||||
}
|
||||
break;
|
||||
}
|
||||
GetFramework().GetBalloonManager().OnClick(m2::PointD(point.x, point.y), isLongClick == YES);
|
||||
}
|
||||
|
||||
- (void) onSingleTap:(NSValue *)point
|
||||
|
@ -378,12 +293,14 @@ const long long LITE_IDL = 431183278L;
|
|||
[self processMapClickAtPoint:[point CGPointValue] longClick:YES];
|
||||
}
|
||||
|
||||
- (void)showSearchResultAsBookmarkAtMercatorPoint:(m2::PointD const &)pt withInfo:(Framework::AddressInfo const &)info
|
||||
- (void)showSearchResultAsBookmarkAtMercatorPoint:(const m2::PointD &)pt withInfo:(const search::AddressInfo &)info
|
||||
{
|
||||
[m_balloonView clear];
|
||||
m_balloonView.globalPosition = CGPointMake(pt.x, pt.y);
|
||||
[self updatePinTexts:info];
|
||||
[m_balloonView showInView];
|
||||
GetFramework().GetBalloonManager().ShowAddress(pt, info);
|
||||
}
|
||||
|
||||
- (void)showBalloonWithCategoryIndex:(int)cat andBookmarkIndex:(int)bm
|
||||
{
|
||||
// TODO:
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
|
@ -401,32 +318,32 @@ const long long LITE_IDL = 431183278L;
|
|||
self.title = NSLocalizedString(@"back", @"Back button in nav bar to show the map");
|
||||
|
||||
// Helper to display/hide pin on screen tap
|
||||
m_balloonView = [[BalloonView alloc] initWithTarget:self andSelector:@selector(onBalloonClicked)];
|
||||
|
||||
// @TODO refactor cyclic dependence.
|
||||
// Here we're creating view and window handle in it, and later we should pass framework to the view.
|
||||
EAGLView * v = (EAGLView *)self.view;
|
||||
// @TODO implement balloon view in a cross-platform code
|
||||
v.balloonView = m_balloonView;
|
||||
m_balloonView = [[BalloonView alloc] initWithTarget:self];
|
||||
|
||||
Framework & f = GetFramework();
|
||||
|
||||
typedef void (*onCompassStatusChangedFn)(id, SEL, int);
|
||||
SEL onCompassStatusChangedSel = @selector(onCompassStatusChanged:);
|
||||
onCompassStatusChangedFn onCompassStatusChangedImpl = (onCompassStatusChangedFn)[self methodForSelector:onCompassStatusChangedSel];
|
||||
|
||||
typedef void (*onMyPositionClickedFn)(id, SEL, m2::PointD const &);
|
||||
SEL onMyPositionClickedSel = @selector(onMyPosionClick:);
|
||||
onMyPositionClickedFn onMyPosiionClickedImpl = (onMyPositionClickedFn)[self methodForSelector:onMyPositionClickedSel];
|
||||
// Init balloon callbacks.
|
||||
// TODO -----------------------------------------------------------------------------------------------
|
||||
typedef void (*BalloonFnT)(id, SEL, m2::PointD const &, search::AddressInfo const &);
|
||||
SEL balloonSelector = @selector(onBalloonClicked:withInfo:);
|
||||
BalloonFnT balloonFn = (BalloonFnT)[self methodForSelector:balloonSelector];
|
||||
|
||||
BalloonManager & manager = f.GetBalloonManager();
|
||||
manager.ConnectPoiListener(bind(balloonFn, self, balloonSelector, _1, _2));
|
||||
// TODO -----------------------------------------------------------------------------------------------
|
||||
|
||||
typedef void (*CompassStatusFnT)(id, SEL, int);
|
||||
SEL compassStatusSelector = @selector(onCompassStatusChanged:);
|
||||
CompassStatusFnT compassStatusFn = (CompassStatusFnT)[self methodForSelector:compassStatusSelector];
|
||||
|
||||
shared_ptr<location::State> ls = f.GetLocationState();
|
||||
ls->AddCompassStatusListener(bind(onCompassStatusChangedImpl, self, onCompassStatusChangedSel, _1));
|
||||
ls->AddOnPositionClickListener(bind(onMyPosiionClickedImpl, self, onMyPositionClickedSel,_1));
|
||||
ls->AddCompassStatusListener(bind(compassStatusFn, self, compassStatusSelector, _1));
|
||||
|
||||
m_StickyThreshold = 10;
|
||||
|
||||
m_CurrentAction = NOTHING;
|
||||
|
||||
EAGLView * v = (EAGLView *)self.view;
|
||||
[v initRenderPolicy];
|
||||
|
||||
// restore previous screen position
|
||||
|
@ -707,48 +624,6 @@ NSInteger compareAddress(id l, id r, void * context)
|
|||
GetFramework().SetupMeasurementSystem();
|
||||
}
|
||||
|
||||
-(void)onBookmarkClickWithBookmarkAndCategory:(BookmarkAndCategory const)bmAndCat
|
||||
{
|
||||
Framework &f = GetFramework();
|
||||
// Already added bookmark was clicked
|
||||
BookmarkCategory * cat = f.GetBmCategory(bmAndCat.first);
|
||||
if (cat)
|
||||
{
|
||||
// Automatically reveal hidden bookmark on a click
|
||||
if (!cat->IsVisible())
|
||||
{
|
||||
// Category visibility will be autosaved after editing bookmark
|
||||
cat->SetVisible(true);
|
||||
[self Invalidate];
|
||||
}
|
||||
|
||||
Bookmark const * bm = cat->GetBookmark(bmAndCat.second);
|
||||
if (bm)
|
||||
{
|
||||
m2::PointD const globalPos = bm->GetOrg();
|
||||
// Set it before changing balloon title to display different images in case of creating/editing Bookmark
|
||||
m_balloonView.editedBookmark = bmAndCat;
|
||||
m_balloonView.globalPosition = CGPointMake(globalPos.x, globalPos.y);
|
||||
// Reset description BEFORE title, as title's setter also takes it into an account for Balloon text generation
|
||||
string const & descr = bm->GetDescription();
|
||||
if (!descr.empty())
|
||||
m_balloonView.notes = [NSString stringWithUTF8String:descr.c_str()];
|
||||
else
|
||||
m_balloonView.notes = nil;
|
||||
|
||||
m_balloonView.title = [NSString stringWithUTF8String:bm->GetName().c_str()];
|
||||
m_balloonView.color = [NSString stringWithUTF8String:bm->GetType().c_str()];
|
||||
m_balloonView.setName = [NSString stringWithUTF8String:cat->GetName().c_str()];
|
||||
[m_balloonView showInView];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)showBalloonWithCategoryIndex:(int)index andBookmarkIndex:(int)bmIndex
|
||||
{
|
||||
[self onBookmarkClickWithBookmarkAndCategory:BookmarkAndCategory(index, bmIndex)];
|
||||
}
|
||||
|
||||
- (void)showAppStoreRatingMenu
|
||||
{
|
||||
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@"App Store"
|
||||
|
@ -839,14 +714,6 @@ NSInteger compareAddress(id l, id r, void * context)
|
|||
}
|
||||
}
|
||||
|
||||
- (void)showBalloonWithText:(NSString *)text andGlobalPoint:(m2::PointD) point
|
||||
{
|
||||
[m_balloonView clear];
|
||||
m_balloonView.globalPosition = CGPointMake(point.x, point.y);
|
||||
m_balloonView.title = text;
|
||||
[m_balloonView showInView];
|
||||
}
|
||||
|
||||
- (void) destroyPopover
|
||||
{
|
||||
[popover release];
|
||||
|
@ -888,7 +755,6 @@ NSInteger compareAddress(id l, id r, void * context)
|
|||
UIBarButtonItem * closeButton = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"back", nil) style: UIBarButtonItemStyleDone target:self action:@selector(returnToApiApp)] autorelease];
|
||||
self.navigationItem.leftBarButtonItem = closeButton;
|
||||
|
||||
|
||||
// UIBarButtonItem * hide = [[[UIBarButtonItem alloc] initWithTitle:@"hide" style: UIBarButtonItemStyleDone target:self action:@selector(onHideClicked)] autorelease];
|
||||
// self.navigationItem.rightBarButtonItem = hide;
|
||||
self.navigationItem.title = [NSString stringWithUTF8String:GetFramework().GetMapApiAppTitle().c_str()];
|
||||
|
|
|
@ -251,12 +251,10 @@ void InitLocalizedStrings()
|
|||
m_navController.navigationBarHidden = YES;
|
||||
}
|
||||
|
||||
-(void) showParsedBookmarkOnMap:(url_scheme::ApiPoint const &)apiPoint
|
||||
-(void) showParsedBookmarkOnMap:(url_api::Request const &) request
|
||||
{
|
||||
[self showMap];
|
||||
m2::PointD const globalPoint(MercatorBounds::LonToX(apiPoint.m_lon), MercatorBounds::LatToY(apiPoint.m_lat));
|
||||
NSString * name = [NSString stringWithUTF8String:apiPoint.m_name.c_str()];
|
||||
[m_mapViewController showBalloonWithText:name andGlobalPoint:globalPoint];
|
||||
GetFramework().GetBalloonManager().ShowUrlRequest(request);
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -517,7 +517,7 @@ static void OnSearchResultCallback(search::Results const & res)
|
|||
{
|
||||
m_framework->ShowSearchResult(res);
|
||||
|
||||
Framework::AddressInfo info;
|
||||
search::AddressInfo info;
|
||||
info.MakeFrom(res);
|
||||
|
||||
[[MapsAppDelegate theApp].m_mapViewController showSearchResultAsBookmarkAtMercatorPoint:res.GetFeatureCenter() withInfo:info];
|
||||
|
|
|
@ -332,7 +332,7 @@ namespace
|
|||
|
||||
static void GetReadableTypes(search::Engine const * eng, int8_t lang,
|
||||
feature::TypesHolder & types,
|
||||
Framework::AddressInfo & info)
|
||||
search::AddressInfo & info)
|
||||
{
|
||||
types.SortBySpec();
|
||||
|
||||
|
@ -367,7 +367,7 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
void FillAddress(search::Engine const * eng, Framework::AddressInfo & info)
|
||||
void FillAddress(search::Engine const * eng, search::AddressInfo & info)
|
||||
{
|
||||
int8_t const lang = eng->GetCurrentLanguage();
|
||||
|
||||
|
@ -435,7 +435,7 @@ namespace
|
|||
m_eps = max(rect.SizeX(), rect.SizeY());
|
||||
}
|
||||
|
||||
void FillLocality(Framework::AddressInfo & info, Framework const & fm)
|
||||
void FillLocality(search::AddressInfo & info, Framework const & fm)
|
||||
{
|
||||
SortResults();
|
||||
//LOG(LDEBUG, (m_cont));
|
||||
|
@ -470,15 +470,7 @@ namespace
|
|||
}
|
||||
}
|
||||
|
||||
void Framework::GetAddressInfo(m2::PointD const & pxPoint, AddressInfo & info) const
|
||||
{
|
||||
// Input point is in pixel coordinates.
|
||||
m2::PointD const pt = PtoG(pxPoint);
|
||||
|
||||
GetAddressInfoForGlobalPoint(pt, info);
|
||||
}
|
||||
|
||||
void Framework::GetAddressInfoForGlobalPoint(m2::PointD const & pt, AddressInfo & info) const
|
||||
void Framework::GetAddressInfoForGlobalPoint(m2::PointD const & pt, search::AddressInfo & info) const
|
||||
{
|
||||
info.Clear();
|
||||
|
||||
|
@ -508,7 +500,7 @@ void Framework::GetAddressInfoForGlobalPoint(m2::PointD const & pt, AddressInfo
|
|||
GetLocality(pt, info);
|
||||
}
|
||||
|
||||
void Framework::GetAddressInfo(FeatureType const & ft, m2::PointD const & pt, AddressInfo & info) const
|
||||
void Framework::GetAddressInfo(FeatureType const & ft, m2::PointD const & pt, search::AddressInfo & info) const
|
||||
{
|
||||
info.Clear();
|
||||
|
||||
|
@ -531,7 +523,7 @@ void Framework::GetAddressInfo(FeatureType const & ft, m2::PointD const & pt, Ad
|
|||
//GetLocality(pt, info);
|
||||
}
|
||||
|
||||
void Framework::GetLocality(m2::PointD const & pt, AddressInfo & info) const
|
||||
void Framework::GetLocality(m2::PointD const & pt, search::AddressInfo & info) const
|
||||
{
|
||||
CheckerT & checker = GetChecker();
|
||||
|
||||
|
@ -546,109 +538,3 @@ void Framework::GetLocality(m2::PointD const & pt, AddressInfo & info) const
|
|||
|
||||
getLocality.FillLocality(info, *this);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// Framework::AddressInfo implementation
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void Framework::AddressInfo::MakeFrom(search::Result const & res)
|
||||
{
|
||||
ASSERT_EQUAL ( res.GetResultType(), search::Result::RESULT_FEATURE, () );
|
||||
|
||||
// push the feature type
|
||||
string const type = res.GetFeatureType();
|
||||
if (!type.empty())
|
||||
m_types.push_back(type);
|
||||
else
|
||||
ASSERT ( false, ("Search result with empty type") );
|
||||
|
||||
// assign name if it's not equal with type
|
||||
string name = res.GetString();
|
||||
if (name != type)
|
||||
m_name.swap(name);
|
||||
}
|
||||
|
||||
string Framework::AddressInfo::GetPinName() const
|
||||
{
|
||||
return m_name.empty() ? m_house : m_name;
|
||||
}
|
||||
|
||||
string Framework::AddressInfo::GetPinType() const
|
||||
{
|
||||
char const * type = GetBestType();
|
||||
return (type ? type : "");
|
||||
}
|
||||
|
||||
string Framework::AddressInfo::FormatPinText() const
|
||||
{
|
||||
// select name or house if name is empty
|
||||
string const & ret = (m_name.empty() ? m_house : m_name);
|
||||
|
||||
char const * type = GetBestType();
|
||||
if (type)
|
||||
{
|
||||
if (ret.empty())
|
||||
return type;
|
||||
else
|
||||
return ret + " (" + string(type) + ')';
|
||||
}
|
||||
else
|
||||
return ret;
|
||||
}
|
||||
|
||||
string Framework::AddressInfo::FormatAddress() const
|
||||
{
|
||||
string result = m_house;
|
||||
if (!m_street.empty())
|
||||
{
|
||||
if (!result.empty())
|
||||
result += ' ';
|
||||
result += m_street;
|
||||
}
|
||||
if (!m_city.empty())
|
||||
{
|
||||
if (!result.empty())
|
||||
result += ", ";
|
||||
result += m_city;
|
||||
}
|
||||
if (!m_country.empty())
|
||||
{
|
||||
if (!result.empty())
|
||||
result += ", ";
|
||||
result += m_country;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
string Framework::AddressInfo::FormatTypes() const
|
||||
{
|
||||
string result;
|
||||
for (size_t i = 0; i < m_types.size(); ++i)
|
||||
{
|
||||
ASSERT ( !m_types.empty(), () );
|
||||
if (!result.empty())
|
||||
result += ' ';
|
||||
result += m_types[i];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
char const * Framework::AddressInfo::GetBestType() const
|
||||
{
|
||||
if (!m_types.empty())
|
||||
{
|
||||
ASSERT ( !m_types[0].empty(), () );
|
||||
return m_types[0].c_str();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void Framework::AddressInfo::Clear()
|
||||
{
|
||||
m_country.clear();
|
||||
m_city.clear();
|
||||
m_street.clear();
|
||||
m_house.clear();
|
||||
m_name.clear();
|
||||
m_types.clear();
|
||||
}
|
||||
|
|
190
map/balloon_manager.cpp
Normal file
190
map/balloon_manager.cpp
Normal file
|
@ -0,0 +1,190 @@
|
|||
#include "bookmark_balloon.hpp"
|
||||
#include "balloon_manager.hpp"
|
||||
#include "framework.hpp"
|
||||
|
||||
#include "../search/result.hpp"
|
||||
|
||||
#include "../graphics/depth_constants.hpp"
|
||||
|
||||
#include "../gui/controller.hpp"
|
||||
|
||||
|
||||
BalloonManager::BalloonManager(Framework & f)
|
||||
: m_f(f), m_updateForLocation(false)
|
||||
{
|
||||
}
|
||||
|
||||
void BalloonManager::CreateBookmarkBalloon()
|
||||
{
|
||||
CHECK(m_f.GetGuiController(), ());
|
||||
CHECK(m_f.GetLocationState(), ());
|
||||
|
||||
BookmarkBalloon::Params bp;
|
||||
bp.m_position = graphics::EPosAbove;
|
||||
bp.m_depth = graphics::balloonBaseDepth;
|
||||
bp.m_pivot = m2::PointD(0, 0);
|
||||
bp.m_framework = &m_f;
|
||||
|
||||
m_balloon.reset(new BookmarkBalloon(bp));
|
||||
m_balloon->setIsVisible(false);
|
||||
|
||||
m_f.GetGuiController()->AddElement(m_balloon);
|
||||
m_f.GetLocationState()->AddOnPositionClickListener(bind(&BalloonManager::OnPositionClicked, this, _1));
|
||||
}
|
||||
|
||||
void BalloonManager::RenderPolicyCreated(graphics::EDensity density)
|
||||
{
|
||||
if (m_balloon == 0)
|
||||
CreateBookmarkBalloon();
|
||||
|
||||
m_balloon->setImage(graphics::Image::Info("arrow.png", density));
|
||||
}
|
||||
|
||||
void BalloonManager::ScreenSizeChanged(int width, int height)
|
||||
{
|
||||
if (m_balloon)
|
||||
m_balloon->onScreenSize(width, height);
|
||||
}
|
||||
|
||||
void BalloonManager::LocationChanged(location::GpsInfo const & info)
|
||||
{
|
||||
if (m_balloon && m_updateForLocation)
|
||||
{
|
||||
m_balloon->setGlbPivot(m2::PointD(MercatorBounds::LonToX(info.m_longitude),
|
||||
MercatorBounds::LatToY(info.m_latitude)));
|
||||
}
|
||||
}
|
||||
|
||||
void BalloonManager::OnPositionClicked(m2::PointD const & pt)
|
||||
{
|
||||
Show(pt, m_f.GetStringsBundle().GetString("my_position"), "");
|
||||
|
||||
m_balloon->setOnClickListener(bind(&BalloonManager::OnActivateMyPosition, this, _1));
|
||||
|
||||
m_updateForLocation = true;
|
||||
}
|
||||
|
||||
void BalloonManager::Show(m2::PointD const & pt, string const & name, string const & type)
|
||||
{
|
||||
m_updateForLocation = false;
|
||||
|
||||
m_balloon->setGlbPivot(pt);
|
||||
m_balloon->setBookmarkCaption(name, type);
|
||||
m_balloon->showAnimated();
|
||||
|
||||
m_f.Invalidate();
|
||||
}
|
||||
|
||||
void BalloonManager::Hide()
|
||||
{
|
||||
m_updateForLocation = false;
|
||||
|
||||
m_balloon->hide();
|
||||
|
||||
m_f.Invalidate();
|
||||
}
|
||||
|
||||
void BalloonManager::ShowAddress(m2::PointD const & pt, search::AddressInfo const & info)
|
||||
{
|
||||
string name = info.GetPinName();
|
||||
string type = info.GetPinType();
|
||||
if (name.empty() && type.empty())
|
||||
name = m_f.GetStringsBundle().GetString("dropped_pin");
|
||||
|
||||
Show(pt, name, type);
|
||||
|
||||
m_balloon->setOnClickListener(bind(&BalloonManager::OnActivatePOI, this, _1, info));
|
||||
}
|
||||
|
||||
void BalloonManager::ShowApiPoint(url_scheme::ApiPoint const & apiPoint)
|
||||
{
|
||||
Show(m2::PointD(MercatorBounds::LonToX(apiPoint.m_lon),
|
||||
MercatorBounds::LatToY(apiPoint.m_lat)),
|
||||
apiPoint.m_name, "");
|
||||
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(), "");
|
||||
m_balloon->setOnClickListener(bind(&BalloonManager::OnActivateBookmark, this, _1, bmAndCat));
|
||||
}
|
||||
|
||||
void BalloonManager::OnClick(m2::PointD const & pxPoint, bool isLongTouch)
|
||||
{
|
||||
url_scheme::ApiPoint apiPoint;
|
||||
if (m_f.GetMapApiPoint(pxPoint, apiPoint))
|
||||
{
|
||||
Show(m2::PointD(MercatorBounds::LonToX(apiPoint.m_lon),
|
||||
MercatorBounds::LatToY(apiPoint.m_lat)),
|
||||
apiPoint.m_name, "");
|
||||
m_balloon->setOnClickListener(bind(&BalloonManager::OnActivateAPI, this, _1, apiPoint));
|
||||
}
|
||||
else
|
||||
{
|
||||
search::AddressInfo addrInfo;
|
||||
m2::PointD pxPivot;
|
||||
BookmarkAndCategory bmAndCat;
|
||||
|
||||
switch (m_f.GetBookmarkOrPoi(pxPoint, pxPivot, addrInfo, bmAndCat))
|
||||
{
|
||||
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));
|
||||
return;
|
||||
}
|
||||
|
||||
case Framework::POI:
|
||||
if (!m_balloon->isVisible())
|
||||
{
|
||||
ShowAddress(m_f.PtoG(pxPivot), addrInfo);
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
if (isLongTouch)
|
||||
{
|
||||
m2::PointD const glbPoint = m_f.PtoG(pxPoint);
|
||||
m_f.GetAddressInfoForGlobalPoint(glbPoint, addrInfo);
|
||||
ShowAddress(glbPoint, addrInfo);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// hide the balloon by default if no any Show before
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
|
||||
void BalloonManager::ClearListeners()
|
||||
{
|
||||
m_poiListener.clear();
|
||||
m_bookmarkListener.clear();
|
||||
m_apiListener.clear();
|
||||
m_positionListener.clear();
|
||||
}
|
||||
|
||||
void BalloonManager::OnActivateMyPosition(gui::Element *)
|
||||
{
|
||||
m2::PointD const & pt = m_balloon->glbPivot();
|
||||
m_positionListener(MercatorBounds::YToLat(pt.y),
|
||||
MercatorBounds::XToLon(pt.x));
|
||||
}
|
||||
|
||||
void BalloonManager::OnActivatePOI(gui::Element *, search::AddressInfo const & info)
|
||||
{
|
||||
m_poiListener(m_balloon->glbPivot(), info);
|
||||
}
|
||||
|
||||
void BalloonManager::OnActivateAPI(gui::Element *, url_scheme::ApiPoint const & apiPoint)
|
||||
{
|
||||
m_apiListener(apiPoint);
|
||||
}
|
||||
|
||||
void BalloonManager::OnActivateBookmark(gui::Element *, BookmarkAndCategory const & bmAndCat)
|
||||
{
|
||||
m_bookmarkListener(bmAndCat);
|
||||
}
|
66
map/balloon_manager.hpp
Normal file
66
map/balloon_manager.hpp
Normal file
|
@ -0,0 +1,66 @@
|
|||
#pragma once
|
||||
#include "bookmark.hpp"
|
||||
|
||||
#include "../graphics/defines.hpp"
|
||||
|
||||
#include "../geometry/point2d.hpp"
|
||||
|
||||
#include "../std/shared_ptr.hpp"
|
||||
#include "../std/function.hpp"
|
||||
|
||||
|
||||
class Framework;
|
||||
class BookmarkBalloon;
|
||||
namespace location { class GpsInfo; }
|
||||
namespace gui { class Element; }
|
||||
namespace search { struct AddressInfo; }
|
||||
namespace url_scheme { struct ApiPoint; }
|
||||
|
||||
class BalloonManager
|
||||
{
|
||||
Framework & m_f;
|
||||
shared_ptr<BookmarkBalloon> m_balloon;
|
||||
bool m_updateForLocation;
|
||||
|
||||
void CreateBookmarkBalloon();
|
||||
|
||||
void OnPositionClicked(m2::PointD const & pt);
|
||||
void OnActivateMyPosition(gui::Element *);
|
||||
void OnActivatePOI(gui::Element *, search::AddressInfo const & info);
|
||||
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);
|
||||
|
||||
public:
|
||||
BalloonManager(Framework & f);
|
||||
|
||||
void RenderPolicyCreated(graphics::EDensity density);
|
||||
void LocationChanged(location::GpsInfo const & info);
|
||||
void ScreenSizeChanged(int width, int height);
|
||||
|
||||
void ShowAddress(m2::PointD const & pt, search::AddressInfo const & info);
|
||||
void ShowApiPoint(url_scheme::ApiPoint const & apiPoint);
|
||||
void ShowBookmark(BookmarkAndCategory bmAndCat);
|
||||
|
||||
void OnClick(m2::PointD const & pxPoint, bool isLongTouch);
|
||||
|
||||
void Hide();
|
||||
|
||||
private:
|
||||
/// @name Platform dependent listeners to show special activities.
|
||||
//@{
|
||||
function<void (m2::PointD const &, search::AddressInfo const &)> m_poiListener;
|
||||
function<void (BookmarkAndCategory const &)> m_bookmarkListener;
|
||||
function<void (url_scheme::ApiPoint const &)> m_apiListener;
|
||||
function<void (double, double)> m_positionListener;
|
||||
|
||||
public:
|
||||
template <class T> void ConnectPoiListener(T const & t) { m_poiListener = t; }
|
||||
template <class T> void ConnectBookmarkListener(T const & t) { m_bookmarkListener = t; }
|
||||
template <class T> void ConnectApiListener(T const & t) { m_apiListener = t; }
|
||||
template <class T> void ConnectPositionListener(T const & t) { m_positionListener = t; }
|
||||
|
||||
void ClearListeners();
|
||||
//@}
|
||||
};
|
|
@ -129,6 +129,7 @@ void Framework::OnLocationUpdate(location::GpsInfo const & info)
|
|||
#endif
|
||||
|
||||
m_informationDisplay.locationState()->OnLocationUpdate(rInfo);
|
||||
m_balloonManager.LocationChanged(rInfo);
|
||||
}
|
||||
|
||||
void Framework::OnCompassUpdate(location::CompassInfo const & info)
|
||||
|
@ -169,12 +170,9 @@ static void GetResourcesMaps(vector<string> & outMaps)
|
|||
}
|
||||
|
||||
Framework::Framework()
|
||||
: //m_hasPendingInvalidate(false),
|
||||
//m_doForceUpdate(false),
|
||||
m_animator(this),
|
||||
: m_animator(this),
|
||||
m_queryMaxScaleMode(false),
|
||||
m_drawPlacemark(false),
|
||||
//m_hasPendingShowRectFixed(false),
|
||||
|
||||
/// @todo It's not a class state, so no need to store it in memory.
|
||||
/// Move this constants to Ruler (and don't store them at all).
|
||||
|
@ -192,7 +190,8 @@ Framework::Framework()
|
|||
m_informationDisplay(this),
|
||||
m_lowestMapVersion(numeric_limits<int>::max()),
|
||||
m_benchmarkEngine(0),
|
||||
m_bmManager(*this)
|
||||
m_bmManager(*this),
|
||||
m_balloonManager(*this)
|
||||
{
|
||||
// Checking whether we should enable benchmark.
|
||||
bool isBenchmarkingEnabled = false;
|
||||
|
@ -210,6 +209,7 @@ Framework::Framework()
|
|||
|
||||
m_stringsBundle.SetDefaultString("dropped_pin", "Dropped Pin");
|
||||
m_stringsBundle.SetDefaultString("my_places", "My Places");
|
||||
m_stringsBundle.SetDefaultString("my_position", "My Position");
|
||||
|
||||
m_animController.reset(new anim::Controller());
|
||||
|
||||
|
@ -705,11 +705,9 @@ void Framework::OnSize(int w, int h)
|
|||
|
||||
m2::RectI const & viewPort = m_renderPolicy->OnSize(w, h);
|
||||
|
||||
m_navigator.OnSize(
|
||||
viewPort.minX(),
|
||||
viewPort.minY(),
|
||||
viewPort.SizeX(),
|
||||
viewPort.SizeY());
|
||||
m_navigator.OnSize(viewPort.minX(), viewPort.minY(), viewPort.SizeX(), viewPort.SizeY());
|
||||
|
||||
m_balloonManager.ScreenSizeChanged(w, h);
|
||||
}
|
||||
|
||||
m_width = w;
|
||||
|
@ -1297,10 +1295,9 @@ void Framework::ShowSearchResult(search::Result const & res)
|
|||
|
||||
ShowRectExVisibleScale(rect);
|
||||
|
||||
// On iOS, we draw search results as bookmarks
|
||||
#ifndef OMIM_OS_IPHONE
|
||||
DrawPlacemark(res.GetFeatureCenter());
|
||||
#endif
|
||||
search::AddressInfo info;
|
||||
info.MakeFrom(res);
|
||||
m_balloonManager.ShowAddress(res.GetFeatureCenter(), info);
|
||||
}
|
||||
|
||||
bool Framework::GetDistanceAndAzimut(m2::PointD const & point,
|
||||
|
@ -1366,6 +1363,8 @@ void Framework::SetRenderPolicy(RenderPolicy * renderPolicy)
|
|||
|
||||
m_informationDisplay.setVisualScale(m_renderPolicy->VisualScale());
|
||||
|
||||
m_balloonManager.RenderPolicyCreated(m_renderPolicy->Density());
|
||||
|
||||
if (m_width != 0 && m_height != 0)
|
||||
OnSize(m_width, m_height);
|
||||
|
||||
|
@ -1481,7 +1480,7 @@ bool Framework::IsBenchmarking() const
|
|||
return m_benchmarkEngine != 0;
|
||||
}
|
||||
|
||||
shared_ptr<graphics::OverlayElement> const GetClosestToPivot(list<shared_ptr<graphics::OverlayElement> > const & l,
|
||||
shared_ptr<graphics::OverlayElement> GetClosestToPivot(list<shared_ptr<graphics::OverlayElement> > const & l,
|
||||
m2::PointD const & pxPoint)
|
||||
{
|
||||
double dist = numeric_limits<double>::max();
|
||||
|
@ -1502,7 +1501,8 @@ shared_ptr<graphics::OverlayElement> const GetClosestToPivot(list<shared_ptr<gra
|
|||
return res;
|
||||
}
|
||||
|
||||
bool Framework::GetVisiblePOI(m2::PointD const & pxPoint, m2::PointD & pxPivot, AddressInfo & info) const
|
||||
bool Framework::GetVisiblePOI(m2::PointD const & pxPoint, m2::PointD & pxPivot,
|
||||
search::AddressInfo & info) const
|
||||
{
|
||||
m_renderPolicy->FrameLock();
|
||||
|
||||
|
@ -1552,40 +1552,16 @@ bool Framework::GetVisiblePOI(m2::PointD const & pxPoint, m2::PointD & pxPivot,
|
|||
return false;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
string GenerateNameAndAddress(Framework::AddressInfo const & info)
|
||||
{
|
||||
if (info.m_name.empty())
|
||||
return info.FormatAddress();
|
||||
else
|
||||
return info.m_name + ", " + info.FormatAddress();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
string Framework::GetNameAndAddressAtPoint(m2::PointD const & pxPoint)
|
||||
{
|
||||
AddressInfo info;
|
||||
GetAddressInfo(pxPoint, info);
|
||||
return GenerateNameAndAddress(info);
|
||||
}
|
||||
|
||||
string Framework::GetNameAndAddressAtGlobalPoint(m2::PointD const & glPoint)
|
||||
{
|
||||
AddressInfo info;
|
||||
GetAddressInfoForGlobalPoint(glPoint, info);
|
||||
return GenerateNameAndAddress(info);
|
||||
}
|
||||
|
||||
Framework::BookmarkOrPoi Framework::GetBookmarkOrPoi(m2::PointD const & pxPoint, m2::PointD & pxPivot, AddressInfo & info, BookmarkAndCategory & bmCat)
|
||||
Framework::BookmarkOrPoi Framework::GetBookmarkOrPoi(m2::PointD const & pxPoint, m2::PointD & pxPivot,
|
||||
search::AddressInfo & info, BookmarkAndCategory & bmCat)
|
||||
{
|
||||
bmCat = GetBookmark(pxPoint);
|
||||
if (IsValid(bmCat))
|
||||
return Framework::BOOKMARK;
|
||||
|
||||
if (GetVisiblePOI(pxPoint, pxPivot, info))
|
||||
{
|
||||
//We need almost the exact position of the bookmark, parameter 0.1 resolves the error in 2 pixels
|
||||
// We need almost the exact position of the bookmark, parameter 0.1 resolves the error in 2 pixels
|
||||
bmCat = GetBookmark(pxPivot, 0.1);
|
||||
if (IsValid(bmCat))
|
||||
return Framework::BOOKMARK;
|
||||
|
|
|
@ -8,8 +8,12 @@
|
|||
#include "navigator.hpp"
|
||||
#include "animator.hpp"
|
||||
#include "feature_vec_model.hpp"
|
||||
|
||||
#include "bookmark.hpp"
|
||||
#include "bookmark_manager.hpp"
|
||||
#include "balloon_manager.hpp"
|
||||
|
||||
#include "url_api.hpp"
|
||||
#include "mwm_url.hpp"
|
||||
|
||||
#include "../defines.hpp"
|
||||
|
@ -38,7 +42,12 @@
|
|||
|
||||
//#define DRAW_TOUCH_POINTS
|
||||
|
||||
namespace search { class Result; }
|
||||
namespace search
|
||||
{
|
||||
class Result;
|
||||
struct AddressInfo;
|
||||
}
|
||||
|
||||
namespace gui { class Controller; }
|
||||
namespace anim { class Controller; }
|
||||
|
||||
|
@ -129,6 +138,7 @@ protected:
|
|||
BenchmarkEngine * m_benchmarkEngine;
|
||||
|
||||
BookmarkManager m_bmManager;
|
||||
BalloonManager m_balloonManager;
|
||||
|
||||
void ClearAllCaches();
|
||||
|
||||
|
@ -321,36 +331,19 @@ public:
|
|||
/// @param[in] pixPt Current touch point in device pixel coordinates.
|
||||
void GetFeatureTypes(m2::PointD pixPt, vector<string> & types) const;
|
||||
|
||||
struct AddressInfo
|
||||
{
|
||||
string m_country, m_city, m_street, m_house, m_name;
|
||||
vector<string> m_types;
|
||||
|
||||
void MakeFrom(search::Result const & res);
|
||||
|
||||
string GetPinName() const;
|
||||
string GetPinType() const;
|
||||
|
||||
string FormatPinText() const;
|
||||
string FormatAddress() const;
|
||||
string FormatTypes() const;
|
||||
char const * GetBestType() const;
|
||||
|
||||
void Clear();
|
||||
};
|
||||
|
||||
/// Get address information for point on map.
|
||||
void GetAddressInfo(m2::PointD const & pxPoint, AddressInfo & info) const;
|
||||
void GetAddressInfoForGlobalPoint(m2::PointD const & pt, AddressInfo & info) const;
|
||||
inline void GetAddressInfoForPixelPoint(m2::PointD const & pxPoint, search::AddressInfo & info) const
|
||||
{
|
||||
GetAddressInfoForGlobalPoint(PtoG(pxPoint), info);
|
||||
}
|
||||
void GetAddressInfoForGlobalPoint(m2::PointD const & pt, search::AddressInfo & info) const;
|
||||
|
||||
private:
|
||||
void GetAddressInfo(FeatureType const & ft, m2::PointD const & pt, AddressInfo & info) const;
|
||||
void GetLocality(m2::PointD const & pt, AddressInfo & info) const;
|
||||
void GetAddressInfo(FeatureType const & ft, m2::PointD const & pt, search::AddressInfo & info) const;
|
||||
void GetLocality(m2::PointD const & pt, search::AddressInfo & info) const;
|
||||
|
||||
public:
|
||||
bool GetVisiblePOI(m2::PointD const & pxPoint, m2::PointD & pxPivot, AddressInfo & info) const;
|
||||
string GetNameAndAddressAtPoint(m2::PointD const & pxPoint);
|
||||
string GetNameAndAddressAtGlobalPoint(m2::PointD const & glPoint);
|
||||
bool GetVisiblePOI(m2::PointD const & pxPoint, m2::PointD & pxPivot, search::AddressInfo & info) const;
|
||||
|
||||
enum BookmarkOrPoi
|
||||
{
|
||||
|
@ -359,7 +352,8 @@ public:
|
|||
POI = 2
|
||||
};
|
||||
|
||||
BookmarkOrPoi GetBookmarkOrPoi(m2::PointD const & pxPoint, m2::PointD & pxPivot, AddressInfo & info, BookmarkAndCategory & bmCat);
|
||||
BookmarkOrPoi GetBookmarkOrPoi(m2::PointD const & pxPoint, m2::PointD & pxPivot,
|
||||
search::AddressInfo & info, BookmarkAndCategory & bmCat);
|
||||
|
||||
virtual void BeginPaint(shared_ptr<PaintEvent> const & e);
|
||||
/// Function for calling from platform dependent-paint function.
|
||||
|
@ -443,6 +437,8 @@ public:
|
|||
|
||||
StringsBundle const & GetStringsBundle();
|
||||
|
||||
BalloonManager & GetBalloonManager() { return m_balloonManager; }
|
||||
|
||||
/// Checks, whether the country which contains
|
||||
/// the specified point is loaded
|
||||
bool IsCountryLoaded(m2::PointD const & pt) const;
|
||||
|
|
|
@ -56,6 +56,7 @@ HEADERS += \
|
|||
geometry_processors.hpp \
|
||||
bookmark_manager.hpp \
|
||||
ge0_parser.hpp \
|
||||
balloon_manager.hpp \
|
||||
|
||||
SOURCES += \
|
||||
feature_vec_model.cpp \
|
||||
|
@ -103,6 +104,7 @@ SOURCES += \
|
|||
bookmark_manager.cpp \
|
||||
ge0_parser.cpp \
|
||||
../api/src/c/api-client.c \
|
||||
balloon_manager.cpp \
|
||||
|
||||
!iphone*:!bada*:!android* {
|
||||
HEADERS += qgl_render_context.hpp
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
#include "../../map/framework.hpp"
|
||||
|
||||
#include "../../search/result.hpp"
|
||||
|
||||
#include "../../platform/platform.hpp"
|
||||
|
||||
#include "../../coding/internal/file_data.hpp"
|
||||
|
@ -342,8 +344,9 @@ namespace
|
|||
char const * st, char const * house,
|
||||
char const * typeEn, char const * typeRu)
|
||||
{
|
||||
Framework::AddressInfo info;
|
||||
fm.GetAddressInfo(fm.GtoP(m2::PointD(MercatorBounds::LonToX(lon), MercatorBounds::LatToY(lat))), info);
|
||||
search::AddressInfo info;
|
||||
fm.GetAddressInfoForGlobalPoint(
|
||||
m2::PointD(MercatorBounds::LonToX(lon), MercatorBounds::LatToY(lat)), info);
|
||||
|
||||
TEST_EQUAL(info.m_name, name, ());
|
||||
TEST_EQUAL(info.m_street, st, ());
|
||||
|
|
|
@ -62,6 +62,11 @@ namespace qt
|
|||
m_frameFn();
|
||||
}
|
||||
|
||||
void DummyAPI(url_scheme::ApiPoint const &) {}
|
||||
void DummyBookmark(BookmarkAndCategory const &) {}
|
||||
void DummyPOI(m2::PointD const &, search::AddressInfo const &) {}
|
||||
void DummyPosition(double, double) {}
|
||||
|
||||
DrawWidget::DrawWidget(QWidget * pParent)
|
||||
: QGLWidget(pParent),
|
||||
m_isInitialized(false),
|
||||
|
@ -72,6 +77,12 @@ namespace qt
|
|||
//m_redrawInterval(100),
|
||||
m_pScale(0)
|
||||
{
|
||||
// Initialize with some stubs for test.
|
||||
BalloonManager & manager = GetBalloonManager();
|
||||
manager.ConnectApiListener(&DummyAPI);
|
||||
manager.ConnectBookmarkListener(&DummyBookmark);
|
||||
manager.ConnectPoiListener(&DummyPOI);
|
||||
manager.ConnectPositionListener(&DummyPosition);
|
||||
}
|
||||
|
||||
DrawWidget::~DrawWidget()
|
||||
|
@ -266,18 +277,12 @@ namespace qt
|
|||
LOG(LERROR, (e.what()));
|
||||
}
|
||||
|
||||
graphics::EDensity const density = m_framework->GetRenderPolicy()->Density();
|
||||
m_images[IMAGE_PLUS] = ImageT("plus.png", density);
|
||||
m_images[IMAGE_ARROW] = ImageT("arrow.png", density);
|
||||
m_isInitialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
void DrawWidget::resizeGL(int w, int h)
|
||||
{
|
||||
if (m_bookmarkBalloon)
|
||||
m_bookmarkBalloon->onScreenSize(w, h);
|
||||
|
||||
m_framework->OnSize(w, h);
|
||||
m_framework->Invalidate();
|
||||
|
||||
|
@ -340,105 +345,7 @@ namespace qt
|
|||
|
||||
void DrawWidget::OnPressTaskEvent(double x, double y, unsigned ms)
|
||||
{
|
||||
m2::PointD pt(x, y);
|
||||
m2::PointD pivot;
|
||||
|
||||
Framework::AddressInfo addressInfo;
|
||||
BookmarkAndCategory bm;
|
||||
switch (m_framework->GetBookmarkOrPoi(pt, pivot, addressInfo, bm))
|
||||
{
|
||||
case Framework::BOOKMARK:
|
||||
{
|
||||
const Bookmark * bookmark = m_framework->GetBmCategory(bm.first)->GetBookmark(bm.second);
|
||||
ActivatePopup(bookmark->GetOrg(), bookmark->GetName(), "", IMAGE_ARROW);
|
||||
return;
|
||||
}
|
||||
|
||||
case Framework::POI:
|
||||
if (!GetBookmarkBalloon()->isVisible())
|
||||
{
|
||||
ActivatePopupWithAdressInfo(m_framework->PtoG(pivot), addressInfo);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
if (ms == LONG_TOUCH_MS)
|
||||
{
|
||||
m_framework->GetAddressInfo(pt, addressInfo);
|
||||
ActivatePopupWithAdressInfo(m_framework->PtoG(pt), addressInfo);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
DiactivatePopup();
|
||||
}
|
||||
|
||||
void DrawWidget::ActivatePopup(m2::PointD const & pivot,
|
||||
string const & name,
|
||||
string const & type,
|
||||
PopupImageIndexT index)
|
||||
{
|
||||
BookmarkBalloon * balloon = GetBookmarkBalloon();
|
||||
|
||||
m_framework->DisablePlacemark();
|
||||
|
||||
balloon->setImage(m_images[index]);
|
||||
balloon->setGlbPivot(pivot);
|
||||
balloon->setBookmarkCaption(name, type);
|
||||
balloon->showAnimated();
|
||||
|
||||
m_framework->Invalidate();
|
||||
}
|
||||
|
||||
void DrawWidget::ActivatePopupWithAdressInfo(m2::PointD const & pivot, Framework::AddressInfo const & addrInfo)
|
||||
{
|
||||
string name = addrInfo.GetPinName();
|
||||
string type = addrInfo.GetPinType();
|
||||
if (name.empty() && type.empty())
|
||||
name = m_framework->GetStringsBundle().GetString("dropped_pin");
|
||||
|
||||
ActivatePopup(pivot, name, type, IMAGE_PLUS);
|
||||
|
||||
m_framework->DrawPlacemark(pivot);
|
||||
m_framework->Invalidate();
|
||||
}
|
||||
|
||||
void DrawWidget::DiactivatePopup()
|
||||
{
|
||||
BookmarkBalloon * balloon = GetBookmarkBalloon();
|
||||
|
||||
balloon->hide();
|
||||
m_framework->DisablePlacemark();
|
||||
m_framework->Invalidate();
|
||||
}
|
||||
|
||||
void DrawWidget::CreateBookmarkBalloon()
|
||||
{
|
||||
BookmarkBalloon::Params bp;
|
||||
|
||||
bp.m_position = graphics::EPosAbove;
|
||||
bp.m_depth = graphics::balloonBaseDepth;
|
||||
bp.m_pivot = m2::PointD(0.0, 0.0);
|
||||
bp.m_mainText = "Bookmark";
|
||||
bp.m_framework = m_framework.get();
|
||||
|
||||
m_bookmarkBalloon.reset(new BookmarkBalloon(bp));
|
||||
m_bookmarkBalloon->setIsVisible(false);
|
||||
|
||||
/// @todo Process adding bookmark.
|
||||
//m_bookmarkBalloon->setOnClickListener(bind(&DrawWidget::OnBalloonClick, this, _1));
|
||||
|
||||
m_framework->GetGuiController()->AddElement(m_bookmarkBalloon);
|
||||
m_bookmarkBalloon->onScreenSize(width(), height());
|
||||
}
|
||||
|
||||
BookmarkBalloon * DrawWidget::GetBookmarkBalloon()
|
||||
{
|
||||
if (!m_bookmarkBalloon)
|
||||
CreateBookmarkBalloon();
|
||||
|
||||
return m_bookmarkBalloon.get();
|
||||
GetBalloonManager().OnClick(m2::PointD(x, y), true);
|
||||
}
|
||||
|
||||
namespace
|
||||
|
@ -498,7 +405,7 @@ namespace qt
|
|||
QMenu menu;
|
||||
|
||||
// Get POI under cursor or nearest address by point.
|
||||
Framework::AddressInfo info;
|
||||
search::AddressInfo info;
|
||||
m2::PointD dummy;
|
||||
if (m_framework->GetVisiblePOI(pt, dummy, info))
|
||||
{
|
||||
|
@ -506,7 +413,7 @@ namespace qt
|
|||
}
|
||||
else
|
||||
{
|
||||
m_framework->GetAddressInfo(pt, info);
|
||||
m_framework->GetAddressInfoForPixelPoint(pt, info);
|
||||
}
|
||||
|
||||
// Get feature types under cursor.
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
#pragma once
|
||||
|
||||
#include "../base/scheduled_task.hpp"
|
||||
|
||||
#include "../map/window_handle.hpp"
|
||||
#include "../map/framework.hpp"
|
||||
#include "../map/navigator.hpp"
|
||||
#include "../map/qgl_render_context.hpp"
|
||||
#include "../map/bookmark_balloon.hpp"
|
||||
|
||||
#include "../base/scheduled_task.hpp"
|
||||
|
||||
#include "../platform/video_timer.hpp"
|
||||
|
||||
|
@ -109,17 +108,6 @@ namespace qt
|
|||
void KillPressTask();
|
||||
void OnPressTaskEvent(double x, double y, unsigned ms);
|
||||
|
||||
typedef graphics::Image::Info ImageT;
|
||||
ImageT m_images[2];
|
||||
enum PopupImageIndexT { IMAGE_PLUS = 0, IMAGE_ARROW = 1 };
|
||||
void ActivatePopup(m2::PointD const & pivot, string const & name, string const & type, PopupImageIndexT index);
|
||||
void ActivatePopupWithAdressInfo(m2::PointD const & pivot, Framework::AddressInfo const & addrInfo);
|
||||
void DiactivatePopup();
|
||||
|
||||
shared_ptr<BookmarkBalloon> m_bookmarkBalloon;
|
||||
void CreateBookmarkBalloon();
|
||||
BookmarkBalloon * GetBookmarkBalloon();
|
||||
|
||||
protected:
|
||||
/// @name Overriden from base_type.
|
||||
//@{
|
||||
|
@ -150,5 +138,7 @@ namespace qt
|
|||
|
||||
shared_ptr<ScheduledTask> m_scheduledTasks;
|
||||
double m_taskX, m_taskY;
|
||||
|
||||
BalloonManager & GetBalloonManager() { return m_framework->GetBalloonManager(); }
|
||||
};
|
||||
}
|
||||
|
|
|
@ -69,4 +69,118 @@ void Results::AddResultCheckExisting(Result const & r)
|
|||
AddResult(r);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
// AddressInfo implementation
|
||||
////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void AddressInfo::MakeFrom(Result const & res)
|
||||
{
|
||||
ASSERT_EQUAL ( res.GetResultType(), Result::RESULT_FEATURE, () );
|
||||
|
||||
// push the feature type
|
||||
string const type = res.GetFeatureType();
|
||||
if (!type.empty())
|
||||
m_types.push_back(type);
|
||||
else
|
||||
{
|
||||
ASSERT ( false, ("Search result with empty type") );
|
||||
}
|
||||
|
||||
// assign name if it's not equal with type
|
||||
string name = res.GetString();
|
||||
if (name != type)
|
||||
m_name.swap(name);
|
||||
}
|
||||
|
||||
string AddressInfo::GetPinName() const
|
||||
{
|
||||
return m_name.empty() ? m_house : m_name;
|
||||
}
|
||||
|
||||
string AddressInfo::GetPinType() const
|
||||
{
|
||||
char const * type = GetBestType();
|
||||
return (type ? type : "");
|
||||
}
|
||||
|
||||
string AddressInfo::FormatPinText() const
|
||||
{
|
||||
// select name or house if name is empty
|
||||
string const & ret = (m_name.empty() ? m_house : m_name);
|
||||
|
||||
char const * type = GetBestType();
|
||||
if (type)
|
||||
{
|
||||
if (ret.empty())
|
||||
return type;
|
||||
else
|
||||
return ret + " (" + string(type) + ')';
|
||||
}
|
||||
else
|
||||
return ret;
|
||||
}
|
||||
|
||||
string AddressInfo::FormatAddress() const
|
||||
{
|
||||
string result = m_house;
|
||||
if (!m_street.empty())
|
||||
{
|
||||
if (!result.empty())
|
||||
result += ' ';
|
||||
result += m_street;
|
||||
}
|
||||
if (!m_city.empty())
|
||||
{
|
||||
if (!result.empty())
|
||||
result += ", ";
|
||||
result += m_city;
|
||||
}
|
||||
if (!m_country.empty())
|
||||
{
|
||||
if (!result.empty())
|
||||
result += ", ";
|
||||
result += m_country;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
string AddressInfo::FormatTypes() const
|
||||
{
|
||||
string result;
|
||||
for (size_t i = 0; i < m_types.size(); ++i)
|
||||
{
|
||||
ASSERT ( !m_types.empty(), () );
|
||||
if (!result.empty())
|
||||
result += ' ';
|
||||
result += m_types[i];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
string AddressInfo::FormatNameAndAddress() const
|
||||
{
|
||||
string const addr = FormatAddress();
|
||||
return (m_name.empty() ? addr : m_name + ", " + addr);
|
||||
}
|
||||
|
||||
char const * AddressInfo::GetBestType() const
|
||||
{
|
||||
if (!m_types.empty())
|
||||
{
|
||||
ASSERT ( !m_types[0].empty(), () );
|
||||
return m_types[0].c_str();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void AddressInfo::Clear()
|
||||
{
|
||||
m_country.clear();
|
||||
m_city.clear();
|
||||
m_street.clear();
|
||||
m_house.clear();
|
||||
m_name.clear();
|
||||
m_types.clear();
|
||||
}
|
||||
|
||||
} // namespace search
|
||||
|
|
|
@ -107,4 +107,24 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
struct AddressInfo
|
||||
{
|
||||
string m_country, m_city, m_street, m_house, m_name;
|
||||
vector<string> m_types;
|
||||
|
||||
void MakeFrom(search::Result const & res);
|
||||
|
||||
string GetPinName() const;
|
||||
string GetPinType() const;
|
||||
|
||||
string FormatPinText() const;
|
||||
string FormatAddress() const;
|
||||
string FormatTypes() const;
|
||||
string FormatNameAndAddress() const;
|
||||
|
||||
char const * GetBestType() const;
|
||||
|
||||
void Clear();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue