[ios] Update ruler & copyright position.

This commit is contained in:
Ilya Grechuhin 2015-05-27 15:54:43 +03:00 committed by Alex Zolotarev
parent 87f5fd6060
commit a9423b4f9f
7 changed files with 62 additions and 10 deletions

View file

@ -7,9 +7,12 @@
//
#import <UIKit/UIKit.h>
#import "MWMSideMenuDelegate.h"
@interface MWMSideMenuButton : UIButton
@property (weak, nonatomic) id<MWMSideMenuInformationDisplayProtocol> delegate;
- (void)addSelfToView:(UIView *)parentView;
- (void)addSelfHiddenToView:(UIView *)parentView;

View file

@ -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

View file

@ -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 <NSObject>
- (void)setRulerPivot:(m2::PointD)pivot;
- (void)setCopyrightLabelPivot:(m2::PointD)pivot;
@end

View file

@ -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() <MWMSideMenuInformationDisplayProtocol>
@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

View file

@ -7,10 +7,13 @@
//
#import <UIKit/UIKit.h>
#import "MWMSideMenuDelegate.h"
@interface MWMSideMenuView : UIView
@property (weak, nonatomic, readonly) IBOutlet UIView * dimBackground;
@property (weak, nonatomic) id<MWMSideMenuInformationDisplayProtocol> delegate;
@property (nonatomic) NSUInteger outOfDateCount;
- (instancetype)initWithFrame:(CGRect)frame __attribute__((unavailable("initWithFrame is not available")));
- (instancetype)init __attribute__((unavailable("init is not available")));

View file

@ -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;

View file

@ -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 = "<group>"; 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 = "<group>"; };
340F24641B15F01D00F874CD /* MWMSideMenuDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MWMSideMenuDelegate.h; sourceTree = "<group>"; };
343F262C1AEFC4A300388A6D /* MWMFrameworkUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMFrameworkUtils.h; sourceTree = "<group>"; };
343F262D1AEFC4A300388A6D /* MWMFrameworkUtils.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMFrameworkUtils.mm; sourceTree = "<group>"; };
343F262F1AEFDB1A00388A6D /* Framework.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = Framework.cpp; path = ../../Classes/Framework.cpp; sourceTree = "<group>"; };
@ -349,7 +350,7 @@
34BC72111B0DECAE0012A34B /* MWMMapViewControlsManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMMapViewControlsManager.mm; sourceTree = "<group>"; };
34BC72131B0DECAE0012A34B /* MWMMapViewControlsCommon.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMMapViewControlsCommon.h; sourceTree = "<group>"; };
34BC72141B0DECAE0012A34B /* MWMSideMenuButton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMSideMenuButton.h; sourceTree = "<group>"; };
34BC72151B0DECAE0012A34B /* MWMSideMenuButton.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MWMSideMenuButton.m; sourceTree = "<group>"; };
34BC72151B0DECAE0012A34B /* MWMSideMenuButton.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMSideMenuButton.mm; sourceTree = "<group>"; };
34BC72161B0DECAE0012A34B /* MWMSideMenuManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMSideMenuManager.h; sourceTree = "<group>"; };
34BC72171B0DECAE0012A34B /* MWMSideMenuManager.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MWMSideMenuManager.mm; sourceTree = "<group>"; };
34BC72181B0DECAE0012A34B /* MWMSideMenuView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MWMSideMenuView.h; sourceTree = "<group>"; };
@ -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 = "<group>";
@ -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 */,