clean up the behavior with the group color picker

This commit is contained in:
Mitchell Livingston 2008-03-23 04:36:30 +00:00
parent 86a701be34
commit 5681c18c02
8 changed files with 41 additions and 35 deletions

View File

@ -2123,6 +2123,7 @@
GCC_WARN_SHADOW = NO;
GCC_WARN_SIGN_COMPARE = NO;
GCC_WARN_UNUSED_FUNCTION = NO;
GCC_WARN_UNUSED_LABEL = NO;
GCC_WARN_UNUSED_PARAMETER = NO;
GCC_WARN_UNUSED_VALUE = NO;
GCC_WARN_UNUSED_VARIABLE = NO;

View File

@ -35,7 +35,9 @@
- (int) numberOfGroups;
- (int) orderValueForIndex: (int) index;
- (int) rowValueForIndex: (int) index;
- (int) indexForRow: (int) row;
- (CTGradient *) gradientForIndex: (int) index;
- (NSString *) nameForIndex: (int) index;
@ -45,8 +47,8 @@
- (NSImage *) imageForIndex: (int) index isSmall: (BOOL) small;
- (NSImage *) imageForRowIndex: (int) row isSmall: (BOOL) small;
- (NSColor *) colorForRowIndex: (int) row;
- (NSColor *) setColor: (NSColor *) color forRowIndex: (int) row;
- (NSColor *) colorForIndex: (int) index;
- (NSColor *) setColor: (NSColor *) color forIndex: (int) index;
- (void) addGroupWithName: (NSString *) name color: (NSColor *) color;
- (void) removeGroupWithRowIndexes: (NSIndexSet *) rowIndexes;

View File

@ -112,7 +112,7 @@ GroupsController * fGroupsInstance = nil;
return [fGroups count];
}
- (int) orderValueForIndex: (int) index
- (int) rowValueForIndex: (int) index
{
if (index != -1)
{
@ -124,16 +124,21 @@ GroupsController * fGroupsInstance = nil;
return -1;
}
- (int) indexForRow: (int) row
{
return [[[fGroups objectAtIndex: row] objectForKey: @"Index"] intValue];
}
- (CTGradient *) gradientForIndex: (int) index
{
int orderIndex = [self orderValueForIndex: index];
int orderIndex = [self rowValueForIndex: index];
return orderIndex != -1 ? [self gradientForColor: [[fGroups objectAtIndex: orderIndex] objectForKey: @"Color"]] : nil;
}
- (NSString *) nameForIndex: (int) index
{
int orderIndex = [self orderValueForIndex: index];
return orderIndex != -1 ? [self nameForRowIndex: [self orderValueForIndex: orderIndex]] : nil;
int orderIndex = [self rowValueForIndex: index];
return orderIndex != -1 ? [self nameForRowIndex: orderIndex] : nil;
}
- (NSString *) nameForRowIndex: (int) index
@ -151,7 +156,7 @@ GroupsController * fGroupsInstance = nil;
- (NSImage *) imageForIndex: (int) index isSmall: (BOOL) small
{
int orderIndex = [self orderValueForIndex: index];
int orderIndex = [self rowValueForIndex: index];
return orderIndex != -1 ? [self imageForRowIndex: orderIndex isSmall: small] : nil;
}
@ -160,14 +165,15 @@ GroupsController * fGroupsInstance = nil;
return [self imageForGroup: [fGroups objectAtIndex: row] isSmall: small];
}
- (NSColor *) colorForRowIndex: (int) row
- (NSColor *) colorForIndex: (int) index
{
return [[fGroups objectAtIndex: row] objectForKey: @"Color"];
int orderIndex = [self rowValueForIndex: index];
return orderIndex != -1 ? [[fGroups objectAtIndex: orderIndex] objectForKey: @"Color"] : nil;
}
- (NSColor *) setColor: (NSColor *) color forRowIndex: (int) row
- (NSColor *) setColor: (NSColor *) color forIndex: (int) index
{
[[fGroups objectAtIndex: row] setObject: color forKey: @"Color"];
[[fGroups objectAtIndex: [self rowValueForIndex: index]] setObject: color forKey: @"Color"];
[[GroupsController groups] saveGroups];
[[NSNotificationCenter defaultCenter] postNotificationName: @"UpdateGroups" object: self];
@ -212,7 +218,6 @@ GroupsController * fGroupsInstance = nil;
[[NSNotificationCenter defaultCenter] postNotificationName: @"GroupValueRemoved" object: self userInfo:
[NSDictionary dictionaryWithObject: indexes forKey: @"Indexes"]];
#warning move to controller?
if ([indexes containsIndex: [[NSUserDefaults standardUserDefaults] integerForKey: @"FilterGroup"]])
[[NSUserDefaults standardUserDefaults] setInteger: -2 forKey: @"FilterGroup"];

View File

@ -31,7 +31,7 @@
IBOutlet NSTableView * fTableView;
IBOutlet NSSegmentedControl * fAddRemoveControl;
int fCurrentColorRow;
int fCurrentColorIndex;
}
+ (GroupsWindowController *) groupsWindow;

