diff --git a/AppKit/CPControl.j b/AppKit/CPControl.j index c8fcb0680..4efbb4ffc 100644 --- a/AppKit/CPControl.j +++ b/AppKit/CPControl.j @@ -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) }; } diff --git a/AppKit/CPView.j b/AppKit/CPView.j index 277e01e2b..e0e637e17 100644 --- a/AppKit/CPView.j +++ b/AppKit/CPView.j @@ -332,7 +332,8 @@ var CPViewHighDPIDrawingEnabled = YES; + (CPDictionary)themeAttributes { return @{ - @"css-based": NO + @"css-based": NO, + @"nib2cib-adjustment-frame": CGRectMakeZero() }; } diff --git a/Tools/nib2cib/NSControl.j b/Tools/nib2cib/NSControl.j index 0123d2b00..f8ec577bb 100644 --- a/Tools/nib2cib/NSControl.j +++ b/Tools/nib2cib/NSControl.j @@ -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 diff --git a/Tools/nib2cib/NSView.j b/Tools/nib2cib/NSView.j index ba2ef46d8..7b32ace13 100644 --- a/Tools/nib2cib/NSView.j +++ b/Tools/nib2cib/NSView.j @@ -25,6 +25,7 @@ @import +@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