mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-11-13 10:13:50 +00:00
add size to fit for buttons. Closes #34.
This commit is contained in:
1 parent
81d23aafab
commit
ae8fd0c2d4
2 files changed
+20
-2
No files matched your search
+14
-2
@@ -125,8 +125,8 @@ var _CPButtonClassName = nil,
|
||||
|
||||
+ (id)themedAttributes
|
||||
{
|
||||
return [CPDictionary dictionaryWithObjects:[_CGInsetMakeZero(), _CGInsetMakeZero(), nil]
|
||||
forKeys:[@"bezel-inset", @"content-inset", @"bezel-color"]];
|
||||
return [CPDictionary dictionaryWithObjects:[_CGInsetMakeZero(), _CGInsetMakeZero(), nil, 24.0]
|
||||
forKeys:[@"bezel-inset", @"content-inset", @"bezel-color", @"default-height"]];
|
||||
}
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
@@ -374,6 +374,18 @@ var _CPButtonClassName = nil,
|
||||
return bounds;
|
||||
}
|
||||
|
||||
/*!
|
||||
Adjust the size of the button to fit the title and surrounding button image.
|
||||
*/
|
||||
- (void)sizeToFit
|
||||
{
|
||||
var size = [([self title] || " ") sizeWithFont:[self font]],
|
||||
contentInset = [self currentValueForThemedAttributeName:@"content-inset"],
|
||||
defaultHeight = [self currentValueForThemedAttributeName:@"default-height"];
|
||||
|
||||
[self setFrameSize:CGSizeMake(size.width + contentInset.left + contentInset.right, defaultHeight)];
|
||||
}
|
||||
|
||||
- (CGRect)rectForEphemeralSubviewNamed:(CPString)aName
|
||||
{
|
||||
if (aName === "bezel-view")
|
||||
|
||||
@@ -208,3 +208,9 @@ function CGPointFromEvent(anEvent)
|
||||
{
|
||||
return _CGPointMake(anEvent.clientX, anEvent.clientY);
|
||||
}
|
||||
|
||||
function CPStringFromInset(anInset)
|
||||
{
|
||||
return anInset.top+" "+anInset.left+" "+anInset.bottom+" "+anInset.right;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user