Skip to content

Commit 24a4475

Browse files
committed
Fix help menu offset by using layout constraint instead
1 parent bb5a8c3 commit 24a4475

File tree

3 files changed

+33
-24
lines changed

3 files changed

+33
-24
lines changed

GitUp/Application/Base.lproj/Document.xib

Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<dependencies>
44
<deployment identifier="macosx"/>
55
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="24506"/>
6+
<capability name="NSView safe area layout guides" minToolsVersion="12.0"/>
67
<capability name="Search Toolbar Item" minToolsVersion="12.0" minSystemVersion="11.0"/>
78
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
89
</dependencies>
@@ -17,6 +18,7 @@
1718
<outlet property="helpOpenButton" destination="cA6-Ht-e3Z" id="GWb-T7-oe0"/>
1819
<outlet property="helpTextField" destination="hTO-MR-3XZ" id="x1j-wP-MJw"/>
1920
<outlet property="helpView" destination="Zjf-1c-7Wk" id="V4P-Tc-ofE"/>
21+
<outlet property="helpViewToTabViewConstraint" destination="LZl-0T-rYC" id="5vI-sR-jdT"/>
2022
<outlet property="hiddenWarningView" destination="4K3-nK-X1O" id="und-Lh-TE7"/>
2123
<outlet property="indexDiffsButton" destination="8hM-1U-Hhn" id="iu9-J3-Muk"/>
2224
<outlet property="infoTextField1" destination="cbp-6y-jbG" id="kuD-M7-wz2"/>
@@ -59,16 +61,14 @@
5961
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES" fullSizeContentView="YES"/>
6062
<windowCollectionBehavior key="collectionBehavior" fullScreenPrimary="YES"/>
6163
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
62-
<rect key="contentRect" x="253" y="204" width="1000" height="500"/>
64+
<rect key="contentRect" x="253" y="204" width="612" height="365"/>
6365
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1410"/>
6466
<value key="minSize" type="size" width="800" height="490"/>
65-
<view key="contentView" id="gIp-Ho-8D9">
66-
<rect key="frame" x="0.0" y="0.0" width="1000" height="500"/>
67-
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
67+
<view key="contentView" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="gIp-Ho-8D9">
68+
<rect key="frame" x="0.0" y="0.0" width="612" height="365"/>
6869
<subviews>
69-
<customView hidden="YES" appearanceType="aqua" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Zjf-1c-7Wk" customClass="GIColorView">
70-
<rect key="frame" x="0.0" y="400" width="1000" height="50"/>
71-
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
70+
<customView hidden="YES" appearanceType="aqua" ambiguous="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Zjf-1c-7Wk" customClass="GIColorView">
71+
<rect key="frame" x="0.0" y="211" width="612" height="50"/>
7272
<subviews>
7373
<textField focusRingType="none" horizontalHuggingPriority="251" verticalHuggingPriority="750" horizontalCompressionResistancePriority="250" fixedFrame="YES" setsMaxLayoutWidthAtFirstLayout="YES" translatesAutoresizingMaskIntoConstraints="NO" id="hTO-MR-3XZ">
7474
<rect key="frame" x="8" y="8" width="818" height="31"/>
@@ -80,7 +80,7 @@
8080
</textFieldCell>
8181
</textField>
8282
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="W0y-nq-maS">
83-
<rect key="frame" x="910" y="16" width="80" height="17"/>
83+
<rect key="frame" x="522" y="16" width="80" height="17"/>
8484
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
8585
<buttonCell key="cell" type="roundRect" title="Continue" bezelStyle="roundedRect" alignment="center" controlSize="small" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="3Bn-bb-IAI">
8686
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@@ -91,7 +91,7 @@
9191
</connections>
9292
</button>
9393
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="etB-ce-0PB">
94-
<rect key="frame" x="832" y="16" width="60" height="17"/>
94+
<rect key="frame" x="444" y="16" width="60" height="17"/>
9595
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
9696
<buttonCell key="cell" type="roundRect" title="Got It!" bezelStyle="roundedRect" alignment="center" controlSize="small" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="U4W-Zh-R2B">
9797
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@@ -102,7 +102,7 @@
102102
</connections>
103103
</button>
104104
<button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="cA6-Ht-e3Z">
105-
<rect key="frame" x="900" y="16" width="90" height="17"/>
105+
<rect key="frame" x="512" y="16" width="90" height="17"/>
106106
<autoresizingMask key="autoresizingMask" flexibleMinX="YES" flexibleMinY="YES"/>
107107
<buttonCell key="cell" type="roundRect" title="Learn More…" bezelStyle="roundedRect" alignment="center" controlSize="small" state="on" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="ux0-pi-0du">
108108
<behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
@@ -113,20 +113,22 @@
113113
</connections>
114114
</button>
115115
</subviews>
116+
<constraints>
117+
<constraint firstAttribute="height" constant="50" id="1ZV-wN-Zgh"/>
118+
</constraints>
116119
<userDefinedRuntimeAttributes>
117120
<userDefinedRuntimeAttribute type="color" keyPath="backgroundColor">
118121
<color key="value" red="1" green="0.87657738947652419" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
119122
</userDefinedRuntimeAttribute>
120123
</userDefinedRuntimeAttributes>
121124
</customView>
122-
<tabView fixedFrame="YES" drawsBackground="NO" allowsTruncatedLabels="NO" type="noTabsNoBorder" translatesAutoresizingMaskIntoConstraints="NO" id="8LX-i4-RBG">
123-
<rect key="frame" x="0.0" y="0.0" width="1000" height="500"/>
124-
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
125+
<tabView ambiguous="YES" drawsBackground="NO" allowsTruncatedLabels="NO" type="noTabsNoBorder" translatesAutoresizingMaskIntoConstraints="NO" id="8LX-i4-RBG">
126+
<rect key="frame" x="0.0" y="0.0" width="612" height="365"/>
125127
<font key="font" metaFont="system"/>
126128
<tabViewItems>
127129
<tabViewItem label="Map" identifier="map" id="N3S-ZN-7aj">
128-
<view key="view" id="KTA-UW-CKM">
129-
<rect key="frame" x="0.0" y="0.0" width="1000" height="500"/>
130+
<view key="view" ambiguous="YES" id="KTA-UW-CKM">
131+
<rect key="frame" x="0.0" y="0.0" width="612" height="365"/>
130132
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
131133
</view>
132134
</tabViewItem>
@@ -181,6 +183,18 @@
181183
</tabViewItems>
182184
</tabView>
183185
</subviews>
186+
<constraints>
187+
<constraint firstItem="87c-pF-02X" firstAttribute="top" secondItem="Zjf-1c-7Wk" secondAttribute="top" id="D2d-qL-deh"/>
188+
<constraint firstItem="8LX-i4-RBG" firstAttribute="trailing" secondItem="87c-pF-02X" secondAttribute="trailing" id="GCZ-r5-980"/>
189+
<constraint firstItem="8LX-i4-RBG" firstAttribute="top" secondItem="Zjf-1c-7Wk" secondAttribute="bottom" id="LZl-0T-rYC"/>
190+
<constraint firstItem="Zjf-1c-7Wk" firstAttribute="trailing" secondItem="87c-pF-02X" secondAttribute="trailing" id="M7t-0p-HEb"/>
191+
<constraint firstItem="8LX-i4-RBG" firstAttribute="top" secondItem="gIp-Ho-8D9" secondAttribute="top" priority="999" id="anM-q1-lzo"/>
192+
<constraint firstItem="8LX-i4-RBG" firstAttribute="leading" secondItem="87c-pF-02X" secondAttribute="leading" id="cyW-aG-PlQ"/>
193+
<constraint firstItem="Zjf-1c-7Wk" firstAttribute="leading" secondItem="87c-pF-02X" secondAttribute="leading" id="fLu-3d-miy"/>
194+
<constraint firstItem="8LX-i4-RBG" firstAttribute="bottom" secondItem="87c-pF-02X" secondAttribute="bottom" id="seL-8w-yF7"/>
195+
</constraints>
196+
<viewLayoutGuide key="safeArea" id="87c-pF-02X"/>
197+
<viewLayoutGuide key="layoutMargins" id="TtR-dW-CBE"/>
184198
</view>
185199
<toolbar key="toolbar" implicitIdentifier="42EAA8AB-C985-49E8-81F5-068903B112A9" centeredItem="zlv-TE-Jdd" autosavesConfiguration="NO" allowsUserCustomization="NO" showsBaselineSeparator="NO" displayMode="iconOnly" sizeMode="regular" id="eX2-uf-7aH">
186200
<allowedToolbarItems>
@@ -280,7 +294,7 @@
280294
<outlet property="delegate" destination="-2" id="YNn-Pj-uPM"/>
281295
</connections>
282296
</toolbar>
283-
<point key="canvasLocation" x="-175" y="59"/>
297+
<point key="canvasLocation" x="-113" y="-62"/>
284298
</window>
285299
<customView id="p3q-Tt-mR8" userLabel="Map View">
286300
<rect key="frame" x="0.0" y="0.0" width="1000" height="518"/>

