diff --git a/android/jni/com/mapswithme/maps/Framework.cpp b/android/jni/com/mapswithme/maps/Framework.cpp index 68fe9de6f7..228fffab88 100644 --- a/android/jni/com/mapswithme/maps/Framework.cpp +++ b/android/jni/com/mapswithme/maps/Framework.cpp @@ -66,7 +66,7 @@ namespace android void Framework::OnPositionClicked(m2::PointD const & point) { string name = NativeFramework()->GetStringsBundle().GetString("my_position"); - ActivatePopup(point, name, IMAGE_PLUS); + ActivatePopup(point, name, "", IMAGE_PLUS); m_doUpdateBalloonPositionFromLocation = true; } @@ -193,6 +193,7 @@ namespace android m_work.SetUpdatesEnabled(true); m_work.EnterForeground(); + UpdateBalloonSize(); return true; } @@ -226,6 +227,7 @@ namespace android void Framework::Resize(int w, int h) { m_work.OnSize(w, h); + UpdateBalloonSize(); } void Framework::DrawFrame() @@ -593,7 +595,7 @@ namespace android case ::Framework::BOOKMARK: { Bookmark const * pBM = m_work.GetBmCategory(bmAndCat.first)->GetBookmark(bmAndCat.second); - ActivatePopup(pBM->GetOrg(), pBM->GetName(), IMAGE_ARROW); + ActivatePopup(pBM->GetOrg(), pBM->GetName(), string(""), IMAGE_ARROW); return; } case ::Framework::POI: @@ -621,17 +623,18 @@ namespace android void Framework::ActivatePopupWithAddressInfo(m2::PointD const & pos, ::Framework::AddressInfo const & addrInfo) { - string name = addrInfo.FormatPinText(); - if (name.empty()) + string name = addrInfo.GetPinName(); + string type = addrInfo.GetPinType(); + if (name.empty() && type.empty()) name = m_work.GetStringsBundle().GetString("dropped_pin"); - ActivatePopup(pos, name, IMAGE_PLUS); + ActivatePopup(pos, name, type, IMAGE_PLUS); m_work.DrawPlacemark(pos); m_work.Invalidate(); } - void Framework::ActivatePopup(m2::PointD const & pos, string const & name, PopupImageIndexT index) + void Framework::ActivatePopup(m2::PointD const & pos, string const & name, string const & type, PopupImageIndexT index) { // stop updating balloon position m_doUpdateBalloonPositionFromLocation = false; @@ -642,8 +645,8 @@ namespace android b->setImage(m_images[index]); b->setGlbPivot(pos); - b->setBookmarkName(name); - b->setIsVisible(true); + b->setBookmarkCaption(name, type); + b->showAnimated(); m_work.Invalidate(); } @@ -653,7 +656,7 @@ namespace android m_doUpdateBalloonPositionFromLocation = false; BookmarkBalloon * b = GetBookmarkBalloon(); - b->setIsVisible(false); + b->hide(); m_work.DisablePlacemark(); m_work.Invalidate(); @@ -698,21 +701,25 @@ namespace android bp.m_position = graphics::EPosAbove; bp.m_depth = graphics::maxDepth; bp.m_pivot = m2::PointD(0, 0); - bp.m_imageMarginBottom = 10; - bp.m_imageMarginLeft = 0; - bp.m_imageMarginRight = 10; - bp.m_imageMarginTop = 7; - bp.m_textMarginBottom = 10; - bp.m_textMarginLeft = 10; - bp.m_textMarginRight = 10; - bp.m_textMarginTop = 7; - bp.m_text = "Bookmark"; + bp.m_mainText = "Bookmark"; bp.m_framework = &m_work; m_bmBaloon.reset(new BookmarkBalloon(bp)); m_bmBaloon->setIsVisible(false); m_bmBaloon->setOnClickListener(bind(&Framework::OnBalloonClick, this, _1)); m_work.GetGuiController()->AddElement(m_bmBaloon); + UpdateBalloonSize(); + } + + void Framework::UpdateBalloonSize() + { + if (m_bmBaloon == NULL) + return; + + int width = m_work.GetNavigator().Screen().GetWidth(); + int height = m_work.GetNavigator().Screen().GetHeight(); + + m_bmBaloon->onScreenSize(width, height); } BookmarkBalloon * Framework::GetBookmarkBalloon() @@ -770,7 +777,7 @@ namespace android m2::PointD pt(MercatorBounds::LonToX(request.m_viewportLon), MercatorBounds::LatToY(request.m_viewportLat)); - ActivatePopup(pt, request.m_points.front().m_name, IMAGE_PLUS); + ActivatePopup(pt, request.m_points.front().m_name, "", IMAGE_PLUS); m_work.DrawPlacemark(pt); m_work.Invalidate(); diff --git a/android/jni/com/mapswithme/maps/Framework.hpp b/android/jni/com/mapswithme/maps/Framework.hpp index f97f5b07cb..5d52e5a0a8 100644 --- a/android/jni/com/mapswithme/maps/Framework.hpp +++ b/android/jni/com/mapswithme/maps/Framework.hpp @@ -62,9 +62,11 @@ namespace android ImageT m_images[2]; enum PopupImageIndexT { IMAGE_PLUS = 0, IMAGE_ARROW = 1 }; - void ActivatePopup(m2::PointD const & pos, string const & name, PopupImageIndexT index); + 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 m_bmBaloon; string m_bmType; diff --git a/qt/draw_widget.cpp b/qt/draw_widget.cpp index 05064af001..3022483af7 100644 --- a/qt/draw_widget.cpp +++ b/qt/draw_widget.cpp @@ -71,8 +71,6 @@ namespace qt //m_redrawInterval(100), m_pScale(0) { - //m_timer = new QTimer(this); - //connect(m_timer, SIGNAL(timeout()), this, SLOT(ScaleTimerElapsed())); } DrawWidget::~DrawWidget() @@ -276,6 +274,9 @@ namespace qt void DrawWidget::resizeGL(int w, int h) { + if (m_bookmarkBalloon) + m_bookmarkBalloon->onScreenSize(w, h); + m_framework->OnSize(w, h); m_framework->Invalidate(); @@ -348,7 +349,7 @@ namespace qt case Framework::BOOKMARK: { const Bookmark * bookmark = m_framework->GetBmCategory(bm.first)->GetBookmark(bm.second); - ActivatePopup(bookmark->GetOrg(), bookmark->GetName(), IMAGE_ARROW); + ActivatePopup(bookmark->GetOrg(), bookmark->GetName(), "", IMAGE_ARROW); return; } @@ -372,7 +373,10 @@ namespace qt DiactivatePopup(); } - void DrawWidget::ActivatePopup(m2::PointD const & pivot, string const & name, PopupImageIndexT index) + void DrawWidget::ActivatePopup(m2::PointD const & pivot, + string const & name, + string const & type, + PopupImageIndexT index) { BookmarkBalloon * balloon = GetBookmarkBalloon(); @@ -380,19 +384,20 @@ namespace qt balloon->setImage(m_images[index]); balloon->setGlbPivot(pivot); - balloon->setBookmarkName(name); - balloon->setIsVisible(true); + balloon->setBookmarkCaption(name, type); + balloon->showAnimated(); m_framework->Invalidate(); } void DrawWidget::ActivatePopupWithAdressInfo(m2::PointD const & pivot, Framework::AddressInfo const & addrInfo) { - string name = addrInfo.FormatPinText(); - if (name.empty()) + string name = addrInfo.GetPinName(); + string type = addrInfo.GetPinType(); + if (name.empty() && type.empty()) name = m_framework->GetStringsBundle().GetString("dropped_pin"); - ActivatePopup(pivot, name, IMAGE_PLUS); + ActivatePopup(pivot, name, type, IMAGE_PLUS); m_framework->DrawPlacemark(pivot); m_framework->Invalidate(); @@ -402,7 +407,7 @@ namespace qt { BookmarkBalloon * balloon = GetBookmarkBalloon(); - balloon->setIsVisible(false); + balloon->hide(); m_framework->DisablePlacemark(); m_framework->Invalidate(); } @@ -414,15 +419,7 @@ namespace qt bp.m_position = graphics::EPosAbove; bp.m_depth = graphics::maxDepth; bp.m_pivot = m2::PointD(0.0, 0.0); - bp.m_text = "Bookmark"; - bp.m_textMarginLeft = 10; - bp.m_textMarginTop = 7; - bp.m_textMarginRight = 10; - bp.m_textMarginBottom = 10; - bp.m_imageMarginLeft = 0; - bp.m_imageMarginTop = 7; - bp.m_imageMarginRight = 10; - bp.m_imageMarginBottom = 10; + bp.m_mainText = "Bookmark"; bp.m_framework = m_framework.get(); m_bookmarkBalloon.reset(new BookmarkBalloon(bp)); @@ -432,6 +429,7 @@ namespace qt //m_bookmarkBalloon->setOnClickListener(bind(&DrawWidget::OnBalloonClick, this, _1)); m_framework->GetGuiController()->AddElement(m_bookmarkBalloon); + m_bookmarkBalloon->onScreenSize(width(), height()); } BookmarkBalloon * DrawWidget::GetBookmarkBalloon() diff --git a/qt/draw_widget.hpp b/qt/draw_widget.hpp index f9c6d669c7..14fd2a69a1 100644 --- a/qt/draw_widget.hpp +++ b/qt/draw_widget.hpp @@ -112,7 +112,7 @@ namespace qt 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, PopupImageIndexT index); + 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();