mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-03 17:33:41 +00:00
Merge branch 'master' of github.com:280north/cappuccino
This commit is contained in:
@@ -94,7 +94,9 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
if (_segments.length == aCount)
|
||||
return;
|
||||
|
||||
var height = CGRectGetHeight([self bounds]);
|
||||
var height = CGRectGetHeight([self bounds]),
|
||||
dividersBefore = MAX(0, _segments.length - 1),
|
||||
dividersAfter = MAX(0, aCount - 1);
|
||||
|
||||
if (_segments.length < aCount)
|
||||
{
|
||||
@@ -113,6 +115,14 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
if (_selectedSegment >= _segments.length)
|
||||
_selectedSegment = -1;
|
||||
|
||||
// Make space for/remove space used by dividers.
|
||||
var thickness = [self currentValueForThemeAttribute:@"divider-thickness"],
|
||||
delta = thickness * (dividersAfter - dividersBefore),
|
||||
frame = [self frame];
|
||||
|
||||
if (delta)
|
||||
[self setFrameSize:CGSizeMake(frame.size.width + delta, frame.size.height)];
|
||||
|
||||
[self tileWithChangedSegment:0];
|
||||
}
|
||||
|
||||
@@ -607,7 +617,7 @@ CPSegmentSwitchTrackingMomentary = 2;
|
||||
segmentWidth = [segment width],
|
||||
themeState = _themeStates[aSegment] | (_themeState & CPThemeStateDisabled),
|
||||
contentInset = [self valueForThemeAttribute:@"content-inset" inState:themeState],
|
||||
font = [self valueForThemeAttribute:@"font" inState:themeState];
|
||||
font = [self font];
|
||||
|
||||
if (!segmentWidth)
|
||||
{
|
||||
|
||||
@@ -145,8 +145,8 @@ if (input == nil)
|
||||
if (!anObject || !anObject.isa)
|
||||
return NO;
|
||||
|
||||
return [anObject isKindOfClass:CPException] &&
|
||||
name === [anObject name] &&
|
||||
return [anObject isKindOfClass:CPException] &&
|
||||
name === [anObject name] &&
|
||||
message === [anObject message] &&
|
||||
(_userInfo === [anObject userInfo] || ([_userInfo isEqual:[anObject userInfo]]));
|
||||
}
|
||||
|
||||
@@ -252,11 +252,14 @@ var _ivarForKey = function(theObject, aKey)
|
||||
|
||||
- (void)setValuesForKeysWithDictionary:(CPDictionary)keyedValues
|
||||
{
|
||||
var value, key, keyEnumerator = [keyedValues keyEnumerator];
|
||||
while(key = [keyEnumerator nextObject])
|
||||
var value,
|
||||
key,
|
||||
keyEnumerator = [keyedValues keyEnumerator];
|
||||
|
||||
while (key = [keyEnumerator nextObject])
|
||||
{
|
||||
value = [keyedValues objectForKey: key];
|
||||
if(value === [CPNull null])
|
||||
if (value === [CPNull null])
|
||||
[self setValue: nil forKey: key];
|
||||
else
|
||||
[self setValue: value forKey: key];
|
||||
@@ -284,7 +287,7 @@ var _ivarForKey = function(theObject, aKey)
|
||||
|
||||
- (void)setValue:(id)aValue forKey:(CPString)aKey
|
||||
{
|
||||
if(aValue)
|
||||
if (aValue)
|
||||
[self setObject:aValue forKey:aKey];
|
||||
else
|
||||
[self removeObjectForKey: aKey];
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
newValue = [aChange objectForKey:CPKeyValueChangeNewKey],
|
||||
indexes = [aChange objectForKey:CPKeyValueChangeIndexesKey];
|
||||
|
||||
if(newValue === [CPNull null])
|
||||
if (newValue === [CPNull null])
|
||||
newValue = nil;
|
||||
|
||||
if (changeKind === CPKeyValueChangeSetting)
|
||||
@@ -102,7 +102,7 @@
|
||||
}
|
||||
|
||||
//decide if this is a unordered or ordered to-many relationship
|
||||
if([newValue isKindOfClass: [CPSet class]] || [oldValue isKindOfClass: [CPSet class]])
|
||||
if ([newValue isKindOfClass: [CPSet class]] || [oldValue isKindOfClass: [CPSet class]])
|
||||
{
|
||||
if (changeKind === CPKeyValueChangeInsertion)
|
||||
[[self mutableSetValueForKeyPath:aKeyPath] unionSet:newValue];
|
||||
@@ -205,7 +205,7 @@ _CPKeyValueChangeSetMutationNewValueKey = @"_CPKeyValueChangeSetMutationNewValue
|
||||
|
||||
var _changeKindForSetMutationKind = function(mutationKind)
|
||||
{
|
||||
switch(mutationKind)
|
||||
switch (mutationKind)
|
||||
{
|
||||
case CPKeyValueUnionSetMutation:
|
||||
return CPKeyValueChangeInsertion;
|
||||
@@ -247,7 +247,7 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld,
|
||||
|
||||
- (id)initWithTarget:(id)aTarget
|
||||
{
|
||||
if(self = [super init])
|
||||
if (self = [super init])
|
||||
{
|
||||
_targetObject = aTarget;
|
||||
_nativeClass = [aTarget class];
|
||||
@@ -460,14 +460,15 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld,
|
||||
{
|
||||
changes = changeOptions;
|
||||
|
||||
var indexes = [changes objectForKey:CPKeyValueChangeIndexesKey];
|
||||
var setMutationKind = changes[_CPKeyValueChangeSetMutationKindKey];
|
||||
var indexes = [changes objectForKey:CPKeyValueChangeIndexesKey],
|
||||
setMutationKind = changes[_CPKeyValueChangeSetMutationKindKey];
|
||||
|
||||
if(setMutationKind)
|
||||
if (setMutationKind)
|
||||
{
|
||||
var setMutationObjects = [changes[_CPKeyValueChangeSetMutationObjectsKey] copy];
|
||||
var setExistingObjects = [[_targetObject valueForKey: aKey] copy];
|
||||
if(setMutationKind == CPKeyValueMinusSetMutation)
|
||||
var setMutationObjects = [changes[_CPKeyValueChangeSetMutationObjectsKey] copy],
|
||||
setExistingObjects = [[_targetObject valueForKey: aKey] copy];
|
||||
|
||||
if (setMutationKind == CPKeyValueMinusSetMutation)
|
||||
{
|
||||
[setExistingObjects intersectSet: setMutationObjects];
|
||||
[changes setValue:setExistingObjects forKey:CPKeyValueChangeOldKey];
|
||||
@@ -477,13 +478,13 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld,
|
||||
[setExistingObjects minusSet: setMutationObjects];
|
||||
[changes setValue:setExistingObjects forKey:CPKeyValueChangeOldKey];
|
||||
}
|
||||
|
||||
|
||||
//for unordered to-many relationships (CPSet) even new values can only be calculated before!!!
|
||||
if (setMutationKind === CPKeyValueUnionSetMutation || setMutationKind === CPKeyValueSetSetMutation)
|
||||
{
|
||||
[setMutationObjects minusSet: setExistingObjects];
|
||||
//hide new value (for CPKeyValueObservingOptionPrior messages)
|
||||
//as long as "didChangeValue..." is not yet called!
|
||||
//as long as "didChangeValue..." is not yet called!
|
||||
changes[_CPKeyValueChangeSetMutationNewValueKey] = setMutationObjects;
|
||||
}
|
||||
}
|
||||
@@ -519,10 +520,10 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld,
|
||||
|
||||
[changes removeObjectForKey:CPKeyValueChangeNotificationIsPriorKey];
|
||||
|
||||
var indexes = [changes objectForKey:CPKeyValueChangeIndexesKey];
|
||||
var setMutationKind = changes[_CPKeyValueChangeSetMutationKindKey];
|
||||
var indexes = [changes objectForKey:CPKeyValueChangeIndexesKey],
|
||||
setMutationKind = changes[_CPKeyValueChangeSetMutationKindKey];
|
||||
|
||||
if(setMutationKind)
|
||||
if (setMutationKind)
|
||||
{
|
||||
//old and new values for unordered to-many relationships can only be calculated before
|
||||
//set precalculated hidden new value as soon as "didChangeValue..." is called!
|
||||
@@ -668,8 +669,9 @@ var kvoNewAndOld = CPKeyValueObservingOptionNew | CPKeyValueObservingOptionOld,
|
||||
|
||||
if (!aKey)
|
||||
return;
|
||||
var changeKind = _changeKindForSetMutationKind(mutationKind);
|
||||
var changeOptions = [CPDictionary dictionaryWithObject:changeKind forKey:CPKeyValueChangeKindKey];
|
||||
|
||||
var changeKind = _changeKindForSetMutationKind(mutationKind),
|
||||
changeOptions = [CPDictionary dictionaryWithObject:changeKind forKey:CPKeyValueChangeKindKey];
|
||||
//set hidden change-dict ivars to support unordered to-many relationships
|
||||
changeOptions[_CPKeyValueChangeSetMutationObjectsKey] = objects;
|
||||
changeOptions[_CPKeyValueChangeSetMutationKindKey] = mutationKind;
|
||||
|
||||
@@ -39,7 +39,7 @@ var _CPKeyedUnarchiverCannotDecodeObjectOfClassNameOriginalClassesSelector
|
||||
_CPKeyedUnarchiverDidFinishSelector = 1 << 4,
|
||||
CPKeyedUnarchiverDelegate_unarchiver_cannotDecodeObjectOfClassName_originalClasses_ = 1 << 5;
|
||||
|
||||
var _CPKeyedArchiverNullString = "$null"
|
||||
var _CPKeyedArchiverNullString = "$null",
|
||||
|
||||
_CPKeyedArchiverUIDKey = "CP$UID",
|
||||
|
||||
|
||||
@@ -21,19 +21,26 @@
|
||||
[tabView setTabViewType:CPNoTabsBezelBorder];
|
||||
[tabView setTabViewType:CPTopTabsBezelBorder];
|
||||
|
||||
var view = [[CPView alloc] initWithFrame:CGRectMake(20, 20, 200, 200)];
|
||||
[view addSubview:[CPTextField labelWithTitle:@"First"]];
|
||||
var item = [[CPTabViewItem alloc] initWithIdentifier:@"a"];
|
||||
[item setView:view];
|
||||
[item setLabel:"Test"];
|
||||
[tabView addTabViewItem:item];
|
||||
var tabs = [
|
||||
"First Tab", "a label",
|
||||
"Second Tab", "another label",
|
||||
"Third Tab", "a third label",
|
||||
"Fourth Tab", "label 4",
|
||||
/*"5th Tab", "label 5",
|
||||
"6th Tab", "label 6",
|
||||
"7th Tab", "label 7",*/
|
||||
];
|
||||
|
||||
view = [[CPView alloc] initWithFrame:CGRectMake(20, 20, 200, 200)];
|
||||
[view addSubview:[CPTextField labelWithTitle:@"Second"]];
|
||||
item = [[CPTabViewItem alloc] initWithIdentifier:@"a"];
|
||||
[item setView:view];
|
||||
[item setLabel:"Test2"];
|
||||
[tabView addTabViewItem:item];
|
||||
for (var i = 0; i < tabs.length; i += 2)
|
||||
{
|
||||
var view = [[CPView alloc] initWithFrame:CGRectMake(20, 20, 200, 200)];
|
||||
[view addSubview:[CPTextField labelWithTitle:tabs[i + 1]]];
|
||||
|
||||
var item = [[CPTabViewItem alloc] initWithIdentifier:tabs[i]];
|
||||
[item setView:view];
|
||||
[item setLabel:tabs[i]];
|
||||
[tabView addTabViewItem:item];
|
||||
}
|
||||
|
||||
[contentView addSubview:tabView];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user