Skip to content

Commit

Permalink
Removed drawers in CueSheetDocument and replaced with inspector panel
Browse files Browse the repository at this point in the history
  • Loading branch information
sbooth committed Feb 27, 2020
1 parent 296d0ee commit 2183744
Show file tree
Hide file tree
Showing 10 changed files with 1,693 additions and 1,718 deletions.
9 changes: 2 additions & 7 deletions CueSheet/CueSheetDocument.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
@interface CueSheetDocument : NSDocument
{
IBOutlet NSArrayController *_trackController;
IBOutlet NSDrawer *_trackDrawer;
IBOutlet NSDrawer *_artDrawer;
IBOutlet NSPanel *_metadataPanel;
IBOutlet NSTableView *_trackTable;
IBOutlet NSTextField *_discNumberTextField;
IBOutlet NSTextField *_discTotalTextField;
Expand Down Expand Up @@ -67,8 +66,7 @@
- (IBAction) queryMusicBrainz:(id)sender;
- (void) queryMusicBrainzNonInteractive;

- (IBAction) toggleTrackInformation:(id)sender;
- (IBAction) toggleAlbumArt:(id)sender;
- (IBAction) toggleMetadataInspectorPanel:(id)sender;

- (IBAction) selectNextTrack:(id)sender;
- (IBAction) selectPreviousTrack:(id)sender;
Expand Down Expand Up @@ -101,9 +99,6 @@
- (NSImage *) albumArt;
- (void) setAlbumArt:(NSImage *)albumArt;

- (NSUInteger) albumArtWidth;
- (NSUInteger) albumArtHeight;

- (NSNumber *) discNumber;
- (void) setDiscNumber:(NSNumber *)discNumber;

Expand Down
37 changes: 19 additions & 18 deletions CueSheet/CueSheetDocument.m
Original file line number Diff line number Diff line change
Expand Up @@ -102,20 +102,12 @@ - (BOOL) validateMenuItem:(NSMenuItem *)item
return [_trackController canSelectNext];
else if([item action] == @selector(selectPreviousTrack:))
return [_trackController canSelectPrevious];
else if([item action] == @selector(toggleTrackInformation:)) {
if(NSDrawerOpenState == [_trackDrawer state] || NSDrawerOpeningState == [_trackDrawer state])
[item setTitle:NSLocalizedStringFromTable(@"Hide Metadata", @"Menus", @"")];
else if([item action] == @selector(toggleMetadataInspectorPanel:)) {
if([_metadataPanel isVisible])
[item setTitle:NSLocalizedStringFromTable(@"Hide Track Inspector", @"Menus", @"")];
else
[item setTitle:NSLocalizedStringFromTable(@"Show Metadata", @"Menus", @"")];

return YES;
}
else if([item action] == @selector(toggleAlbumArt:)) {
if(NSDrawerOpenState == [_artDrawer state] || NSDrawerOpeningState == [_artDrawer state])
[item setTitle:NSLocalizedStringFromTable(@"Hide Album Art", @"Menus", @"")];
else
[item setTitle:NSLocalizedStringFromTable(@"Show Album Art", @"Menus", @"")];

[item setTitle:NSLocalizedStringFromTable(@"Show Track Inspector", @"Menus", @"")];

return YES;
}
else
Expand Down Expand Up @@ -599,8 +591,11 @@ - (IBAction) queryMusicBrainz:(id)sender
PerformMusicBrainzQuery([self discID], ^(NSArray *results) {
// NSAssert(0 != matchCount, NSLocalizedStringFromTable(@"No matching discs were found.", @"Exceptions", @""));

if(0 == [results count]) {
return;
}
// If only match was found, update ourselves
if(1 == [results count]) {
else if(1 == [results count]) {
NSDictionary *release = [results firstObject];
[self updateMetadataFromMusicBrainz:release];
NSString *releaseID = [release objectForKey:@"albumId"];
Expand Down Expand Up @@ -643,8 +638,16 @@ - (void) queryMusicBrainzNonInteractive
});
}

- (IBAction) toggleTrackInformation:(id)sender { [_trackDrawer toggle:sender]; }
- (IBAction) toggleAlbumArt:(id)sender { [_artDrawer toggle:sender]; }
- (IBAction) toggleMetadataInspectorPanel:(id)sender
{
if(![_metadataPanel isVisible]) {
[_metadataPanel orderFront:sender];
}
else {
[_metadataPanel orderOut:sender];
}
}

- (IBAction) selectNextTrack:(id)sender { [_trackController selectNext:sender]; }
- (IBAction) selectPreviousTrack:(id)sender { [_trackController selectPrevious:sender]; }

Expand Down Expand Up @@ -698,8 +701,6 @@ - (NSString *) composer { return [[_composer retain] autorelease]; }
- (NSString *) comment { return [[_comment retain] autorelease]; }

- (NSImage *) albumArt { return [[_albumArt retain] autorelease]; }
- (NSUInteger) albumArtWidth { return (NSUInteger)[[self albumArt] size].width; }
- (NSUInteger) albumArtHeight { return (NSUInteger)[[self albumArt] size].height; }

- (NSNumber *) discNumber { return [[_discNumber retain] autorelease]; }
- (NSNumber *) discTotal { return [[_discTotal retain] autorelease]; }
Expand Down
28 changes: 8 additions & 20 deletions CueSheet/CueSheetDocumentToolbar.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
#import "CueSheetDocumentToolbar.h"

static NSString *EncodeToolbarItemIdentifier = @"org.sbooth.Max.CueSheetDocument.Toolbar.Encode";
static NSString *TrackInfoToolbarItemIdentifier = @"org.sbooth.Max.CueSheetDocument.Toolbar.TrackInfo";
static NSString *AlbumArtToolbarItemIdentifier = @"org.sbooth.Max.CueSheetDocument.Toolbar.AlbumArt";
static NSString *MetadataToolbarItemIdentifier = @"org.sbooth.Max.CueSheetDocument.Toolbar.Metadata";
static NSString *SelectNextTrackToolbarItemIdentifier = @"org.sbooth.Max.CueSheetDocument.Toolbar.SelectNextTrack";
static NSString *SelectPreviousTrackToolbarItemIdentifier = @"org.sbooth.Max.CueSheetDocument.Toolbar.SelectPreviousTrack";
static NSString *QueryMusicBrainzToolbarItemIdentifier = @"org.sbooth.Max.CueSheetDocument.Toolbar.QueryMusicBrainz";
Expand Down Expand Up @@ -75,35 +74,24 @@ - (NSToolbarItem *) toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString
[toolbarItem setTarget:_document];
[toolbarItem setAction:@selector(encode:)];
}
else if([itemIdentifier isEqualToString:TrackInfoToolbarItemIdentifier]) {
else if([itemIdentifier isEqualToString:MetadataToolbarItemIdentifier]) {
toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier] autorelease];

[toolbarItem setLabel:NSLocalizedStringFromTable(@"Metadata", @"CueSheet", @"")];
[toolbarItem setPaletteLabel:NSLocalizedStringFromTable(@"Metadata", @"CueSheet", @"")];
[toolbarItem setToolTip:NSLocalizedStringFromTable(@"Show or hide detailed track metadata", @"CueSheet", @"")];
[toolbarItem setImage:[NSImage imageNamed:@"TrackInfoToolbarImage"]];
[toolbarItem setImage:[NSImage imageNamed:@"NSInfo"]];

[toolbarItem setTarget:_document];
[toolbarItem setAction:@selector(toggleTrackInformation:)];
}
else if([itemIdentifier isEqualToString:AlbumArtToolbarItemIdentifier]) {
toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier] autorelease];

