forked from organicmaps/organicmaps
A universal interface for changing pivot points on widgets on the map was implemented. Now with the help of the interface it's possible to change pivot points of any widget on the map.
This commit is contained in:
parent
29311d27a8
commit
ccdcd85f9f
4 changed files with 70 additions and 4 deletions
|
@ -186,6 +186,11 @@ CountryStatusDisplay * Framework::GetCountryStatusDisplay() const
|
|||
return m_informationDisplay.countryStatusDisplay().get();
|
||||
}
|
||||
|
||||
void Framework::SetWidgetPivot(InformationDisplay::WidgetType widget, m2::PointD const & pivot)
|
||||
{
|
||||
m_informationDisplay.SetWidgetPivot(widget, pivot);
|
||||
}
|
||||
|
||||
void Framework::GetMaps(vector<string> & maps) const
|
||||
{
|
||||
Platform & pl = GetPlatform();
|
||||
|
@ -783,7 +788,7 @@ void Framework::OnSize(int w, int h)
|
|||
// if gui controller not initialized, than we work in mode "Without gui"
|
||||
// and no need to set gui layout. We will not render it.
|
||||
if (m_guiController->GetCacheScreen())
|
||||
m_informationDisplay.setDisplayRect(m2::RectI(0, 0, w, h));
|
||||
m_informationDisplay.SetWidgetPivotsByDefault(w, h);
|
||||
m_renderPolicy->OnSize(w, h);
|
||||
}
|
||||
#else
|
||||
|
|
|
@ -283,6 +283,22 @@ public:
|
|||
CountryStatusDisplay * GetCountryStatusDisplay() const;
|
||||
ScalesProcessor & GetScalesProcessor() { return m_scales; }
|
||||
|
||||
/*!
|
||||
* \brief SetWidgetPivot() places widgets on the screen.
|
||||
* \param widget is a widget ID.
|
||||
* \param pivot is a pivot point of a widget in framebuffer coordinates.
|
||||
* That means pivot points are measured in pixels.
|
||||
* \note The default pivot points of the widgets on the map are set by
|
||||
* InformationDisplay::SetWidgetPivotsByDefault() method. If you decide
|
||||
* to change the default behavior by calling the method
|
||||
* you should take into account that SetWidgetPivot() shall be called:
|
||||
* - on the start of the program;
|
||||
* - when the screen orientation is changed;
|
||||
* - when the screen size is changed;
|
||||
* A caller of Framework::OnSize() is a good place for it.
|
||||
*/
|
||||
void SetWidgetPivot(InformationDisplay::WidgetType widget, m2::PointD const & pivot);
|
||||
|
||||
/// Safe function to get current visual scale.
|
||||
/// Call it when you need do calculate pixel rect (not matter if m_renderPolicy == 0).
|
||||
/// @return 1.0 if m_renderPolicy == 0 (possible for Android).
|
||||
|
|
|
@ -157,12 +157,14 @@ void InformationDisplay::setController(gui::Controller * controller)
|
|||
m_framework->GetAnimController()->AddTask(task);
|
||||
}
|
||||
|
||||
void InformationDisplay::setDisplayRect(m2::RectI const & rect)
|
||||
void InformationDisplay::SetWidgetPivotsByDefault(int screenWidth, int screenHeight)
|
||||
{
|
||||
double rulerOffsX = RULLER_X_OFFSET;
|
||||
double rulerOffsY = RULLER_Y_OFFSET;
|
||||
double compassOffsX = COMPASS_X_OFFSET;
|
||||
double compassOffsY = COMPASS_Y_OFFSET;
|
||||
m2::RectI const rect = m2::RectI(0, 0, screenWidth, screenHeight);
|
||||
|
||||
#ifdef OMIM_OS_ANDROID
|
||||
if (GetPlatform().IsTablet())
|
||||
{
|
||||
|
@ -282,3 +284,33 @@ void InformationDisplay::ResetRouteMatchingInfo()
|
|||
{
|
||||
m_locationState->ResetRouteMatchingInfo();
|
||||
}
|
||||
|
||||
void InformationDisplay::SetWidgetPivot(WidgetType widget, m2::PointD const & pivot)
|
||||
{
|
||||
ASSERT(m_ruler, ());
|
||||
switch(widget)
|
||||
{
|
||||
case WidgetType::Ruler:
|
||||
if (m_ruler)
|
||||
m_ruler->setPivot(pivot);
|
||||
return;
|
||||
case WidgetType::CopyrightLabel:
|
||||
if (m_copyrightLabel)
|
||||
m_copyrightLabel->setPivot(pivot);
|
||||
return;
|
||||
case WidgetType::CountryStatusDisplay:
|
||||
if (m_countryStatusDisplay)
|
||||
m_countryStatusDisplay->setPivot(pivot);
|
||||
return;
|
||||
case WidgetType::CompassArrow:
|
||||
if (m_compassArrow)
|
||||
m_compassArrow->setPivot(pivot);
|
||||
return;
|
||||
case WidgetType::DebugLable:
|
||||
if (m_debugLabel)
|
||||
m_debugLabel->setPivot(pivot);
|
||||
return;
|
||||
default:
|
||||
ASSERT(false, ());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,12 +58,23 @@ class InformationDisplay
|
|||
void InitCopyright(Framework * fw);
|
||||
|
||||
public:
|
||||
enum class WidgetType {
|
||||
Ruler = 0,
|
||||
CopyrightLabel,
|
||||
CountryStatusDisplay,
|
||||
CompassArrow,
|
||||
DebugLable
|
||||
};
|
||||
|
||||
InformationDisplay(Framework * framework);
|
||||
|
||||
void setController(gui::Controller * controller);
|
||||
|
||||
void setDisplayRect(m2::RectI const & rect);
|
||||
/*!
|
||||
* \brief SetWidgetPivotsByDefault sets the default pivot points for all the widgets on the map.
|
||||
* The pivot points can be overridden by a call of SetWidgetPivot()
|
||||
* after Framework::OnSize() call.
|
||||
*/
|
||||
void SetWidgetPivotsByDefault(int screenWidth, int screenHeight);
|
||||
void setVisualScale(double visualScale);
|
||||
|
||||
bool isCopyrightActive() const;
|
||||
|
@ -88,4 +99,6 @@ public:
|
|||
shared_ptr<CountryStatusDisplay> const & countryStatusDisplay() const;
|
||||
|
||||
void ResetRouteMatchingInfo();
|
||||
|
||||
void SetWidgetPivot(WidgetType widget, m2::PointD const & pivot);
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue