Permalink
Browse files

Merge pull request #2030 from origsun/master

Remove a private API in PSMTabBarCell
  • Loading branch information...
abhibeckert committed Dec 1, 2014
2 parents 1af7e14 + 0043203 commit b5e972f4504043dfb9c358e272e93fb59ae2127f
@@ -35,6 +35,7 @@
NSColor *_countColor;
BOOL _isEdited;
NSColor *_backgroundColor;
id _customControlView;
}
// creation/destruction
@@ -43,8 +44,8 @@
- (void)dealloc;
// accessors
- (id)controlView;
- (void)setControlView:(id)view;
- (id)customControlView;
- (void)setCustomControlView:(id)view;
- (NSTrackingRectTag)closeButtonTrackingTag;
- (void)setCloseButtonTrackingTag:(NSTrackingRectTag)tag;
- (NSTrackingRectTag)cellTrackingTag;
@@ -23,7 +23,7 @@ @implementation PSMTabBarCell
- (id)initWithControlView:(PSMTabBarControl *)controlView
{
if ( (self = [super init]) ) {
_controlView = controlView;
_customControlView = controlView;
_closeButtonTrackingTag = 0;
_cellTrackingTag = 0;
_closeButtonOver = NO;
@@ -45,7 +45,7 @@ - (id)initWithControlView:(PSMTabBarControl *)controlView
- (id)initPlaceholderWithFrame:(NSRect)frame expanded:(BOOL)value inControlView:(PSMTabBarControl *)controlView
{
if ( (self = [super init]) ) {
_controlView = controlView;
_customControlView = controlView;
_isPlaceholder = YES;
if (!value) {
if ([controlView orientation] == PSMTabBarHorizontalOrientation) {
@@ -90,15 +90,15 @@ - (void)dealloc
#pragma mark -
#pragma mark Accessors
- (id)controlView
- (id)customControlView
{
return _controlView;
return _customControlView;
}
- (void)setControlView:(id)view
- (void)setCustomControlView:(id)view
{
// no retain release pattern, as this simply switches a tab to another view.
_controlView = view;
_customControlView = view;
}
- (NSTrackingRectTag)closeButtonTrackingTag
@@ -136,7 +136,7 @@ - (void)setFrame:(NSRect)rect
_frame = rect;
//move the status indicator along with the rest of the cell
if (![[self indicator] isHidden] && ![_controlView isTabBarHidden]) {
if (![[self indicator] isHidden] && ![_customControlView isTabBarHidden]) {
[[self indicator] setFrame:[self indicatorRectForFrame:rect]];
}
}
@@ -146,7 +146,7 @@ - (void)setStringValue:(NSString *)aString
[super setStringValue:aString];
_stringSize = [[self attributedStringValue] size];
// need to redisplay now - binding observation was too quick.
[_controlView update];
[_customControlView update];
}
- (NSSize)stringSize
@@ -156,7 +156,7 @@ - (NSSize)stringSize
- (NSAttributedString *)attributedStringValue
{
return [[(PSMTabBarControl *)_controlView style] attributedStringValueForTabCell:self];
return [[(PSMTabBarControl *)_customControlView style] attributedStringValueForTabCell:self];
}
- (NSInteger)tabState
@@ -183,8 +183,8 @@ - (void)setIsInOverflowMenu:(BOOL)value
{
if (_isInOverflowMenu != value) {
_isInOverflowMenu = value;
if ([[[self controlView] delegate] respondsToSelector:@selector(tabView:tabViewItem:isInOverflowMenu:)]) {
[[[self controlView] delegate] tabView:[self controlView] tabViewItem:[self representedObject] isInOverflowMenu:_isInOverflowMenu];
if ([[[self customControlView] delegate] respondsToSelector:@selector(tabView:tabViewItem:isInOverflowMenu:)]) {
[[[self customControlView] delegate] tabView:[self customControlView] tabViewItem:[self representedObject] isInOverflowMenu:_isInOverflowMenu];
}
}
}
@@ -201,7 +201,7 @@ - (void)setCloseButtonPressed:(BOOL)value
- (BOOL)closeButtonOver
{
return (_closeButtonOver && ([_controlView allowsBackgroundTabClosing] || ([self tabState] & PSMTab_SelectedMask) || [[NSApp currentEvent] modifierFlags] & NSCommandKeyMask));
return (_closeButtonOver && ([_customControlView allowsBackgroundTabClosing] || ([self tabState] & PSMTab_SelectedMask) || [[NSApp currentEvent] modifierFlags] & NSCommandKeyMask));
}
- (void)setCloseButtonOver:(BOOL)value
@@ -237,7 +237,7 @@ - (BOOL)hasIcon
- (void)setHasIcon:(BOOL)value
{
_hasIcon = value;
//[_controlView update:[[self controlView] automaticallyAnimates]]; // binding notice is too fast
//[_customControlView update:[[self customControlView] automaticallyAnimates]]; // binding notice is too fast
}
- (BOOL)hasLargeImage
@@ -259,7 +259,7 @@ - (NSInteger)count
- (void)setCount:(NSInteger)value
{
_count = value;
//[_controlView update:[[self controlView] automaticallyAnimates]]; // binding notice is too fast
//[_customControlView update:[[self customControlView] automaticallyAnimates]]; // binding notice is too fast
}
- (NSColor *)countColor
@@ -307,7 +307,7 @@ - (BOOL)isEdited
- (void)setIsEdited:(BOOL)value
{
_isEdited = value;
//[_controlView update:[[self controlView] automaticallyAnimates]]; // binding notice is too fast
//[_customControlView update:[[self customControlView] automaticallyAnimates]]; // binding notice is too fast
}
- (NSColor *)backgroundColor {
@@ -327,32 +327,32 @@ - (void)setBackgroundColor:(NSColor *)aColor
- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
// the progress indicator, label, icon, or count has changed - redraw the control view
//[_controlView update];
//[_customControlView update];
//I seem to have run into some odd issue with update not being called at the right time. This seems to avoid the problem.
[_controlView performSelector:@selector(update) withObject:nil afterDelay:0.0];
[_customControlView performSelector:@selector(update) withObject:nil afterDelay:0.0];
}
#pragma mark -
#pragma mark Component Attributes
- (NSRect)indicatorRectForFrame:(NSRect)cellFrame
{
return [[(PSMTabBarControl *)_controlView style] indicatorRectForTabCell:self];
return [[(PSMTabBarControl *)_customControlView style] indicatorRectForTabCell:self];
}
- (NSRect)closeButtonRectForFrame:(NSRect)cellFrame
{
return [[(PSMTabBarControl *)_controlView style] closeButtonRectForTabCell:self withFrame:cellFrame];
return [[(PSMTabBarControl *)_customControlView style] closeButtonRectForTabCell:self withFrame:cellFrame];
}
- (CGFloat)minimumWidthOfCell
{
return [[(PSMTabBarControl *)_controlView style] minimumWidthOfTabCell:self];
return [[(PSMTabBarControl *)_customControlView style] minimumWidthOfTabCell:self];
}
- (CGFloat)desiredWidthOfCell
{
return [[(PSMTabBarControl *)_controlView style] desiredWidthOfTabCell:self];
return [[(PSMTabBarControl *)_customControlView style] desiredWidthOfTabCell:self];
}
#pragma mark -
@@ -361,14 +361,14 @@ - (CGFloat)desiredWidthOfCell
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
if (_isPlaceholder) {
if (![_controlView usesSafariStyleDragging]) {
if (![_customControlView usesSafariStyleDragging]) {
[[NSColor colorWithCalibratedWhite:0.0f alpha:0.2f] set];
NSRectFillUsingOperation(cellFrame, NSCompositeSourceAtop);
}
return;
}
[[(PSMTabBarControl *)_controlView style] drawTabCell:self];
[[(PSMTabBarControl *)_customControlView style] drawTabCell:self];
}
#pragma mark -
@@ -382,15 +382,15 @@ - (void)mouseEntered:(NSEvent *)theEvent
}
if ([theEvent trackingNumber] == _cellTrackingTag) {
[self setHighlighted:YES];
[_controlView setNeedsDisplay:NO];
[_customControlView setNeedsDisplay:NO];
}
// scrubtastic
if ([_controlView allowsScrubbing] && ([theEvent modifierFlags] & NSAlternateKeyMask))
[_controlView tabClick:self];
if ([_customControlView allowsScrubbing] && ([theEvent modifierFlags] & NSAlternateKeyMask))
[_customControlView tabClick:self];
// tell the control we only need to redraw the affected tab
[_controlView setNeedsDisplayInRect:NSInsetRect([self frame], -2, -2)];
[_customControlView setNeedsDisplayInRect:NSInsetRect([self frame], -2, -2)];
}
- (void)mouseExited:(NSEvent *)theEvent
@@ -402,19 +402,19 @@ - (void)mouseExited:(NSEvent *)theEvent
if ([theEvent trackingNumber] == _cellTrackingTag) {
[self setHighlighted:NO];
[_controlView setNeedsDisplay:NO];
[_customControlView setNeedsDisplay:NO];
}
//tell the control we only need to redraw the affected tab
[_controlView setNeedsDisplayInRect:NSInsetRect([self frame], -2, -2)];
[_customControlView setNeedsDisplayInRect:NSInsetRect([self frame], -2, -2)];
}
#pragma mark -
#pragma mark Drag Support
- (NSImage *)dragImage
{
NSRect cellFrame = [(id <PSMTabStyle>)[(PSMTabBarControl *)_controlView style] dragRectForTabCell:self orientation:(PSMTabBarOrientation)[(PSMTabBarControl *)_controlView orientation]];
NSRect cellFrame = [(id <PSMTabStyle>)[(PSMTabBarControl *)_customControlView style] dragRectForTabCell:self orientation:(PSMTabBarOrientation)[(PSMTabBarControl *)_customControlView orientation]];
//NSRect cellFrame = [self frame];
// Determine the target coordinates to draw into
@@ -432,7 +432,7 @@ - (NSImage *)dragImage
[image lockFocusFlipped:YES];
#endif
[self setFrame:tabDrawFrame];
[(id <PSMTabStyle>)[(PSMTabBarControl *)_controlView style] drawTabCell:self];
[(id <PSMTabStyle>)[(PSMTabBarControl *)_customControlView style] drawTabCell:self];
[self setFrame:oldFrame];
[image unlockFocus];
@@ -515,10 +515,10 @@ - (id)accessibilityAttributeValue:(NSString *)attribute {
if ([attribute isEqualToString: NSAccessibilityRoleAttribute]) {
attributeValue = NSAccessibilityButtonRole;
} else if ([attribute isEqualToString: NSAccessibilityHelpAttribute]) {
if ([[[self controlView] delegate] respondsToSelector:@selector(accessibilityStringForTabView:objectCount:)]) {
if ([[[self customControlView] delegate] respondsToSelector:@selector(accessibilityStringForTabView:objectCount:)]) {
attributeValue = [NSString stringWithFormat:@"%@, %lu %@", [self stringValue],
(unsigned long)[self count],
[[[self controlView] delegate] accessibilityStringForTabView:[[self controlView] tabView] objectCount:[self count]]];
[[[self customControlView] delegate] accessibilityStringForTabView:[[self customControlView] tabView] objectCount:[self count]]];
} else {
attributeValue = [self stringValue];
}
@@ -549,7 +549,7 @@ - (NSString *)accessibilityActionDescription:(NSString *)action
- (void)accessibilityPerformAction:(NSString *)action {
if ([action isEqualToString:NSAccessibilityPressAction]) {
// this tab was selected
[_controlView tabClick:self];
[_customControlView tabClick:self];
}
}
@@ -367,7 +367,7 @@ - (void)performDragOperation
}
[[[self destinationTabBar] cells] replaceObjectAtIndex:destinationIndex withObject:[self draggedCell]];
[[self draggedCell] setControlView:[self destinationTabBar]];
[[self draggedCell] setCustomControlView:[self destinationTabBar]];
// move actual NSTabViewItem
if ([self sourceTabBar] != [self destinationTabBar]) {
@@ -474,7 +474,7 @@ - (void)draggedImageEndedAt:(NSPoint)aPoint operation:(NSDragOperation)operation
//rebind the cell to the new control
[control bindPropertiesForCell:[self draggedCell] andTabViewItem:[[self draggedCell] representedObject]];
[[self draggedCell] setControlView:control];
[[self draggedCell] setCustomControlView:control];
[[[self sourceTabBar] tabView] removeTabViewItem:[[self draggedCell] representedObject]];
@@ -757,7 +757,7 @@ - (void)drawTabCell:(PSMTabBarCell *)cell
[bezier lineToPoint:NSMakePoint(NSMaxX(aRect), NSMaxY(aRect))];
[bezier lineToPoint:NSMakePoint(NSMaxX(aRect), NSMinY(aRect))];
if ([[cell controlView] frame].size.height < 2) {
if ([[cell customControlView] frame].size.height < 2) {
// special case of hidden control; need line across top of cell
[bezier moveToPoint:NSMakePoint(aRect.origin.x, aRect.origin.y + 0.5)];
[bezier lineToPoint:NSMakePoint(aRect.origin.x+aRect.size.width, aRect.origin.y + 0.5)];
@@ -854,7 +854,7 @@ - (void)drawTabCell:(PSMTabBarCell *)cell
[NSGraphicsContext restoreGraphicsState];
[shadow release];
[self drawInteriorWithTabCell:cell inView:[cell controlView]];
[self drawInteriorWithTabCell:cell inView:[cell customControlView]];
}
- (void)drawBackgroundInRect:(NSRect)rect
@@ -340,7 +340,7 @@ - (void)drawTabCell:(PSMTabBarCell *)cell;
else
currentTint = [cell controlTint];
if (![[[cell controlView] window] isKeyWindow])
if (![[[cell customControlView] window] isKeyWindow])
currentTint = NSClearControlTint;
NSImage *bgImage;
@@ -381,7 +381,7 @@ - (void)drawTabCell:(PSMTabBarCell *)cell;
[aquaDivider compositeToPoint:NSMakePoint(cellFrame.origin.x + cellFrame.size.width - 1.0, cellFrame.origin.y + cellFrame.size.height) operation:NSCompositeSourceOver];
}
[self drawInteriorWithTabCell:cell inView:[cell controlView]];
[self drawInteriorWithTabCell:cell inView:[cell customControlView]];
}
- (void)drawBackgroundInRect:(NSRect)rect
@@ -423,7 +423,7 @@ - (void)drawTabCell:(PSMTabBarCell *)cell
}
}
[self drawInteriorWithTabCell:cell inView:[cell controlView]];
[self drawInteriorWithTabCell:cell inView:[cell customControlView]];
}
@@ -433,7 +433,7 @@ - (void)drawInteriorWithTabCell:(PSMTabBarCell *)cell inView:(NSView*)controlVie
BOOL showsBaselineSeparator = NO;
/*
NSToolbar *toolbar = [[[cell controlView] window] toolbar];
NSToolbar *toolbar = [[[cell customControlView] window] toolbar];
BOOL showsBaselineSeparator = (toolbar && [toolbar respondsToSelector:@selector(showsBaselineSeparator)] && [toolbar showsBaselineSeparator]);
*/
if (!showsBaselineSeparator) {
@@ -373,7 +373,7 @@ - (void)drawTabCell:(PSMTabBarCell *)cell
[bezier lineToPoint:NSMakePoint(aRect.origin.x+aRect.size.width-2.5, aRect.origin.y+aRect.size.height)];
[bezier lineToPoint:NSMakePoint(aRect.origin.x+aRect.size.width, aRect.origin.y+aRect.size.height-1.5)];
[bezier lineToPoint:NSMakePoint(aRect.origin.x+aRect.size.width, aRect.origin.y)];
if ([[cell controlView] frame].size.height < 2) {
if ([[cell customControlView] frame].size.height < 2) {
// special case of hidden control; need line across top of cell
[bezier moveToPoint:NSMakePoint(aRect.origin.x, aRect.origin.y+0.5)];
[bezier lineToPoint:NSMakePoint(aRect.origin.x+aRect.size.width, aRect.origin.y+0.5)];
@@ -442,7 +442,7 @@ - (void)drawTabCell:(PSMTabBarCell *)cell
[NSGraphicsContext restoreGraphicsState];
[self drawInteriorWithTabCell:cell inView:[cell controlView]];
[self drawInteriorWithTabCell:cell inView:[cell customControlView]];
}
@@ -748,7 +748,7 @@ - (void)drawTabCell:(PSMTabBarCell *)cell
[NSGraphicsContext restoreGraphicsState];
[self drawInteriorWithTabCell:cell inView:[cell controlView]];
[self drawInteriorWithTabCell:cell inView:[cell customControlView]];
}
@@ -312,7 +312,7 @@ - (void)drawTabCell:(PSMTabBarCell *)cell
{
NSRect cellFrame = [cell frame];
NSToolbar *toolbar = [[[cell controlView] window] toolbar];
NSToolbar *toolbar = [[[cell customControlView] window] toolbar];
BOOL showsBaselineSeparator = (toolbar && [toolbar respondsToSelector:@selector(showsBaselineSeparator)] && [toolbar showsBaselineSeparator]);
if (!showsBaselineSeparator) {
cellFrame.origin.y += 1.0;
@@ -409,7 +409,7 @@ - (void)drawTabCell:(PSMTabBarCell *)cell
}
}
[self drawInteriorWithTabCell:cell inView:[cell controlView]];
[self drawInteriorWithTabCell:cell inView:[cell customControlView]];
}
@@ -149,6 +149,7 @@ Tim Davis\
(
\f2\fs24 BGHUDButtonCell
\f0\fs22 )\
Jie Xu (@origsun)\
\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\qc\pardirnatural
@@ -211,4 +212,4 @@ All rights reserved.\
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\qc\pardirnatural
\cf0 Icon by {\field{\*\fldinst{HYPERLINK "http://kenichiyoshida.jp/"}}{\fldrslt Kenichi Yoshida}}, with thanks to {\field{\*\fldinst{HYPERLINK "http://panic.com/"}}{\fldrslt Panic}}\
GUI design by {\field{\*\fldinst{HYPERLINK "http://www.sequelpro.com/"}}{\fldrslt Sequel Pro}} team.\
}
}
Oops, something went wrong.

0 comments on commit b5e972f

Please sign in to comment.