[toolbarItem setLabel:NSLocalizedStringFromTable(@"Album Art", @"CompactDisc", @"")];
[toolbarItem setPaletteLabel:NSLocalizedStringFromTable(@"Album Art", @"CompactDisc", @"")];
[toolbarItem setToolTip:NSLocalizedStringFromTable(@"Show or hide the artwork associated with this album", @"CompactDisc", @"")];
[toolbarItem setImage:[NSImage imageNamed:@"AlbumArtToolbarImage"]];

[toolbarItem setTarget:_document];
[toolbarItem setAction:@selector(toggleAlbumArt:)];
[toolbarItem setAction:@selector(toggleMetadataInspectorPanel:)];
}
else if([itemIdentifier isEqualToString:SelectNextTrackToolbarItemIdentifier]) {
toolbarItem = [[[NSToolbarItem alloc] initWithItemIdentifier:itemIdentifier] autorelease];

[toolbarItem setLabel:NSLocalizedStringFromTable(@"Next", @"CompactDisc", @"")];
[toolbarItem setPaletteLabel:NSLocalizedStringFromTable(@"Next", @"CompactDisc", @"")];
[toolbarItem setToolTip:NSLocalizedStringFromTable(@"Select the next track for editing", @"CompactDisc", @"")];
[toolbarItem setImage:[NSImage imageNamed:@"SelectNextTrackToolbarImage"]];
[toolbarItem setImage:[NSImage imageNamed:@"NSGoRightTemplate"]];

[toolbarItem setTarget:_document];
[toolbarItem setAction:@selector(selectNextTrack:)];
Expand All @@ -114,7 +102,7 @@ - (NSToolbarItem *) toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString
[toolbarItem setLabel:NSLocalizedStringFromTable(@"Previous", @"CompactDisc", @"")];
[toolbarItem setPaletteLabel:NSLocalizedStringFromTable(@"Previous", @"CompactDisc", @"")];
[toolbarItem setToolTip:NSLocalizedStringFromTable(@"Select the previous track for editing", @"CompactDisc", @"")];
[toolbarItem setImage:[NSImage imageNamed:@"SelectPreviousTrackToolbarImage"]];
[toolbarItem setImage:[NSImage imageNamed:@"NSGoLeftTemplate"]];

[toolbarItem setTarget:_document];
[toolbarItem setAction:@selector(selectPreviousTrack:)];
Expand All @@ -139,15 +127,15 @@ - (NSToolbarItem *) toolbar:(NSToolbar *)toolbar itemForItemIdentifier:(NSString
- (NSArray *) toolbarDefaultItemIdentifiers:(NSToolbar *)toolbar
{
return [NSArray arrayWithObjects:EncodeToolbarItemIdentifier,
TrackInfoToolbarItemIdentifier, AlbumArtToolbarItemIdentifier,
MetadataToolbarItemIdentifier,
QueryMusicBrainzToolbarItemIdentifier,
nil];
}

- (NSArray *) toolbarAllowedItemIdentifiers:(NSToolbar *) toolbar
{
return [NSArray arrayWithObjects:EncodeToolbarItemIdentifier,
TrackInfoToolbarItemIdentifier, AlbumArtToolbarItemIdentifier,
MetadataToolbarItemIdentifier,
SelectPreviousTrackToolbarItemIdentifier, SelectNextTrackToolbarItemIdentifier,
QueryMusicBrainzToolbarItemIdentifier,
NSToolbarSeparatorItemIdentifier, NSToolbarSpaceItemIdentifier, NSToolbarFlexibleSpaceItemIdentifier,
Expand Down
Loading

0 comments on commit 2183744

Please sign in to comment.