mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
New: Modern Cocoa behavior and methods, ticked sliders and Aristo3 CSS theme ready (#2926)
This commit is contained in:
@@ -22,15 +22,10 @@
|
||||
|
||||
@import "CPControl.j"
|
||||
@import "CPWindow_Constants.j"
|
||||
@import "CPSlider.j"
|
||||
|
||||
@global CPApp
|
||||
|
||||
@typedef CPTickMarkPosition
|
||||
CPTickMarkBelow = 0;
|
||||
CPTickMarkAbove = 1;
|
||||
CPTickMarkLeft = CPTickMarkAbove;
|
||||
CPTickMarkRight = CPTickMarkBelow;
|
||||
|
||||
@typedef CPLevelIndicatorStyle
|
||||
CPRelevancyLevelIndicatorStyle = 0;
|
||||
CPContinuousCapacityLevelIndicatorStyle = 1;
|
||||
|
||||
+802
-150
File diff suppressed because it is too large
Load Diff
+70
-11
@@ -24,6 +24,7 @@
|
||||
|
||||
@import "NSCell.j"
|
||||
|
||||
@class Nib2Cib
|
||||
|
||||
@implementation CPSlider (CPCoding)
|
||||
|
||||
@@ -44,6 +45,9 @@
|
||||
|
||||
_altIncrementValue = [cell altIncrementValue];
|
||||
[self setSliderType:[cell sliderType]];
|
||||
[self setAllowsTickMarkValuesOnly:[cell allowsTickMarkValuesOnly]];
|
||||
[self setTickMarkPosition:[cell tickMarkPosition]];
|
||||
[self setNumberOfTickMarks:[cell numberOfTickMarks]];
|
||||
[self setEnabled:[cell isEnabled]];
|
||||
}
|
||||
|
||||
@@ -63,12 +67,17 @@
|
||||
[self NS_initWithCell:cell];
|
||||
[self _adjustNib2CibSize];
|
||||
|
||||
var frame = [self frame];
|
||||
var directAdjustment = [[Nib2Cib defaultTheme] valueForAttributeWithName:@"direct-nib2cib-adjustment" forClass:[self class]];
|
||||
|
||||
if ([self sliderType] === CPCircularSlider)
|
||||
[self setFrameSize:CGSizeMake(frame.size.width + 2.0, frame.size.height + 2.0)];
|
||||
else
|
||||
[self setFrame:CGRectMake(frame.origin.x + 2, frame.origin.y, frame.size.width - 4, frame.size.height)];
|
||||
if (!directAdjustment)
|
||||
{
|
||||
var frame = [self frame];
|
||||
|
||||
if ([self sliderType] === CPCircularSlider)
|
||||
[self setFrameSize:CGSizeMake(frame.size.width + 2.0, frame.size.height + 2.0)];
|
||||
else
|
||||
[self setFrame:CGRectMake(frame.origin.x + 2, frame.origin.y, frame.size.width - 4, frame.size.height)];
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -79,15 +88,62 @@
|
||||
return [CPSlider class];
|
||||
}
|
||||
|
||||
- (CGRect)_nib2CibAdjustment
|
||||
{
|
||||
var directAdjustment = [[Nib2Cib defaultTheme] valueForAttributeWithName:@"direct-nib2cib-adjustment" forClass:[self class]];
|
||||
|
||||
if (!directAdjustment)
|
||||
return [super _nib2CibAdjustment];
|
||||
|
||||
var size = [self frameSize],
|
||||
state;
|
||||
|
||||
if ([self sliderType] === CPCircularSlider)
|
||||
state = CPThemeStateCircular;
|
||||
else if (size.height > size.width)
|
||||
{
|
||||
state = CPThemeStateVertical;
|
||||
state = state.and(([self tickMarkPosition] === CPTickMarkPositionTrailing) ? CPThemeStateBelowRightTickedSlider : CPThemeStateAboveLeftTickedSlider);
|
||||
}
|
||||
else
|
||||
{
|
||||
state = CPThemeStateNormal;
|
||||
state = state.and(([self tickMarkPosition] === CPTickMarkPositionBelow) ? CPThemeStateBelowRightTickedSlider : CPThemeStateAboveLeftTickedSlider);
|
||||
}
|
||||
|
||||
if ([self numberOfTickMarks] > 0)
|
||||
state = state.and(CPThemeStateTickedSlider);
|
||||
|
||||
// Theme has not been loaded yet.
|
||||
// Get attribute value directly from the theme or from the default value of the object otherwise.
|
||||
var frameAdjustment = [[Nib2Cib defaultTheme] valueForAttributeWithName:@"nib2cib-adjustment-frame" inState:state forClass:[self class]];
|
||||
|
||||
if (frameAdjustment)
|
||||
return frameAdjustment;
|
||||
|
||||
if ([self hasThemeAttribute:@"nib2cib-adjustment-frame"])
|
||||
{
|
||||
frameAdjustment = [self valueForThemeAttribute:@"nib2cib-adjustment-frame" inState:state];
|
||||
|
||||
if (frameAdjustment)
|
||||
return frameAdjustment;
|
||||
}
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSSliderCell : NSCell
|
||||
{
|
||||
double _minValue @accessors(readonly, getter=minValue);
|
||||
double _maxValue @accessors(readonly, getter=maxValue);
|
||||
double _altIncrementValue @accessors(readonly, getter=altIncrementValue);
|
||||
BOOL _vertical @accessors(readonly, getter=isVertical);
|
||||
int _sliderType @accessors(readonly, getter=sliderType);
|
||||
double _minValue @accessors(readonly, getter=minValue);
|
||||
double _maxValue @accessors(readonly, getter=maxValue);
|
||||
double _altIncrementValue @accessors(readonly, getter=altIncrementValue);
|
||||
BOOL _vertical @accessors(readonly, getter=isVertical);
|
||||
int _sliderType @accessors(readonly, getter=sliderType);
|
||||
BOOL _allowsTickMarkValuesOnly @accessors(readonly, getter=allowsTickMarkValuesOnly);
|
||||
int _tickMarkPosition @accessors(readonly, getter=tickMarkPosition);
|
||||
int _numberOfTickMarks @accessors(readonly, getter=numberOfTickMarks);
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
@@ -103,7 +159,10 @@
|
||||
self._altIncrementValue = [aCoder decodeDoubleForKey:@"NSAltIncValue"];
|
||||
self._isVertical = [aCoder decodeBoolForKey:@"NSVertical"];
|
||||
|
||||
self._sliderType = [aCoder decodeIntForKey:@"NSSliderType"];
|
||||
self._sliderType = [aCoder decodeIntForKey:@"NSSliderType"];
|
||||
self._allowsTickMarkValuesOnly = [aCoder decodeIntForKey:@"NSAllowsTickMarkValuesOnly"];
|
||||
self._tickMarkPosition = [aCoder decodeIntForKey:@"NSTickMarkPosition"];
|
||||
self._numberOfTickMarks = [aCoder decodeIntForKey:@"NSNumberOfTickMarks"];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
Reference in New Issue
Block a user