• R/O
  • HTTP
  • SSH
  • HTTPS

提交

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

BathyScapheのアイコンセット生成&適用ツール


Commit MetaInfo

修订版da22ab8d2582bcb8c7f2b5d7b8a607ba483c6533 (tree)
时间2012-05-30 22:32:58
作者masakih <masakih@user...>
Commitermasakih

Log Message

[Mod] カラーセットのUndoサポート

更改概述

差异

--- a/IconSetDocument.m
+++ b/IconSetDocument.m
@@ -138,6 +138,10 @@ static NSArray *sThreadIdentifiers;
138138 [nobinobi bind:@"middleImage" toObject:self withKeyPath:@"lastUpdatedHeaderMiddle.image" options:nil];
139139 [nobinobi bind:@"rightImage" toObject:self withKeyPath:@"lastUpdatedHeaderRight.image" options:nil];
140140
141+ [colorSet addObserver:self forKeyPath:@"threadsListColor" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:colorSet];
142+ [colorSet addObserver:self forKeyPath:@"includeColors" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:colorSet];
143+ [colorSet addObserver:self forKeyPath:@"useStripe" options:NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld context:colorSet];
144+
141145 if( !wrapper ) {
142146 wrapper = [[NSFileWrapper alloc] initDirectoryWithFileWrappers:nil];
143147 }
@@ -336,8 +340,6 @@ static NSArray *sThreadIdentifiers;
336340
337341 if( plist ) {
338342 [wrapper addFileWithPath:path];
339-
340- [self updateChangeCount:NSChangeDone];
341343 }
342344 }
343345
@@ -414,6 +416,27 @@ static NSArray *sThreadIdentifiers;
414416 }
415417 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
416418 {
419+ if(object == colorSet) {
420+ NSUndoManager *um = [self undoManager];
421+ if([keyPath isEqualToString:@"threadsListColor"]) {
422+ id old = [change objectForKey:NSKeyValueChangeOldKey];
423+ if([old isEqual:[NSNull null]]) old = nil;
424+ [[um prepareWithInvocationTarget:colorSet] setThreadsListColor:old];
425+ return;
426+ }
427+
428+ NSNumber *old = [change objectForKey:NSKeyValueChangeOldKey];
429+ NSNumber *new = [change objectForKey:NSKeyValueChangeNewKey];
430+ if([old isEqualToNumber:new]) return;
431+
432+ if([keyPath isEqualToString:@"includeColors"]) {
433+ [[um prepareWithInvocationTarget:colorSet] setIncludeColors:[old boolValue]];
434+ } else if([keyPath isEqualToString:@"useStripe"]) {
435+ [[um prepareWithInvocationTarget:colorSet] setUseStripe:[old boolValue]];
436+ }
437+
438+ return;
439+ }
417440 if(![keyPath isEqual:BSCIImageFileWrapperKey]) return;
418441
419442 NSFileWrapper *imageFileWrapper = [object valueForKey:keyPath];