From 3d0a156816d4c1cf08eaed0d36b5034bc0b94a4d Mon Sep 17 00:00:00 2001 From: Matthias Neeracher Date: Sun, 14 Aug 2011 00:52:20 +0200 Subject: [PATCH] Much simpler, better, media control UI --- Medianno.xcodeproj/project.pbxproj | 12 + Medianno/MADocWindow.h | 11 +- Medianno/MADocWindow.mm | 116 ++----- Medianno/en.lproj/Localizable.strings | 10 + Medianno/en.lproj/MADocument.xib | 54 +-- Medianno/en.lproj/MainMenu.xib | 473 ++++++++++++-------------- 6 files changed, 278 insertions(+), 398 deletions(-) create mode 100644 Medianno/en.lproj/Localizable.strings diff --git a/Medianno.xcodeproj/project.pbxproj b/Medianno.xcodeproj/project.pbxproj index d5cf6e5..5d9a164 100644 --- a/Medianno.xcodeproj/project.pbxproj +++ b/Medianno.xcodeproj/project.pbxproj @@ -26,6 +26,7 @@ 950BB7A713F467A400D8E669 /* MAAddMedia.xib in Resources */ = {isa = PBXBuildFile; fileRef = 950BB7A513F467A400D8E669 /* MAAddMedia.xib */; }; 950BB7AA13F46BAF00D8E669 /* MAAddMediaSheet.mm in Sources */ = {isa = PBXBuildFile; fileRef = 950BB7A913F46BAF00D8E669 /* MAAddMediaSheet.mm */; }; 950BB7AD13F46ECF00D8E669 /* MAAppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 950BB7AC13F46ECF00D8E669 /* MAAppController.mm */; }; + 95C534E013F732A200A07932 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 95C534DE13F732A200A07932 /* Localizable.strings */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -60,6 +61,7 @@ 950BB7A913F46BAF00D8E669 /* MAAddMediaSheet.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MAAddMediaSheet.mm; sourceTree = ""; }; 950BB7AB13F46ECF00D8E669 /* MAAppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MAAppController.h; sourceTree = ""; }; 950BB7AC13F46ECF00D8E669 /* MAAppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MAAppController.mm; sourceTree = ""; }; + 95C534DF13F732A200A07932 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -122,6 +124,7 @@ 950BB67613F1F26200D8E669 /* main.m */, 950BB67813F1F26200D8E669 /* Medianno-Prefix.pch */, 950BB67913F1F26200D8E669 /* Credits.rtf */, + 95C534DE13F732A200A07932 /* Localizable.strings */, ); name = "Supporting Files"; sourceTree = ""; @@ -225,6 +228,7 @@ 950BB68113F1F26200D8E669 /* MADocument.xib in Resources */, 950BB68413F1F26200D8E669 /* MainMenu.xib in Resources */, 950BB7A713F467A400D8E669 /* MAAddMedia.xib in Resources */, + 95C534E013F732A200A07932 /* Localizable.strings in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -295,6 +299,14 @@ path = Medianno; sourceTree = ""; }; + 95C534DE13F732A200A07932 /* Localizable.strings */ = { + isa = PBXVariantGroup; + children = ( + 95C534DF13F732A200A07932 /* en */, + ); + name = Localizable.strings; + sourceTree = ""; + }; /* End PBXVariantGroup section */ /* Begin XCBuildConfiguration section */ diff --git a/Medianno/MADocWindow.h b/Medianno/MADocWindow.h index 709b9ba..bfb2979 100644 --- a/Medianno/MADocWindow.h +++ b/Medianno/MADocWindow.h @@ -21,15 +21,8 @@ - (IBAction)addMediaFiles:(id)sender; - (void)addMedia:(NSArray *)urls; - (IBAction)addAnnotation:(id)sender; - -- (IBAction)hugeSkipBackward:(id)sender; -- (IBAction)largeSkipBackward:(id)sender; -- (IBAction)smallSkipBackward:(id)sender; -- (IBAction)tinySkipBackward:(id)sender; -- (IBAction)hugeSkipForward:(id)sender; -- (IBAction)largeSkipForward:(id)sender; -- (IBAction)smallSkipForward:(id)sender; -- (IBAction)tinySkipForward:(id)sender; +- (IBAction)mediaSkipBackward:(id)sender; +- (IBAction)mediaSkipForward:(id)sender; - (IBAction)toggleMediaPlay:(id)sender; @end diff --git a/Medianno/MADocWindow.mm b/Medianno/MADocWindow.mm index eca150c..7f5bfab 100644 --- a/Medianno/MADocWindow.mm +++ b/Medianno/MADocWindow.mm @@ -105,57 +105,53 @@ [movieView play:sender]; } +- (BOOL)validateUserInterfaceItem:(id )item +{ + if ([item action] == @selector(toggleMediaPlay:)) { + NSMenuItem * menuItem = (NSMenuItem *)item; + if ([[movieView movie] rate] > 0.0f) + [menuItem setTitle:NSLocalizedString(@"Pause", @"Pause playback")]; + else + [menuItem setTitle:NSLocalizedString(@"Play", @"Start playback")]; + } + return YES; +} + #pragma mark Media navigation -- (void)skipTimeInterval:(NSTimeInterval)timeInterval +static NSTimeInterval sLastSkip = 0.0; + +- (void)resetSkipFactor:(id)sender { - QTTime interval= QTMakeTimeWithTimeInterval(abs(timeInterval)); + sLastSkip = 0.0; +} + +- (void)skipTimeInterval +{ + QTTime interval= QTMakeTimeWithTimeInterval(abs(sLastSkip)); QTTime current = [[movieView movie] currentTime]; - if (timeInterval > 0) + if (sLastSkip > 0) current = QTTimeIncrement(current, interval); else current = QTTimeDecrement(current, interval); [[movieView movie] setCurrentTime:current]; + sLastSkip *= 1.1; + [NSRunLoop cancelPreviousPerformRequestsWithTarget:self selector:@selector(resetSkipFactor:) object:self]; + [self performSelector:@selector(resetSkipFactor:) withObject:self afterDelay:1.0]; } -- (IBAction)hugeSkipBackward:(id)sender +- (IBAction)mediaSkipBackward:(id)sender { - [self skipTimeInterval:-15.0*60.0]; + if (sLastSkip >= 0) + sLastSkip = -1.0; + [self skipTimeInterval]; } -- (IBAction)largeSkipBackward:(id)sender +- (IBAction)mediaSkipForward:(id)sender { - [self skipTimeInterval:-5.0*60.0]; -} - -- (IBAction)smallSkipBackward:(id)sender -{ - [self skipTimeInterval:-60.0]; -} - -- (IBAction)tinySkipBackward:(id)sender -{ - [self skipTimeInterval:-10.0]; -} - -- (IBAction)tinySkipForward:(id)sender -{ - [self skipTimeInterval:10.0]; -} - -- (IBAction)smallSkipForward:(id)sender -{ - [self skipTimeInterval:60.0]; -} - -- (IBAction)largeSkipForward:(id)sender -{ - [self skipTimeInterval:5.0*60.0]; -} - -- (IBAction)hugeSkipForward:(id)sender -{ - [self skipTimeInterval:15.0*60.0]; + if (sLastSkip <= 0) + sLastSkip = 1.0; + [self skipTimeInterval]; } #pragma mark Tag token manipulation @@ -199,48 +195,10 @@ - (void)sendEvent:(NSEvent *)event { - if ([event type] == NSKeyDown && [event modifierFlags] & NSNumericPadKeyMask) { - MADocWindow * controller = [self windowController]; - switch ([[event characters] characterAtIndex:0]) { - case '0': - case '5': - [controller toggleMediaPlay:self]; - return; - case '+': - case 3: - [controller addAnnotation:self]; - return; - case '9': - [controller hugeSkipBackward:self]; - return; - case '8': - [controller largeSkipBackward:self]; - return; - case '7': - [controller smallSkipBackward:self]; - return; - case '4': - [controller tinySkipBackward:self]; - return; - case '6': - [controller tinySkipForward:self]; - return; - case '1': - [controller smallSkipForward:self]; - return; - case '2': - [controller largeSkipForward:self]; - return; - case '3': - [controller hugeSkipForward:self]; - return; - default: - NSBeep(); - return; - } - } - - [super sendEvent:event]; + if ([event type] == NSKeyDown && [[event characters] characterAtIndex:0]==3) + [[self windowController] addAnnotation:self]; + else + [super sendEvent:event]; } - (void)keyDown:(NSEvent *)event diff --git a/Medianno/en.lproj/Localizable.strings b/Medianno/en.lproj/Localizable.strings new file mode 100644 index 0000000..70e84d5 --- /dev/null +++ b/Medianno/en.lproj/Localizable.strings @@ -0,0 +1,10 @@ +/* + Localizable.strings + Medianno + + Created by Matthias Neeracher on 8/14/11. + Copyright 2011 Apple Computer. All rights reserved. +*/ + +"Play" = "Play"; +"Pause"= "Pause"; diff --git a/Medianno/en.lproj/MADocument.xib b/Medianno/en.lproj/MADocument.xib index 58589ac..158bbc0 100644 --- a/Medianno/en.lproj/MADocument.xib +++ b/Medianno/en.lproj/MADocument.xib @@ -1469,14 +1469,8 @@ YES addAnnotation: addMediaFiles: - hugeSkipBackward: - hugeSkipForward: - largeSkipBackward: - largeSkipForward: - smallSkipBackward: - smallSkipForward: - tinySkipBackward: - tinySkipForward: + mediaSkipBackward: + mediaSkipForward: toggleMediaPlay: @@ -1486,12 +1480,6 @@ id id id - id - id - id - id - id - id @@ -1500,14 +1488,8 @@ YES addAnnotation: addMediaFiles: - hugeSkipBackward: - hugeSkipForward: - largeSkipBackward: - largeSkipForward: - smallSkipBackward: - smallSkipForward: - tinySkipBackward: - tinySkipForward: + mediaSkipBackward: + mediaSkipForward: toggleMediaPlay: @@ -1521,35 +1503,11 @@ id - hugeSkipBackward: + mediaSkipBackward: id - hugeSkipForward: - id - - - largeSkipBackward: - id - - - largeSkipForward: - id - - - smallSkipBackward: - id - - - smallSkipForward: - id - - - tinySkipBackward: - id - - - tinySkipForward: + mediaSkipForward: id diff --git a/Medianno/en.lproj/MainMenu.xib b/Medianno/en.lproj/MainMenu.xib index 775d00b..4293527 100644 --- a/Medianno/en.lproj/MainMenu.xib +++ b/Medianno/en.lproj/MainMenu.xib @@ -767,12 +767,12 @@ submenuAction: - + Media YES - - + + Add Annotation t 1048576 @@ -780,8 +780,8 @@ - - + + YES YES @@ -790,111 +790,31 @@ - - + + Play IA - 524288 2147483647 - - - Skip - + + + Skip Backward + + 1048576 + 2147483647 + + + + + + Skip Forward + + 1048576 2147483647 - submenuAction: - - Skip - - YES - - - Back 15m - 1 - 1048576 - 2147483647 - - - - - - Back 5m - 2 - 1048576 - 2147483647 - - - - - - Back 1m - 3 - 1048576 - 2147483647 - - - - - - Back 10s - 4 - 1048576 - 2147483647 - - - - - - YES - YES - - - 2147483647 - - - - - - Forward 10s - 5 - 1048576 - 2147483647 - - - - - - Forward 1m - 6 - 1048576 - 2147483647 - - - - - - Forward 5m - 7 - 1048576 - 2147483647 - - - - - - Forward 15m - 8 - 1048576 - 2147483647 - - - - - @@ -985,6 +905,9 @@ NSFontManager + + MAAppController + @@ -1385,81 +1308,41 @@ addAnnotation: - + - 542 - - - - hugeSkipBackward: - - - - 546 + 578 toggleMediaPlay: - + - 564 + 579 - largeSkipBackward: + mediaSkipBackward: - + - 565 + 581 - smallSkipBackward: + mediaSkipForward: - + - 566 + 582 - - tinySkipBackward: - - + + delegate + + - 567 - - - - tinySkipForward: - - - - 568 - - - - smallSkipForward: - - - - 569 - - - - largeSkipForward: - - - - 570 - - - - hugeSkipForward: - - - - 571 + 584 @@ -2101,22 +1984,10 @@ YES - + - - 537 - - - YES - - - - - - - 540 @@ -2128,90 +1999,48 @@ - 541 - - - - - 543 - + 573 + YES - + + + + + - + - 544 - - - YES - - - - - - - - - - - + 574 + + - 545 - - + 575 + + - 547 - - + 576 + + - 549 - - + 577 + + - 551 - - + 580 + + - 553 - - - - - 554 - - - - - 556 - - - - - 558 - - - - - 560 - - - - - 562 - - - - - 563 - - + 583 + + + AppController @@ -2297,26 +2126,18 @@ 5.IBPluginDependency 532.IBPluginDependency 536.IBPluginDependency - 537.IBPluginDependency 538.IBPluginDependency 540.IBPluginDependency - 541.IBPluginDependency - 543.IBPluginDependency - 544.IBPluginDependency - 545.IBPluginDependency - 547.IBPluginDependency - 549.IBPluginDependency - 551.IBPluginDependency - 553.IBPluginDependency - 554.IBPluginDependency - 556.IBPluginDependency - 558.IBPluginDependency 56.IBPluginDependency - 560.IBPluginDependency - 562.IBPluginDependency - 563.IBPluginDependency 57.IBPluginDependency + 573.IBPluginDependency + 574.IBPluginDependency + 575.IBPluginDependency + 576.IBPluginDependency + 577.IBPluginDependency 58.IBPluginDependency + 580.IBPluginDependency + 583.IBPluginDependency 72.IBPluginDependency 73.IBPluginDependency 74.IBPluginDependency @@ -2432,14 +2253,6 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin - com.apple.InterfaceBuilder.CocoaPlugin @@ -2454,7 +2267,7 @@ - 571 + 589 @@ -2477,6 +2290,142 @@ + + MAAppController + NSObject + + IBProjectSource + ./Classes/MAAppController.h + + + + MADocWindow + NSWindowController + + YES + + YES + addAnnotation: + addMediaFiles: + mediaSkipBackward: + mediaSkipForward: + toggleMediaPlay: + + + YES + id + id + id + id + id + + + + YES + + YES + addAnnotation: + addMediaFiles: + mediaSkipBackward: + mediaSkipForward: + toggleMediaPlay: + + + YES + + addAnnotation: + id + + + addMediaFiles: + id + + + mediaSkipBackward: + id + + + mediaSkipForward: + id + + + toggleMediaPlay: + id + + + + + YES + + YES + annotationController + annotationTable + mediaController + mediaTable + movieView + tokenColumn + tokenFieldProto + + + YES + NSArrayController + NSTableView + NSArrayController + NSTableView + QTMovieView + NSTableColumn + NSTokenField + + + + YES + + YES + annotationController + annotationTable + mediaController + mediaTable + movieView + tokenColumn + tokenFieldProto + + + YES + + annotationController + NSArrayController + + + annotationTable + NSTableView + + + mediaController + NSArrayController + + + mediaTable + NSTableView + + + movieView + QTMovieView + + + tokenColumn + NSTableColumn + + + tokenFieldProto + NSTokenField + + + + + IBProjectSource + ./Classes/MADocWindow.h + + 0