Skip to content
This repository was archived by the owner on Nov 19, 2019. It is now read-only.

Commit 876063b

Browse files
author
Frank Dowsett
committed
Correct the desired width for Adium's tabs from double counting the icon and close button.
1 parent fcc1899 commit 876063b

File tree

2 files changed

+35
-2
lines changed

2 files changed

+35
-2
lines changed

Source/PSMAdiumTabStyle.m

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,39 @@ - (NSAttributedString *)attributedStringValueForTabCell:(PSMTabBarCell *)cell {
197197
#pragma mark -
198198
#pragma mark Determining Cell Size
199199

200+
- (CGFloat)desiredWidthOfTabCell:(PSMTabBarCell *)cell {
201+
CGFloat resultWidth = 0.0;
202+
203+
// left margin
204+
resultWidth = MARGIN_X;
205+
206+
// icon or close button?
207+
if ([cell hasIcon]) {
208+
resultWidth += kPSMTabBarIconWidth + kPSMTabBarCellPadding;
209+
} else if ([cell shouldDrawCloseButton]) {
210+
NSImage *image = [cell closeButtonImageOfType:PSMCloseButtonImageTypeStandard];
211+
resultWidth += [image size].width + kPSMTabBarCellPadding;
212+
}
213+
214+
// the label
215+
resultWidth += [[cell attributedStringValue] size].width;
216+
217+
// object counter?
218+
if ([cell count] > 0) {
219+
resultWidth += [cell objectCounterSize].width + kPSMTabBarCellPadding;
220+
}
221+
222+
// indicator?
223+
if ([[cell indicator] isHidden] == NO) {
224+
resultWidth += kPSMTabBarCellPadding + kPSMTabBarIndicatorWidth;
225+
}
226+
227+
// right margin
228+
resultWidth += MARGIN_X;
229+
230+
return ceil(resultWidth);
231+
}
232+
200233
- (CGFloat)heightOfTabCellsForTabBarControl:(PSMTabBarControl *)tabBarControl {
201234
PSMTabBarOrientation orientation = [tabBarControl orientation];
202235
return((orientation == PSMTabBarHorizontalOrientation) ? kPSMTabBarControlHeight : kPSMTabBarControlSourceListHeight);

Source/PSMTabBarCell.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ - (NSRect)closeButtonRectForBounds:(NSRect)theRect {
353353
- (CGFloat)minimumWidthOfCell {
354354

355355
id < PSMTabStyle > style = [[self controlView] style];
356-
if ([style respondsToSelector:@selector(minimumWidthOfTabCell)]) {
356+
if ([style respondsToSelector:@selector(minimumWidthOfTabCell:)]) {
357357
return [style minimumWidthOfTabCell:self];
358358
} else {
359359
return [self _minimumWidthOfCell];
@@ -363,7 +363,7 @@ - (CGFloat)minimumWidthOfCell {
363363
- (CGFloat)desiredWidthOfCell {
364364

365365
id < PSMTabStyle > style = [[self controlView] style];
366-
if ([style respondsToSelector:@selector(desiredWidthOfTabCell)]) {
366+
if ([style respondsToSelector:@selector(desiredWidthOfTabCell:)]) {
367367
return [style desiredWidthOfTabCell:self];
368368
} else {
369369
return [self _desiredWidthOfCell];

0 commit comments

Comments
 (0)