Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix for ticket #6: Analog-ize progress meter.

  • Loading branch information...
commit 8f3c9bf940898d98c8e0dcab9a016a89e7a5e3d2 1 parent d0d5c63
@lemnar lemnar authored
View
4 BlitzPDFView.h
@@ -5,10 +5,10 @@
@class CounterView;
@interface BlitzPDFView : PDFView {
- uint16_t secondsElapsed;
+ NSTimeInterval secondsElapsed;
IBOutlet CounterView *counterView;
}
-@property uint16_t secondsElapsed;
+@property NSTimeInterval secondsElapsed;
@property(assign) NSUInteger pageIndex;
@property(assign) BOOL running;
View
6 BlitzPDFView.m
@@ -11,11 +11,11 @@ - (void)dealloc {
[super dealloc];
}
-- (uint16_t) secondsElapsed {
+- (NSTimeInterval) secondsElapsed {
return secondsElapsed;
}
-- (void)setSecondsElapsed:(uint16_t)secs {
+- (void)setSecondsElapsed:(NSTimeInterval)secs {
secondsElapsed = secs;
counterView.secondsElapsed = secs;
[counterView setNeedsDisplay:YES];
@@ -42,7 +42,7 @@ - (void)setRunning:(BOOL)running;
}
- (IBAction)updateSecondsElapsed:(id)sender {
- self.secondsElapsed = [sender intValue];
+ self.secondsElapsed = [sender doubleValue];
[self setNeedsDisplay:YES];
}
View
1  Blitz_Prefix.pch
@@ -7,4 +7,5 @@
#import <ScriptingBridge/ScriptingBridge.h>
#define SECONDS_PER_SLIDE (15)
+ #define UPDATES_PER_SECOND (60)
#endif
View
4 CounterView.h
@@ -7,13 +7,13 @@
#define kCounterViewWedgeBackground @"CounterViewWedgeBackground"
@interface CounterView : NSView {
- uint16_t secondsElapsed;
+ NSTimeInterval secondsElapsed;
NSColor *ringForeground;
NSColor *ringBackground;
NSColor *wedgeForeground;
NSColor *wedgeBackground;
}
-@property uint16_t secondsElapsed;
+@property NSTimeInterval secondsElapsed;
@property (retain) NSColor *ringForeground;
@property (retain) NSColor *ringBackground;
@property (retain) NSColor *wedgeForeground;
View
2  CounterView.m
@@ -10,7 +10,7 @@ @implementation CounterView
- (void) updateSecondsElapsed:(NSNotification*) note {
NSNumber* secondsElapsedValue = [[note userInfo] valueForKey:@"secondsElapsed"];
- self.secondsElapsed = [secondsElapsedValue unsignedIntValue];
+ self.secondsElapsed = [secondsElapsedValue doubleValue];
[self setNeedsDisplay:YES];
}
View
6 MyAppDelegate.h
@@ -12,7 +12,7 @@
@interface MyAppDelegate : NSObject {
NSMutableArray *windowControllers;
NSWindowController *preferencesWindowController;
- NSUInteger secondsElapsed;
+ NSTimeInterval secondsElapsed;
KeynoteApplication *keynote;
bool running;
NSTimer *timer;
@@ -21,12 +21,12 @@
@property (retain) NSMutableArray *windowControllers;
@property (retain) NSWindowController *preferencesWindowController;
@property (retain) KeynoteApplication *keynote;
-@property (assign, setter=setSecondsElapsed:) NSUInteger secondsElapsed;
+@property (assign, setter=setSecondsElapsed:) NSTimeInterval secondsElapsed;
@property (assign) bool running;
@property (retain) NSTimer *timer;
- (IBAction)startStopReset:(id)sender;
-- (void) setSecondsElapsed:(NSUInteger)elapsed;
+- (void) setSecondsElapsed:(NSTimeInterval)elapsed;
- (IBAction)showFloatingCounters:(id)sender;
- (IBAction)showPreferences:(id)sender;
View
10 MyAppDelegate.m
@@ -66,7 +66,7 @@ - (IBAction)startStopReset:(id)sender
}
else
{
- self.timer = [NSTimer scheduledTimerWithTimeInterval:1
+ self.timer = [NSTimer scheduledTimerWithTimeInterval:(1.0 / UPDATES_PER_SECOND)
target:self
selector:@selector(tick:)
userInfo:nil
@@ -75,12 +75,12 @@ - (IBAction)startStopReset:(id)sender
}
}
-- (void) setSecondsElapsed:(NSUInteger)elapsed
+- (void) setSecondsElapsed:(NSTimeInterval)elapsed
{
secondsElapsed = elapsed;
NSDictionary* userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithUnsignedInt:self.secondsElapsed],
+ [NSNumber numberWithDouble:self.secondsElapsed],
@"secondsElapsed",
0, nil];
@@ -96,9 +96,9 @@ - (void) advanceSlide {
- (void) tick:(NSTimer*) timer {
if (self.secondsElapsed < 5 * 60)
{
- self.secondsElapsed += 1;
+ self.secondsElapsed += 1.0 / UPDATES_PER_SECOND;
- if ((self.secondsElapsed % SECONDS_PER_SLIDE == 0))
+ if ((int)floor(UPDATES_PER_SECOND * self.secondsElapsed) % (UPDATES_PER_SECOND * SECONDS_PER_SLIDE) == 0)
[self advanceSlide];
}
else
View
2  MyDocument.h
@@ -7,7 +7,7 @@
@private BOOL isInFullScreenMode;
- NSUInteger secondsElapsed;
+ NSTimeInterval secondsElapsed;
NSUInteger pageIndex;
BOOL running;
}
View
8 MyDocument.m
@@ -14,7 +14,7 @@ @interface MyDocument ()
@property (retain, nonatomic) PDFDocument *pdfDocument;
@property (retain, nonatomic) NSTimer *timer;
@property (nonatomic) BOOL isInFullScreenMode;
-@property(assign) NSUInteger secondsElapsed;
+@property(assign) NSTimeInterval secondsElapsed;
@property(assign,readwrite) BOOL running;
@end
@@ -156,7 +156,7 @@ - (BOOL)readFromURL:(NSURL *)initWithURL ofType:(NSString *)typeName error:(NSEr
}
- (void)updateElapsedTimer:(NSTimer*)timer_ {
- if (self.secondsElapsed != 0 && (self.secondsElapsed % SECONDS_PER_SLIDE == 0)) {
+ if (self.secondsElapsed != 0 && ((int)floor(UPDATES_PER_SECOND * self.secondsElapsed) % (UPDATES_PER_SECOND * SECONDS_PER_SLIDE) == 0)) {
// Triggers page change in associated speaker notes window controller
self.pageIndex++;
if (self.pageIndex >= pdfDocument.pageCount) {
@@ -165,7 +165,7 @@ - (void)updateElapsedTimer:(NSTimer*)timer_ {
}
}
- self.secondsElapsed += 1;
+ self.secondsElapsed += 1.0 / UPDATES_PER_SECOND;
}
- (void)makeWindowControllers;
@@ -234,7 +234,7 @@ - (IBAction)start:(id)sender;
{
self.running = YES;
self.secondsElapsed = 0.0;
- self.timer = [[NSTimer scheduledTimerWithTimeInterval:1.0
+ self.timer = [[NSTimer scheduledTimerWithTimeInterval:1.0 / UPDATES_PER_SECOND
target:self
selector:@selector(updateElapsedTimer:)
userInfo:nil
View
2  SpeakerSlidesView.h
@@ -15,7 +15,7 @@
@interface SpeakerSlidesView : NSView
{
- uint16_t secondsElapsed;
+ NSTimeInterval secondsElapsed;
CounterView *counterView;
@private
SpeakerSlidePDFView *_currentSlideView, *_nextSlideView;
View
6 SpeakerSlidesView.m
@@ -65,11 +65,11 @@ - (void)dealloc;
[super dealloc];
}
-- (uint16_t) secondsElapsed {
+- (NSTimeInterval) secondsElapsed {
return secondsElapsed;
}
-- (void)setSecondsElapsed:(uint16_t)secs {
+- (void)setSecondsElapsed:(NSTimeInterval)secs {
secondsElapsed = secs;
counterView.secondsElapsed = secs;
[counterView setNeedsDisplay:YES];
@@ -105,7 +105,7 @@ - (void)setRunning:(BOOL)running;
}
- (IBAction)updateSecondsElapsed:(id)sender {
- self.secondsElapsed = [sender intValue];
+ self.secondsElapsed = [sender doubleValue];
[self setNeedsDisplay:YES];
}
Please sign in to comment.
Something went wrong with that request. Please try again.