Repo created

This commit is contained in:
Fr4nz D13trich 2025-11-22 13:58:55 +01:00
parent 4af19165ec
commit 68073add76
12458 changed files with 12350765 additions and 2 deletions

View file

@ -0,0 +1,13 @@
@class MWMZoomButtonsView;
@interface MWMZoomButtons : NSObject
@property (nonatomic) BOOL hidden;
- (instancetype)init __attribute__((unavailable("init is not available")));
- (instancetype)initWithParentView:(UIView *)view;
- (void)setTopBound:(CGFloat)bound;
- (void)setBottomBound:(CGFloat)bound;
- (void)mwm_refreshUI;
@end

View file

@ -0,0 +1,122 @@
#import "MWMZoomButtons.h"
#import "MWMZoomButtonsView.h"
#import "Statistics.h"
#include "Framework.h"
#include "platform/settings.hpp"
#include "indexer/scales.hpp"
static NSString * const kMWMZoomButtonsViewNibName = @"MWMZoomButtonsView";
@interface MWMZoomButtons()
@property (nonatomic) IBOutlet MWMZoomButtonsView * zoomView;
@property (weak, nonatomic) IBOutlet UIButton * zoomInButton;
@property (weak, nonatomic) IBOutlet UIButton * zoomOutButton;
@property (nonatomic) BOOL zoomSwipeEnabled;
@property (nonatomic, readonly) BOOL isZoomEnabled;
@end
@implementation MWMZoomButtons
- (instancetype)initWithParentView:(UIView *)view
{
self = [super init];
if (self)
{
[[NSBundle mainBundle] loadNibNamed:kMWMZoomButtonsViewNibName owner:self options:nil];
[view addSubview:self.zoomView];
[self.zoomView layoutIfNeeded];
self.zoomView.topBound = 0.0;
self.zoomView.bottomBound = view.height;
self.zoomSwipeEnabled = NO;
}
return self;
}
- (void)setTopBound:(CGFloat)bound
{
self.zoomView.topBound = bound;
}
- (void)setBottomBound:(CGFloat)bound
{
self.zoomView.bottomBound = bound;
}
- (void)zoomIn
{
[Statistics logEvent:kStatEventName(kStatZoom, kStatIn)];
GetFramework().Scale(Framework::SCALE_MAG, true);
}
- (void)zoomOut
{
[Statistics logEvent:kStatEventName(kStatZoom, kStatOut)];
GetFramework().Scale(Framework::SCALE_MIN, true);
}
- (void)mwm_refreshUI
{
[self.zoomView mwm_refreshUI];
}
#pragma mark - Actions
- (IBAction)zoomTouchDown:(UIButton *)sender
{
self.zoomSwipeEnabled = YES;
}
- (IBAction)zoomTouchUpInside:(UIButton *)sender
{
self.zoomSwipeEnabled = NO;
if ([sender isEqual:self.zoomInButton])
[self zoomIn];
else
[self zoomOut];
}
- (IBAction)zoomTouchUpOutside:(UIButton *)sender
{
self.zoomSwipeEnabled = NO;
}
- (IBAction)zoomSwipe:(UIPanGestureRecognizer *)sender
{
if (!self.zoomSwipeEnabled)
return;
UIView * const superview = self.zoomView.superview;
CGFloat const translation = -[sender translationInView:superview].y / superview.bounds.size.height;
CGFloat const scaleFactor = exp(translation);
GetFramework().Scale(scaleFactor, false);
}
#pragma mark - Properties
- (BOOL)isZoomEnabled
{
bool zoomButtonsEnabled = true;
(void)settings::Get("ZoomButtonsEnabled", zoomButtonsEnabled);
return zoomButtonsEnabled;
}
- (BOOL)hidden
{
return self.isZoomEnabled ? self.zoomView.hidden : YES;
}
- (void)setHidden:(BOOL)hidden
{
if (self.isZoomEnabled)
[self.zoomView setHidden:hidden animated:YES];
else
self.zoomView.hidden = YES;
}
@end

View file

@ -0,0 +1,13 @@
#import <UIKit/UIKit.h>
@interface MWMZoomButtonsView : UIView
@property (nonatomic) CGFloat topBound;
@property (nonatomic) CGFloat bottomBound;
- (instancetype)initWithFrame:(CGRect)frame __attribute__((unavailable("initWithFrame is not available")));
- (instancetype)init __attribute__((unavailable("init is not available")));
- (void)setHidden:(BOOL)hidden animated:(BOOL)animated;
@end

View file

