Skip to content

Commit

Permalink
Minor CPTabView optimisation.
Browse files Browse the repository at this point in the history
  • Loading branch information
aljungberg committed Aug 28, 2012
1 parent b28673d commit f535a6a
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions AppKit/CPTabView.j
Expand Up @@ -79,11 +79,11 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
{
_selectedIndex = CPNotFound;

_tabs = [[CPSegmentedControl alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
_tabs = [[CPSegmentedControl alloc] initWithFrame:_CGRectMake(0, 0, 0, 0)];
[_tabs setHitTests:NO];

var height = [_tabs valueForThemeAttribute:@"default-height"];
[_tabs setFrameSize:CGSizeMake(0, height)];
[_tabs setFrameSize:_CGSizeMake(0, height)];

_box = [[CPBox alloc] initWithFrame:[self bounds]];
[self setBackgroundColor:[CPColor colorWithCalibratedWhite:0.95 alpha:1.0]];
Expand Down Expand Up @@ -350,11 +350,11 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
else
{
var aFrame = [self frame],
segmentedHeight = CGRectGetHeight([_tabs frame]),
segmentedHeight = _CGRectGetHeight([_tabs frame]),
origin = _type === CPTopTabsBezelBorder ? segmentedHeight / 2 : 0;

[_box setFrame:CGRectMake(0, origin, CGRectGetWidth(aFrame),
CGRectGetHeight(aFrame) - segmentedHeight / 2)];
[_box setFrame:_CGRectMake(0, origin, _CGRectGetWidth(aFrame),
_CGRectGetHeight(aFrame) - segmentedHeight / 2)];

[self addSubview:_tabs];
}
Expand Down Expand Up @@ -439,13 +439,13 @@ var CPTabViewDidSelectTabViewItemSelector = 1,

- (void)_repositionTabs
{
var horizontalCenterOfSelf = CGRectGetWidth([self bounds]) / 2,
verticalCenterOfTabs = CGRectGetHeight([_tabs bounds]) / 2;
var horizontalCenterOfSelf = _CGRectGetWidth([self bounds]) / 2,
verticalCenterOfTabs = _CGRectGetHeight([_tabs bounds]) / 2;

if (_type === CPBottomTabsBezelBorder)
[_tabs setCenter:CGPointMake(horizontalCenterOfSelf, CGRectGetHeight([self bounds]) - verticalCenterOfTabs)];
[_tabs setCenter:_CGPointMake(horizontalCenterOfSelf, _CGRectGetHeight([self bounds]) - verticalCenterOfTabs)];
else
[_tabs setCenter:CGPointMake(horizontalCenterOfSelf, verticalCenterOfTabs)];
[_tabs setCenter:_CGPointMake(horizontalCenterOfSelf, verticalCenterOfTabs)];
}

- (void)_setSelectedIndex:(CPNumber)index
Expand All @@ -471,9 +471,7 @@ var CPTabViewDidSelectTabViewItemSelector = 1,
}

if (_selectedIndex === CPNotFound)
{
[self selectFirstTabViewItem:self];
}
}

@end
Expand Down

0 comments on commit f535a6a

Please sign in to comment.