fixed some bugs with gui::Balloon rendering. added "arrow" and "plus" images logic into BookmarkBalloon.
|
@ -576,7 +576,7 @@ namespace android
|
|||
if (ValidateBookmarkAndCategory(bac))
|
||||
{
|
||||
Bookmark b = *(m_work.GetBmCategory(bac.first)->GetBookmark(bac.second));
|
||||
ActivatePopup(b.GetOrg(), b.GetName());
|
||||
ActivatePopup(b.GetOrg(), b.GetName(), "right-arrow.png");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -647,17 +647,18 @@ namespace android
|
|||
bmkname = cstream.str();
|
||||
}
|
||||
|
||||
ActivatePopup(bmkPosition, bmkname);
|
||||
ActivatePopup(bmkPosition, bmkname, "plus.png");
|
||||
m_work.DrawPlacemark(bmkPosition);
|
||||
m_work.Invalidate();
|
||||
}
|
||||
|
||||
void Framework::ActivatePopup(m2::PointD const & bmkPosition, string const & name)
|
||||
void Framework::ActivatePopup(m2::PointD const & bmkPosition, string const & name, string const & imageName)
|
||||
{
|
||||
gui::BookmarkBalloon * b = GetBookmarkBalloon();
|
||||
BookmarkBalloon * b = GetBookmarkBalloon();
|
||||
|
||||
m_work.DisablePlacemark();
|
||||
b->setBookmarkPivot(bmkPosition);
|
||||
b->setImage(graphics::Image::Info(imageName.c_str(), m_work.GetRenderPolicy()->Density()));
|
||||
b->setGlbPivot(bmkPosition);
|
||||
b->setBookmarkName(name);
|
||||
b->setIsVisible(true);
|
||||
m_work.Invalidate();
|
||||
|
@ -665,7 +666,7 @@ namespace android
|
|||
|
||||
void Framework::DeactivatePopup()
|
||||
{
|
||||
gui::BookmarkBalloon * b = GetBookmarkBalloon();
|
||||
BookmarkBalloon * b = GetBookmarkBalloon();
|
||||
b->setIsVisible(false);
|
||||
m_work.DisablePlacemark();
|
||||
m_work.Invalidate();
|
||||
|
@ -673,9 +674,9 @@ namespace android
|
|||
|
||||
void Framework::OnBalloonClick(gui::Element * e)
|
||||
{
|
||||
gui::BookmarkBalloon * balloon = GetBookmarkBalloon();
|
||||
BookmarkBalloon * balloon = GetBookmarkBalloon();
|
||||
|
||||
BookmarkAndCategory bac = m_work.GetBookmark(m_work.GtoP(balloon->getBookmarkPivot()));
|
||||
BookmarkAndCategory bac = m_work.GetBookmark(m_work.GtoP(balloon->glbPivot()));
|
||||
if (ValidateBookmarkAndCategory(bac))
|
||||
{
|
||||
m_balloonClickListener(bac);
|
||||
|
@ -685,14 +686,14 @@ namespace android
|
|||
BookmarkCategory * cat;
|
||||
if (m_work.GetBmCategoriesCount() == 0)
|
||||
{
|
||||
m_work.AddBookmark(m_work.GetStringsBundle().GetString("my_places"), Bookmark(balloon->getBookmarkPivot(), balloon->getBookmarkName(), "placemark-red"));
|
||||
m_work.AddBookmark(m_work.GetStringsBundle().GetString("my_places"), Bookmark(balloon->glbPivot(), balloon->bookmarkName(), "placemark-red"));
|
||||
cat = m_work.GetBmCategory(m_work.GetBmCategoriesCount()-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
cat = m_work.GetBmCategory(m_work.GetBmCategoriesCount()-1);
|
||||
LOG(LDEBUG,("Paladin", (balloon->getBookmarkPivot(), balloon->getBookmarkName(), "placemark-red")));
|
||||
m_work.AddBookmark(cat->GetName(), Bookmark(balloon->getBookmarkPivot(), balloon->getBookmarkName(), "placemark-red"));
|
||||
Bookmark bm(balloon->glbPivot(), balloon->bookmarkName(), "placemark-red");
|
||||
m_work.AddBookmark(cat->GetName(), bm);
|
||||
}
|
||||
cat->SaveToKMLFile();
|
||||
int catSize = cat->GetBookmarksCount() - 1;
|
||||
|
@ -714,28 +715,35 @@ namespace android
|
|||
m_balloonClickListener.clear();
|
||||
}
|
||||
|
||||
BookmarkBalloon * Framework::GetBookmarkBalloon()
|
||||
{
|
||||
if (!m_bmBaloon)
|
||||
CreateBookmarkBalloon();
|
||||
return m_bmBaloon.get();
|
||||
}
|
||||
|
||||
void Framework::CreateBookmarkBalloon()
|
||||
{
|
||||
CHECK(m_work.GetGuiController(), ());
|
||||
CHECK(m_work.GetRenderPolicy(), ());
|
||||
|
||||
gui::Balloon::Params bp;
|
||||
BookmarkBalloon::Params bp;
|
||||
|
||||
bp.m_position = graphics::EPosAbove;
|
||||
bp.m_depth = graphics::maxDepth;
|
||||
bp.m_depth = graphics::maxDepth - 3;
|
||||
bp.m_pivot = m2::PointD(0, 0);
|
||||
bp.m_imageMarginBottom = 10;
|
||||
bp.m_imageMarginLeft = 10;
|
||||
bp.m_imageMarginLeft = 0;
|
||||
bp.m_imageMarginRight = 10;
|
||||
bp.m_imageMarginTop = 10;
|
||||
bp.m_imageMarginTop = 7;
|
||||
bp.m_textMarginBottom = 10;
|
||||
bp.m_textMarginLeft = 10;
|
||||
bp.m_textMarginRight = 10;
|
||||
bp.m_textMarginTop = 10;
|
||||
bp.m_image = graphics::Image::Info("arrow.png", m_work.GetRenderPolicy()->Density());
|
||||
bp.m_textMarginTop = 7;
|
||||
bp.m_text = "Bookmark";
|
||||
bp.m_framework = &m_work;
|
||||
|
||||
m_bmBaloon.reset(new gui::BookmarkBalloon(bp, &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);
|
||||
|
|
|
@ -65,7 +65,7 @@ namespace android
|
|||
|
||||
bool HandleOnSmthClick(double x, double y);
|
||||
bool AdditionalHandlingForLongClick(double x, double y);
|
||||
void ActivatePopup(m2::PointD const & bmkPosition, string const & name);
|
||||
void ActivatePopup(m2::PointD const & bmkPosition, string const & name, string const & imageName);
|
||||
void ActivatePopupWithAddressInfo(m2::PointD const & bmkPosition, ::Framework::AddressInfo const & adInfo);
|
||||
|
||||
void ToCamelCase(string & c);
|
||||
|
@ -75,16 +75,11 @@ namespace android
|
|||
return (bac.first > -1 && bac.second > -1);
|
||||
}
|
||||
|
||||
shared_ptr<gui::BookmarkBalloon> m_bmBaloon;
|
||||
shared_ptr<BookmarkBalloon> m_bmBaloon;
|
||||
|
||||
void OnBalloonClick(gui::Element * e);
|
||||
void CreateBookmarkBalloon();
|
||||
inline gui::BookmarkBalloon * GetBookmarkBalloon()
|
||||
{
|
||||
if (!m_bmBaloon)
|
||||
CreateBookmarkBalloon();
|
||||
return m_bmBaloon.get();
|
||||
}
|
||||
BookmarkBalloon * GetBookmarkBalloon();
|
||||
|
||||
public:
|
||||
Framework();
|
||||
|
|
BIN
data/resources-hdpi/plus.png
Normal file
After Width: | Height: | Size: 232 B |
BIN
data/resources-hdpi/right-arrow.png
Normal file
After Width: | Height: | Size: 506 B |
BIN
data/resources-ldpi/plus.png
Normal file
After Width: | Height: | Size: 163 B |
BIN
data/resources-ldpi/right-arrow.png
Normal file
After Width: | Height: | Size: 247 B |
Before Width: | Height: | Size: 1.7 KiB |
BIN
data/resources-mdpi/plus.png
Normal file
After Width: | Height: | Size: 207 B |
BIN
data/resources-mdpi/right-arrow.png
Normal file
After Width: | Height: | Size: 292 B |
Before Width: | Height: | Size: 3.4 KiB |
BIN
data/resources-xhdpi/plus.png
Normal file
After Width: | Height: | Size: 272 B |
BIN
data/resources-xhdpi/right-arrow.png
Normal file
After Width: | Height: | Size: 709 B |
|
@ -23,7 +23,9 @@ namespace graphics
|
|||
{}
|
||||
|
||||
Image::Info::Info(char const * name, EDensity density)
|
||||
: Resource::Info(Resource::EImage), m_size(0, 0)
|
||||
: Resource::Info(Resource::EImage),
|
||||
m_size(0, 0),
|
||||
m_resourceName(name)
|
||||
{
|
||||
string resName = graphics::resourcePath(name, density);
|
||||
|
||||
|
@ -69,7 +71,7 @@ namespace graphics
|
|||
Image::Info const * ri = static_cast<Image::Info const *>(r);
|
||||
|
||||
if (m_resourceName != ri->m_resourceName)
|
||||
m_resourceName < ri->m_resourceName;
|
||||
return m_resourceName < ri->m_resourceName;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -43,22 +43,22 @@ namespace gui
|
|||
tp.m_text = m_text;
|
||||
tp.m_position = graphics::EPosRight;
|
||||
tp.m_pivot = m2::PointD(0, 0);
|
||||
tp.m_depth = depth();
|
||||
tp.m_depth = depth() + 1;
|
||||
|
||||
m_textView.reset(new TextView(tp));
|
||||
|
||||
m_textView->setFont(Element::EActive, graphics::FontDesc(20, graphics::Color(0, 0, 0, 255), true));
|
||||
m_textView->setFont(Element::EActive, graphics::FontDesc(20, graphics::Color(255, 255, 255, 255)));
|
||||
|
||||
ImageView::Params ip;
|
||||
|
||||
ip.m_pivot = m2::PointD(0, 0);
|
||||
ip.m_position = graphics::EPosRight;
|
||||
ip.m_depth = depth();
|
||||
ip.m_depth = depth() + 1;
|
||||
ip.m_image = m_image;
|
||||
|
||||
m_imageView.reset(new ImageView(ip));
|
||||
|
||||
m_arrowHeight = 20;
|
||||
m_arrowHeight = 10;
|
||||
m_arrowAngle = ang::DegreeToRad(90);
|
||||
m_arrowWidth = 2 * tan(m_arrowAngle / 2) * m_arrowHeight;
|
||||
}
|
||||
|
@ -88,13 +88,13 @@ namespace gui
|
|||
graphics::EPosition pos = position();
|
||||
|
||||
if (pos == graphics::EPosAbove)
|
||||
r.setMaxY(r.maxY() + m_arrowHeight);
|
||||
r.setMaxY(r.maxY() + m_arrowHeight * k);
|
||||
else if (pos == graphics::EPosUnder)
|
||||
r.setMinY(r.minY() - m_arrowHeight);
|
||||
r.setMinY(r.minY() - m_arrowHeight * k);
|
||||
else if (pos == graphics::EPosRight)
|
||||
r.setMinX(r.minX() - m_arrowHeight);
|
||||
r.setMinX(r.minX() - m_arrowHeight * k);
|
||||
else if (pos == graphics::EPosLeft)
|
||||
r.setMaxX(r.maxX() + m_arrowHeight);
|
||||
r.setMaxX(r.maxX() + m_arrowHeight * k);
|
||||
|
||||
m_boundRects[0] = m2::AnyRectD(r);
|
||||
|
||||
|
@ -122,6 +122,8 @@ namespace gui
|
|||
double imt = m_imageMarginTop * k;
|
||||
double imb = m_imageMarginBottom * k;
|
||||
|
||||
double arrowHeight = m_arrowHeight * k;
|
||||
|
||||
double w = tml + tr.SizeX() + tmr
|
||||
+ iml + ir.SizeX() + imr;
|
||||
|
||||
|
@ -134,29 +136,29 @@ namespace gui
|
|||
if (pos == graphics::EPosAbove)
|
||||
{
|
||||
m_textView->setPivot(m2::PointD(pv.x - w / 2 + tml,
|
||||
pv.y - h / 2 - m_arrowHeight));
|
||||
pv.y - h / 2 - arrowHeight));
|
||||
m_imageView->setPivot(m2::PointD(pv.x + w / 2 - imr - ir.SizeX(),
|
||||
pv.y - h / 2 - m_arrowHeight));
|
||||
pv.y - h / 2 - arrowHeight));
|
||||
}
|
||||
else if (pos == graphics::EPosUnder)
|
||||
{
|
||||
m_textView->setPivot(m2::PointD(pv.x - w / 2 + tml,
|
||||
pv.y + h / 2 + m_arrowHeight));
|
||||
pv.y + h / 2 + arrowHeight));
|
||||
m_imageView->setPivot(m2::PointD(pv.x + w / 2 - imr - ir.SizeX(),
|
||||
pv.y + h / 2 + m_arrowHeight));
|
||||
pv.y + h / 2 + arrowHeight));
|
||||
}
|
||||
else if (pos == graphics::EPosLeft)
|
||||
{
|
||||
m_textView->setPivot(m2::PointD(pv.x - w - m_arrowHeight + tml,
|
||||
m_textView->setPivot(m2::PointD(pv.x - w - arrowHeight + tml,
|
||||
pv.y));
|
||||
m_imageView->setPivot(m2::PointD(pv.x - m_arrowHeight - imr - ir.SizeX(),
|
||||
m_imageView->setPivot(m2::PointD(pv.x - arrowHeight - imr - ir.SizeX(),
|
||||
pv.y));
|
||||
}
|
||||
else if (pos == graphics::EPosRight)
|
||||
{
|
||||
m_textView->setPivot(m2::PointD(pv.x + m_arrowHeight + tml,
|
||||
m_textView->setPivot(m2::PointD(pv.x + arrowHeight + tml,
|
||||
pv.y));
|
||||
m_imageView->setPivot(m2::PointD(pv.x + m_arrowHeight + tml + tr.SizeX() + tmr + imr,
|
||||
m_imageView->setPivot(m2::PointD(pv.x + arrowHeight + tml + tr.SizeX() + tmr + imr,
|
||||
pv.y));
|
||||
}
|
||||
|
||||
|
@ -182,17 +184,19 @@ namespace gui
|
|||
|
||||
m2::RectD const & r = roughBoundRect();
|
||||
|
||||
double k = visualScale();
|
||||
|
||||
double bw = r.SizeX();
|
||||
double bh = r.SizeY();
|
||||
double aw = m_arrowWidth;
|
||||
double ah = m_arrowHeight;
|
||||
double aw = m_arrowWidth * k;
|
||||
double ah = m_arrowHeight * k;
|
||||
|
||||
graphics::EPosition pos = position();
|
||||
graphics::Path<float> p;
|
||||
|
||||
if (pos & graphics::EPosAbove)
|
||||
{
|
||||
bh -= m_arrowHeight;
|
||||
bh -= ah;
|
||||
|
||||
p.reset(m2::PointF(-aw / 2, -ah));
|
||||
p.lineRel(m2::PointF(-bw / 2 + aw / 2, 0));
|
||||
|
@ -205,7 +209,7 @@ namespace gui
|
|||
}
|
||||
else if (pos & graphics::EPosUnder)
|
||||
{
|
||||
bh -= m_arrowHeight;
|
||||
bh -= ah;
|
||||
|
||||
p.reset(m2::PointF(aw / 2, ah));
|
||||
p.lineRel(m2::PointF(bw / 2 - aw / 2, 0));
|
||||
|
@ -248,9 +252,9 @@ namespace gui
|
|||
{
|
||||
checkDirtyLayout();
|
||||
|
||||
// r->drawRectangle(roughBoundRect(), graphics::Color(0, 0, 255, 128), depth());
|
||||
// r->drawRectangle(m_textView->roughBoundRect(), graphics::Color(0, 255, 255, 128), depth());
|
||||
// r->drawRectangle(m_imageView->roughBoundRect(), graphics::Color(0, 255, 0, 128), depth());
|
||||
// r->drawRectangle(roughBoundRect(), graphics::Color(0, 0, 255, 128), depth() + 1);
|
||||
// r->drawRectangle(m_textView->roughBoundRect(), graphics::Color(0, 255, 255, 128), depth() + 1);
|
||||
// r->drawRectangle(m_imageView->roughBoundRect(), graphics::Color(0, 255, 0, 128), depth() + 1);
|
||||
|
||||
math::Matrix<double, 3, 3> drawM = math::Shift(
|
||||
math::Identity<double, 3>(),
|
||||
|
@ -303,4 +307,11 @@ namespace gui
|
|||
setIsDirtyLayout(true);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void Balloon::setImage(graphics::Image::Info const & info)
|
||||
{
|
||||
m_imageView->setImage(info);
|
||||
setIsDirtyLayout(true);
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,6 +85,7 @@ namespace gui
|
|||
void setOnClickListener(TOnClickListener const & fn);
|
||||
|
||||
void setText(string const & s);
|
||||
void setImage(graphics::Image::Info const & info);
|
||||
|
||||
bool onTapStarted(m2::PointD const & pt);
|
||||
bool onTapMoved(m2::PointD const & pt);
|
||||
|
|
|
@ -84,4 +84,10 @@ namespace gui
|
|||
r->drawDisplayList(m_displayList.get(), drawM * m);
|
||||
}
|
||||
}
|
||||
void ImageView::setImage(graphics::Image::Info const & info)
|
||||
{
|
||||
m_image = info;
|
||||
setIsDirtyLayout(true);
|
||||
invalidate();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,5 +42,6 @@ namespace gui
|
|||
vector<m2::AnyRectD> const & boundRects() const;
|
||||
|
||||
void draw(graphics::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const;
|
||||
void setImage(graphics::Image::Info const & info);
|
||||
};
|
||||
}
|
||||
|
|
|
@ -3,43 +3,40 @@
|
|||
|
||||
#define POPUP_PADDING 23
|
||||
|
||||
namespace gui
|
||||
BookmarkBalloon::BookmarkBalloon(Params const & p)
|
||||
: Balloon(p),
|
||||
m_framework(p.m_framework)
|
||||
{
|
||||
BookmarkBalloon::BookmarkBalloon(Params const & p, Framework const * framework)
|
||||
: Balloon(p),
|
||||
m_framework(framework)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
void BookmarkBalloon::update()
|
||||
void BookmarkBalloon::update()
|
||||
{
|
||||
Balloon::update();
|
||||
if (isVisible())
|
||||
{
|
||||
Balloon::update();
|
||||
if (isVisible())
|
||||
{
|
||||
m2::PointD newPivot(m_framework->GtoP(m_bookmarkPivot));
|
||||
newPivot.y -= POPUP_PADDING * visualScale();
|
||||
setPivot(newPivot);
|
||||
}
|
||||
}
|
||||
|
||||
void BookmarkBalloon::setBookmarkPivot(m2::PointD const & pivot)
|
||||
{
|
||||
m_bookmarkPivot = pivot;
|
||||
}
|
||||
|
||||
m2::PointD const BookmarkBalloon::getBookmarkPivot()
|
||||
{
|
||||
return m_bookmarkPivot;
|
||||
}
|
||||
|
||||
void BookmarkBalloon::setBookmarkName(std::string const & name)
|
||||
{
|
||||
m_bookmarkName = name;
|
||||
setText(name);//.substr(0, 13));
|
||||
}
|
||||
|
||||
std::string const BookmarkBalloon::getBookmarkName()
|
||||
{
|
||||
return m_bookmarkName;
|
||||
m2::PointD newPivot(m_framework->GtoP(m_glbPivot));
|
||||
newPivot.y -= POPUP_PADDING * visualScale();
|
||||
setPivot(newPivot);
|
||||
}
|
||||
}
|
||||
|
||||
void BookmarkBalloon::setGlbPivot(m2::PointD const & pivot)
|
||||
{
|
||||
m_glbPivot = pivot;
|
||||
}
|
||||
|
||||
m2::PointD const BookmarkBalloon::glbPivot()
|
||||
{
|
||||
return m_glbPivot;
|
||||
}
|
||||
|
||||
void BookmarkBalloon::setBookmarkName(string const & name)
|
||||
{
|
||||
m_bookmarkName = name;
|
||||
setText(name);//.substr(0, 13));
|
||||
}
|
||||
|
||||
string const & BookmarkBalloon::bookmarkName()
|
||||
{
|
||||
return m_bookmarkName;
|
||||
}
|
||||
|
|
|
@ -1,25 +1,35 @@
|
|||
#pragma once
|
||||
|
||||
#include "../gui/balloon.hpp"
|
||||
#include "../std/string.hpp"
|
||||
|
||||
class Framework;
|
||||
|
||||
namespace gui
|
||||
/// Balloon, which displays information about bookmark
|
||||
class BookmarkBalloon : public gui::Balloon
|
||||
{
|
||||
class BookmarkBalloon : public Balloon
|
||||
private:
|
||||
|
||||
m2::PointD m_glbPivot;
|
||||
Framework const * m_framework;
|
||||
string m_bookmarkName;
|
||||
|
||||
void update();
|
||||
|
||||
public:
|
||||
|
||||
typedef gui::Balloon base_t;
|
||||
|
||||
struct Params : public base_t::Params
|
||||
{
|
||||
private:
|
||||
void update();
|
||||
m2::PointD m_bookmarkPivot;
|
||||
Framework const * m_framework;
|
||||
std::string m_bookmarkName;
|
||||
|
||||
public:
|
||||
BookmarkBalloon(Params const & p, Framework const * framework);
|
||||
|
||||
void setBookmarkPivot(m2::PointD const & pivot);
|
||||
m2::PointD const getBookmarkPivot();
|
||||
void setBookmarkName(std::string const & name);
|
||||
std::string const getBookmarkName();
|
||||
};
|
||||
}
|
||||
|
||||
BookmarkBalloon(Params const & p);
|
||||
|
||||
void setGlbPivot(m2::PointD const & pivot);
|
||||
m2::PointD const glbPivot();
|
||||
|
||||
void setBookmarkName(string const & name);
|
||||
string const & bookmarkName();
|
||||
};
|
||||
|
|
|
@ -284,7 +284,7 @@ void InformationDisplay::drawMemoryWarning(Drawer * drawer)
|
|||
|
||||
void InformationDisplay::drawPlacemark(Drawer * pDrawer, string const & symbol, m2::PointD const & pt)
|
||||
{
|
||||
pDrawer->drawSymbol(pt, symbol, graphics::EPosAbove, graphics::maxDepth);
|
||||
pDrawer->drawSymbol(pt, symbol, graphics::EPosAbove, graphics::maxDepth - 4);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|