@ -0,0 +1,137 @@
#import "Common.h"
#import "MWMZoomButtonsView.h"
#import "MWMMapViewControlsCommon.h"
static CGFloat const kZoomViewOffsetToTopBound = 12.0;
static CGFloat const kZoomViewOffsetToBottomBound = 40.0;
static CGFloat const kZoomViewOffsetToFrameBound = 294.0;
static CGFloat const kZoomViewHideBoundPercent = 0.4;
@interface MWMZoomButtonsView()
@property (nonatomic) CGRect defaultBounds;
@end
@implementation MWMZoomButtonsView
- (void)awakeFromNib
{
self.defaultBounds = self.bounds;
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}
- (void)layoutSubviews
{
self.bounds = self.defaultBounds;
[self layoutXPosition:self.hidden];
[self layoutYPosition];
[super layoutSubviews];
}
- (void)layoutXPosition:(BOOL)hidden
{
if (hidden)
self.minX = self.superview.width;
else
self.maxX = self.superview.width - kViewControlsOffsetToBounds;
}
- (void)layoutYPosition
{
CGFloat const maxY = MIN(self.superview.height - kZoomViewOffsetToFrameBound, self.bottomBound - kZoomViewOffsetToBottomBound);
self.minY = MAX(maxY - self.height, self.topBound + kZoomViewOffsetToTopBound);
}
- (void)moveAnimated
{
if (self.hidden)
return;
[UIView animateWithDuration:framesDuration(kMenuViewMoveFramesCount) animations:^{ [self layoutYPosition]; }];
}
- (void)fadeAnimatedIn:(BOOL)show
{
[UIView animateWithDuration:framesDuration(kMenuViewHideFramesCount) animations:^{ self.alpha = show ? 1.0 : 0.0; }];
}
- (void)animate
{
CGFloat const hideBound = kZoomViewHideBoundPercent * self.superview.height;
BOOL const isHidden = self.alpha == 0.0;
BOOL const willHide = (self.bottomBound < hideBound) || (self.defaultBounds.size.height > self.bottomBound - self.topBound);
if (willHide)
{
if (!isHidden)
[self fadeAnimatedIn:NO];
}
else
{
[self moveAnimated];
if (isHidden)
[self fadeAnimatedIn:YES];
}
}
#pragma mark - Properties
- (void)setHidden:(BOOL)hidden animated:(BOOL)animated
{
if (animated)
{
if (self.hidden == hidden)
return;
if (!hidden)
self.hidden = NO;
[self layoutXPosition:!hidden];
[UIView animateWithDuration:framesDuration(kMenuViewHideFramesCount) animations:^
{
[self layoutXPosition:hidden];
}
completion:^(BOOL finished)
{
if (hidden)
self.hidden = YES;
}];
}
else
{
self.hidden = hidden;
}
}
@synthesize topBound = _topBound;
- (void)setTopBound:(CGFloat)topBound
{
if (equalScreenDimensions(_topBound, topBound))
return;
_topBound = topBound;
[self animate];
}
- (CGFloat)topBound
{
return MAX(0.0, _topBound);
}
@synthesize bottomBound = _bottomBound;
- (void)setBottomBound:(CGFloat)bottomBound
{
if (equalScreenDimensions(_bottomBound, bottomBound))
return;
_bottomBound = bottomBound;
[self animate];
}
- (CGFloat)bottomBound
{
if (!self.superview)
return _bottomBound;
BOOL const isPortrait = self.superview.width < self.superview.height;
CGFloat limit = IPAD ? 320.0 : isPortrait ? 200.0 : 80.0;
return MIN(self.superview.height - limit, _bottomBound);
}
@end

View file

@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15A284" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="MWMZoomButtons">
<connections>
<outlet property="zoomInButton" destination="NO3-Xl-Oka" id="ePH-BR-gfW"/>
<outlet property="zoomOutButton" destination="hwn-8L-cFX" id="fYk-mf-gUY"/>
<outlet property="zoomView" destination="ek2-ZW-pCm" id="N0e-Rh-Unp"/>
</connections>
</placeholder>
<view contentMode="scaleToFill" id="ek2-ZW-pCm" customClass="MWMZoomButtonsView">
<rect key="frame" x="0.0" y="0.0" width="56" height="116"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="NO3-Xl-Oka" userLabel="ZoomIn" customClass="MWMButton">
<rect key="frame" x="0.0" y="0.0" width="56" height="56"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" image="btn_zoom_in_light">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="imageName" value="btn_zoom_in"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="zoomTouchDown:" destination="-1" eventType="touchDown" id="5VF-m8-Lwc"/>
<action selector="zoomTouchUpInside:" destination="-1" eventType="touchUpInside" id="wbL-zf-fH8"/>
<action selector="zoomTouchUpOutside:" destination="-1" eventType="touchUpOutside" id="w6V-A2-cZM"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" id="hwn-8L-cFX" userLabel="ZoomOut" customClass="MWMButton">
<rect key="frame" x="0.0" y="60" width="56" height="56"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<state key="normal" image="btn_zoom_out_light">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="string" keyPath="imageName" value="btn_zoom_out"/>
</userDefinedRuntimeAttributes>
<connections>
<action selector="zoomTouchDown:" destination="-1" eventType="touchDown" id="o4X-Kp-9ka"/>
<action selector="zoomTouchUpInside:" destination="-1" eventType="touchUpInside" id="Gcq-hm-Nk8"/>
<action selector="zoomTouchUpOutside:" destination="-1" eventType="touchUpOutside" id="cX7-sp-3L3"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<gestureRecognizers/>
<nil key="simulatedStatusBarMetrics"/>
<nil key="simulatedTopBarMetrics"/>
<nil key="simulatedBottomBarMetrics"/>
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
<connections>
<outletCollection property="gestureRecognizers" destination="6qU-Ff-Ae5" appends="YES" id="jeT-Jr-P7T"/>
</connections>
<point key="canvasLocation" x="165" y="-6"/>
</view>
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
<panGestureRecognizer minimumNumberOfTouches="1" id="6qU-Ff-Ae5">
<connections>
<action selector="zoomSwipe:" destination="-1" id="jq1-Qs-vUJ"/>
</connections>
</panGestureRecognizer>
</objects>
<resources>
<image name="btn_zoom_in_light" width="56" height="56"/>
<image name="btn_zoom_out_light" width="56" height="56"/>
</resources>
</document>