Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 58 lines (48 sloc) 1.673 kB
d669050 @heipei Add PBCollapsibleSplitView as subclass of PBNiceSplitView
heipei authored
1 //
2 // PBCollapsibleSplitView.m
3 // GitX
4 //
5 // Created by Johannes Gilger on 6/21/09.
6 // Copyright 2009 Johannes Gilger. All rights reserved.
7 //
8
9 #import "PBCollapsibleSplitView.h"
10
11 @implementation PBCollapsibleSplitView
12 @synthesize topViewMin, bottomViewMin;
13
14 - (void)setTopMin:(CGFloat)topMin andBottomMin:(CGFloat)bottomMin {
15 topViewMin = topMin;
16 bottomViewMin = bottomMin;
17 }
18
19 - (void)uncollapse {
20 for (NSView *subview in [self subviews]) {
21 if([self isSubviewCollapsed:subview]) {
22 [self setPosition:[self frame].size.height / 3 ofDividerAtIndex:0];
23 [self adjustSubviews];
24 }
25 }
26 }
27
193b834 @heipei PBCollapsibleSplitView: Enable collapse/uncollapse using keys
heipei authored
28 - (void)collapseSubview:(NSInteger)index {
29 // Already collapsed, just uncollapse
30 if ([self isSubviewCollapsed:[[self subviews] objectAtIndex:index]]) {
31 [self setPosition:splitterPosition ofDividerAtIndex:0];
32 return;
33 }
34
35 // Store splitterposition if the other view isn't collapsed
36 if (![self isSubviewCollapsed:[[self subviews] objectAtIndex:(index + 1) % 2]])
37 splitterPosition = [[[self subviews] objectAtIndex:0] frame].size.height;
38
39 if (index == 0) // Top view
40 [self setPosition:0.0 ofDividerAtIndex:0];
41 else // Bottom view
42 [self setPosition:[self frame].size.height ofDividerAtIndex:0];
43 }
44
45 - (void)keyDown:(NSEvent *)event {
46 if (!([event modifierFlags] & NSShiftKeyMask && [event modifierFlags] & NSCommandKeyMask))
47 return [super keyDown:event];
48
49 if ([event keyCode] == 0x07E) { // Up-Key
50 [self collapseSubview:0];
51 [[self window] makeFirstResponder:[[self subviews] objectAtIndex:1]];
52 } else if ([event keyCode] == 0x07D) { // Down-Key
53 [self collapseSubview:1];
54 [[self window] makeFirstResponder:[[self subviews] objectAtIndex:0]];
55 }
56 }
d669050 @heipei Add PBCollapsibleSplitView as subclass of PBNiceSplitView
heipei authored
57 @end
Something went wrong with that request. Please try again.