Skip to content

Commit

Permalink
Fixed Quick View left pane not resizing its contents
Browse files Browse the repository at this point in the history
  • Loading branch information
swisspol committed Oct 1, 2015
1 parent 3a6edc0 commit 8647eed
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 17 deletions.
31 changes: 27 additions & 4 deletions GitUpKit/Views/GIQuickViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ @interface GIQuickViewController () <GIDiffContentsViewControllerDelegate, GIDif
@property(nonatomic, weak) IBOutlet NSView* contentsView;
@property(nonatomic, weak) IBOutlet NSView* filesView;
@property(nonatomic, weak) IBOutlet NSBox* separatorBox;
@property(nonatomic, weak) IBOutlet GIDualSplitView* mainSplitView;
@property(nonatomic, weak) IBOutlet GIDualSplitView* infoSplitView;
@end

@implementation GIQuickViewController {
Expand All @@ -56,6 +58,23 @@ - (instancetype)initWithRepository:(GCLiveRepository*)repository {
return self;
}

- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self name:NSSplitViewDidResizeSubviewsNotification object:nil];
}

- (void)_recomputeInfoViewFrame {
NSRect frame = _infoView.frame;
NSSize size = [(NSTextFieldCell*)_messageTextField.cell cellSizeForBounds:NSMakeRect(0, 0, _messageTextField.frame.size.width, HUGE_VALF)];
CGFloat delta = ceil(size.height) - _messageTextField.frame.size.height;
_infoView.frame = NSMakeRect(0, 0, frame.size.width, frame.size.height + delta);
}

- (void)_splitViewDidResizeSubviews:(NSNotification*)notification {
if (!self.liveResizing) {
[self _recomputeInfoViewFrame];
}
}

- (void)loadView {
[super loadView];

Expand All @@ -67,6 +86,13 @@ - (void)loadView {
_diffFilesViewController = [[GIDiffFilesViewController alloc] initWithRepository:self.repository];
_diffFilesViewController.delegate = self;
[_filesView replaceWithView:_diffFilesViewController.view];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_splitViewDidResizeSubviews:) name:NSSplitViewDidResizeSubviewsNotification object:_mainSplitView];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_splitViewDidResizeSubviews:) name:NSSplitViewDidResizeSubviewsNotification object:_infoSplitView];
}

- (void)viewDidFinishLiveResize {
[self _recomputeInfoViewFrame];
}

static inline void _AppendStringWithoutTrailingWhiteSpace(NSMutableString* string, NSString* append, NSRange range) {
Expand Down Expand Up @@ -116,11 +142,8 @@ - (void)setCommit:(GCHistoryCommit*)commit {
if (commit != _commit) {
_commit = commit;
if (_commit) {
NSRect frame = _infoView.frame;
_messageTextField.stringValue = _CleanUpCommitMessage(_commit.message);
NSSize size = [(NSTextFieldCell*)_messageTextField.cell cellSizeForBounds:NSMakeRect(0, 0, _messageTextField.frame.size.width, HUGE_VALF)];
CGFloat delta = ceil(size.height) - _messageTextField.frame.size.height;
_infoView.frame = NSMakeRect(0, 0, frame.size.width, frame.size.height + delta);
[self _recomputeInfoViewFrame];

_sha1TextField.stringValue = _commit.SHA1;

Expand Down
28 changes: 15 additions & 13 deletions GitUpKit/Views/en.lproj/GIQuickViewController.xib
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
<outlet property="contentsView" destination="gnd-mU-OFa" id="aua-gs-pD6"/>
<outlet property="filesView" destination="T7C-Lf-raW" id="mzB-kk-e11"/>
<outlet property="infoScrollView" destination="A0F-jI-s4n" id="bGh-0w-P8p"/>
<outlet property="infoSplitView" destination="byI-fn-H6A" id="pd0-S6-weW"/>
<outlet property="infoView" destination="Bpc-ZA-3gm" id="hGF-hw-1ve"/>
<outlet property="mainSplitView" destination="pDr-8S-Qy7" id="Uw3-5d-Y0W"/>
<outlet property="messageTextField" destination="CIg-ZV-lYt" id="4pR-NU-HEE"/>
<outlet property="sha1TextField" destination="9bU-TV-AfR" id="2ke-4d-NUJ"/>
<outlet property="view" destination="Mge-gB-T5T" id="Dk7-8C-xIa"/>
Expand Down Expand Up @@ -51,24 +53,24 @@
<subviews>
<view id="Bpc-ZA-3gm" customClass="GIFlippedView">
<rect key="frame" x="0.0" y="0.0" width="300" height="130"/>
<autoresizingMask key="autoresizingMask"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<subviews>
<customView id="aKy-Bi-5hY">
<rect key="frame" x="0.0" y="0.0" width="300" height="130"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="9bU-TV-AfR">
<rect key="frame" x="8" y="110" width="278" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" scrollable="YES" lineBreakMode="clipping" selectable="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" title="&lt;SHA1&gt;" id="Tsu-dV-mjp">
<rect key="frame" x="8" y="110" width="282" height="14"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" selectable="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" title="&lt;SHA1&gt;" id="Tsu-dV-mjp">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" white="0.5" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" setsMaxLayoutWidthAtFirstLayout="YES" id="CIg-ZV-lYt">
<rect key="frame" x="8" y="84" width="282" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" heightSizable="YES"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<textFieldCell key="cell" controlSize="small" selectable="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" title="&lt;MESSAGE&gt;" id="fqu-LQ-wKF">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" white="0.25" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
Expand All @@ -82,17 +84,17 @@
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="Men-K8-VwT">
<rect key="frame" x="21" y="55" width="269" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" title="&lt;AUTHOR&gt;" id="11W-Hl-yV0">
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" title="&lt;AUTHOR NAME&gt;" id="11W-Hl-yV0">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" white="0.5" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="NMY-tY-Mrh">
<rect key="frame" x="21" y="41" width="269" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" title="&lt;AUTHOR_DATE&gt;" id="ESf-oA-sr2">
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" title="&lt;AUTHOR DATE&gt;" id="ESf-oA-sr2">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" white="0.5" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
Expand All @@ -105,17 +107,17 @@
</imageView>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="5Yv-8b-x0c">
<rect key="frame" x="21" y="19" width="269" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" title="&lt;COMMITTER&gt;" id="4Tl-BB-pru">
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" title="&lt;COMMITTER NAME&gt;" id="4Tl-BB-pru">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" white="0.5" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
</textFieldCell>
</textField>
<textField horizontalHuggingPriority="251" verticalHuggingPriority="750" id="p8J-vi-dDp">
<rect key="frame" x="21" y="7" width="269" height="14"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" title="&lt;COMMITTER_DATE&gt;" id="Dbg-2h-APW">
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
<textFieldCell key="cell" controlSize="small" lineBreakMode="truncatingTail" truncatesLastVisibleLine="YES" allowsUndo="NO" sendsActionOnEndEditing="YES" alignment="left" title="&lt;COMMITTER DATE&gt;" id="Dbg-2h-APW">
<font key="font" metaFont="smallSystem"/>
<color key="textColor" white="0.5" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<color key="backgroundColor" name="controlColor" catalog="System" colorSpace="catalog"/>
Expand Down

0 comments on commit 8647eed

Please sign in to comment.