mirror of
https://github.com/microtherion/VocalEasel.git
synced 2024-12-22 19:23:59 +00:00
Edit per-section groove
This commit is contained in:
parent
cda0deee12
commit
cb78a2ba75
|
@ -55,10 +55,12 @@ enum {
|
|||
- (int) repeatVolta;
|
||||
- (bool) brandNew;
|
||||
|
||||
- (void) setKey:(int)key transpose:(BOOL)transpose inSections:(NSRange)sections;
|
||||
- (void) setTimeNum:(int)num denom:(int)denom inSections:(NSRange)sections;
|
||||
- (void) setDivisions:(int)divisions inSections:(NSRange)sections;
|
||||
- (void) setRepeatVolta:(int)repeatVolta;
|
||||
- (void) setKey:(int)key transpose:(BOOL)transpose inSections:(NSRange)sections;
|
||||
- (void) setTimeNum:(int)num denom:(int)denom inSections:(NSRange)sections;
|
||||
- (void) setDivisions:(int)divisions inSections:(NSRange)sections;
|
||||
- (void) setGroove:(NSString *)groove inSections:(NSRange)sections;
|
||||
|
||||
- (void) setRepeatVolta:(int)repeatVolta;
|
||||
|
||||
- (IBAction) showOutput:(id)sender;
|
||||
- (IBAction) showLog:(id)sender;
|
||||
|
|
|
@ -241,13 +241,23 @@
|
|||
{
|
||||
[self willChangeSong];
|
||||
[self willChangeValueForKey:@"songDivisions"];
|
||||
[self willChangeSong];
|
||||
while (sections.length-- > 0)
|
||||
song->ChangeDivisions(sections.location++, divisions);
|
||||
[self didChangeValueForKey:@"songDivisions"];
|
||||
[self didChangeSong];
|
||||
}
|
||||
|
||||
- (void) setGroove:(NSString *)groove inSections:(NSRange)sections
|
||||
{
|
||||
const char * grv = [groove UTF8String];
|
||||
[self willChangeSong];
|
||||
[self willChangeValueForKey:@"songGroove"];
|
||||
while (sections.length-- > 0)
|
||||
song->fProperties[sections.location++].fGroove = grv;
|
||||
[self didChangeValueForKey:@"songGroove"];
|
||||
[self didChangeSong];
|
||||
}
|
||||
|
||||
- (int) repeatVolta
|
||||
{
|
||||
return repeatVolta;
|
||||
|
|
|
@ -58,8 +58,6 @@
|
|||
[fDocument stop:self];
|
||||
if (returnCode == NSAlertFirstButtonReturn)
|
||||
[(VLSheetView *)contextInfo setGroove:[[fBrowser selectedCellInColumn:1] stringValue]];
|
||||
else
|
||||
[(VLSheetView *)contextInfo setGroove:nil];
|
||||
|
||||
[[self window] orderOut:self];
|
||||
}
|
||||
|
|
|
@ -517,4 +517,4 @@ advanceAt:
|
|||
return [self readFromPlist:outPlist error:outError];
|
||||
}
|
||||
|
||||
@end
|
||||
@end
|
|
@ -998,13 +998,15 @@ static int8_t sSharpAcc[] = {
|
|||
[doc addObserver:self forKeyPath:@"songTime" options:0 context:nil];
|
||||
[doc addObserver:self forKeyPath:@"songDivisions" options:0 context:nil];
|
||||
[doc addObserver:self forKeyPath:@"songGroove" options:0 context:nil];
|
||||
[self setGrooveMenu:[doc valueForKey:@"songGroove"]];
|
||||
|
||||
VLSong * song = [self song];
|
||||
fNumTopLedgers = std::max<int>(song->CountTopLedgers(), 1);
|
||||
fNumBotLedgers = std::max<int>(song->CountBotLedgers(), 1);
|
||||
fNumStanzas = std::max<int>(song->CountStanzas(), 2);
|
||||
|
||||
[fGrooveMenu addItemsWithTitles:
|
||||
[[NSUserDefaults standardUserDefaults] arrayForKey:@"VLGrooves"]];
|
||||
|
||||
[self updateMenus];
|
||||
}
|
||||
|
||||
|
@ -1030,7 +1032,7 @@ static int8_t sSharpAcc[] = {
|
|||
} else if ([keyPath isEqual:@"songDivisions"]) {
|
||||
[self updateDivisionMenu];
|
||||
} else if ([keyPath isEqual:@"songGroove"]) {
|
||||
[self setGrooveMenu:[[self document] valueForKey:@"songGroove"]];
|
||||
[self updateGrooveMenu];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1049,26 +1051,7 @@ static int8_t sSharpAcc[] = {
|
|||
|
||||
- (void)setGroove:(NSString *)groove
|
||||
{
|
||||
if (groove) {
|
||||
[[self document] setValue:groove forKey:@"songGroove"];
|
||||
[self setGrooveMenu:groove];
|
||||
} else {
|
||||
[fGrooveMenu selectItemAtIndex:2];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setGrooveMenu:(NSString *)groove
|
||||
{
|
||||
int removeIndex = [fGrooveMenu indexOfItemWithTitle:groove];
|
||||
if (removeIndex < 0 && [fGrooveMenu numberOfItems] > 11)
|
||||
removeIndex = 11;
|
||||
if (removeIndex >= 0)
|
||||
[fGrooveMenu removeItemAtIndex:removeIndex];
|
||||
[fGrooveMenu insertItemWithTitle:groove atIndex:2];
|
||||
[fGrooveMenu selectItemAtIndex:2];
|
||||
NSArray * grooves = [fGrooveMenu itemTitles];
|
||||
grooves = [grooves subarrayWithRange:NSMakeRange(2, [grooves count]-2)];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:grooves forKey:@"VLGrooves"];
|
||||
[[self document] setGroove:groove inSections:[self sectionsInSelection]];
|
||||
}
|
||||
|
||||
- (IBAction)editDisplayOptions:(id)sender
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
- (void)updateKeyMenu;
|
||||
- (void)updateTimeMenu;
|
||||
- (void)updateDivisionMenu;
|
||||
- (void)updateGrooveMenu;
|
||||
|
||||
- (void)updateMenus;
|
||||
|
||||
@end
|
||||
|
|
|
@ -406,11 +406,41 @@ inline int TimeTag(const VLProperties & prop)
|
|||
[[menu itemWithTag:firstTag] setState:firstState];
|
||||
}
|
||||
|
||||
- (void)updateGrooveMenu
|
||||
{
|
||||
NSRange sections = [self sectionsInSelection];
|
||||
VLSong * song = [self song];
|
||||
NSMutableArray* grooves = [NSMutableArray array];
|
||||
|
||||
while (sections.length-- > 0) {
|
||||
NSString * groove =
|
||||
[NSString stringWithUTF8String:
|
||||
song->fProperties[sections.location++].fGroove.c_str()];
|
||||
if (![grooves containsObject:groove])
|
||||
[grooves addObject:groove];
|
||||
}
|
||||
int selected = [grooves count];
|
||||
int history = [fGrooveMenu numberOfItems]-2;
|
||||
while (history-- > 0) {
|
||||
NSString * groove = [fGrooveMenu itemTitleAtIndex:2];
|
||||
[fGrooveMenu removeItemAtIndex:2];
|
||||
if (![grooves containsObject:groove])
|
||||
[grooves addObject:groove];
|
||||
}
|
||||
[fGrooveMenu addItemsWithTitles:grooves];
|
||||
[fGrooveMenu selectItemAtIndex:2];
|
||||
if (selected > 1)
|
||||
while (selected-- > 0)
|
||||
[[fGrooveMenu itemAtIndex:selected+2] setState:NSMixedState];
|
||||
[[NSUserDefaults standardUserDefaults] setObject:grooves forKey:@"VLGrooves"];
|
||||
}
|
||||
|
||||
- (void)updateMenus
|
||||
{
|
||||
[self updateKeyMenu];
|
||||
[self updateTimeMenu];
|
||||
[self updateDivisionMenu];
|
||||
[self updateGrooveMenu];
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
Loading…
Reference in New Issue
Block a user