diff --git a/data/resources-default/default.ui b/data/resources-default/default.ui
index f7f55ac059..2ab18d8422 100644
--- a/data/resources-default/default.ui
+++ b/data/resources-default/default.ui
@@ -1,38 +1,38 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
-
-
+
+
+
-
-
-
+
+
+
diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuView.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuView.mm
index 95a5e156a8..d641849b02 100644
--- a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuView.mm
+++ b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuView.mm
@@ -1,5 +1,6 @@
#import "Common.h"
#import "MapsAppDelegate.h"
+#import "EAGLView.h"
#import "MWMBottomMenuView.h"
#import "UIButton+RuntimeAttributes.h"
#import "UIColor+MapsMeColor.h"
@@ -69,7 +70,7 @@
}
[UIView animateWithDuration:kDefaultAnimationDuration animations:^{ [self updateAlphaAndColor]; }
completion:^(BOOL finished) { [self updateVisibility]; }];
- [self layoutWidgets];
+ ((EAGLView *)self.superview).widgetsManager.bottomBound = self.mainButtons.height;
[super layoutSubviews];
}
@@ -171,19 +172,6 @@
}
}
-- (void)layoutWidgets
-{
- UIView * superView = self.superview;
- CGFloat const contentScaleFactor = superView.contentScaleFactor;
- m2::PointD const pivot(superView.width * contentScaleFactor - 36.0,
- (superView.height - self.mainButtons.height) * contentScaleFactor - 24.0);
-
- gui::TWidgetsLayoutInfo layout;
- layout[gui::WIDGET_RULER] = pivot;
- layout[gui::WIDGET_COPYRIGHT] = pivot;
- GetFramework().SetWidgetLayout(move(layout));
-}
-
- (void)layoutGeometry
{
switch (self.state)
diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm
index 48dadf9108..7a4e8156fe 100644
--- a/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm
+++ b/iphone/Maps/Classes/CustomViews/MapViewControls/BottomMenu/MWMBottomMenuViewController.mm
@@ -1,4 +1,5 @@
#import "Common.h"
+#import "EAGLView.h"
#import "MapsAppDelegate.h"
#import "MapViewController.h"
#import "MWMActivityViewController.h"
@@ -529,6 +530,7 @@ typedef NS_ENUM(NSUInteger, MWMBottomMenuViewCell)
- (void)setLeftBound:(CGFloat)leftBound
{
((MWMBottomMenuView *)self.view).leftBound = leftBound;
+ ((EAGLView *)self.controller.view).widgetsManager.leftBound = leftBound;
}
- (CGFloat)leftBound
diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm
index 27e51053e9..06b107f0db 100644
--- a/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm
+++ b/iphone/Maps/Classes/CustomViews/MapViewControls/MWMMapViewControlsManager.mm
@@ -1,5 +1,6 @@
#import "Common.h"
#import "CountryTreeVC.h"
+#import "EAGLView.h"
#import "MapsAppDelegate.h"
#import "MapViewController.h"
#import "MWMAlertViewController.h"
@@ -564,7 +565,8 @@ extern NSString * const kAlohalyticsTapEventKey;
_hidden = hidden;
self.zoomHidden = _zoomHidden;
self.menuState = _menuState;
- GetFramework().SetFullScreenMode(hidden);
+ EAGLView * glView = (EAGLView *)self.ownerController.view;
+ glView.widgetsManager.fullScreen = hidden;
}
- (void)setZoomHidden:(BOOL)zoomHidden
diff --git a/iphone/Maps/Classes/EAGLView.h b/iphone/Maps/Classes/EAGLView.h
index a8df3d1365..a9121a63b8 100644
--- a/iphone/Maps/Classes/EAGLView.h
+++ b/iphone/Maps/Classes/EAGLView.h
@@ -1,5 +1,4 @@
-#import
-
+#import "MWMMapWidgets.h"
#include "../../std/shared_ptr.hpp"
#include "../../indexer/map_style.hpp"
@@ -21,6 +20,8 @@ namespace dp
CGRect lastViewSize;
}
+@property (nonatomic) MWMMapWidgets * widgetsManager;
+
- (void)deallocateNative;
- (CGPoint)viewPoint2GlobalPoint:(CGPoint)pt;
- (CGPoint)globalPoint2ViewPoint:(CGPoint)pt;
diff --git a/iphone/Maps/Classes/EAGLView.mm b/iphone/Maps/Classes/EAGLView.mm
index d8bcb2d36d..e3d0742d3d 100644
--- a/iphone/Maps/Classes/EAGLView.mm
+++ b/iphone/Maps/Classes/EAGLView.mm
@@ -1,14 +1,11 @@
-#import
-#import
#import "Common.h"
#import "EAGLView.h"
#import "MWMDirectionView.h"
-#include "Framework.h"
-#include "indexer/classificator_loader.hpp"
#import "../Platform/opengl/iosOGLContextFactory.h"
-#include "drape_frontend/gui/skin.hpp"
+#include "Framework.h"
+#include "indexer/classificator_loader.hpp"
#include "platform/platform.hpp"
@@ -16,65 +13,7 @@
#include "std/limits.hpp"
#include "std/unique_ptr.hpp"
-
@implementation EAGLView
-{
- unique_ptr m_skin;
-}
-
-namespace
-{
-// Returns DPI as exact as possible. It works for iPhone, iPad and iWatch.
-double getExactDPI()
-{
- float const iPadDPI = 132.f;
- float const iPhoneDPI = 163.f;
- float const mDPI = 160.f;
-
- UIScreen * screen = [UIScreen mainScreen];
- float const scale = [screen respondsToSelector:@selector(scale)] ? [screen scale] : 1.f;
-
- switch (UI_USER_INTERFACE_IDIOM())
- {
- case UIUserInterfaceIdiomPhone:
- return iPhoneDPI * scale;
- case UIUserInterfaceIdiomPad:
- return iPadDPI * scale;
- default:
- return mDPI * scale;
- }
-}
-
-graphics::EDensity getDensityType(int exactDensityDPI, double scale)
-{
- if (scale > 2)
- return graphics::EDensityIPhone6Plus;
-
- typedef pair P;
- P dens[] = {
- // P(120, graphics::EDensityLDPI),
- P(160, graphics::EDensityMDPI),
- P(240, graphics::EDensityHDPI),
- P(320, graphics::EDensityXHDPI),
- P(480, graphics::EDensityXXHDPI)
- };
-
- int prevRange = numeric_limits::max();
- int bestRangeIndex = 0;
- for (int i = 0; i < ARRAY_SIZE(dens); i++)
- {
- int currRange = abs(exactDensityDPI - dens[i].first);
- if (currRange <= prevRange)
- {
- bestRangeIndex = i;
- prevRange = currRange;
- }
- else
- break;
- }
- return dens[bestRangeIndex].second;
-}
-} // namespace
// You must implement this method
+ (Class)layerClass
@@ -90,6 +29,7 @@ graphics::EDensity getDensityType(int exactDensityDPI, double scale)
if ((self = [super initWithCoder:coder]))
{
lastViewSize = CGRectZero;
+ _widgetsManager = [[MWMMapWidgets alloc] init];
// Setup Layer Properties
CAEAGLLayer * eaglLayer = (CAEAGLLayer *)self.layer;
@@ -118,16 +58,7 @@ graphics::EDensity getDensityType(int exactDensityDPI, double scale)
p.m_surfaceHeight = height;
p.m_visualScale = self.contentScaleFactor;
- /// @TODO (iOS developers) remove this stuff and create real logic for init and layout core widgets
- 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;
- });
-
- p.m_widgetsInitInfo[gui::WIDGET_SCALE_LABEL] = gui::Position(dp::LeftBottom);
-
+ [self.widgetsManager setupWidgets:p];
GetFramework().CreateDrapeEngine(make_ref(m_factory), move(p));
NSLog(@"EAGLView createDrapeEngine Ended");
@@ -160,19 +91,7 @@ graphics::EDensity getDensityType(int exactDensityDPI, double scale)
GetFramework().OnSize(w, h);
- /// @TODO (iOS developers) remove this stuff and create real logic for layout core widgets
- if (m_skin)
- {
- m_skin->Resize(w, h);
-
- gui::TWidgetsLayoutInfo layout;
- m_skin->ForEach([&layout](gui::EWidget w, gui::Position const & pos)
- {
- layout[w] = pos.m_pixelPivot;
- });
-
- GetFramework().SetWidgetLayout(move(layout));
- }
+ [self.widgetsManager resize:CGSizeMake(w, h)];
}
- (double)correctContentScale
diff --git a/iphone/Maps/Classes/Widgets/MWMMapWidgets.h b/iphone/Maps/Classes/Widgets/MWMMapWidgets.h
new file mode 100644
index 0000000000..d1a462c3ed
--- /dev/null
+++ b/iphone/Maps/Classes/Widgets/MWMMapWidgets.h
@@ -0,0 +1,12 @@
+#include "Framework.h"
+
+@interface MWMMapWidgets : NSObject
+
+@property (nonatomic) BOOL fullScreen;
+@property (nonatomic) CGFloat leftBound;
+@property (nonatomic) CGFloat bottomBound;
+
+- (void)setupWidgets:(Framework::DrapeCreationParams &)p;
+- (void)resize:(CGSize)size;
+
+@end
diff --git a/iphone/Maps/Classes/Widgets/MWMMapWidgets.mm b/iphone/Maps/Classes/Widgets/MWMMapWidgets.mm
new file mode 100644
index 0000000000..257d985165
--- /dev/null
+++ b/iphone/Maps/Classes/Widgets/MWMMapWidgets.mm
@@ -0,0 +1,89 @@
+#import "MWMMapWidgets.h"
+
+#include "drape_frontend/gui/skin.hpp"
+#include "std/unique_ptr.hpp"
+
+@interface MWMMapWidgets ()
+
+@property (nonatomic) float visualScale;
+
+@end
+
+@implementation MWMMapWidgets
+{
+ unique_ptr m_skin;
+}
+
+- (void)setupWidgets:(Framework::DrapeCreationParams &)p
+{
+ 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;
+ });
+#ifdef DEBUG
+ p.m_widgetsInitInfo[gui::WIDGET_SCALE_LABEL] = gui::Position(dp::LeftBottom);
+#endif
+}
+
+- (void)resize:(CGSize)size
+{
+ m_skin->Resize(size.width, size.height);
+ [self layoutWidgets];
+}
+
+- (void)layoutWidgets
+{
+ gui::TWidgetsLayoutInfo layout;
+ if (self.fullScreen)
+ {
+ layout[gui::WIDGET_RULER] = m_skin->ResolvePosition(gui::WIDGET_RULER).m_pixelPivot;
+ layout[gui::WIDGET_COMPASS] = m_skin->ResolvePosition(gui::WIDGET_COMPASS).m_pixelPivot;
+ }
+ else
+ {
+ 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:
+ pivot += m2::PointF(self.leftBound, -self.bottomBound) * self.visualScale;
+ break;
+ case gui::WIDGET_SCALE_LABLE:
+ case gui::WIDGET_COUNTRY_STATUS:
+ break;
+ }
+ layout[w] = pivot;
+ });
+ }
+ GetFramework().SetWidgetLayout(move(layout));
+}
+
+#pragma mark - Properties
+
+- (void)setFullScreen:(BOOL)fullScreen
+{
+ _fullScreen = fullScreen;
+ [self layoutWidgets];
+}
+
+- (void)setLeftBound:(CGFloat)leftBound
+{
+ _leftBound = MAX(leftBound, 0.0);
+ [self layoutWidgets];
+}
+
+- (void)setBottomBound:(CGFloat)bottomBound
+{
+ _bottomBound = bottomBound;
+ [self layoutWidgets];
+}
+
+@end
diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj
index 325c816167..070cd37c94 100644
--- a/iphone/Maps/Maps.xcodeproj/project.pbxproj
+++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj
@@ -123,6 +123,7 @@
34F45E8E1B96E88100AC93F8 /* MWMSearchTabButtonsView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34F45E8D1B96E88100AC93F8 /* MWMSearchTabButtonsView.mm */; };
34F45E901B96E8B100AC93F8 /* MWMSearchTabButtonsView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 34F45E8F1B96E8B100AC93F8 /* MWMSearchTabButtonsView.xib */; };
34F8ADD91B97229A004184CC /* MWMSearchTableView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34F8ADD81B97229A004184CC /* MWMSearchTableView.mm */; };
+ 34FE4C451BCC013500066718 /* MWMMapWidgets.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34FE4C441BCC013500066718 /* MWMMapWidgets.mm */; settings = {ASSET_TAGS = (); }; };
45159BF91B0CA2D5009BFA85 /* resources-6plus in Resources */ = {isa = PBXBuildFile; fileRef = 45159BF81B0CA2D5009BFA85 /* resources-6plus */; };
4519503A1B7A3E070085DA05 /* patterns.txt in Resources */ = {isa = PBXBuildFile; fileRef = 451950391B7A3E070085DA05 /* patterns.txt */; };
4519503B1B7A3E390085DA05 /* patterns.txt in Resources */ = {isa = PBXBuildFile; fileRef = 451950391B7A3E070085DA05 /* patterns.txt */; };
@@ -1012,6 +1013,8 @@
34F45E8F1B96E8B100AC93F8 /* MWMSearchTabButtonsView.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = MWMSearchTabButtonsView.xib; sourceTree = ""; };
34F8ADD71B97229A004184CC /* MWMSearchTableView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMSearchTableView.h; sourceTree = ""; };
34F8ADD81B97229A004184CC /* MWMSearchTableView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMSearchTableView.mm; sourceTree = ""; };
+ 34FE4C431BCC013500066718 /* MWMMapWidgets.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMMapWidgets.h; sourceTree = ""; };
+ 34FE4C441BCC013500066718 /* MWMMapWidgets.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMMapWidgets.mm; sourceTree = ""; };
3D443C9C19E421EE0025C2FC /* sv */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sv; path = sv.lproj/Localizable.strings; sourceTree = ""; };
45159BF81B0CA2D5009BFA85 /* resources-6plus */ = {isa = PBXFileReference; lastKnownFileType = folder; name = "resources-6plus"; path = "../../data/resources-6plus"; sourceTree = ""; };
451950391B7A3E070085DA05 /* patterns.txt */ = {isa = PBXFileReference; lastKnownFileType = text; name = patterns.txt; path = ../../data/patterns.txt; sourceTree = ""; };
@@ -1576,6 +1579,7 @@
isa = PBXGroup;
children = (
F607C18B1C047FCA00B53A87 /* Segue */,
+ 34FE4C421BCC013500066718 /* Widgets */,
346EDAD81B9F0E15004F8DB5 /* Components */,
340837101B7243B500B5C185 /* Share */,
340F24601B1490ED00F874CD /* RouteState */,
@@ -2142,6 +2146,15 @@
path = RoutePreview;
sourceTree = "";
};
+ 34FE4C421BCC013500066718 /* Widgets */ = {
+ isa = PBXGroup;
+ children = (
+ 34FE4C431BCC013500066718 /* MWMMapWidgets.h */,
+ 34FE4C441BCC013500066718 /* MWMMapWidgets.mm */,
+ );
+ path = Widgets;
+ sourceTree = "";
+ };
560634EF1B787EBE00F3D670 /* Sound */ = {
isa = PBXGroup;
children = (
@@ -3406,6 +3419,7 @@
F62404FB1AAF3DB200B58DB6 /* UILabel+RuntimeAttributes.mm in Sources */,
34CC4C0E1B82069C00E44C1F /* MWMSearchTabbedCollectionViewCell.mm in Sources */,
F6588E2C1B15C26700EE1E58 /* MWMTextView.mm in Sources */,
+ 34FE4C451BCC013500066718 /* MWMMapWidgets.mm in Sources */,
F61B0F2C1B8B82DB00C08258 /* MWMNextTurnPanel.mm in Sources */,
F6F722F81AE1572400DA3DA1 /* MWMiPhonePortraitPlacePage.mm in Sources */,
F6CB21681AEFC6AA00FB8963 /* MWMPlacePageActionBar.mm in Sources */,
@@ -3422,8 +3436,6 @@
34CFFE8B1B7DE6FD009D0C9F /* MWMSearchManager.mm in Sources */,
F6BBF2C61B4FFB72000CF8E2 /* MWMLocationAlert.mm in Sources */,
F66A8FB01B09F268001B9C97 /* MWMPlacePage.mm in Sources */,
- 34BC72251B0DECAE0012A34B /* MWMSideMenuButton.mm in Sources */,
- EE7F29821219ECA300EB67A9 /* RenderContext.mm in Sources */,
F6ED13911B1EF96B0095C6DE /* MWMBookmarkDescriptionViewController.mm in Sources */,
349A35851B53E967009677EE /* MWMDownloadMapRequestView.mm in Sources */,
F64F19991AB81A00006EAF7E /* MWMAlertViewController.mm in Sources */,
diff --git a/map/framework.hpp b/map/framework.hpp
index a5899fc452..381bdc08d6 100644
--- a/map/framework.hpp
+++ b/map/framework.hpp
@@ -555,13 +555,5 @@ private:
routing::RouterType m_currentRouterType;
//@}
-public:
- /// @name Full screen mode
- //@{
- void SetFullScreenMode(bool enable) { m_isFullScreenMode = enable; }
-private:
- bool m_isFullScreenMode = false;
- //@}
-
DECLARE_THREAD_CHECKER(m_threadChecker);
};