From a9423b4f9f226f7e1f860cc8bd1a7fccd97890dc Mon Sep 17 00:00:00 2001 From: Ilya Grechuhin Date: Wed, 27 May 2015 15:54:43 +0300 Subject: [PATCH] [ios] Update ruler & copyright position. --- .../SideMenu/MWMSideMenuButton.h | 3 +++ ...MSideMenuButton.m => MWMSideMenuButton.mm} | 7 +++++- .../SideMenu/MWMSideMenuDelegate.h | 16 ++++++++++++++ .../SideMenu/MWMSideMenuManager.mm | 22 ++++++++++++++++++- .../SideMenu/MWMSideMenuView.h | 3 +++ .../SideMenu/MWMSideMenuView.mm | 11 ++++++---- iphone/Maps/Maps.xcodeproj/project.pbxproj | 10 +++++---- 7 files changed, 62 insertions(+), 10 deletions(-) rename iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/{MWMSideMenuButton.m => MWMSideMenuButton.mm} (88%) create mode 100644 iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuDelegate.h diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuButton.h b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuButton.h index b23ba3da17..ef8b017034 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuButton.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuButton.h @@ -7,9 +7,12 @@ // #import +#import "MWMSideMenuDelegate.h" @interface MWMSideMenuButton : UIButton +@property (weak, nonatomic) id delegate; + - (void)addSelfToView:(UIView *)parentView; - (void)addSelfHiddenToView:(UIView *)parentView; diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuButton.m b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuButton.mm similarity index 88% rename from iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuButton.m rename to iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuButton.mm index f52dbd94a6..bcfd29e541 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuButton.m +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuButton.mm @@ -68,8 +68,8 @@ { [super layoutSubviews]; self.bounds = self.defaultBounds; - [self layoutXPosition:self.hidden]; self.maxY = self.superview.height - 2.0 * kViewControlsOffsetToBounds; + [self layoutXPosition:self.hidden]; } - (void)layoutXPosition:(BOOL)hidden @@ -78,6 +78,11 @@ self.minX = self.superview.width; else self.maxX = self.superview.width - 2.0 * kViewControlsOffsetToBounds; + + CGFloat const contentScaleFactor = self.superview.contentScaleFactor; + m2::PointD const pivot(self.minX * contentScaleFactor - 2.0 * kViewControlsOffsetToBounds, self.maxY * contentScaleFactor - kViewControlsOffsetToBounds); + [self.delegate setRulerPivot:pivot]; + [self.delegate setCopyrightLabelPivot:pivot]; } #pragma mark - Properties diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuDelegate.h b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuDelegate.h new file mode 100644 index 0000000000..b5dc0ffab2 --- /dev/null +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuDelegate.h @@ -0,0 +1,16 @@ +// +// MWMSideMenuDelegate.h +// Maps +// +// Created by Ilya Grechuhin on 27.05.15. +// Copyright (c) 2015 MapsWithMe. All rights reserved. +// + +#include "geometry/point2d.hpp" + +@protocol MWMSideMenuInformationDisplayProtocol + +- (void)setRulerPivot:(m2::PointD)pivot; +- (void)setCopyrightLabelPivot:(m2::PointD)pivot; + +@end diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuManager.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuManager.mm index 2b035d019b..a3529c62c4 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuManager.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuManager.mm @@ -7,6 +7,7 @@ // #import "MWMSideMenuManager.h" +#import "MWMSideMenuDelegate.h" #import "MWMSideMenuButton.h" #import "MWMSideMenuView.h" #import "BookmarksRootVC.h" @@ -17,13 +18,17 @@ #import "ShareActionSheet.h" #import "MapViewController.h" #import "MWMMapViewControlsManager.h" +#import "Framework.h" + #import "3party/Alohalytics/src/alohalytics_objc.h" +#include "map/information_display.hpp" + static NSString * const kMWMSideMenuViewsNibName = @"MWMSideMenuViews"; extern NSString * const kAlohalyticsTapEventKey; -@interface MWMSideMenuManager() +@interface MWMSideMenuManager() @property (weak, nonatomic) MapViewController * parentController; @property (nonatomic) IBOutlet MWMSideMenuButton * menuButton; @@ -40,6 +45,9 @@ extern NSString * const kAlohalyticsTapEventKey; { self.parentController = controller; [[NSBundle mainBundle] loadNibNamed:kMWMSideMenuViewsNibName owner:self options:nil]; + self.menuButton.delegate = self; + self.sideMenu.delegate = self; + self.sideMenu.outOfDateCount = GetFramework().GetCountryTree().GetActiveMapLayout().GetOutOfDateCount(); [self addCloseMenuWithTap]; self.state = MWMSideMenuStateInactive; } @@ -112,6 +120,18 @@ extern NSString * const kAlohalyticsTapEventKey; self.state = MWMSideMenuStateActive; } +#pragma mark - MWMSideMenuInformationDisplayProtocol + +- (void)setRulerPivot:(m2::PointD)pivot +{ + GetFramework().GetInformationDisplay().SetWidgetPivot(InformationDisplay::WidgetType::Ruler, pivot); +} + +- (void)setCopyrightLabelPivot:(m2::PointD)pivot +{ + GetFramework().GetInformationDisplay().SetWidgetPivot(InformationDisplay::WidgetType::CopyrightLabel, pivot); +} + #pragma mark - Properties - (void)setState:(MWMSideMenuState)state diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuView.h b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuView.h index 3b16559d65..3ff948215b 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuView.h +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuView.h @@ -7,10 +7,13 @@ // #import +#import "MWMSideMenuDelegate.h" @interface MWMSideMenuView : UIView @property (weak, nonatomic, readonly) IBOutlet UIView * dimBackground; +@property (weak, nonatomic) id delegate; +@property (nonatomic) NSUInteger outOfDateCount; - (instancetype)initWithFrame:(CGRect)frame __attribute__((unavailable("initWithFrame is not available"))); - (instancetype)init __attribute__((unavailable("init is not available"))); diff --git a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuView.mm b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuView.mm index dc811bff0d..66ac5b3ec7 100644 --- a/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuView.mm +++ b/iphone/Maps/Classes/CustomViews/MapViewControls/SideMenu/MWMSideMenuView.mm @@ -9,7 +9,6 @@ #import "MWMSideMenuView.h" #import "UIKitCategories.h" #import "MWMMapViewControlsCommon.h" -#import "Framework.h" static CGSize const kBadgeSize = CGSizeMake(24.0, 24.0); @@ -159,6 +158,11 @@ static CGSize const kBadgeSize = CGSizeMake(24.0, 24.0); self.downloadCount.maxX = self.downloadMapsButton.maxX; self.downloadBadge.minY = self.downloadMapsButton.minY; self.downloadCount.minY = self.downloadMapsButton.minY; + + CGFloat const contentScaleFactor = self.superview.contentScaleFactor; + m2::PointD const pivot(self.searchButton.minX * contentScaleFactor - 2.0 * kViewControlsOffsetToBounds, self.searchButton.maxY * contentScaleFactor - kViewControlsOffsetToBounds); + [self.delegate setRulerPivot:pivot]; + [self.delegate setCopyrightLabelPivot:pivot]; } #pragma mark - Animations @@ -181,8 +185,7 @@ static CGSize const kBadgeSize = CGSizeMake(24.0, 24.0); - (void)updateMenuOutOfDateBadge { - int const outOfDateCount = GetFramework().GetCountryTree().GetActiveMapLayout().GetOutOfDateCount(); - if (outOfDateCount == 0) + if (self.outOfDateCount == 0) return; CATransform3D const zeroScale = CATransform3DScale(CATransform3DIdentity, 0.0, 0.0, 1.0); self.downloadBadge.layer.transform = zeroScale; @@ -191,7 +194,7 @@ static CGSize const kBadgeSize = CGSizeMake(24.0, 24.0); self.downloadCount.alpha = 0.0; self.downloadBadge.hidden = NO; self.downloadCount.hidden = NO; - self.downloadCount.text = @(outOfDateCount).stringValue; + self.downloadCount.text = @(self.outOfDateCount).stringValue; [UIView animateWithDuration:framesDuration(4) animations:^ { self.downloadBadge.layer.transform = CATransform3DIdentity; diff --git a/iphone/Maps/Maps.xcodeproj/project.pbxproj b/iphone/Maps/Maps.xcodeproj/project.pbxproj index 8da599fbe0..038bc17851 100644 --- a/iphone/Maps/Maps.xcodeproj/project.pbxproj +++ b/iphone/Maps/Maps.xcodeproj/project.pbxproj @@ -39,7 +39,7 @@ 34BC72221B0DECAE0012A34B /* MWMLocationButtonView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34BC720E1B0DECAE0012A34B /* MWMLocationButtonView.mm */; }; 34BC72231B0DECAE0012A34B /* MWMLocationButtonView.xib in Resources */ = {isa = PBXBuildFile; fileRef = 34BC720F1B0DECAE0012A34B /* MWMLocationButtonView.xib */; }; 34BC72241B0DECAE0012A34B /* MWMMapViewControlsManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34BC72111B0DECAE0012A34B /* MWMMapViewControlsManager.mm */; }; - 34BC72251B0DECAE0012A34B /* MWMSideMenuButton.m in Sources */ = {isa = PBXBuildFile; fileRef = 34BC72151B0DECAE0012A34B /* MWMSideMenuButton.m */; }; + 34BC72251B0DECAE0012A34B /* MWMSideMenuButton.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34BC72151B0DECAE0012A34B /* MWMSideMenuButton.mm */; }; 34BC72261B0DECAE0012A34B /* MWMSideMenuManager.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34BC72171B0DECAE0012A34B /* MWMSideMenuManager.mm */; }; 34BC72271B0DECAE0012A34B /* MWMSideMenuView.mm in Sources */ = {isa = PBXBuildFile; fileRef = 34BC72191B0DECAE0012A34B /* MWMSideMenuView.mm */; }; 34BC72281B0DECAE0012A34B /* MWMSideMenuViews.xib in Resources */ = {isa = PBXBuildFile; fileRef = 34BC721A1B0DECAE0012A34B /* MWMSideMenuViews.xib */; }; @@ -312,6 +312,7 @@ 28A0AB4B0D9B1048005BE974 /* Maps_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = Maps_Prefix.pch; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; 28AD73870D9D96C1002E5188 /* MainWindow.xib */ = {isa = PBXFileReference; lastKnownFileType = file.xib; path = MainWindow.xib; sourceTree = SOURCE_ROOT; }; 29B97316FDCFA39411CA2CEA /* main.mm */ = {isa = PBXFileReference; explicitFileType = sourcecode.cpp.objcpp; fileEncoding = 4; path = main.mm; sourceTree = ""; }; + 340F24641B15F01D00F874CD /* MWMSideMenuDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMSideMenuDelegate.h; sourceTree = ""; }; 343F262C1AEFC4A300388A6D /* MWMFrameworkUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMFrameworkUtils.h; sourceTree = ""; }; 343F262D1AEFC4A300388A6D /* MWMFrameworkUtils.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMFrameworkUtils.mm; sourceTree = ""; }; 343F262F1AEFDB1A00388A6D /* Framework.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Framework.cpp; path = ../../Classes/Framework.cpp; sourceTree = ""; }; @@ -349,7 +350,7 @@ 34BC72111B0DECAE0012A34B /* MWMMapViewControlsManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMMapViewControlsManager.mm; sourceTree = ""; }; 34BC72131B0DECAE0012A34B /* MWMMapViewControlsCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMMapViewControlsCommon.h; sourceTree = ""; }; 34BC72141B0DECAE0012A34B /* MWMSideMenuButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMSideMenuButton.h; sourceTree = ""; }; - 34BC72151B0DECAE0012A34B /* MWMSideMenuButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MWMSideMenuButton.m; sourceTree = ""; }; + 34BC72151B0DECAE0012A34B /* MWMSideMenuButton.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMSideMenuButton.mm; sourceTree = ""; }; 34BC72161B0DECAE0012A34B /* MWMSideMenuManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMSideMenuManager.h; sourceTree = ""; }; 34BC72171B0DECAE0012A34B /* MWMSideMenuManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMSideMenuManager.mm; sourceTree = ""; }; 34BC72181B0DECAE0012A34B /* MWMSideMenuView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMSideMenuView.h; sourceTree = ""; }; @@ -994,12 +995,13 @@ children = ( 34BC72131B0DECAE0012A34B /* MWMMapViewControlsCommon.h */, 34BC72141B0DECAE0012A34B /* MWMSideMenuButton.h */, - 34BC72151B0DECAE0012A34B /* MWMSideMenuButton.m */, + 34BC72151B0DECAE0012A34B /* MWMSideMenuButton.mm */, 34BC72161B0DECAE0012A34B /* MWMSideMenuManager.h */, 34BC72171B0DECAE0012A34B /* MWMSideMenuManager.mm */, 34BC72181B0DECAE0012A34B /* MWMSideMenuView.h */, 34BC72191B0DECAE0012A34B /* MWMSideMenuView.mm */, 34BC721A1B0DECAE0012A34B /* MWMSideMenuViews.xib */, + 340F24641B15F01D00F874CD /* MWMSideMenuDelegate.h */, ); path = SideMenu; sourceTree = ""; @@ -1883,7 +1885,7 @@ 97C9851E186AE3C500AF7E9E /* Reachability.m in Sources */, 977E26B919E2E64200BA2219 /* MapsObservers.mm in Sources */, EE7F29821219ECA300EB67A9 /* RenderContext.mm in Sources */, - 34BC72251B0DECAE0012A34B /* MWMSideMenuButton.m in Sources */, + 34BC72251B0DECAE0012A34B /* MWMSideMenuButton.mm in Sources */, F64F19991AB81A00006EAF7E /* MWMAlertViewController.mm in Sources */, FAFCB63613366E78001A5C59 /* WebViewController.mm in Sources */, 34BC72221B0DECAE0012A34B /* MWMLocationButtonView.mm in Sources */,