Skip to content
Browse files

Added basic loop counter and stepper UI

  • Loading branch information...
1 parent 41d1c7e commit f8b98c8a77c6670b52b9f3d49beb0648bc3cc9a1 @kallepersson kallepersson committed Feb 16, 2012
Showing with 158 additions and 10 deletions.
  1. +8 −0 AppDelegate.h
  2. +28 −1 AppDelegate.m
  3. +122 −9 en.lproj/MainMenu.xib
View
8 AppDelegate.h
@@ -19,16 +19,24 @@
@property (weak) IBOutlet NSLevelIndicator *currentTimeBar;
@property (weak) IBOutlet NSTextField *currentTimeLabel;
@property (weak) IBOutlet NSTextField *currentTrackLabel;
+@property (weak) IBOutlet NSTextField *loopCountLabel;
+@property (weak) IBOutlet NSStepper *loopCountStepper;
@property (assign) BOOL paused;
@property (assign) QTTime startTime;
@property (assign) QTTime endTime;
@property (assign) QTTime currentTime;
@property (assign) long timeScale;
+@property (assign) int loopCount;
+
+//The value where we'll start looping infinitely
+@property (assign) int loopInfiniteCount;
+
@property (retain) QTMovie *music;
- (void)checkTime:(NSTimer*)theTimer;
+- (IBAction)loopStepperStep:(id)sender;
- (IBAction)playButtonClick:(id)sender;
- (IBAction)startSliderSet:(id)sender;
- (IBAction)endSliderSet:(id)sender;
View
29 AppDelegate.m
@@ -19,25 +19,48 @@ @implementation AppDelegate
@synthesize currentTimeBar;
@synthesize playButton;
@synthesize currentTrackLabel;
+@synthesize loopCountLabel;
+@synthesize loopCountStepper;
+@synthesize loopCount;
+@synthesize loopInfiniteCount;
@synthesize timeScale;
@synthesize startTime;
@synthesize endTime;
@synthesize currentTime;
@synthesize music;
@synthesize paused;
+-(void) setTheLoopCount:(int)theLoopCount{
+ //Sets the property and updates the label
+ [self setLoopCount:theLoopCount];
+ if([self loopCount] < [self loopInfiniteCount]) {
+ [loopCountLabel setStringValue:[NSString stringWithFormat:@"x%d",self.loopCount]];
+ }
+ else {
+ [loopCountLabel setStringValue:@""];
+ }
+ //Finally update the stepper so it's synchronized
+ [loopCountStepper setIntValue:[self loopCount]];
+}
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[[self window] setTitleBarHeight:30.0];
[[self window] setTrafficLightButtonsLeftMargin:7.0];
+ [self setLoopInfiniteCount:31];
+ [self setTheLoopCount:10];
+ [[self loopCountStepper] setMaxValue:(double)[self loopInfiniteCount]];
}
-(void) checkTime:(NSTimer*)theTimer{
currentTime = [music currentTime];
- if(currentTime.timeValue >= endTime.timeValue && startTime.timeValue < endTime.timeValue){
+ if(currentTime.timeValue >= endTime.timeValue && startTime.timeValue < endTime.timeValue && [self loopCount] > 0){
+ if([self loopCount] < [self loopInfiniteCount]) {
+ //[self loopInfiniteCount] is the magic infinite number
+ [self setTheLoopCount:[self loopCount]-1];
+ }
[music setCurrentTime:startTime];
}
@@ -139,6 +162,10 @@ - (IBAction)playButtonClick:(id)sender {
}
}
+- (IBAction)loopStepperStep:(id)sender {
+ [self setTheLoopCount:[loopCountStepper intValue]];
+}
+
- (IBAction)openFile:(id)sender {
NSOpenPanel *openPanel = [NSOpenPanel openPanel];
NSInteger tvarNSInteger = [openPanel runModal];
View
131 en.lproj/MainMenu.xib
@@ -11,6 +11,7 @@
<string key="NS.object.0">1938</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
+ <string>NSStepper</string>
<string>NSMenuItem</string>
<string>NSMenu</string>
<string>NSTextFieldCell</string>
@@ -22,6 +23,7 @@
<string>NSSlider</string>
<string>NSSliderCell</string>
<string>NSCustomObject</string>
+ <string>NSStepperCell</string>
<string>NSView</string>
<string>NSWindowTemplate</string>
<string>NSTextField</string>
@@ -337,12 +339,12 @@
<string key="NSFrame">{{8, 82}, {40, 40}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
- <reference key="NSNextKeyView" ref="353695766"/>
+ <reference key="NSNextKeyView" ref="238452651"/>
<string key="NSReuseIdentifierKey">_NS:687</string>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="14965766">
<int key="NSCellFlags">67239424</int>
- <int key="NSCellFlags2">134250496</int>
+ <int key="NSCellFlags2">32768</int>
<string key="NSContents"/>
<object class="NSFont" key="NSSupport" id="556841281">
<string key="NSName">LucidaGrande</string>
@@ -351,11 +353,11 @@
</object>
<string key="NSCellIdentifier">_NS:687</string>
<reference key="NSControlView" ref="690740704"/>
- <int key="NSButtonFlags">922501375</int>
- <int key="NSButtonFlags2">130</int>
+ <int key="NSButtonFlags">-2038677249</int>
+ <int key="NSButtonFlags2">6</int>
<object class="NSCustomResource" key="NSNormalImage">
<string key="NSClassName">NSImage</string>
- <string key="NSResourceName">NSRightFacingTriangleTemplate</string>
+ <string key="NSResourceName">NSGoRightTemplate</string>
</object>
<string key="NSAlternateContents"/>
<string key="NSKeyEquivalent"/>
@@ -366,7 +368,7 @@
<object class="NSTextField" id="353695766">
<reference key="NSNextResponder" ref="439893737"/>
<int key="NSvFlags">268</int>
- <string key="NSFrame">{{59, 86}, {245, 34}}</string>
+ <string key="NSFrame">{{121, 86}, {215, 34}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="753304525"/>
@@ -492,13 +494,53 @@
<bool key="NSVertical">NO</bool>
</object>
</object>
+ <object class="NSStepper" id="153453889">
+ <reference key="NSNextResponder" ref="439893737"/>
+ <int key="NSvFlags">268</int>
+ <string key="NSFrame">{{84, 89}, {19, 27}}</string>
+ <reference key="NSSuperview" ref="439893737"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="353695766"/>
+ <string key="NSReuseIdentifierKey">_NS:3914</string>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSStepperCell" key="NSCell" id="985223941">
+ <int key="NSCellFlags">917024</int>
+ <int key="NSCellFlags2">0</int>
+ <string key="NSCellIdentifier">_NS:3914</string>
+ <reference key="NSControlView" ref="153453889"/>
+ <double key="NSValue">10</double>
+ <double key="NSMaxValue">31</double>
+ <double key="NSIncrement">1</double>
+ <bool key="NSAutorepeat">YES</bool>
+ </object>
+ </object>
+ <object class="NSTextField" id="238452651">
+ <reference key="NSNextResponder" ref="439893737"/>
+ <int key="NSvFlags">268</int>
+ <string key="NSFrame">{{42, 95}, {38, 17}}</string>
+ <reference key="NSSuperview" ref="439893737"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="153453889"/>
+ <string key="NSReuseIdentifierKey">_NS:3944</string>
+ <bool key="NSEnabled">YES</bool>
+ <object class="NSTextFieldCell" key="NSCell" id="852473342">
+ <int key="NSCellFlags">68288064</int>
+ <int key="NSCellFlags2">71304192</int>
+ <string key="NSContents">x10</string>
+ <reference key="NSSupport" ref="556841281"/>
+ <string key="NSCellIdentifier">_NS:3944</string>
+ <reference key="NSControlView" ref="238452651"/>
+ <reference key="NSBackgroundColor" ref="515411080"/>
+ <reference key="NSTextColor" ref="41212231"/>
+ </object>
+ </object>
</array>
<string key="NSFrameSize">{400, 380}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="379503995"/>
</object>
- <string key="NSScreenRect">{{0, 0}, {2560, 1440}}</string>
+ <string key="NSScreenRect">{{0, 0}, {1440, 878}}</string>
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
<bool key="NSWindowIsRestorable">YES</bool>
</object>
@@ -684,6 +726,30 @@
</object>
<int key="connectionID">613</int>
</object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">loopCountLabel</string>
+ <reference key="source" ref="976324537"/>
+ <reference key="destination" ref="238452651"/>
+ </object>
+ <int key="connectionID">620</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBOutletConnection" key="connection">
+ <string key="label">loopCountStepper</string>
+ <reference key="source" ref="976324537"/>
+ <reference key="destination" ref="153453889"/>
+ </object>
+ <int key="connectionID">621</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBActionConnection" key="connection">
+ <string key="label">loopStepperStep:</string>
+ <reference key="source" ref="976324537"/>
+ <reference key="destination" ref="153453889"/>
+ </object>
+ <int key="connectionID">622</int>
+ </object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
@@ -890,6 +956,8 @@
<reference ref="840108087"/>
<reference ref="690740704"/>
<reference ref="753304525"/>
+ <reference ref="238452651"/>
+ <reference ref="153453889"/>
</array>
<reference key="parent" ref="972006081"/>
</object>
@@ -1010,6 +1078,32 @@
<reference key="object" ref="804262355"/>
<reference key="parent" ref="752942585"/>
</object>
+ <object class="IBObjectRecord">
+ <int key="objectID">614</int>
+ <reference key="object" ref="153453889"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="985223941"/>
+ </array>
+ <reference key="parent" ref="439893737"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">615</int>
+ <reference key="object" ref="985223941"/>
+ <reference key="parent" ref="153453889"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">617</int>
+ <reference key="object" ref="238452651"/>
+ <array class="NSMutableArray" key="children">
+ <reference ref="852473342"/>
+ </array>
+ <reference key="parent" ref="439893737"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">618</int>
+ <reference key="object" ref="852473342"/>
+ <reference key="parent" ref="238452651"/>
+ </object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
@@ -1058,6 +1152,10 @@
<string key="578.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="579.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="58.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="614.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="615.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="617.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+ <string key="618.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="72.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="73.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="79.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -1069,7 +1167,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
- <int key="maxID">613</int>
+ <int key="maxID">622</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -1079,6 +1177,7 @@
<dictionary class="NSMutableDictionary" key="actions">
<string key="currentTimeBarSet:">id</string>
<string key="endSliderSet:">id</string>
+ <string key="loopStepperStep:">id</string>
<string key="openFile:">id</string>
<string key="playButtonClick:">id</string>
<string key="startSliderSet:">id</string>
@@ -1092,6 +1191,10 @@
<string key="name">endSliderSet:</string>
<string key="candidateClassName">id</string>
</object>
+ <object class="IBActionInfo" key="loopStepperStep:">
+ <string key="name">loopStepperStep:</string>
+ <string key="candidateClassName">id</string>
+ </object>
<object class="IBActionInfo" key="openFile:">
<string key="name">openFile:</string>
<string key="candidateClassName">id</string>
@@ -1110,6 +1213,8 @@
<string key="currentTimeLabel">NSTextField</string>
<string key="currentTrackLabel">NSTextField</string>
<string key="endSlider">NSSlider</string>
+ <string key="loopCountLabel">NSTextField</string>
+ <string key="loopCountStepper">NSStepper</string>
<string key="playButton">NSButton</string>
<string key="startSlider">NSSlider</string>
<string key="window">INAppStoreWindow</string>
@@ -1131,6 +1236,14 @@
<string key="name">endSlider</string>
<string key="candidateClassName">NSSlider</string>
</object>
+ <object class="IBToOneOutletInfo" key="loopCountLabel">
+ <string key="name">loopCountLabel</string>
+ <string key="candidateClassName">NSTextField</string>
+ </object>
+ <object class="IBToOneOutletInfo" key="loopCountStepper">
+ <string key="name">loopCountStepper</string>
+ <string key="candidateClassName">NSStepper</string>
+ </object>
<object class="IBToOneOutletInfo" key="playButton">
<string key="name">playButton</string>
<string key="candidateClassName">NSButton</string>
@@ -1164,9 +1277,9 @@
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<dictionary class="NSMutableDictionary" key="IBDocument.LastKnownImageSizes">
+ <string key="NSGoRightTemplate">{9, 9}</string>
<string key="NSMenuCheckmark">{11, 11}</string>
<string key="NSMenuMixedState">{10, 3}</string>
- <string key="NSRightFacingTriangleTemplate">{9, 9}</string>
<string key="cover">{300, 300}</string>
</dictionary>
</data>

0 comments on commit f8b98c8

Please sign in to comment.
Something went wrong with that request. Please try again.