2006-10-28 09:18:55 +00:00
|
|
|
|
//
|
2007-04-27 06:41:34 +00:00
|
|
|
|
// File: VLSheetWindow.mm - Control lead sheet editing window
|
2006-10-28 09:18:55 +00:00
|
|
|
|
//
|
2007-04-27 06:41:34 +00:00
|
|
|
|
// Author(s):
|
|
|
|
|
//
|
|
|
|
|
// (MN) Matthias Neeracher
|
|
|
|
|
//
|
2011-08-29 00:01:49 +00:00
|
|
|
|
// Copyright <20> 2005-2011 Matthias Neeracher
|
2006-10-28 09:18:55 +00:00
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
#import "VLSheetWindow.h"
|
|
|
|
|
#import "VLDocument.h"
|
2011-09-04 01:00:38 +00:00
|
|
|
|
#import "VLPDFWindow.h"
|
|
|
|
|
#import "VLLogWindow.h"
|
2011-09-04 19:48:57 +00:00
|
|
|
|
#import "VLSoundOut.h"
|
2006-10-28 09:18:55 +00:00
|
|
|
|
|
|
|
|
|
@implementation VLEditable
|
|
|
|
|
|
|
|
|
|
- (NSString *) stringValue
|
|
|
|
|
{
|
|
|
|
|
return @"";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) setStringValue:(NSString*)val
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (BOOL) validValue:(NSString*)val
|
|
|
|
|
{
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) moveToNext
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) moveToPrev
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) highlightCursor
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
|
@implementation VLSheetWindow
|
|
|
|
|
|
2011-09-04 01:00:38 +00:00
|
|
|
|
@synthesize logWin;
|
|
|
|
|
|
2006-10-28 09:18:55 +00:00
|
|
|
|
- (id)initWithWindow:(NSWindow *)window
|
|
|
|
|
{
|
|
|
|
|
if (self = [super initWithWindow:window]) {
|
|
|
|
|
editTarget = nil;
|
2011-09-04 19:48:57 +00:00
|
|
|
|
NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
NSOperationQueue * oq = [NSOperationQueue mainQueue];
|
|
|
|
|
soundStartObserver = [nc addObserverForName:(NSString*)kVLSoundStartedNotification
|
|
|
|
|
object:nil queue:oq usingBlock:^(NSNotification *note) {
|
2011-09-04 21:03:55 +00:00
|
|
|
|
[[[self window] toolbar] validateVisibleItems];
|
2011-09-04 19:48:57 +00:00
|
|
|
|
}];
|
|
|
|
|
soundStopObserver = [nc addObserverForName:(NSString*)kVLSoundStoppedNotification
|
|
|
|
|
object:nil queue:oq usingBlock:^(NSNotification *note) {
|
2011-09-04 21:03:55 +00:00
|
|
|
|
[[[self window] toolbar] validateVisibleItems];
|
2011-09-04 19:48:57 +00:00
|
|
|
|
}];
|
2006-10-28 09:18:55 +00:00
|
|
|
|
}
|
|
|
|
|
return self;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-04 19:48:57 +00:00
|
|
|
|
- (void) dealloc
|
|
|
|
|
{
|
|
|
|
|
NSNotificationCenter * nc = [NSNotificationCenter defaultCenter];
|
|
|
|
|
[nc removeObserver:soundStartObserver];
|
|
|
|
|
[nc removeObserver:soundStopObserver];
|
|
|
|
|
}
|
|
|
|
|
|
2006-10-28 09:18:55 +00:00
|
|
|
|
- (VLEditable *)editTarget
|
|
|
|
|
{
|
|
|
|
|
return editTarget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void)setEditTarget:(VLEditable *)editable
|
|
|
|
|
{
|
|
|
|
|
editTarget = editable;
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-18 07:05:04 +00:00
|
|
|
|
- (void) startAnimation
|
|
|
|
|
{
|
2011-08-29 00:01:49 +00:00
|
|
|
|
[progressIndicator startAnimation:self];
|
2007-04-18 07:05:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) stopAnimation
|
|
|
|
|
{
|
2011-08-29 00:01:49 +00:00
|
|
|
|
[progressIndicator stopAnimation:self];
|
2007-04-18 07:05:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-01-29 03:02:25 +00:00
|
|
|
|
- (IBAction) zoomIn: (id) sender
|
|
|
|
|
{
|
|
|
|
|
[sheetView zoomIn:sender];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (IBAction) zoomOut: (id) sender
|
|
|
|
|
{
|
|
|
|
|
[sheetView zoomOut:sender];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) mouseMoved:(NSEvent *)event
|
|
|
|
|
{
|
|
|
|
|
[sheetView mouseMoved:event];
|
|
|
|
|
}
|
|
|
|
|
|
2008-05-29 18:54:30 +00:00
|
|
|
|
- (void) willPlaySequence:(MusicSequence)music
|
|
|
|
|
{
|
|
|
|
|
[sheetView willPlaySequence:music];
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-04 00:00:26 +00:00
|
|
|
|
- (IBAction) togglePlayElements:(id)sender
|
|
|
|
|
{
|
|
|
|
|
[[self document] setPlayElements:[[self document] playElements] ^ [sender tag]];
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-04 19:48:57 +00:00
|
|
|
|
- (BOOL) validateUserInterfaceItem:(id <NSValidatedUserInterfaceItem>)item
|
2011-09-04 00:00:26 +00:00
|
|
|
|
{
|
2011-09-04 19:48:57 +00:00
|
|
|
|
if ([item action] == @selector(togglePlayElements:)) {
|
|
|
|
|
NSMenuItem * menuItem = (NSMenuItem *)item;
|
|
|
|
|
if (int tag = [item tag])
|
2011-09-04 00:00:26 +00:00
|
|
|
|
[menuItem setState:([[self document] playElements] & tag) != 0];
|
2011-09-04 19:48:57 +00:00
|
|
|
|
} else if ([item action] == @selector(playStop:)) {
|
|
|
|
|
NSMenuItem * menuItem = [(NSObject *)item isKindOfClass:[NSMenuItem class]] ? (NSMenuItem *)item : nil;
|
|
|
|
|
NSToolbarItem * toolItem = menuItem ? nil : (NSToolbarItem *)item;
|
|
|
|
|
if (VLSoundOut::Instance()->Playing()) {
|
|
|
|
|
[menuItem setTitle:@"Stop"];
|
|
|
|
|
[toolItem setLabel:@"Stop"];
|
|
|
|
|
[toolItem setImage:[NSImage imageNamed:@"stop.icns"]];
|
|
|
|
|
} else {
|
|
|
|
|
[menuItem setTitle:@"Play"];
|
|
|
|
|
[toolItem setLabel:@"Play"];
|
|
|
|
|
[toolItem setImage:[NSImage imageNamed:@"play.icns"]];
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-09-04 00:00:26 +00:00
|
|
|
|
|
|
|
|
|
return YES;
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-04 01:00:38 +00:00
|
|
|
|
- (IBAction) showLog:(id)sender
|
|
|
|
|
{
|
|
|
|
|
[logWin showWindow:sender];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (void) showLogAndBeep
|
|
|
|
|
{
|
|
|
|
|
[logWin showWindow:self];
|
|
|
|
|
NSBeep();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (IBAction) showOutput:(id)sender
|
|
|
|
|
{
|
|
|
|
|
[[self document] createTmpFileWithExtension:@"pdf" ofType:VLPDFType];
|
|
|
|
|
[pdfWin showWindow:self];
|
|
|
|
|
[pdfWin reloadPDF];
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-04 19:48:57 +00:00
|
|
|
|
- (IBAction) stop:(id)sender
|
|
|
|
|
{
|
|
|
|
|
VLSoundOut::Instance()->Stop();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (IBAction) playStop:(id)sender
|
|
|
|
|
{
|
|
|
|
|
if (VLSoundOut::Instance()->Playing())
|
|
|
|
|
[self stop:sender];
|
|
|
|
|
else
|
|
|
|
|
[[self document] playSong];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (IBAction) playMusic:(id)sender
|
|
|
|
|
{
|
|
|
|
|
switch ([sender tag]) {
|
|
|
|
|
case 1: // Fwd
|
|
|
|
|
VLSoundOut::Instance()->Fwd();
|
|
|
|
|
break;
|
|
|
|
|
case -1: // Rew
|
|
|
|
|
VLSoundOut::Instance()->Bck();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
- (IBAction) adjustTempo:(id)sender
|
|
|
|
|
{
|
|
|
|
|
[[self document] setSongTempo:[[self document] songTempo]+[sender tag]];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2006-10-28 09:18:55 +00:00
|
|
|
|
@end
|