View File

@ -69,7 +69,6 @@ GroupsWindowController * fGroupsWindowInstance = nil;
- (void) windowWillClose: (id) sender
{
#warning remove when streamlined
[[NSColorPanel sharedColorPanel] close];
[fGroupsWindowInstance release];
@ -98,11 +97,11 @@ GroupsWindowController * fGroupsWindowInstance = nil;
[[GroupsController groups] setName: object forRowIndex: row];
else if ([identifier isEqualToString: @"Button"])
{
fCurrentColorRow = row;
fCurrentColorIndex = [[GroupsController groups] indexForRow: row];
NSColorPanel * colorPanel = [NSColorPanel sharedColorPanel];
[colorPanel setContinuous: YES];
[colorPanel setColor: [[GroupsController groups] colorForRowIndex: row]];
[colorPanel setColor: [[GroupsController groups] colorForIndex: fCurrentColorIndex]];
[colorPanel setTarget: self];
[colorPanel setAction: @selector(changeColor:)];
@ -148,16 +147,16 @@ GroupsWindowController * fGroupsWindowInstance = nil;
oldSelected: [fTableView selectedRowIndexes]];
[fTableView selectRowIndexes: selectedIndexes byExtendingSelection: NO];
[fTableView reloadData];
}
return YES;
}
#warning make the color picker a nicer experience
- (void) addRemoveGroup: (id) sender
{
NSIndexSet * indexes;
switch ([[sender cell] tagForSegment: [sender selectedSegment]])
{
case ADD_TAG:
@ -171,18 +170,18 @@ GroupsWindowController * fGroupsWindowInstance = nil;
break;
case REMOVE_TAG:
//safety: when removing a row, just close the color picker
[[NSColorPanel sharedColorPanel] close];
//close color picker if corresponding row is removed
indexes = [fTableView selectedRowIndexes];
if ([[NSColorPanel sharedColorPanel] isVisible]
&& [indexes containsIndex: [[GroupsController groups] rowValueForIndex: fCurrentColorIndex]])
[[NSColorPanel sharedColorPanel] close];
[[GroupsController groups] removeGroupWithRowIndexes: [fTableView selectedRowIndexes]];
[[GroupsController groups] removeGroupWithRowIndexes: indexes];
[fTableView deselectAll: self];
[fTableView reloadData];
break;
default:
return;
}
}
@ -192,7 +191,7 @@ GroupsWindowController * fGroupsWindowInstance = nil;
- (void) changeColor: (id) sender
{
[[GroupsController groups] setColor: [sender color] forRowIndex: fCurrentColorRow];
[[GroupsController groups] setColor: [sender color] forIndex: fCurrentColorIndex];
[fTableView reloadData];
}

View File

@ -42,14 +42,14 @@ typedef enum
int fID;
BOOL fResumeOnWake;
NSDate * fDateAdded, * fDateCompleted, * fDateActivity;
BOOL fResumeOnWake;
NSDate * fDateAdded, * fDateCompleted, * fDateActivity;
BOOL fUseIncompleteFolder;
NSString * fDownloadFolder, * fIncompleteFolder;
BOOL fUseIncompleteFolder;
NSString * fDownloadFolder, * fIncompleteFolder;
BOOL fPublicTorrent;
NSString * fPublicTorrentLocation;
BOOL fPublicTorrent;
NSString * fPublicTorrentLocation;
NSUserDefaults * fDefaults;

View File

@ -1303,7 +1303,7 @@ void completenessChangeCallback(tr_torrent * torrent, cp_status_t status, void *
- (int) groupOrderValue
{
return [[GroupsController groups] orderValueForIndex: fGroupValue];
return [[GroupsController groups] rowValueForIndex: fGroupValue];
}
- (void) checkGroupValueForRemoval: (NSNotification *) notification

View File

@ -32,8 +32,7 @@
NSMutableDictionary * fTitleAttributes, * fStatusAttributes;
BOOL fTracking, fMouseDownControlButton, fMouseDownRevealButton, fMouseDownActionButton,
fHoverControl, fHoverReveal, fHoverAction,
fMouseDownProgressField, fMouseDownMinimalStatusField;
fHoverControl, fHoverReveal, fHoverAction, fMouseDownProgressField, fMouseDownMinimalStatusField;
NSColor * fBarOverlayColor;
CTGradient * fWhiteGradient, * fGrayGradient, * fLightGrayGradient, * fBlueGradient, * fDarkBlueGradient,