GitUp/Application/Document.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ typedef NS_ENUM(NSInteger, WindowModeID) {
3232
@property(nonatomic, strong) IBOutlet NSView* contentView;
3333

3434
@property(nonatomic, weak) IBOutlet NSView* helpView;
35+
@property(nonatomic, strong) IBOutlet NSLayoutConstraint* helpViewToTabViewConstraint;
3536
@property(nonatomic, weak) IBOutlet NSTextField* helpTextField;
3637
@property(nonatomic, weak) IBOutlet NSButton* helpContinueButton;
3738
@property(nonatomic, weak) IBOutlet NSButton* helpDismissButton;

GitUp/Application/Document.m

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -910,17 +910,11 @@ - (void)_showHelpWithIdentifier:(NSString*)identifier {
910910
XLOG_DEBUG_UNREACHABLE();
911911
}
912912
if (showHelp) {
913-
NSWindow* window = _mainTabView.window;
914-
CGRect frame = window.frame;
915-
CGRect layoutRect = window.contentLayoutRect;
916-
CGFloat toolbarHeight = frame.size.height - layoutRect.size.height;
917-
918-
NSRect contentBounds = _contentView.bounds;
919913
_helpView.hidden = NO;
920-
_mainTabView.frame = NSMakeRect(contentBounds.origin.x, contentBounds.origin.y, contentBounds.size.width, contentBounds.size.height - _helpView.frame.size.height - toolbarHeight);
914+
_helpViewToTabViewConstraint.active = YES;
921915
} else if (!_helpView.hidden) {
922-
_mainTabView.frame = _contentView.bounds;
923916
_helpView.hidden = YES;
917+
_helpViewToTabViewConstraint.active = NO;
924918
}
925919
}
926920

0 commit comments

Comments
 (0)