forked from organicmaps/organicmaps
Minor refactoring of InformationDisplay:
- remove useless class data - do not recalculate layout on every frame draw; do it when size changed only - use unique_ptr instead of shared_ptr - remove useless includes
This commit is contained in:
parent
573e647de3
commit
d9ca6e56ef
22 changed files with 319 additions and 459 deletions
|
@ -1,10 +1,13 @@
|
|||
#include "button.hpp"
|
||||
#include "controller.hpp"
|
||||
#include "text_view.hpp"
|
||||
|
||||
#include "../graphics/screen.hpp"
|
||||
#include "../graphics/display_list.hpp"
|
||||
|
||||
#include "../geometry/transformations.hpp"
|
||||
|
||||
|
||||
namespace gui
|
||||
{
|
||||
Button::Params::Params()
|
||||
|
@ -112,15 +115,15 @@ namespace gui
|
|||
|
||||
cs->beginFrame();
|
||||
|
||||
shared_ptr<graphics::DisplayList> & dl = m_dls[state];
|
||||
unique_ptr<graphics::DisplayList> & dl = m_dls[state];
|
||||
|
||||
dl.reset();
|
||||
dl.reset(cs->createDisplayList());
|
||||
|
||||
cs->setDisplayList(dl.get());
|
||||
|
||||
double k = visualScale();
|
||||
m2::RectD rr = roughBoundRect();
|
||||
double const k = visualScale();
|
||||
m2::RectD const rr = roughBoundRect();
|
||||
|
||||
cs->drawRoundedRectangle(m2::RectD(-rr.SizeX() / 2,
|
||||
-rr.SizeY() / 2,
|
||||
|
@ -192,16 +195,9 @@ namespace gui
|
|||
|
||||
checkDirtyLayout();
|
||||
|
||||
math::Matrix<double, 3, 3> drawM = math::Shift(math::Identity<double, 3>(),
|
||||
pivot());
|
||||
math::Matrix<double, 3, 3> const drawM = math::Shift(math::Identity<double, 3>(), pivot());
|
||||
|
||||
map<EState, shared_ptr<graphics::DisplayList> >::const_iterator it;
|
||||
it = m_dls.find(state());
|
||||
|
||||
if (it != m_dls.end())
|
||||
r->drawDisplayList(it->second.get(), drawM * m);
|
||||
else
|
||||
LOG(LDEBUG/*LWARNING*/, ("m_dls[state] is not set!"));
|
||||
r->drawDisplayList(m_dls.at(state()).get(), drawM * m);
|
||||
|
||||
m_textView->draw(r, m);
|
||||
}
|
||||
|
@ -224,4 +220,3 @@ namespace gui
|
|||
Element::setColor(state, c);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
#include "element.hpp"
|
||||
#include "text_view.hpp"
|
||||
|
||||
#include "../std/function.hpp"
|
||||
#include "../std/string.hpp"
|
||||
#include "../std/unique_ptr.hpp"
|
||||
|
||||
|
||||
namespace graphics
|
||||
{
|
||||
class OverlayElement;
|
||||
class DisplayList;
|
||||
|
||||
namespace gl
|
||||
{
|
||||
|
@ -19,6 +20,8 @@ namespace graphics
|
|||
|
||||
namespace gui
|
||||
{
|
||||
class TextView;
|
||||
|
||||
class Button : public Element
|
||||
{
|
||||
public:
|
||||
|
@ -33,14 +36,12 @@ namespace gui
|
|||
unsigned m_minHeight;
|
||||
|
||||
unique_ptr<TextView> m_textView;
|
||||
map<EState, shared_ptr<graphics::DisplayList> > m_dls;
|
||||
map<EState, unique_ptr<graphics::DisplayList> > m_dls;
|
||||
|
||||
void cacheButtonBody(EState state);
|
||||
|
||||
mutable vector<m2::AnyRectD> m_boundRects;
|
||||
|
||||
void cache();
|
||||
|
||||
public:
|
||||
|
||||
struct Params : Element::Params
|
||||
|
@ -53,14 +54,8 @@ namespace gui
|
|||
|
||||
Button(Params const & p);
|
||||
|
||||
bool onTapStarted(m2::PointD const & pt);
|
||||
bool onTapMoved(m2::PointD const & pt);
|
||||
bool onTapEnded(m2::PointD const & pt);
|
||||
bool onTapCancelled(m2::PointD const & pt);
|
||||
|
||||
void setOnClickListener(TOnClickListener const & l);
|
||||
|
||||
void setPivot(m2::PointD const & pv);
|
||||
void setFont(EState state, graphics::FontDesc const & font);
|
||||
void setColor(EState state, graphics::Color const & c);
|
||||
|
||||
|
@ -73,17 +68,22 @@ namespace gui
|
|||
void setMinHeight(unsigned minHeightInDIP);
|
||||
unsigned minHeight() const;
|
||||
|
||||
void setController(Controller * controller);
|
||||
|
||||
/// Inherited from OverlayElement
|
||||
/// @{
|
||||
|
||||
/// @name Override from graphics::OverlayElement and gui::Element.
|
||||
//@{
|
||||
vector<m2::AnyRectD> const & boundRects() const;
|
||||
void draw(graphics::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const;
|
||||
void setPivot(m2::PointD const & pv);
|
||||
|
||||
void purge();
|
||||
void layout();
|
||||
void cache();
|
||||
|
||||
/// @}
|
||||
void setController(Controller * controller);
|
||||
|
||||
bool onTapStarted(m2::PointD const & pt);
|
||||
bool onTapMoved(m2::PointD const & pt);
|
||||
bool onTapEnded(m2::PointD const & pt);
|
||||
bool onTapCancelled(m2::PointD const & pt);
|
||||
//@}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -5,6 +5,11 @@
|
|||
|
||||
#include "../graphics/glyph.hpp"
|
||||
#include "../graphics/screen.hpp"
|
||||
#include "../graphics/display_list.hpp"
|
||||
#include "../graphics/glyph_layout.hpp"
|
||||
|
||||
|
||||
using namespace graphics;
|
||||
|
||||
namespace gui
|
||||
{
|
||||
|
@ -14,11 +19,11 @@ namespace gui
|
|||
m_text = p.m_text;
|
||||
m_uniText = strings::MakeUniString(p.m_text);
|
||||
|
||||
setFont(EActive, graphics::FontDesc(12, graphics::Color(0, 0, 0, 255)));
|
||||
setFont(EPressed, graphics::FontDesc(12, graphics::Color(0, 0, 0, 255)));
|
||||
setFont(EActive, FontDesc(12, Color(0, 0, 0, 255)));
|
||||
setFont(EPressed, FontDesc(12, Color(0, 0, 0, 255)));
|
||||
|
||||
setColor(EActive, graphics::Color(graphics::Color(192, 192, 192, 255)));
|
||||
setColor(EPressed, graphics::Color(graphics::Color(64, 64, 64, 255)));
|
||||
setColor(EActive, Color(Color(192, 192, 192, 255)));
|
||||
setColor(EPressed, Color(Color(64, 64, 64, 255)));
|
||||
}
|
||||
|
||||
void CachedTextView::setText(string const & text)
|
||||
|
@ -31,7 +36,7 @@ namespace gui
|
|||
}
|
||||
}
|
||||
|
||||
void CachedTextView::setFont(EState state, graphics::FontDesc const & desc)
|
||||
void CachedTextView::setFont(EState state, FontDesc const & desc)
|
||||
{
|
||||
setIsDirtyLayout(true);
|
||||
Element::setFont(state, desc);
|
||||
|
@ -57,7 +62,7 @@ namespace gui
|
|||
return m_boundRects;
|
||||
}
|
||||
|
||||
void CachedTextView::draw(graphics::OverlayRenderer *r, math::Matrix<double, 3, 3> const & m) const
|
||||
void CachedTextView::draw(OverlayRenderer *r, math::Matrix<double, 3, 3> const & m) const
|
||||
{
|
||||
if (isVisible())
|
||||
{
|
||||
|
@ -66,11 +71,11 @@ namespace gui
|
|||
math::Matrix<double, 3, 3> id = math::Identity<double, 3>();
|
||||
|
||||
if (m_maskedLayout)
|
||||
for (unsigned i = 0; i < m_uniText.size(); ++i)
|
||||
for (size_t i = 0; i < m_uniText.size(); ++i)
|
||||
r->drawDisplayList(m_maskedDls[i].get(),
|
||||
math::Shift(id, m_maskedLayout->entries()[i].m_pt + m_maskedLayout->pivot()));
|
||||
|
||||
for (unsigned i = 0; i < m_uniText.size(); ++i)
|
||||
for (size_t i = 0; i < m_uniText.size(); ++i)
|
||||
r->drawDisplayList(m_dls[i].get(),
|
||||
math::Shift(id, m_layout->entries()[i].m_pt + m_layout->pivot()));
|
||||
}
|
||||
|
@ -81,29 +86,27 @@ namespace gui
|
|||
layout();
|
||||
|
||||
DisplayListCache * dlc = m_controller->GetDisplayListCache();
|
||||
graphics::FontDesc fontDesc = font(EActive);
|
||||
FontDesc fontDesc = font(EActive);
|
||||
|
||||
if (fontDesc.m_isMasked)
|
||||
{
|
||||
m_maskedDls.resize(m_uniText.size());
|
||||
for (unsigned i = 0; i < m_uniText.size(); ++i)
|
||||
m_maskedDls[i] = dlc->FindGlyph(graphics::GlyphKey(m_uniText[i],
|
||||
fontDesc.m_size,
|
||||
fontDesc.m_isMasked,
|
||||
fontDesc.m_isMasked ? fontDesc.m_maskColor : fontDesc.m_color));
|
||||
for (size_t i = 0; i < m_uniText.size(); ++i)
|
||||
m_maskedDls[i] = dlc->FindGlyph(GlyphKey(m_uniText[i],
|
||||
fontDesc.m_size,
|
||||
fontDesc.m_isMasked,
|
||||
fontDesc.m_isMasked ? fontDesc.m_maskColor : fontDesc.m_color));
|
||||
|
||||
fontDesc.m_isMasked = false;
|
||||
}
|
||||
|
||||
m_dls.resize(m_uniText.size());
|
||||
|
||||
for (unsigned i = 0; i < m_uniText.size(); ++i)
|
||||
m_dls[i] = dlc->FindGlyph(graphics::GlyphKey(m_uniText[i],
|
||||
fontDesc.m_size,
|
||||
fontDesc.m_isMasked,
|
||||
fontDesc.m_color));
|
||||
|
||||
|
||||
for (size_t i = 0; i < m_uniText.size(); ++i)
|
||||
m_dls[i] = dlc->FindGlyph(GlyphKey(m_uniText[i],
|
||||
fontDesc.m_size,
|
||||
fontDesc.m_isMasked,
|
||||
fontDesc.m_color));
|
||||
}
|
||||
|
||||
void CachedTextView::purge()
|
||||
|
@ -116,23 +119,23 @@ namespace gui
|
|||
if (m_uniText.empty())
|
||||
return;
|
||||
|
||||
graphics::FontDesc fontDesc = font(EActive);
|
||||
FontDesc fontDesc = font(EActive);
|
||||
|
||||
if (fontDesc.m_isMasked)
|
||||
{
|
||||
m_maskedLayout.reset(new graphics::GlyphLayout(m_controller->GetGlyphCache(),
|
||||
fontDesc,
|
||||
pivot(),
|
||||
m_uniText,
|
||||
position()));
|
||||
m_maskedLayout.reset(new GlyphLayout(m_controller->GetGlyphCache(),
|
||||
fontDesc,
|
||||
pivot(),
|
||||
m_uniText,
|
||||
position()));
|
||||
fontDesc.m_isMasked = false;
|
||||
}
|
||||
|
||||
m_layout.reset(new graphics::GlyphLayout(m_controller->GetGlyphCache(),
|
||||
fontDesc,
|
||||
pivot(),
|
||||
m_uniText,
|
||||
position()));
|
||||
m_layout.reset(new GlyphLayout(m_controller->GetGlyphCache(),
|
||||
fontDesc,
|
||||
pivot(),
|
||||
m_uniText,
|
||||
position()));
|
||||
}
|
||||
|
||||
void CachedTextView::setPivot(m2::PointD const & pv)
|
||||
|
|
|
@ -2,16 +2,19 @@
|
|||
|
||||
#include "element.hpp"
|
||||
|
||||
#include "../std/map.hpp"
|
||||
#include "../std/vector.hpp"
|
||||
#include "../std/shared_ptr.hpp"
|
||||
|
||||
#include "../base/string_utils.hpp"
|
||||
#include "../base/matrix.hpp"
|
||||
|
||||
#include "../graphics/glyph_cache.hpp"
|
||||
#include "../graphics/display_list.hpp"
|
||||
#include "../graphics/glyph_layout.hpp"
|
||||
#include "../std/vector.hpp"
|
||||
#include "../std/shared_ptr.hpp"
|
||||
#include "../std/unique_ptr.hpp"
|
||||
|
||||
|
||||
namespace graphics
|
||||
{
|
||||
class DisplayList;
|
||||
class GlyphLayout;
|
||||
}
|
||||
|
||||
namespace gui
|
||||
{
|
||||
|
|
|
@ -1,41 +1,42 @@
|
|||
#include "display_list_cache.hpp"
|
||||
|
||||
#include "../graphics/screen.hpp"
|
||||
#include "../graphics/display_list.hpp"
|
||||
#include "../graphics/glyph.hpp"
|
||||
#include "../graphics/depth_constants.hpp"
|
||||
|
||||
#include "../std/cstring.hpp"
|
||||
|
||||
using namespace graphics;
|
||||
|
||||
namespace gui
|
||||
{
|
||||
DisplayListCache::DisplayListCache(graphics::Screen * CacheScreen,
|
||||
graphics::GlyphCache * GlyphCache)
|
||||
DisplayListCache::DisplayListCache(Screen * CacheScreen,
|
||||
GlyphCache * GlyphCache)
|
||||
: m_CacheScreen(CacheScreen),
|
||||
m_GlyphCache(GlyphCache)
|
||||
{}
|
||||
|
||||
shared_ptr<graphics::DisplayList> const & DisplayListCache::FindGlyph(graphics::GlyphKey const & key)
|
||||
shared_ptr<DisplayList> const & DisplayListCache::FindGlyph(GlyphKey const & key)
|
||||
{
|
||||
TGlyphs::const_iterator it = m_Glyphs.find(key);
|
||||
|
||||
if (it != m_Glyphs.end())
|
||||
return it->second;
|
||||
|
||||
shared_ptr<graphics::DisplayList> & dl = m_Glyphs[key];
|
||||
shared_ptr<DisplayList> & dl = m_Glyphs[key];
|
||||
|
||||
dl.reset(m_CacheScreen->createDisplayList());
|
||||
|
||||
m_CacheScreen->beginFrame();
|
||||
m_CacheScreen->setDisplayList(dl.get());
|
||||
|
||||
uint32_t resID = m_CacheScreen->mapInfo(graphics::Glyph::Info(key, m_GlyphCache));
|
||||
graphics::Resource const * res = m_CacheScreen->fromID(resID);
|
||||
uint32_t resID = m_CacheScreen->mapInfo(Glyph::Info(key, m_GlyphCache));
|
||||
Resource const * res = m_CacheScreen->fromID(resID);
|
||||
|
||||
ASSERT(res->m_cat == graphics::Resource::EGlyph, ());
|
||||
graphics::Glyph const * glyph = static_cast<graphics::Glyph const *>(res);
|
||||
ASSERT(res->m_cat == Resource::EGlyph, ());
|
||||
Glyph const * glyph = static_cast<Glyph const *>(res);
|
||||
|
||||
m_CacheScreen->drawGlyph(m2::PointD(0, 0), m2::PointD(0, 0), ang::AngleD(0), 0, glyph, graphics::maxDepth - 10);
|
||||
m_CacheScreen->drawGlyph(m2::PointD(0, 0), m2::PointD(0, 0), ang::AngleD(0), 0, glyph, maxDepth - 10);
|
||||
|
||||
m_CacheScreen->setDisplayList(0);
|
||||
m_CacheScreen->endFrame();
|
||||
|
@ -43,16 +44,17 @@ namespace gui
|
|||
return dl;
|
||||
}
|
||||
|
||||
void DisplayListCache::TouchGlyph(graphics::GlyphKey const & key)
|
||||
void DisplayListCache::TouchGlyph(GlyphKey const & key)
|
||||
{
|
||||
FindGlyph(key);
|
||||
}
|
||||
|
||||
bool DisplayListCache::HasGlyph(graphics::GlyphKey const & key)
|
||||
bool DisplayListCache::HasGlyph(GlyphKey const & key)
|
||||
{
|
||||
return m_Glyphs.find(key) != m_Glyphs.end();
|
||||
}
|
||||
|
||||
/*
|
||||
void DisplayListCache::TouchSymbol(char const * name)
|
||||
{
|
||||
FindSymbol(name);
|
||||
|
@ -63,7 +65,7 @@ namespace gui
|
|||
return m_Symbols.find(name) != m_Symbols.end();
|
||||
}
|
||||
|
||||
shared_ptr<graphics::DisplayList> const & DisplayListCache::FindSymbol(char const * name)
|
||||
shared_ptr<DisplayList> const & DisplayListCache::FindSymbol(char const * name)
|
||||
{
|
||||
string s(name);
|
||||
TSymbols::const_iterator it = m_Symbols.find(s);
|
||||
|
@ -71,27 +73,25 @@ namespace gui
|
|||
if (it != m_Symbols.end())
|
||||
return it->second;
|
||||
|
||||
shared_ptr<graphics::DisplayList> & dl = m_Symbols[s];
|
||||
shared_ptr<DisplayList> & dl = m_Symbols[s];
|
||||
|
||||
dl.reset(m_CacheScreen->createDisplayList());
|
||||
|
||||
m_CacheScreen->beginFrame();
|
||||
m_CacheScreen->setDisplayList(dl.get());
|
||||
|
||||
graphics::EPosition pos = graphics::EPosAbove;
|
||||
if (strcmp(name, "search-result") == 0)
|
||||
{
|
||||
LOG(LDEBUG, ("Position checked"));
|
||||
pos = graphics::EPosCenter;
|
||||
}
|
||||
EPosition pos = EPosAbove;
|
||||
if (s == "search-result")
|
||||
pos = EPosCenter;
|
||||
|
||||
/// @todo do not cache depth in display list. use separate vertex shader and uniform constant
|
||||
/// to specify it while rendering display list.
|
||||
m_CacheScreen->drawSymbol(m2::PointD(0, 0), name, pos, graphics::poiDepth);
|
||||
m_CacheScreen->drawSymbol(m2::PointD(0, 0), name, pos, poiDepth);
|
||||
|
||||
m_CacheScreen->setDisplayList(0);
|
||||
m_CacheScreen->endFrame();
|
||||
|
||||
return dl;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#include "../graphics/glyph_cache.hpp"
|
||||
|
||||
#include "../std/shared_ptr.hpp"
|
||||
|
||||
#include "../graphics/screen.hpp"
|
||||
|
||||
namespace graphics
|
||||
{
|
||||
class Screen;
|
||||
class DisplayList;
|
||||
}
|
||||
|
||||
namespace gui
|
||||
{
|
||||
|
@ -26,21 +34,20 @@ namespace gui
|
|||
DisplayListCache(graphics::Screen * CacheScreen,
|
||||
graphics::GlyphCache * GlyphCache);
|
||||
|
||||
/// Add element to cache if need be
|
||||
/// Add element to cache if needed
|
||||
void TouchGlyph(graphics::GlyphKey const & key);
|
||||
/// Find glyph in cache, caching if needed.
|
||||
shared_ptr<graphics::DisplayList> const & FindGlyph(graphics::GlyphKey const & key);
|
||||
/// Check, whether the glyph is present in cache.
|
||||
bool HasGlyph(graphics::GlyphKey const & key);
|
||||
|
||||
/// @todo refactor to have common functions TouchInfo, FindInfo, HasInfo
|
||||
/// taking as example ResourceCache mapInfo, findInfo, hasInfo functions
|
||||
|
||||
/*
|
||||
/// Add symbol to cache if needed
|
||||
void TouchSymbol(char const * name);
|
||||
/// Find symbol in cache, caching if needed
|
||||
shared_ptr<graphics::DisplayList> const & FindSymbol(char const * name);
|
||||
/// Check, whether the display list for specified symbol is present in cache
|
||||
bool HasSymbol(char const * name);
|
||||
*/
|
||||
};
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace gui
|
|||
|
||||
void Element::draw(graphics::OverlayRenderer *r, math::Matrix<double, 3, 3> const & m) const
|
||||
{
|
||||
for (unsigned i = 0; i < boundRects().size(); ++i)
|
||||
for (size_t i = 0; i < boundRects().size(); ++i)
|
||||
r->drawRectangle(boundRects()[i], color(state()), depth());
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
#pragma once
|
||||
|
||||
#include "../geometry/point2d.hpp"
|
||||
|
||||
#include "../graphics/overlay_element.hpp"
|
||||
#include "../graphics/color.hpp"
|
||||
#include "../graphics/font_desc.hpp"
|
||||
|
||||
#include "../std/map.hpp"
|
||||
|
||||
|
||||
namespace graphics
|
||||
{
|
||||
namespace gl
|
||||
|
@ -83,12 +82,15 @@ namespace gui
|
|||
virtual void layout();
|
||||
/// set the parent controller for this element.
|
||||
virtual void setController(Controller * controller);
|
||||
|
||||
/// check if the layout of element is dirty and re-layout element if needed.
|
||||
void checkDirtyLayout() const;
|
||||
|
||||
/// @name Override from OverlayElement.
|
||||
//@{
|
||||
void draw(graphics::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const;
|
||||
double priority() const;
|
||||
|
||||
void setTransformation(const math::Matrix<double, 3, 3> & m);
|
||||
//@}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#include "alfa_animation_task.hpp"
|
||||
|
||||
#include "framework.hpp"
|
||||
|
||||
AlfaAnimationTask::AlfaAnimationTask(double start, double end, double timeInterval, double timeOffset, Framework * f)
|
||||
|
||||
AlfaAnimationTask::AlfaAnimationTask(double start, double end,
|
||||
double timeInterval, double timeOffset,
|
||||
Framework * f)
|
||||
: m_start(start)
|
||||
, m_end(end)
|
||||
, m_current(start)
|
||||
|
@ -25,17 +27,18 @@ float AlfaAnimationTask::GetCurrentAlfa() const
|
|||
void AlfaAnimationTask::OnStart(double ts)
|
||||
{
|
||||
m_timeStart = ts;
|
||||
base_t::OnStart(ts);
|
||||
BaseT::OnStart(ts);
|
||||
m_f->Invalidate();
|
||||
}
|
||||
|
||||
void AlfaAnimationTask::OnStep(double ts)
|
||||
{
|
||||
base_t::OnStep(ts);
|
||||
double elapsed = ts - (m_timeStart + m_timeOffset);
|
||||
BaseT::OnStep(ts);
|
||||
|
||||
double const elapsed = ts - (m_timeStart + m_timeOffset);
|
||||
if (elapsed >= 0.0)
|
||||
{
|
||||
double t = elapsed / m_timeInterval;
|
||||
double const t = elapsed / m_timeInterval;
|
||||
if (t > 1.0)
|
||||
{
|
||||
m_current = m_end;
|
||||
|
|
|
@ -2,16 +2,19 @@
|
|||
|
||||
#include "../anim/task.hpp"
|
||||
|
||||
|
||||
class Framework;
|
||||
|
||||
class AlfaAnimationTask : public anim::Task
|
||||
{
|
||||
typedef anim::Task base_t;
|
||||
typedef anim::Task BaseT;
|
||||
|
||||
public:
|
||||
AlfaAnimationTask(double start, double end, double timeInterval, double timeOffset, Framework * f);
|
||||
AlfaAnimationTask(double start, double end,
|
||||
double timeInterval, double timeOffset,
|
||||
Framework * f);
|
||||
|
||||
bool IsHiding() const;
|
||||
|
||||
float GetCurrentAlfa() const;
|
||||
|
||||
virtual void OnStart(double ts);
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
#include "compass_arrow.hpp"
|
||||
|
||||
#include "framework.hpp"
|
||||
#include "alfa_animation_task.hpp"
|
||||
|
||||
|
@ -7,13 +6,11 @@
|
|||
|
||||
#include "../gui/controller.hpp"
|
||||
|
||||
#include "../geometry/any_rect2d.hpp"
|
||||
#include "../geometry/transformations.hpp"
|
||||
#include "../graphics/display_list.hpp"
|
||||
|
||||
#include "../graphics/display_list.hpp"
|
||||
#include "../graphics/screen.hpp"
|
||||
#include "../graphics/pen.hpp"
|
||||
|
||||
|
||||
using namespace graphics;
|
||||
|
||||
|
@ -24,7 +21,6 @@ CompassArrow::Params::Params()
|
|||
CompassArrow::CompassArrow(Params const & p)
|
||||
: base_t(p),
|
||||
m_angle(0),
|
||||
m_displayList(NULL),
|
||||
m_boundRects(1),
|
||||
m_framework(p.m_framework)
|
||||
{
|
||||
|
@ -80,7 +76,7 @@ vector<m2::AnyRectD> const & CompassArrow::boundRects() const
|
|||
return m_boundRects;
|
||||
}
|
||||
|
||||
void CompassArrow::draw(graphics::OverlayRenderer * r,
|
||||
void CompassArrow::draw(OverlayRenderer * r,
|
||||
math::Matrix<double, 3, 3> const & m) const
|
||||
{
|
||||
if (isBaseVisible())
|
||||
|
@ -96,7 +92,7 @@ void CompassArrow::draw(graphics::OverlayRenderer * r,
|
|||
m_angle),
|
||||
pivot());
|
||||
|
||||
r->drawDisplayList(m_displayList, drawM * m, &holder);
|
||||
r->drawDisplayList(m_dl.get(), drawM * m, &holder);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -155,13 +151,13 @@ const Resource * CompassArrow::GetCompassResource() const
|
|||
|
||||
void CompassArrow::cache()
|
||||
{
|
||||
graphics::Screen * cacheScreen = m_controller->GetCacheScreen();
|
||||
Screen * cacheScreen = m_controller->GetCacheScreen();
|
||||
|
||||
purge();
|
||||
m_displayList = cacheScreen->createDisplayList();
|
||||
m_dl.reset();
|
||||
m_dl.reset(cacheScreen->createDisplayList());
|
||||
|
||||
cacheScreen->beginFrame();
|
||||
cacheScreen->setDisplayList(m_displayList);
|
||||
cacheScreen->setDisplayList(m_dl.get());
|
||||
cacheScreen->applyVarAlfaStates();
|
||||
|
||||
Resource const * res = GetCompassResource();
|
||||
|
@ -199,8 +195,7 @@ void CompassArrow::cache()
|
|||
|
||||
void CompassArrow::purge()
|
||||
{
|
||||
delete m_displayList;
|
||||
m_displayList = NULL;
|
||||
m_dl.reset();
|
||||
}
|
||||
|
||||
bool CompassArrow::isBaseVisible() const
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#pragma once
|
||||
|
||||
#include "../gui/element.hpp"
|
||||
#include "../geometry/any_rect2d.hpp"
|
||||
|
||||
#include "../std/shared_ptr.hpp"
|
||||
#include "../std/unique_ptr.hpp"
|
||||
|
||||
|
||||
namespace anim
|
||||
{
|
||||
|
@ -26,7 +28,7 @@ private:
|
|||
|
||||
double m_angle;
|
||||
|
||||
graphics::DisplayList * m_displayList;
|
||||
unique_ptr<graphics::DisplayList> m_dl;
|
||||
|
||||
shared_ptr<anim::Task> m_animTask;
|
||||
|
||||
|
@ -40,8 +42,6 @@ private:
|
|||
Framework * m_framework;
|
||||
graphics::Resource const * GetCompassResource() const;
|
||||
|
||||
void cache();
|
||||
void purge();
|
||||
bool isBaseVisible() const;
|
||||
|
||||
public:
|
||||
|
@ -60,12 +60,17 @@ public:
|
|||
void SetAngle(double angle);
|
||||
m2::PointD GetPixelSize() const;
|
||||
|
||||
/// @name Override from graphics::Overlayelement and gui::Element.
|
||||
//@{
|
||||
vector<m2::AnyRectD> const & boundRects() const;
|
||||
void draw(graphics::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const;
|
||||
virtual bool isVisible() const;
|
||||
|
||||
bool onTapEnded(m2::PointD const & pt);
|
||||
|
||||
bool isVisible() const;
|
||||
bool roughHitTest(m2::PointD const & pt) const;
|
||||
bool hitTest(m2::PointD const & pt) const;
|
||||
|
||||
void cache();
|
||||
void purge();
|
||||
|
||||
bool onTapEnded(m2::PointD const & pt);
|
||||
//@}
|
||||
};
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "country_status_display.hpp"
|
||||
|
||||
#include "../gui/controller.hpp"
|
||||
#include "../gui/text_view.hpp"
|
||||
|
||||
#include "../graphics/overlay_renderer.hpp"
|
||||
|
||||
|
@ -11,6 +12,7 @@
|
|||
#include "../std/bind.hpp"
|
||||
#include "../std/sstream.hpp"
|
||||
|
||||
|
||||
CountryStatusDisplay::Params::Params()
|
||||
: m_storage(0)
|
||||
{
|
||||
|
@ -147,25 +149,27 @@ CountryStatusDisplay::CountryStatusDisplay(Params const & p)
|
|||
m_slotID = m_storage->Subscribe(bind(&CountryStatusDisplay::CountryStatusChanged, this, _1),
|
||||
bind(&CountryStatusDisplay::CountryProgress, this, _1, _2));
|
||||
|
||||
using namespace graphics;
|
||||
|
||||
gui::Button::Params bp;
|
||||
|
||||
bp.m_depth = depth();
|
||||
bp.m_minWidth = 200;
|
||||
bp.m_minHeight = 40;
|
||||
bp.m_pivot = m2::PointD(0, 0);
|
||||
bp.m_position = graphics::EPosCenter;
|
||||
bp.m_position = EPosCenter;
|
||||
bp.m_text = "Download";
|
||||
|
||||
m_downloadButton.reset(new gui::Button(bp));
|
||||
m_downloadButton->setOnClickListener(bind(&CountryStatusDisplay::downloadCountry, this));
|
||||
m_downloadButton->setIsVisible(false);
|
||||
m_downloadButton->setPosition(graphics::EPosCenter);
|
||||
m_downloadButton->setPosition(EPosCenter);
|
||||
|
||||
m_downloadButton->setFont(EActive, graphics::FontDesc(16, graphics::Color(255, 255, 255, 255)));
|
||||
m_downloadButton->setFont(EPressed, graphics::FontDesc(16, graphics::Color(255, 255, 255, 255)));
|
||||
m_downloadButton->setFont(EActive, FontDesc(16, Color(255, 255, 255, 255)));
|
||||
m_downloadButton->setFont(EPressed, FontDesc(16, Color(255, 255, 255, 255)));
|
||||
|
||||
m_downloadButton->setColor(EActive, graphics::Color(graphics::Color(0, 0, 0, 0.6 * 255)));
|
||||
m_downloadButton->setColor(EPressed, graphics::Color(graphics::Color(0, 0, 0, 0.4 * 255)));
|
||||
m_downloadButton->setColor(EActive, Color(Color(0, 0, 0, 0.6 * 255)));
|
||||
m_downloadButton->setColor(EPressed, Color(Color(0, 0, 0, 0.4 * 255)));
|
||||
|
||||
gui::TextView::Params tp;
|
||||
tp.m_depth = depth();
|
||||
|
@ -175,9 +179,9 @@ CountryStatusDisplay::CountryStatusDisplay(Params const & p)
|
|||
m_statusMsg.reset(new gui::TextView(tp));
|
||||
|
||||
m_statusMsg->setIsVisible(false);
|
||||
m_statusMsg->setPosition(graphics::EPosCenter);
|
||||
m_statusMsg->setPosition(EPosCenter);
|
||||
|
||||
m_statusMsg->setFont(gui::Element::EActive, graphics::FontDesc(18));
|
||||
m_statusMsg->setFont(gui::Element::EActive, FontDesc(18));
|
||||
|
||||
setIsVisible(false);
|
||||
|
||||
|
|
|
@ -4,11 +4,15 @@
|
|||
|
||||
#include "../gui/element.hpp"
|
||||
#include "../gui/button.hpp"
|
||||
#include "../gui/text_view.hpp"
|
||||
|
||||
#include "../std/shared_ptr.hpp"
|
||||
#include "../std/unique_ptr.hpp"
|
||||
|
||||
|
||||
namespace gui
|
||||
{
|
||||
class TextView;
|
||||
}
|
||||
|
||||
/// This class is a composite GUI element to display
|
||||
/// an on-screen GUI for the country, which is not downloaded yet.
|
||||
class CountryStatusDisplay : public gui::Element
|
||||
|
@ -29,9 +33,9 @@ private:
|
|||
void UpdateStatusAndProgress();
|
||||
|
||||
/// download button
|
||||
shared_ptr<gui::Button> m_downloadButton;
|
||||
unique_ptr<gui::Button> m_downloadButton;
|
||||
/// country status message
|
||||
shared_ptr<gui::TextView> m_statusMsg;
|
||||
unique_ptr<gui::TextView> m_statusMsg;
|
||||
/// current map name, "Province" part of the fullName
|
||||
string m_mapName;
|
||||
/// current map group name, "Country" part of the fullName
|
||||
|
@ -45,14 +49,8 @@ private:
|
|||
|
||||
bool m_notEnoughSpace;
|
||||
|
||||
/// bounding rects
|
||||
mutable vector<m2::AnyRectD> m_boundRects;
|
||||
|
||||
/// caching resources for fast rendering.
|
||||
void cache();
|
||||
void purge();
|
||||
void layout();
|
||||
|
||||
string const displayName() const;
|
||||
|
||||
template <class T1, class T2>
|
||||
|
@ -75,20 +73,22 @@ public:
|
|||
void setDownloadListener(gui::Button::TOnClickListener const & l);
|
||||
/// set current country name
|
||||
void setCountryIndex(storage::TIndex const & idx);
|
||||
/// reposition element
|
||||
|
||||
/// @name Override from graphics::OverlayElement and gui::Element.
|
||||
//@{
|
||||
void setPivot(m2::PointD const & pv);
|
||||
/// attach element to controller.
|
||||
void setController(gui::Controller *controller);
|
||||
/// render element
|
||||
void draw(graphics::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const;
|
||||
/// get bounding rects
|
||||
vector<m2::AnyRectD> const & boundRects() const;
|
||||
|
||||
/// react on touch events
|
||||
/// @{
|
||||
void cache();
|
||||
void purge();
|
||||
void layout();
|
||||
|
||||
void setController(gui::Controller * controller);
|
||||
|
||||
bool onTapStarted(m2::PointD const & pt);
|
||||
bool onTapMoved(m2::PointD const & pt);
|
||||
bool onTapEnded(m2::PointD const & pt);
|
||||
bool onTapCancelled(m2::PointD const & pt);
|
||||
/// @}
|
||||
//@}
|
||||
};
|
||||
|
|
|
@ -682,15 +682,13 @@ void Framework::DrawAdditionalInfo(shared_ptr<PaintEvent> const & e)
|
|||
m_informationDisplay.setEmptyCountryIndex(GetCountryIndex(GetViewportCenter()));
|
||||
|
||||
m_informationDisplay.enableCountryStatusDisplay(isEmptyModel);
|
||||
bool isCompassEnabled = ang::AngleIn2PI(m_navigator.Screen().GetAngle()) > my::DegToRad(3.0);
|
||||
bool const isCompassEnabled = ang::AngleIn2PI(m_navigator.Screen().GetAngle()) > my::DegToRad(3.0);
|
||||
m_informationDisplay.enableCompassArrow(isCompassEnabled ||
|
||||
(m_informationDisplay.isCompassArrowEnabled() && m_navigator.InAction()));
|
||||
|
||||
m_informationDisplay.setCompassArrowAngle(m_navigator.Screen().GetAngle());
|
||||
|
||||
m_informationDisplay.setScreen(m_navigator.Screen());
|
||||
|
||||
int drawScale = GetDrawScale();
|
||||
int const drawScale = GetDrawScale();
|
||||
m_informationDisplay.setDebugInfo(0, drawScale);
|
||||
|
||||
m_informationDisplay.enableRuler(drawScale > 4);
|
||||
|
@ -699,6 +697,7 @@ void Framework::DrawAdditionalInfo(shared_ptr<PaintEvent> const & e)
|
|||
#endif
|
||||
|
||||
m_informationDisplay.doDraw(pDrawer);
|
||||
|
||||
pScreen->endFrame();
|
||||
|
||||
m_bmManager.DrawItems(e);
|
||||
|
@ -1613,7 +1612,7 @@ RenderPolicy * Framework::GetRenderPolicy() const
|
|||
|
||||
void Framework::SetupMeasurementSystem()
|
||||
{
|
||||
m_informationDisplay.ruler()->setIsDirtyLayout(true);
|
||||
m_informationDisplay.measurementSystemChanged();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
|
|
|
@ -18,8 +18,6 @@
|
|||
#include "move_screen_task.hpp"
|
||||
#include "track.hpp"
|
||||
|
||||
#include "../defines.hpp"
|
||||
|
||||
#include "../search/search_engine.hpp"
|
||||
|
||||
#include "../routing/routing_engine.hpp"
|
||||
|
@ -35,7 +33,6 @@
|
|||
#include "../geometry/rect2d.hpp"
|
||||
#include "../geometry/screenbase.hpp"
|
||||
|
||||
#include "../base/logging.hpp"
|
||||
#include "../base/strings_bundle.hpp"
|
||||
|
||||
#include "../std/vector.hpp"
|
||||
|
|
|
@ -3,29 +3,20 @@
|
|||
#include "country_status_display.hpp"
|
||||
#include "compass_arrow.hpp"
|
||||
#include "framework.hpp"
|
||||
|
||||
#include "../indexer/mercator.hpp"
|
||||
#include "ruler.hpp"
|
||||
|
||||
#include "../gui/controller.hpp"
|
||||
#include "../gui/button.hpp"
|
||||
#include "../gui/cached_text_view.hpp"
|
||||
|
||||
#include "../graphics/defines.hpp"
|
||||
#include "../graphics/pen.hpp"
|
||||
#include "../graphics/straight_text_element.hpp"
|
||||
#include "../graphics/depth_constants.hpp"
|
||||
|
||||
#include "../base/string_utils.hpp"
|
||||
#include "../base/logging.hpp"
|
||||
#include "../base/math.hpp"
|
||||
#include "../base/mutex.hpp"
|
||||
#include "../base/macros.hpp"
|
||||
#include "../graphics/display_list.hpp"
|
||||
|
||||
#include "../geometry/transformations.hpp"
|
||||
|
||||
#include "../std/fstream.hpp"
|
||||
#include "../std/iomanip.hpp"
|
||||
#include "../std/target_os.hpp"
|
||||
|
||||
using namespace graphics;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -37,10 +28,9 @@ namespace
|
|||
}
|
||||
|
||||
InformationDisplay::InformationDisplay(Framework * fw)
|
||||
: m_bottomShift(0),
|
||||
m_visualScale(1)
|
||||
: m_visualScale(1)
|
||||
{
|
||||
m_fontDesc.m_color = graphics::Color(0x44, 0x44, 0x44, 0xFF);
|
||||
m_fontDesc.m_color = Color(0x44, 0x44, 0x44, 0xFF);
|
||||
|
||||
InitRuler(fw);
|
||||
InitCountryStatusDisplay(fw);
|
||||
|
@ -53,10 +43,11 @@ InformationDisplay::InformationDisplay(Framework * fw)
|
|||
enableMemoryWarning(false);
|
||||
enableBenchmarkInfo(false);
|
||||
enableCountryStatusDisplay(false);
|
||||
|
||||
m_compassArrow->setIsVisible(false);
|
||||
m_ruler->setIsVisible(false);
|
||||
|
||||
for (int i = 0; i < sizeof(m_DebugPts) / sizeof(m2::PointD); ++i)
|
||||
for (size_t i = 0; i < ARRAY_SIZE(m_DebugPts); ++i)
|
||||
m_DebugPts[i] = m2::PointD(0, 0);
|
||||
|
||||
setVisualScale(m_visualScale);
|
||||
|
@ -66,8 +57,8 @@ void InformationDisplay::InitRuler(Framework * fw)
|
|||
{
|
||||
Ruler::Params p;
|
||||
|
||||
p.m_depth = graphics::rulerDepth;
|
||||
p.m_position = graphics::EPosAboveLeft;
|
||||
p.m_depth = rulerDepth;
|
||||
p.m_position = EPosAboveLeft;
|
||||
p.m_framework = fw;
|
||||
|
||||
m_ruler.reset(new Ruler(p));
|
||||
|
@ -78,8 +69,8 @@ void InformationDisplay::InitCountryStatusDisplay(Framework * fw)
|
|||
CountryStatusDisplay::Params p;
|
||||
|
||||
p.m_pivot = m2::PointD(0, 0);
|
||||
p.m_position = graphics::EPosCenter;
|
||||
p.m_depth = graphics::countryStatusDepth;
|
||||
p.m_position = EPosCenter;
|
||||
p.m_depth = countryStatusDepth;
|
||||
p.m_storage = &fw->Storage();
|
||||
|
||||
m_countryStatusDisplay.reset(new CountryStatusDisplay(p));
|
||||
|
@ -89,8 +80,8 @@ void InformationDisplay::InitCompassArrow(Framework * fw)
|
|||
{
|
||||
CompassArrow::Params p;
|
||||
|
||||
p.m_position = graphics::EPosCenter;
|
||||
p.m_depth = graphics::compassDepth;
|
||||
p.m_position = EPosCenter;
|
||||
p.m_depth = compassDepth;
|
||||
p.m_pivot = m2::PointD(0, 0);
|
||||
p.m_framework = fw;
|
||||
|
||||
|
@ -101,10 +92,10 @@ void InformationDisplay::InitLocationState(Framework * fw)
|
|||
{
|
||||
location::State::Params p;
|
||||
|
||||
p.m_position = graphics::EPosCenter;
|
||||
p.m_depth = graphics::locationDepth;
|
||||
p.m_position = EPosCenter;
|
||||
p.m_depth = locationDepth;
|
||||
p.m_pivot = m2::PointD(0, 0);
|
||||
p.m_locationAreaColor = graphics::Color(0x51, 0xA3, 0xDC, 0x46);
|
||||
p.m_locationAreaColor = Color(0x51, 0xA3, 0xDC, 0x46);
|
||||
p.m_framework = fw;
|
||||
|
||||
m_locationState.reset(new location::State(p));
|
||||
|
@ -114,14 +105,14 @@ void InformationDisplay::InitDebugLabel()
|
|||
{
|
||||
gui::CachedTextView::Params p;
|
||||
|
||||
p.m_depth = graphics::debugDepth;
|
||||
p.m_position = graphics::EPosAboveRight;
|
||||
p.m_depth = debugDepth;
|
||||
p.m_position = EPosAboveRight;
|
||||
p.m_pivot = m2::PointD(0, 0);
|
||||
|
||||
m_debugLabel.reset(new gui::CachedTextView(p));
|
||||
}
|
||||
|
||||
void InformationDisplay::setController(gui::Controller *controller)
|
||||
void InformationDisplay::setController(gui::Controller * controller)
|
||||
{
|
||||
m_controller = controller;
|
||||
m_controller->AddElement(m_countryStatusDisplay);
|
||||
|
@ -131,44 +122,21 @@ void InformationDisplay::setController(gui::Controller *controller)
|
|||
m_controller->AddElement(m_debugLabel);
|
||||
}
|
||||
|
||||
void InformationDisplay::setScreen(ScreenBase const & screen)
|
||||
{
|
||||
m_screen = screen;
|
||||
|
||||
m2::RectD const & pxRect = m_screen.PixelRect();
|
||||
if (m_countryStatusDisplay->isVisible())
|
||||
{
|
||||
m2::PointD pt = m2::PointD(pxRect.SizeX() / 2, pxRect.SizeY() / 2) - m2::PointD(0, m_bottomShift * m_visualScale);
|
||||
m_countryStatusDisplay->setPivot(pt);
|
||||
}
|
||||
|
||||
double k = m_controller->GetVisualScale();
|
||||
m2::PointD size = m_compassArrow->GetPixelSize();
|
||||
|
||||
double compassX = COMPASS_X_OFFSET * k + size.x / 2.0;
|
||||
double compassY = pxRect.maxY() - COMPASS_Y_OFFSET * k - size.y / 2.0;
|
||||
|
||||
m_compassArrow->setPivot(m2::PointD(compassX, compassY));
|
||||
}
|
||||
|
||||
void InformationDisplay::setBottomShift(double bottomShift)
|
||||
{
|
||||
m_bottomShift = bottomShift;
|
||||
}
|
||||
|
||||
void InformationDisplay::setDisplayRect(m2::RectI const & rect)
|
||||
{
|
||||
m_displayRect = rect;
|
||||
|
||||
m2::PointD const pt(m2::PointD(m_displayRect.maxX() - RULLER_X_OFFSET * m_visualScale,
|
||||
m_displayRect.maxY() - RULLER_Y_OFFSET * m_visualScale));
|
||||
m_countryStatusDisplay->setPivot(m2::PointD(rect.Center()));
|
||||
|
||||
m_ruler->setPivot(pt);
|
||||
m2::PointD const size = m_compassArrow->GetPixelSize();
|
||||
m_compassArrow->setPivot(m2::PointD(COMPASS_X_OFFSET * m_visualScale + size.x / 2.0,
|
||||
rect.maxY() - COMPASS_Y_OFFSET * m_visualScale - size.y / 2.0));
|
||||
|
||||
m2::PointD const debugLabelPivot(m_displayRect.minX() + 10,
|
||||
m_displayRect.minY() + 50 + 5 * m_visualScale);
|
||||
m_ruler->setPivot(m2::PointD(rect.maxX() - RULLER_X_OFFSET * m_visualScale,
|
||||
rect.maxY() - RULLER_Y_OFFSET * m_visualScale));
|
||||
|
||||
m_debugLabel->setPivot(debugLabelPivot);
|
||||
m_debugLabel->setPivot(m2::PointD(rect.minX() + 10,
|
||||
rect.minY() + 50 + 5 * m_visualScale));
|
||||
}
|
||||
|
||||
void InformationDisplay::enableDebugPoints(bool doEnable)
|
||||
|
@ -183,11 +151,11 @@ void InformationDisplay::setDebugPoint(int pos, m2::PointD const & pt)
|
|||
|
||||
void InformationDisplay::drawDebugPoints(Drawer * pDrawer)
|
||||
{
|
||||
for (int i = 0; i < sizeof(m_DebugPts) / sizeof(m2::PointD); ++i)
|
||||
for (size_t i = 0; i < ARRAY_SIZE(m_DebugPts); ++i)
|
||||
if (m_DebugPts[i] != m2::PointD(0, 0))
|
||||
{
|
||||
pDrawer->screen()->drawArc(m_DebugPts[i], 0, math::pi * 2, 30, graphics::Color(0, 0, 255, 32), graphics::debugDepth);
|
||||
pDrawer->screen()->fillSector(m_DebugPts[i], 0, math::pi * 2, 30, graphics::Color(0, 0, 255, 32), graphics::debugDepth);
|
||||
pDrawer->screen()->drawArc(m_DebugPts[i], 0, math::pi * 2, 30, Color(0, 0, 255, 32), debugDepth);
|
||||
pDrawer->screen()->fillSector(m_DebugPts[i], 0, math::pi * 2, 30, Color(0, 0, 255, 32), debugDepth);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,11 +189,8 @@ void InformationDisplay::enableDebugInfo(bool doEnable)
|
|||
|
||||
void InformationDisplay::setDebugInfo(double frameDuration, int currentScale)
|
||||
{
|
||||
m_frameDuration = frameDuration;
|
||||
m_currentScale = currentScale;
|
||||
|
||||
ostringstream out;
|
||||
out << "Scale : " << m_currentScale;
|
||||
out << "Scale : " << currentScale;
|
||||
|
||||
m_debugLabel->setText(out.str());
|
||||
}
|
||||
|
@ -251,23 +216,15 @@ void InformationDisplay::drawMemoryWarning(Drawer * drawer)
|
|||
|
||||
drawer->screen()->drawText(m_fontDesc,
|
||||
pos,
|
||||
graphics::EPosAboveRight,
|
||||
EPosAboveRight,
|
||||
out.str(),
|
||||
graphics::debugDepth,
|
||||
debugDepth,
|
||||
false);
|
||||
|
||||
if (m_lastMemoryWarning.ElapsedSeconds() > 5)
|
||||
enableMemoryWarning(false);
|
||||
}
|
||||
|
||||
void InformationDisplay::drawPlacemark(Drawer * pDrawer, string const & symbol, m2::PointD const & pt)
|
||||
{
|
||||
pDrawer->screen()->drawDisplayList(m_controller
|
||||
->GetDisplayListCache()
|
||||
->FindSymbol(symbol.c_str()).get(),
|
||||
math::Shift(math::Identity<double, 3>(), pt));
|
||||
}
|
||||
|
||||
void InformationDisplay::enableCompassArrow(bool doEnable)
|
||||
{
|
||||
if (doEnable)
|
||||
|
@ -296,7 +253,7 @@ void InformationDisplay::setEmptyCountryIndex(storage::TIndex const & idx)
|
|||
m_countryStatusDisplay->setCountryIndex(idx);
|
||||
}
|
||||
|
||||
void InformationDisplay::setDownloadListener(gui::Button::TOnClickListener l)
|
||||
void InformationDisplay::setDownloadListener(gui::Button::TOnClickListener const & l)
|
||||
{
|
||||
m_downloadButton->setOnClickListener(l);
|
||||
}
|
||||
|
@ -323,9 +280,9 @@ void InformationDisplay::drawBenchmarkInfo(Drawer * pDrawer)
|
|||
m2::PointD pos(m_displayRect.minX() + 10, m_displayRect.minY() + m_yOffset);
|
||||
pDrawer->screen()->drawText(m_fontDesc,
|
||||
pos,
|
||||
graphics::EPosAboveRight,
|
||||
EPosAboveRight,
|
||||
"benchmark info :",
|
||||
graphics::benchmarkDepth,
|
||||
benchmarkDepth,
|
||||
false);
|
||||
|
||||
size_t const count = m_benchmarkInfo.size();
|
||||
|
@ -343,9 +300,9 @@ void InformationDisplay::drawBenchmarkInfo(Drawer * pDrawer)
|
|||
pos.y += 20;
|
||||
pDrawer->screen()->drawText(m_fontDesc,
|
||||
pos,
|
||||
graphics::EPosAboveRight,
|
||||
EPosAboveRight,
|
||||
out.str(),
|
||||
graphics::benchmarkDepth,
|
||||
benchmarkDepth,
|
||||
false);
|
||||
}
|
||||
}
|
||||
|
@ -371,7 +328,7 @@ shared_ptr<location::State> const & InformationDisplay::locationState() const
|
|||
return m_locationState;
|
||||
}
|
||||
|
||||
shared_ptr<Ruler> const & InformationDisplay::ruler() const
|
||||
void InformationDisplay::measurementSystemChanged()
|
||||
{
|
||||
return m_ruler;
|
||||
m_ruler->setIsDirtyLayout(true);
|
||||
}
|
||||
|
|
|
@ -1,18 +1,17 @@
|
|||
#pragma once
|
||||
|
||||
#include "window_handle.hpp"
|
||||
#include "ruler.hpp"
|
||||
|
||||
#include "../storage/index.hpp"
|
||||
|
||||
#include "../gui/button.hpp"
|
||||
|
||||
#include "../graphics/font_desc.hpp"
|
||||
|
||||
#include "../storage/index.hpp"
|
||||
|
||||
#include "../geometry/point2d.hpp"
|
||||
#include "../geometry/rect2d.hpp"
|
||||
#include "../geometry/screenbase.hpp"
|
||||
|
||||
#include "../base/timer.hpp"
|
||||
#include "../base/logging.hpp"
|
||||
|
||||
#include "../std/shared_ptr.hpp"
|
||||
|
||||
|
||||
namespace location
|
||||
|
@ -32,33 +31,23 @@ namespace gui
|
|||
class Framework;
|
||||
class CountryStatusDisplay;
|
||||
class CompassArrow;
|
||||
class Ruler;
|
||||
|
||||
/// Class, which displays additional information on the primary layer.
|
||||
/// like rules, coordinates, GPS position and heading
|
||||
/// Class, which displays additional information on the primary layer like:
|
||||
/// rules, coordinates, GPS position and heading, compass, Download button, etc.
|
||||
class InformationDisplay
|
||||
{
|
||||
private:
|
||||
|
||||
graphics::FontDesc m_fontDesc;
|
||||
|
||||
ScreenBase m_screen;
|
||||
m2::RectI m_displayRect;
|
||||
int m_yOffset;
|
||||
|
||||
/// for debugging purposes
|
||||
/// up to 10 debugging points
|
||||
/// For debugging purposes up to 10 drawable points.
|
||||
bool m_isDebugPointsEnabled;
|
||||
m2::PointD m_DebugPts[10];
|
||||
|
||||
shared_ptr<Ruler> m_ruler;
|
||||
|
||||
bool m_isCenterEnabled;
|
||||
m2::PointD m_centerPtLonLat;
|
||||
int m_currentScale;
|
||||
|
||||
bool m_isDebugInfoEnabled;
|
||||
double m_frameDuration;
|
||||
|
||||
shared_ptr<gui::Button> m_downloadButton;
|
||||
gui::Controller * m_controller;
|
||||
|
||||
|
@ -73,7 +62,6 @@ private:
|
|||
|
||||
vector<BenchmarkInfo> m_benchmarkInfo;
|
||||
|
||||
double m_bottomShift;
|
||||
double m_visualScale;
|
||||
|
||||
my::Timer m_lastMemoryWarning;
|
||||
|
@ -96,9 +84,7 @@ public:
|
|||
|
||||
void setController(gui::Controller * controller);
|
||||
|
||||
void setScreen(ScreenBase const & screen);
|
||||
void setDisplayRect(m2::RectI const & rect);
|
||||
void setBottomShift(double bottomShift);
|
||||
void setVisualScale(double visualScale);
|
||||
|
||||
void enableDebugPoints(bool doEnable);
|
||||
|
@ -115,7 +101,7 @@ public:
|
|||
void memoryWarning();
|
||||
void drawMemoryWarning(Drawer * pDrawer);
|
||||
|
||||
void drawPlacemark(Drawer * pDrawer, string const & symbol, m2::PointD const & pt);
|
||||
void measurementSystemChanged();
|
||||
|
||||
void enableBenchmarkInfo(bool doEnable);
|
||||
bool addBenchmarkInfo(string const & name, m2::RectD const & globalRect, double frameDuration);
|
||||
|
@ -123,10 +109,6 @@ public:
|
|||
|
||||
void doDraw(Drawer * drawer);
|
||||
|
||||
void enableLog(bool doEnable, WindowHandle * windowHandle);
|
||||
void setLogSize(size_t logSize);
|
||||
void drawLog(Drawer * pDrawer);
|
||||
|
||||
void enableCompassArrow(bool doEnable);
|
||||
bool isCompassArrowEnabled() const;
|
||||
void setCompassArrowAngle(double angle);
|
||||
|
@ -134,12 +116,8 @@ public:
|
|||
shared_ptr<location::State> const & locationState() const;
|
||||
|
||||
void enableCountryStatusDisplay(bool doEnable);
|
||||
void setDownloadListener(gui::Button::TOnClickListener l);
|
||||
void setDownloadListener(gui::Button::TOnClickListener const & l);
|
||||
void setEmptyCountryIndex(storage::TIndex const & idx);
|
||||
|
||||
shared_ptr<CountryStatusDisplay> const & countryStatusDisplay() const;
|
||||
shared_ptr<Ruler> const & ruler() const;
|
||||
|
||||
|
||||
static void logMessage(my::LogLevel, my::SrcPoint const &, string const &);
|
||||
};
|
||||
|
|
|
@ -11,14 +11,14 @@
|
|||
|
||||
#include "../gui/controller.hpp"
|
||||
|
||||
#include "../indexer/mercator.hpp"
|
||||
|
||||
#include "../platform/platform.hpp"
|
||||
#include "../platform/location.hpp"
|
||||
|
||||
#include "../geometry/rect2d.hpp"
|
||||
#include "../geometry/transformations.hpp"
|
||||
|
||||
#include "../indexer/mercator.hpp"
|
||||
|
||||
#include "../base/logging.hpp"
|
||||
|
||||
namespace location
|
||||
{
|
||||
|
@ -36,7 +36,7 @@ namespace location
|
|||
{}
|
||||
|
||||
State::State(Params const & p)
|
||||
: base_t(p),
|
||||
: BaseT(p),
|
||||
m_errorRadius(0),
|
||||
m_position(0, 0),
|
||||
m_drawHeading(0.0),
|
||||
|
|
|
@ -2,11 +2,9 @@
|
|||
|
||||
#include "../gui/element.hpp"
|
||||
|
||||
#include "../platform/location.hpp"
|
||||
|
||||
#include "../geometry/point2d.hpp"
|
||||
#include "../geometry/screenbase.hpp"
|
||||
|
||||
#include "../std/function.hpp"
|
||||
#include "../std/shared_ptr.hpp"
|
||||
#include "../std/unique_ptr.hpp"
|
||||
#include "../std/map.hpp"
|
||||
|
@ -77,7 +75,7 @@ namespace location
|
|||
ELocationProcessMode m_locationProcessMode;
|
||||
ECompassProcessMode m_compassProcessMode;
|
||||
|
||||
typedef gui::Element base_t;
|
||||
typedef gui::Element BaseT;
|
||||
|
||||
graphics::Color m_locationAreaColor;
|
||||
|
||||
|
@ -106,7 +104,7 @@ namespace location
|
|||
void FollowCompass();
|
||||
|
||||
public:
|
||||
struct Params : base_t::Params
|
||||
struct Params : BaseT::Params
|
||||
{
|
||||
graphics::Color m_locationAreaColor;
|
||||
Framework * m_framework;
|
||||
|
@ -155,12 +153,12 @@ namespace location
|
|||
void OnCompassUpdate(location::CompassInfo const & info);
|
||||
//@}
|
||||
|
||||
/// graphics::OverlayElement and gui::Element related methods
|
||||
// @{
|
||||
/// @name Override from graphics::OverlayElement and gui::Element.
|
||||
//@{
|
||||
vector<m2::AnyRectD> const & boundRects() const;
|
||||
void draw(graphics::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const;
|
||||
bool roughHitTest(m2::PointD const & pt) const;
|
||||
bool hitTest(m2::PointD const & pt) const;
|
||||
/// @}
|
||||
//@}
|
||||
};
|
||||
}
|
||||
|
|
215
map/ruler.cpp
215
map/ruler.cpp
|
@ -7,7 +7,6 @@
|
|||
|
||||
#include "../platform/settings.hpp"
|
||||
|
||||
#include "../gui/cached_text_view.hpp"
|
||||
#include "../gui/controller.hpp"
|
||||
|
||||
#include "../graphics/glyph.hpp"
|
||||
|
@ -17,24 +16,28 @@
|
|||
#include "../graphics/uniforms_holder.hpp"
|
||||
|
||||
#include "../indexer/mercator.hpp"
|
||||
|
||||
#include "../geometry/distance_on_sphere.hpp"
|
||||
#include "../geometry/transformations.hpp"
|
||||
|
||||
#include "../base/logging.hpp"
|
||||
#include "../base/string_utils.hpp"
|
||||
#include "../base/macros.hpp"
|
||||
|
||||
|
||||
using namespace graphics;
|
||||
|
||||
namespace
|
||||
{
|
||||
static const float RulerHeight = 2.0;
|
||||
static const int32_t MinPixelWidth = 60;
|
||||
static const int32_t MinMetersWidth = 10;
|
||||
static const int32_t MaxMetersWidth = 1000000;
|
||||
static const int32_t CacheLength = 500;
|
||||
static const int RulerHeight = 2;
|
||||
static const int MinPixelWidth = 60;
|
||||
static const int MinMetersWidth = 10;
|
||||
static const int MaxMetersWidth = 1000000;
|
||||
static const int CacheLength = 500;
|
||||
|
||||
static const int32_t MinUnitValue = -1;
|
||||
static const int32_t MaxUnitValue = numeric_limits<int32_t>::max() - 1;
|
||||
static const int32_t InvalidUnitValue = MaxUnitValue + 1;
|
||||
static const int MinUnitValue = -1;
|
||||
static const int MaxUnitValue = numeric_limits<int>::max() - 1;
|
||||
static const int InvalidUnitValue = MaxUnitValue + 1;
|
||||
|
||||
static const int TextOffsetFromRuler = 3;
|
||||
|
||||
struct UnitValue
|
||||
{
|
||||
|
@ -119,15 +122,14 @@ Ruler::RulerFrame::RulerFrame(Framework & f, const Ruler::RulerFrame::frame_end_
|
|||
|
||||
|
||||
Ruler::RulerFrame::RulerFrame(const Ruler::RulerFrame & other, const Ruler::RulerFrame::frame_end_fn & fn)
|
||||
: m_f(other.m_f)
|
||||
: m_f(other.m_f), m_dl(other.m_dl), m_textDL(other.m_textDL)
|
||||
{
|
||||
m_dl = other.m_dl;
|
||||
m_textDL = other.m_textDL;
|
||||
m_textLengthInPx = other.m_textLengthInPx;
|
||||
m_scale = other.m_scale;
|
||||
m_depth = other.m_depth;
|
||||
m_orgPt = other.m_orgPt;
|
||||
m_callback = fn;
|
||||
|
||||
HideAnimate(false);
|
||||
}
|
||||
|
||||
|
@ -147,121 +149,32 @@ bool Ruler::RulerFrame::IsValid() const
|
|||
return m_dl != NULL && m_textDL != NULL;
|
||||
}
|
||||
|
||||
void Ruler::RulerFrame::Cache(const string & text, graphics::FontDesc const & f)
|
||||
void Ruler::RulerFrame::Cache(const string & text, FontDesc const & f)
|
||||
{
|
||||
gui::Controller * controller = m_f.GetGuiController();
|
||||
graphics::Screen * cs = controller->GetCacheScreen();
|
||||
double k = m_f.GetVisualScale();
|
||||
Screen * cs = controller->GetCacheScreen();
|
||||
double const k = m_f.GetVisualScale();
|
||||
|
||||
// Create solid line DL.
|
||||
if (m_dl == NULL)
|
||||
{
|
||||
m_dl.reset(cs->createDisplayList());
|
||||
|
||||
cs->beginFrame();
|
||||
|
||||
cs->setDisplayList(m_dl.get());
|
||||
|
||||
cs->applyVarAlfaStates();
|
||||
|
||||
// double halfLength = CacheLength / 2.0;
|
||||
|
||||
// graphics::GlyphKey key(strings::LastUniChar("0"), f.m_size, f.m_isMasked, f.m_color);
|
||||
// graphics::Glyph::Info glyphInfo(key, controller->GetGlyphCache());
|
||||
// uint32_t zeroMarkGlyph = cs->mapInfo(glyphInfo);
|
||||
// graphics::Resource const * glyphRes = cs->fromID(zeroMarkGlyph);
|
||||
|
||||
// m2::RectI glyphRect(glyphRes->m_texRect);
|
||||
// double glyphHalfW = glyphRect.SizeX() / 2.0;
|
||||
// double glyphHalfH = glyphRect.SizeY() / 2.0;
|
||||
// double zeroMarkOffset = (glyphHalfH + 2) + 5 * k;
|
||||
|
||||
graphics::Brush::Info brushInfo(graphics::Color(0, 0, 0, 0x99));
|
||||
uint32_t brushId = cs->mapInfo(brushInfo);
|
||||
graphics::Resource const * brushRes = cs->fromID(brushId);
|
||||
m2::RectU brushRect = brushRes->m_texRect;
|
||||
|
||||
//shared_ptr<graphics::gl::BaseTexture> glyphTexture = cs->pipeline(glyphRes->m_pipelineID).texture();
|
||||
m2::PointF brushCenter = cs->pipeline(brushRes->m_pipelineID).texture()->mapPixel(brushRect.Center());
|
||||
|
||||
// 0 1 10 11 18 17
|
||||
// -- -- --
|
||||
// || || ||
|
||||
// || 3, 6 9||8, 12 16||14
|
||||
// 2|--------- -------------|
|
||||
// | |
|
||||
// | |
|
||||
// 4--------------------------
|
||||
// 5 7, 13 15
|
||||
|
||||
m2::PointD coords[] =
|
||||
{
|
||||
// Zero mark geometry
|
||||
/*-4*/ //m2::PointD(0.0, -zeroMarkOffset),
|
||||
/*-3*/ //m2::PointD(0.0, -zeroMarkOffset),
|
||||
/*-2*/ //m2::PointD(0.0, -zeroMarkOffset),
|
||||
/*-1*/ //m2::PointD(0.0, -zeroMarkOffset),
|
||||
// Ruler geometry
|
||||
/* 0*/ //m2::PointD(0.0, -5.0 * k),
|
||||
/* 1*/ //m2::PointD(0.0, -5.0 * k),
|
||||
/* 2*/ //m2::PointD(0.0, -3.0 * k),
|
||||
/* 3*/ m2::PointD(0.0, -RulerHeight * k),
|
||||
/* 4*/ m2::PointD(0.0, 0.0),
|
||||
/* 5*/ //m2::PointD(0.0, 0.0),
|
||||
/* 6*/ //m2::PointD(0.0, -3.0 * k),
|
||||
/* 7*/ //m2::PointD(halfLength - 0.5, 0.0),
|
||||
/* 8*/ //m2::PointD(halfLength - 0.5, -3.0 * k),
|
||||
/* 9*/ //m2::PointD(halfLength - 0.5, -3.0 * k),
|
||||
/*10*/ //m2::PointD(halfLength - 0.5, -7.0 * k),
|
||||
/*11*/ //m2::PointD(halfLength - 0.5, -7.0 * k),
|
||||
/*12*/ //m2::PointD(halfLength - 0.5, -3.0 * k),
|
||||
/*13*/ //m2::PointD(halfLength - 0.5, 0.0 * k),
|
||||
/*14*/ m2::PointD(CacheLength, -RulerHeight * k),
|
||||
/*15*/ m2::PointD(CacheLength, 0.0 * k),
|
||||
/*16*/ //m2::PointD(CacheLength, -3.0 * k),
|
||||
/*17*/ //m2::PointD(CacheLength, -5.0 * k),
|
||||
/*18*/ //m2::PointD(CacheLength, -5.0 * k)
|
||||
};
|
||||
|
||||
//m2::PointF normals[] =
|
||||
//{
|
||||
// Zero mark normals
|
||||
/*-4*/ //m2::PointF(-glyphHalfW + 1, -glyphHalfH),
|
||||
/*-3*/ //m2::PointF(-glyphHalfW + 1, glyphHalfH),
|
||||
/*-2*/ //m2::PointF( glyphHalfW + 1, -glyphHalfH),
|
||||
/*-1*/ //m2::PointF( glyphHalfW + 1, glyphHalfH),
|
||||
// Ruler normals
|
||||
/* 0*/ //m2::PointF( 0.0 , 0.0),
|
||||
/* 1*/ //m2::PointF( 1.0 * k , 0.0),
|
||||
/* 2*/ //m2::PointF( 0.0 , 0.0),
|
||||
/* 3*/ //m2::PointF( 1.0 * k , 0.0),
|
||||
/* 4*/ //m2::PointF( 0.0 , 0.0),
|
||||
/* 5*/ //m2::PointF( 1.0 * k , 0.0),
|
||||
/* 6*/ //m2::PointF( 1.0 * k , 0.0),
|
||||
/* 7*/ //m2::PointF( 1.0 * k , 0.0),
|
||||
/* 8*/ //m2::PointF( 1.0 * k , 0.0),
|
||||
/* 9*/ //m2::PointF( 0.0 , 0.0),
|
||||
/*10*/ //m2::PointF( 0.0 , 0.0),
|
||||
/*11*/ //m2::PointF( 1.0 * k , 0.0),
|
||||
/*12*/ //m2::PointF( 1.0 * k , 0.0),
|
||||
/*13*/ //m2::PointF( 1.0 * k , 0.0),
|
||||
/*14*/ //m2::PointF( 0.0 , 0.0),
|
||||
/*15*/ //m2::PointF( 0.0 , 0.0),
|
||||
/*16*/ //m2::PointF(-1.0 * k , 0.0),
|
||||
/*17*/ //m2::PointF( 0.0 , 0.0),
|
||||
/*18*/ //m2::PointF(-1.0 * k , 0.0)
|
||||
//};
|
||||
|
||||
//vector<m2::PointF> texCoords(ARRAY_SIZE(coords), brushCenter);
|
||||
//texCoords[0] = glyphTexture->mapPixel(m2::PointF(glyphRect.minX(), glyphRect.minY()));
|
||||
//texCoords[1] = glyphTexture->mapPixel(m2::PointF(glyphRect.minX(), glyphRect.maxY()));
|
||||
//texCoords[2] = glyphTexture->mapPixel(m2::PointF(glyphRect.maxX(), glyphRect.minY()));
|
||||
//texCoords[3] = glyphTexture->mapPixel(m2::PointF(glyphRect.maxX(), glyphRect.maxY()));
|
||||
|
||||
//ASSERT(ARRAY_SIZE(coords) == ARRAY_SIZE(normals), ());
|
||||
|
||||
// cs->addTexturedStripStrided(coords, sizeof(m2::PointD),
|
||||
// normals, sizeof(m2::PointF),
|
||||
// &texCoords[0], sizeof(m2::PointF), 4,
|
||||
// m_depth, glyphRes->m_pipelineID);
|
||||
Brush::Info const brushInfo(Color(0, 0, 0, 0x99));
|
||||
Resource const * brushRes = cs->fromID(cs->mapInfo(brushInfo));
|
||||
m2::PointF const brushCenter = cs->pipeline(brushRes->m_pipelineID).texture()->mapPixel(brushRes->m_texRect.Center());
|
||||
|
||||
m2::PointF normal(0.0, 0.0);
|
||||
cs->addTexturedStripStrided(coords , sizeof(m2::PointD),
|
||||
|
@ -270,13 +183,11 @@ void Ruler::RulerFrame::Cache(const string & text, graphics::FontDesc const & f)
|
|||
m_depth, brushRes->m_pipelineID);
|
||||
|
||||
cs->setDisplayList(0);
|
||||
|
||||
cs->applyStates();
|
||||
|
||||
cs->endFrame();
|
||||
}
|
||||
|
||||
// ============================================================ //
|
||||
// Create text DL.
|
||||
|
||||
ASSERT(!text.empty(), ());
|
||||
|
||||
|
@ -290,14 +201,14 @@ void Ruler::RulerFrame::Cache(const string & text, graphics::FontDesc const & f)
|
|||
|
||||
strings::UniString uniString = strings::MakeUniString(text);
|
||||
size_t length = uniString.size();
|
||||
buffer_vector<graphics::Glyph::Info, 8> infos(length, graphics::Glyph::Info());
|
||||
buffer_vector<graphics::Resource::Info const *, 8> resInfos(length, NULL);
|
||||
buffer_vector<Glyph::Info, 8> infos(length, Glyph::Info());
|
||||
buffer_vector<Resource::Info const *, 8> resInfos(length, NULL);
|
||||
buffer_vector<uint32_t, 8> ids(length, 0);
|
||||
buffer_vector<graphics::Resource const *, 8> glyphRes(length, NULL);
|
||||
buffer_vector<Resource const *, 8> glyphRes(length, NULL);
|
||||
|
||||
for (size_t i = 0; i < uniString.size(); ++i)
|
||||
{
|
||||
infos[i] = graphics::Glyph::Info(graphics::GlyphKey(uniString[i], f.m_size, false, f.m_color),
|
||||
infos[i] = Glyph::Info(GlyphKey(uniString[i], f.m_size, false, f.m_color),
|
||||
controller->GetGlyphCache());
|
||||
|
||||
resInfos[i] = &infos[i];
|
||||
|
@ -307,12 +218,12 @@ void Ruler::RulerFrame::Cache(const string & text, graphics::FontDesc const & f)
|
|||
{
|
||||
for (size_t i = 0; i < ids.size(); ++i)
|
||||
{
|
||||
graphics::Resource const * res = cs->fromID(ids[i]);
|
||||
Resource const * res = cs->fromID(ids[i]);
|
||||
glyphRes[i] = res;
|
||||
}
|
||||
|
||||
int32_t pipelineID = glyphRes[0]->m_pipelineID;
|
||||
shared_ptr<graphics::gl::BaseTexture> texture = cs->pipeline(pipelineID).texture();
|
||||
shared_ptr<gl::BaseTexture> texture = cs->pipeline(pipelineID).texture();
|
||||
double lengthFromStart = 0.0;
|
||||
|
||||
buffer_vector<m2::PointF, 48> coords;
|
||||
|
@ -416,19 +327,19 @@ void Ruler::RulerFrame::HideAnimate(bool needPause)
|
|||
CreateAnim(1.0, 0.0, timeInterval, offset, false);
|
||||
}
|
||||
|
||||
void Ruler::RulerFrame::Draw(graphics::OverlayRenderer * r, const math::Matrix<double, 3, 3> & m)
|
||||
void Ruler::RulerFrame::Draw(OverlayRenderer * r, const math::Matrix<double, 3, 3> & m)
|
||||
{
|
||||
ASSERT(m_dl != NULL, ("Main display list is null"));
|
||||
ASSERT(m_textDL != NULL, ("Text display list is null"));
|
||||
graphics::UniformsHolder holder;
|
||||
float a = GetCurrentAlfa();
|
||||
holder.insertValue(graphics::ETransparency, a);
|
||||
ASSERT(m_dl, ());
|
||||
ASSERT(m_textDL, ());
|
||||
|
||||
UniformsHolder holder;
|
||||
holder.insertValue(ETransparency, GetCurrentAlfa());
|
||||
|
||||
r->drawDisplayList(m_dl.get(), math::Shift(
|
||||
math::Scale(m, m2::PointD(m_scale, 1.0)),
|
||||
m_orgPt), &holder);
|
||||
|
||||
double yOffset = -(2 + 3 * m_f.GetVisualScale());
|
||||
double const yOffset = -(2 + TextOffsetFromRuler * m_f.GetVisualScale());
|
||||
r->drawDisplayList(m_textDL.get(),
|
||||
math::Shift(m, m_orgPt + m2::PointF(CacheLength * m_scale - m_textLengthInPx, yOffset)),
|
||||
&holder);
|
||||
|
@ -538,8 +449,6 @@ Ruler::Ruler(Params const & p)
|
|||
m_boundRects(1),
|
||||
m_currentRangeIndex(InvalidUnitValue),
|
||||
m_currSystem(0),
|
||||
m_mainFrame(NULL),
|
||||
m_animFrame(NULL),
|
||||
m_framework(p.m_framework)
|
||||
{
|
||||
setIsVisible(false);
|
||||
|
@ -604,10 +513,7 @@ void Ruler::UpdateText(const string & text)
|
|||
return;
|
||||
|
||||
if (frame->IsValid())
|
||||
{
|
||||
delete m_animFrame;
|
||||
m_animFrame = new RulerFrame(*frame, bind(&Ruler::AnimFrameAnimEnded, this, _1, _2));
|
||||
}
|
||||
m_animFrame.reset(new RulerFrame(*frame, bind(&Ruler::AnimFrameAnimEnded, this, _1, _2)));
|
||||
|
||||
frame->Cache(text, font(EActive));
|
||||
if (isVisible())
|
||||
|
@ -622,42 +528,40 @@ void Ruler::MainFrameAnimEnded(bool isVisible, RulerFrame * frame)
|
|||
|
||||
void Ruler::AnimFrameAnimEnded(bool /*isVisible*/, RulerFrame * frame)
|
||||
{
|
||||
delete frame;
|
||||
m_animFrame = NULL;
|
||||
ASSERT_EQUAL(m_animFrame.get(), frame, ());
|
||||
m_animFrame.reset();
|
||||
}
|
||||
|
||||
Ruler::RulerFrame * Ruler::GetMainFrame()
|
||||
{
|
||||
if (m_mainFrame == NULL)
|
||||
m_mainFrame = new RulerFrame(*m_framework, bind(&Ruler::MainFrameAnimEnded, this, _1, _2), depth());
|
||||
|
||||
return m_mainFrame;
|
||||
if (!m_mainFrame)
|
||||
m_mainFrame.reset(new RulerFrame(*m_framework, bind(&Ruler::MainFrameAnimEnded, this, _1, _2), depth()));
|
||||
return m_mainFrame.get();
|
||||
}
|
||||
|
||||
Ruler::RulerFrame * Ruler::GetMainFrame() const
|
||||
{
|
||||
ASSERT(m_mainFrame != NULL, ());
|
||||
return m_mainFrame;
|
||||
ASSERT(m_mainFrame, ());
|
||||
return m_mainFrame.get();
|
||||
}
|
||||
|
||||
void Ruler::purge()
|
||||
{
|
||||
m_currentRangeIndex = InvalidUnitValue;
|
||||
delete m_mainFrame;
|
||||
m_mainFrame = NULL;
|
||||
|
||||
delete m_animFrame;
|
||||
m_animFrame = NULL;
|
||||
m_mainFrame.reset();
|
||||
m_animFrame.reset();
|
||||
|
||||
setIsVisible(false);
|
||||
}
|
||||
|
||||
void Ruler::update()
|
||||
{
|
||||
double k = visualScale();
|
||||
double const k = visualScale();
|
||||
|
||||
ScreenBase const & screen = m_framework->GetNavigator().Screen();
|
||||
|
||||
int const rulerHeight = my::rounds(5 * k);
|
||||
int const rulerHeight = my::rounds(RulerHeight * k);
|
||||
int const minPxWidth = my::rounds(MinPixelWidth * k);
|
||||
|
||||
// pivot() here is the down right point of the ruler.
|
||||
|
@ -694,16 +598,16 @@ void Ruler::update()
|
|||
|
||||
m2::PointD orgPt = pivot() + m2::PointD(-scalerWidthInPx / 2, rulerHeight / 2);
|
||||
|
||||
if (position() & graphics::EPosLeft)
|
||||
if (position() & EPosLeft)
|
||||
orgPt.x -= scalerWidthInPx / 2;
|
||||
|
||||
if (position() & graphics::EPosRight)
|
||||
if (position() & EPosRight)
|
||||
orgPt.x += scalerWidthInPx / 2;
|
||||
|
||||
if (position() & graphics::EPosAbove)
|
||||
if (position() & EPosAbove)
|
||||
orgPt.y -= rulerHeight / 2;
|
||||
|
||||
if (position() & graphics::EPosUnder)
|
||||
if (position() & EPosUnder)
|
||||
orgPt.y += rulerHeight / 2;
|
||||
|
||||
RulerFrame * frame = GetMainFrame();
|
||||
|
@ -715,7 +619,7 @@ vector<m2::AnyRectD> const & Ruler::boundRects() const
|
|||
{
|
||||
if (isDirtyRect())
|
||||
{
|
||||
graphics::FontDesc const & f = font(EActive);
|
||||
FontDesc const & f = font(EActive);
|
||||
RulerFrame * frame = GetMainFrame();
|
||||
m2::PointD org = frame->GetOrgPoint();
|
||||
m2::PointD size = m2::PointD(CacheLength * frame->GetScale(), f.m_size * 2);
|
||||
|
@ -733,7 +637,7 @@ void Ruler::cache()
|
|||
update();
|
||||
}
|
||||
|
||||
void Ruler::draw(graphics::OverlayRenderer * s, math::Matrix<double, 3, 3> const & m) const
|
||||
void Ruler::draw(OverlayRenderer * s, math::Matrix<double, 3, 3> const & m) const
|
||||
{
|
||||
if (isVisible())
|
||||
{
|
||||
|
@ -745,3 +649,8 @@ void Ruler::draw(graphics::OverlayRenderer * s, math::Matrix<double, 3, 3> const
|
|||
m_animFrame->Draw(s, m);
|
||||
}
|
||||
}
|
||||
|
||||
int Ruler::GetTextOffsetFromLine() const
|
||||
{
|
||||
return TextOffsetFromRuler;
|
||||
}
|
||||
|
|
|
@ -2,14 +2,10 @@
|
|||
|
||||
#include "../gui/element.hpp"
|
||||
|
||||
#include "../geometry/screenbase.hpp"
|
||||
#include "../geometry/point2d.hpp"
|
||||
#include "../geometry/any_rect2d.hpp"
|
||||
|
||||
#include "../graphics/display_list.hpp"
|
||||
|
||||
#include "../std/shared_ptr.hpp"
|
||||
#include "../std/list.hpp"
|
||||
#include "../std/unique_ptr.hpp"
|
||||
#include "../std/function.hpp"
|
||||
|
||||
|
||||
namespace anim
|
||||
{
|
||||
|
@ -18,19 +14,17 @@ namespace anim
|
|||
|
||||
namespace graphics
|
||||
{
|
||||
class DisplayList;
|
||||
|
||||
namespace gl
|
||||
{
|
||||
class OverlayRenderer;
|
||||
}
|
||||
}
|
||||
|
||||
namespace gui
|
||||
{
|
||||
class CachedTextView;
|
||||
}
|
||||
|
||||
class Framework;
|
||||
|
||||
|
||||
class Ruler : public gui::Element
|
||||
{
|
||||
typedef gui::Element base_t;
|
||||
|
@ -73,8 +67,10 @@ class Ruler : public gui::Element
|
|||
|
||||
private:
|
||||
Framework & m_f;
|
||||
|
||||
shared_ptr<graphics::DisplayList> m_dl;
|
||||
shared_ptr<graphics::DisplayList> m_textDL;
|
||||
|
||||
int m_textLengthInPx;
|
||||
double m_scale;
|
||||
double m_depth;
|
||||
|
@ -95,8 +91,9 @@ private:
|
|||
|
||||
RulerFrame * GetMainFrame();
|
||||
RulerFrame * GetMainFrame() const;
|
||||
RulerFrame * m_mainFrame;
|
||||
RulerFrame * m_animFrame;
|
||||
|
||||
unique_ptr<RulerFrame> m_mainFrame;
|
||||
unique_ptr<RulerFrame> m_animFrame;
|
||||
|
||||
Framework * m_framework;
|
||||
|
||||
|
@ -113,6 +110,8 @@ public:
|
|||
void AnimateShow();
|
||||
void AnimateHide();
|
||||
|
||||
/// @name Override from graphics::OverlayElement and gui::Element.
|
||||
//@{
|
||||
vector<m2::AnyRectD> const & boundRects() const;
|
||||
void draw(graphics::OverlayRenderer * r, math::Matrix<double, 3, 3> const & m) const;
|
||||
|
||||
|
@ -120,4 +119,7 @@ public:
|
|||
void layout();
|
||||
void cache();
|
||||
void purge();
|
||||
//@}
|
||||
|
||||
int GetTextOffsetFromLine() const;
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue