forked from organicmaps/organicmaps-tmp
Merge pull request #3960 from igrechuhin/fix-layout
[ios] Fixed navigation layout in landscape mode.
This commit is contained in:
commit
9436392ae5
2 changed files with 35 additions and 24 deletions
|
@ -7,6 +7,7 @@
|
|||
#import "MWMMapViewControlsManager.h"
|
||||
#import "MWMRouter.h"
|
||||
#import "MWMSearch.h"
|
||||
#import "MapViewController.h"
|
||||
#import "UIColor+MapsMeColor.h"
|
||||
#import "UIFont+MapsMeFonts.h"
|
||||
#import "UIImageView+Coloring.h"
|
||||
|
@ -44,7 +45,12 @@ map<NavigationSearchState, NSString *> const kSearchButtonRequest{
|
|||
{NavigationSearchState::MinimizedShop, L(@"shop")},
|
||||
{NavigationSearchState::MinimizedATM, L(@"atm")}};
|
||||
|
||||
BOOL defaultOrientation(CGSize const & size) { return IPAD || (size.height > size.width); }
|
||||
BOOL defaultOrientation(CGSize const & size)
|
||||
{
|
||||
CGSize const & mapViewSize = [MapViewController controller].view.frame.size;
|
||||
CGFloat const minWidth = MIN(mapViewSize.width, mapViewSize.height);
|
||||
return IPAD || (size.height > size.width && size.width >= minWidth);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
@interface MWMNavigationInfoView ()<MWMLocationObserver>
|
||||
|
@ -301,7 +307,10 @@ BOOL defaultOrientation(CGSize const & size) { return IPAD || (size.height > siz
|
|||
|
||||
- (void)setFrame:(CGRect)frame
|
||||
{
|
||||
if (CGRectEqualToRect(self.frame, frame))
|
||||
CGSize const & oldSize = self.frame.size;
|
||||
CGSize const & size = frame.size;
|
||||
if (CGRectEqualToRect(self.frame, frame) || (equalScreenDimensions(oldSize.width, size.width) &&
|
||||
equalScreenDimensions(oldSize.height, size.height)))
|
||||
return;
|
||||
super.frame = frame;
|
||||
[self layoutIfNeeded];
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#import "MWMMapWidgets.h"
|
||||
#import "Common.h"
|
||||
#import "MWMNavigationDashboardManager.h"
|
||||
|
||||
#include "drape_frontend/gui/skin.hpp"
|
||||
|
@ -6,7 +7,7 @@
|
|||
|
||||
@interface MWMMapWidgets ()
|
||||
|
||||
@property (nonatomic) float visualScale;
|
||||
@property(nonatomic) float visualScale;
|
||||
|
||||
@end
|
||||
|
||||
|
@ -20,10 +21,8 @@
|
|||
self.visualScale = p.m_visualScale;
|
||||
m_skin.reset(new gui::Skin(gui::ResolveGuiSkinFile("default"), p.m_visualScale));
|
||||
m_skin->Resize(p.m_surfaceWidth, p.m_surfaceHeight);
|
||||
m_skin->ForEach([&p](gui::EWidget widget, gui::Position const & pos)
|
||||
{
|
||||
p.m_widgetsInitInfo[widget] = pos;
|
||||
});
|
||||
m_skin->ForEach(
|
||||
[&p](gui::EWidget widget, gui::Position const & pos) { p.m_widgetsInitInfo[widget] = pos; });
|
||||
#ifdef DEBUG
|
||||
p.m_widgetsInitInfo[gui::WIDGET_SCALE_LABEL] = gui::Position(dp::LeftBottom);
|
||||
#endif
|
||||
|
@ -47,25 +46,23 @@
|
|||
}
|
||||
else
|
||||
{
|
||||
m_skin->ForEach([&layout, &self](gui::EWidget w, gui::Position const & pos)
|
||||
{
|
||||
m_skin->ForEach([&layout, &self](gui::EWidget w, gui::Position const & pos) {
|
||||
m2::PointF pivot = pos.m_pixelPivot;
|
||||
switch (w)
|
||||
{
|
||||
case gui::WIDGET_RULER:
|
||||
case gui::WIDGET_COPYRIGHT:
|
||||
pivot -= m2::PointF(0.0, self.bottomBound * self.visualScale);
|
||||
break;
|
||||
case gui::WIDGET_COMPASS:
|
||||
{
|
||||
CGFloat const compassBottomBound =
|
||||
self.bottomBound + [MWMNavigationDashboardManager manager].extraCompassBottomOffset;
|
||||
pivot += m2::PointF(self.leftBound, -compassBottomBound) * self.visualScale;
|
||||
break;
|
||||
}
|
||||
case gui::WIDGET_SCALE_LABEL:
|
||||
case gui::WIDGET_CHOOSE_POSITION_MARK:
|
||||
break;
|
||||
case gui::WIDGET_RULER:
|
||||
case gui::WIDGET_COPYRIGHT:
|
||||
pivot -= m2::PointF(0.0, self.bottomBound * self.visualScale);
|
||||
break;
|
||||
case gui::WIDGET_COMPASS:
|
||||
{
|
||||
CGFloat const compassBottomBound =
|
||||
self.bottomBound + [MWMNavigationDashboardManager manager].extraCompassBottomOffset;
|
||||
pivot += m2::PointF(self.leftBound, -compassBottomBound) * self.visualScale;
|
||||
break;
|
||||
}
|
||||
case gui::WIDGET_SCALE_LABEL:
|
||||
case gui::WIDGET_CHOOSE_POSITION_MARK: break;
|
||||
}
|
||||
layout[w] = pivot;
|
||||
});
|
||||
|
@ -83,12 +80,17 @@
|
|||
|
||||
- (void)setLeftBound:(CGFloat)leftBound
|
||||
{
|
||||
_leftBound = MAX(leftBound, 0.0);
|
||||
CGFloat const newLeftBound = MAX(leftBound, 0.0);
|
||||
if (equalScreenDimensions(_leftBound, newLeftBound))
|
||||
return;
|
||||
_leftBound = newLeftBound;
|
||||
[self layoutWidgets];
|
||||
}
|
||||
|
||||
- (void)setBottomBound:(CGFloat)bottomBound
|
||||
{
|
||||
if (equalScreenDimensions(_bottomBound, bottomBound))
|
||||
return;
|
||||
_bottomBound = bottomBound;
|
||||
[self layoutWidgets];
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue