Implement _minimumFrameSize for CPTokenField tokens. Also honor min-size width - not used by Aristo but potentially useful for custom themes.

This commit is contained in:
Alexander Ljungberg committed 2010-10-15 12:40:09 -03:00
1 parent a821614939
commit 8ec78f20d1
2 files changed
+7 -9

No files matched your search

+5 -9
View File
@@ -970,21 +970,17 @@ var CPThemeStateAutoCompleting = @"CPThemeStateAutoCompleting",
_tokenField = tokenField;
}
- (void)sizeToFit
- (CGSize)_minimumFrameSize
{
[super sizeToFit];
var size = [self bounds].size,
var size = CGRectMakeZero(),
minSize = [self currentValueForThemeAttribute:@"min-size"],
contentInset = [self currentValueForThemeAttribute:@"content-inset"];
// Tokens are fixed height, so we could as well have used max-size here.
size.height = minSize.height;
size.width = MAX(minSize.width, [([self stringValue] || @" ") sizeWithFont:[self font]].width + contentInset.left + contentInset.right);
// this is necessary to recalculate the width of the token due to new CPTextField sizeToFit
// behaviour that doesn't resize width on bezeled textfield
size.width = [([self stringValue] || @" ") sizeWithFont:[self font]].width + contentInset.left + contentInset.right;
[self setFrameSize:size];
return size;
}
- (void)layoutSubviews
+2
View File
@@ -848,7 +848,9 @@ var themedButtonValues = nil,
[@"bezel-inset", CGInsetMake(0.0, 0.0, 0.0, 0.0), CPThemeStateBezeled],
[@"content-inset", CGInsetMake(1.0, 24.0, 2.0, 16.0), CPThemeStateBezeled],
// Minimum height == maximum height since tokens are fixed height.
[@"min-size", CGSizeMake(0.0, 19.0)],
[@"max-size", CGSizeMake(-1.0, 19.0)],
[@"vertical-alignment", CPCenterTextAlignment],
];