mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-12 21:51:28 +00:00
FIXED: Before this PR, only CPControl could use nib2cib-adjustment-frame. (#2831)
This commit is contained in:
+1
-2
@@ -137,8 +137,7 @@ var CPControlBlackColor = [CPColor blackColor];
|
||||
@"image-position": CPImageLeft,
|
||||
@"image-scaling": CPScaleToFit,
|
||||
@"min-size": CGSizeMakeZero(),
|
||||
@"max-size": CGSizeMake(-1.0, -1.0),
|
||||
@"nib2cib-adjustment-frame": CGRectMakeZero()
|
||||
@"max-size": CGSizeMake(-1.0, -1.0)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -332,7 +332,8 @@ var CPViewHighDPIDrawingEnabled = YES;
|
||||
+ (CPDictionary)themeAttributes
|
||||
{
|
||||
return @{
|
||||
@"css-based": NO
|
||||
@"css-based": NO,
|
||||
@"nib2cib-adjustment-frame": CGRectMakeZero()
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -25,10 +25,6 @@
|
||||
@import "NSCell.j"
|
||||
@import "NSView.j"
|
||||
|
||||
|
||||
@class Nib2Cib
|
||||
|
||||
|
||||
@implementation CPControl (NSCoding)
|
||||
|
||||
- (id)NS_initWithCoder:(CPCoder)aCoder
|
||||
@@ -68,27 +64,6 @@
|
||||
[self setControlSize:[cell controlSize]];
|
||||
}
|
||||
|
||||
- (CGRect)_nib2CibAdjustment
|
||||
{
|
||||
// Theme has not been loaded yet.
|
||||
// Get attribute value directly from the theme or from the default value of the object otherwise.
|
||||
var theme = [Nib2Cib defaultTheme];
|
||||
|
||||
return [theme valueForAttributeWithName:@"nib2cib-adjustment-frame" inState:[self themeState] forClass:[self class]] || [self currentValueForThemeAttribute:@"nib2cib-adjustment-frame"];
|
||||
}
|
||||
|
||||
- (void)_adjustNib2CibSize
|
||||
{
|
||||
var frame = [self frame],
|
||||
frameAdjustment = [self _nib2CibAdjustment];
|
||||
|
||||
if (frameAdjustment)
|
||||
{
|
||||
var finalFrame = CGRectMake(frame.origin.x + frameAdjustment.origin.x, frame.origin.y - frameAdjustment.origin.y, frame.size.width + frameAdjustment.size.width, frame.size.height + frameAdjustment.size.height);
|
||||
[self setFrame:finalFrame];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSControl : CPControl
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
@import <AppKit/CPView.j>
|
||||
|
||||
@class Nib2Cib
|
||||
|
||||
var NSViewAutoresizingMask = 0x3F,
|
||||
NSViewAutoresizesSubviewsMask = 1 << 8,
|
||||
@@ -117,6 +118,40 @@ var NSViewAutoresizingMask = 0x3F,
|
||||
[self setAutoresizingMask:autoresizingMask];
|
||||
}
|
||||
|
||||
- (CGRect)_nib2CibAdjustment
|
||||
{
|
||||
// Theme has not been loaded yet.
|
||||
// Get attribute value directly from the theme or from the default value of the object otherwise.
|
||||
var theme = [Nib2Cib defaultTheme],
|
||||
frameAdjustment = [theme valueForAttributeWithName:@"nib2cib-adjustment-frame" inState:[self themeState] forClass:[self class]];
|
||||
|
||||
if (frameAdjustment)
|
||||
return frameAdjustment;
|
||||
|
||||
if ([self hasThemeAttribute:@"nib2cib-adjustment-frame"])
|
||||
{
|
||||
frameAdjustment = [self currentValueForThemeAttribute:@"nib2cib-adjustment-frame"];
|
||||
|
||||
if (frameAdjustment)
|
||||
return frameAdjustment;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void)_adjustNib2CibSize
|
||||
{
|
||||
var frame = [self frame],
|
||||
frameAdjustment = [self _nib2CibAdjustment];
|
||||
|
||||
if (frameAdjustment)
|
||||
{
|
||||
var finalFrame = CGRectMake(frame.origin.x + frameAdjustment.origin.x, frame.origin.y - frameAdjustment.origin.y, frame.size.width + frameAdjustment.size.width, frame.size.height + frameAdjustment.size.height);
|
||||
|
||||
[self setFrame:finalFrame];
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSView : CPView
|
||||
|
||||
Reference in New Issue
Block a user