From 12fab5d88453730b6bb2dcf9c8aedc436bcc527f Mon Sep 17 00:00:00 2001 From: "bushuev.m" Date: Tue, 16 Aug 2011 11:45:40 +0400 Subject: [PATCH 1/8] add method - (void)showWithCaption:(NSString *)caption andHideAfter:(NSTimeInterval)delay --- ATMHud.h | 2 ++ ATMHud.m | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/ATMHud.h b/ATMHud.h index ebc5476..17e8f24 100644 --- a/ATMHud.h +++ b/ATMHud.h @@ -102,6 +102,8 @@ typedef enum { - (void)hide; - (void)hideAfter:(NSTimeInterval)delay; +- (void)showWithCaption:(NSString *)caption andHideAfter:(NSTimeInterval)delay; + - (void)playSound:(NSString *)soundPath; @end diff --git a/ATMHud.m b/ATMHud.m index 4c29853..0bd57ce 100644 --- a/ATMHud.m +++ b/ATMHud.m @@ -251,6 +251,12 @@ - (void)hideAfter:(NSTimeInterval)delay { [self performSelector:@selector(hide) withObject:nil afterDelay:delay]; } +- (void)showWithCaption:(NSString *)caption andHideAfter:(NSTimeInterval)delay { + [self setCaption:caption]; + [self show]; + [self hideAfter:delay]; +} + #pragma mark - #pragma mark Internal methods - (void)construct { From 59bd730a7e5cfeac11aa4ddb4eaea88c2c31340e Mon Sep 17 00:00:00 2001 From: "bushuev.m" Date: Fri, 19 Aug 2011 17:21:22 +0400 Subject: [PATCH 2/8] .gitignore, memory leak fixed --- .gitignore | 1 + ATMHudView.h | 2 +- ATMHudView.m | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/ATMHudView.h b/ATMHudView.h index 6c53f7b..2e4091f 100644 --- a/ATMHudView.h +++ b/ATMHudView.h @@ -47,7 +47,7 @@ typedef enum { @property (nonatomic, retain) UIImage *image; @property (nonatomic, retain) UIActivityIndicatorView *activity; @property (nonatomic, assign) UIActivityIndicatorViewStyle activityStyle; -@property (nonatomic, retain) ATMHud *p; +@property (nonatomic, assign) ATMHud *p; @property (nonatomic, assign) BOOL showActivity; diff --git a/ATMHudView.m b/ATMHudView.m index dc8d679..445f1e5 100644 --- a/ATMHudView.m +++ b/ATMHudView.m @@ -86,7 +86,7 @@ - (void)dealloc { [caption release]; [image release]; [activity release]; - [p release]; + p = nil; [backgroundLayer release]; [imageLayer release]; From 014019fd587cdd16a6a15dab46747364d51f71fe Mon Sep 17 00:00:00 2001 From: "bushuev.m" Date: Fri, 19 Aug 2011 17:24:31 +0400 Subject: [PATCH 3/8] added - (void)setCenter:(CGPoint)p --- ATMHud.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ATMHud.m b/ATMHud.m index 0bd57ce..1e62303 100644 --- a/ATMHud.m +++ b/ATMHud.m @@ -161,6 +161,11 @@ - (void)setProgress:(CGFloat)progress { [__view.progressLayer setNeedsDisplay]; } +- (void)setCenter:(CGPoint)p { + center = p; + __view.center = center; +} + #pragma mark - #pragma mark Queue - (void)addQueueItem:(ATMHudQueueItem *)item { From 037cfed0c3539313fe4b575fe0e408c7ee29364e Mon Sep 17 00:00:00 2001 From: "bushuev.m" Date: Fri, 19 Aug 2011 18:25:40 +0400 Subject: [PATCH 4/8] added gray property --- ATMHud.h | 1 + ATMHud.m | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ATMHud.h b/ATMHud.h index 17e8f24..e7b8247 100644 --- a/ATMHud.h +++ b/ATMHud.h @@ -54,6 +54,7 @@ typedef enum { @property (nonatomic, assign) CGFloat margin; @property (nonatomic, assign) CGFloat padding; @property (nonatomic, assign) CGFloat alpha; +@property (nonatomic, assign) CGFloat gray; @property (nonatomic, assign) CGFloat appearScaleFactor; @property (nonatomic, assign) CGFloat disappearScaleFactor; @property (nonatomic, assign) CGFloat progressBorderRadius; diff --git a/ATMHud.m b/ATMHud.m index 1e62303..cf47fbc 100644 --- a/ATMHud.m +++ b/ATMHud.m @@ -24,6 +24,7 @@ - (void)construct; @implementation ATMHud @synthesize margin, padding, alpha, appearScaleFactor, disappearScaleFactor, progressBorderRadius, progressBorderWidth, progressBarRadius, progressBarInset; +@synthesize gray; @synthesize delegate, accessoryPosition; @synthesize center; @synthesize shadowEnabled, blockTouches, allowSuperviewInteraction; @@ -109,10 +110,18 @@ - (void)setAlpha:(CGFloat)value { alpha = value; [CATransaction begin]; [CATransaction setDisableActions:YES]; - __view.backgroundLayer.backgroundColor = [UIColor colorWithWhite:0.0 alpha:value].CGColor; + __view.backgroundLayer.backgroundColor = [UIColor colorWithWhite:gray alpha:value].CGColor; [CATransaction commit]; } +- (void)setGray:(CGFloat)value { + gray = value; + [CATransaction begin]; + [CATransaction setDisableActions:YES]; + __view.backgroundLayer.backgroundColor = [UIColor colorWithWhite:gray alpha:alpha].CGColor; + [CATransaction commit]; +} + - (void)setShadowEnabled:(BOOL)value { shadowEnabled = value; if (shadowEnabled) { @@ -267,6 +276,7 @@ - (void)showWithCaption:(NSString *)caption andHideAfter:(NSTimeInterval)delay { - (void)construct { margin = padding = 10.0; alpha = 0.7; + gray = 0.0; progressBorderRadius = 8.0; progressBorderWidth = 2.0; progressBarRadius = 5.0; From c8fc8bb99b45ba681db3851d4a3cdd4c10038a94 Mon Sep 17 00:00:00 2001 From: "bushuev.m" Date: Mon, 22 Aug 2011 19:33:30 +0400 Subject: [PATCH 5/8] issue hideafter: doesnt reset when a new hud is called fixed --- ATMHud.m | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ATMHud.m b/ATMHud.m index cf47fbc..7722f45 100644 --- a/ATMHud.m +++ b/ATMHud.m @@ -262,6 +262,10 @@ - (void)hide { } - (void)hideAfter:(NSTimeInterval)delay { + [NSObject cancelPreviousPerformRequestsWithTarget:self + selector:@selector(hide) + object:nil]; + [self performSelector:@selector(hide) withObject:nil afterDelay:delay]; } From 247a6b526c635f24b0c0230ecfab2f9426685c0f Mon Sep 17 00:00:00 2001 From: "bushuev.m" Date: Wed, 24 Aug 2011 11:13:47 +0400 Subject: [PATCH 6/8] added autocenter(YES) property --- ATMHud.h | 1 + ATMHud.m | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/ATMHud.h b/ATMHud.h index e7b8247..103165f 100644 --- a/ATMHud.h +++ b/ATMHud.h @@ -67,6 +67,7 @@ typedef enum { @property (nonatomic, assign) BOOL shadowEnabled; @property (nonatomic, assign) BOOL blockTouches; @property (nonatomic, assign) BOOL allowSuperviewInteraction; +@property (nonatomic, assign) BOOL autocenter; // YES @property (nonatomic, retain) NSString *showSound; @property (nonatomic, retain) NSString *updateSound; diff --git a/ATMHud.m b/ATMHud.m index 7722f45..665e040 100644 --- a/ATMHud.m +++ b/ATMHud.m @@ -30,6 +30,7 @@ @implementation ATMHud @synthesize shadowEnabled, blockTouches, allowSuperviewInteraction; @synthesize showSound, updateSound, hideSound; @synthesize __view, sound, displayQueue, queuePosition; +@synthesize autocenter; - (id)init { if ((self = [super init])) { @@ -250,6 +251,12 @@ - (void)showQueueAtIndex:(NSInteger)index { #pragma mark - #pragma mark Controlling - (void)show { + if (autocenter) { + CGRect svb = [self.view superView].bounds; + self.view.center = CGPointMake(svb.origin.x + svb.size.width / 2, + svb.origin.y + svb.size.height / 2); + } + [__view show]; } @@ -299,6 +306,7 @@ - (void)construct { center = CGPointZero; blockTouches = NO; allowSuperviewInteraction = NO; + autocenter = YES; } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { From 6c16c07e7e51fc3fbb95354c5e51bbb87a565b6b Mon Sep 17 00:00:00 2001 From: "bushuev.m" Date: Wed, 24 Aug 2011 11:30:43 +0400 Subject: [PATCH 7/8] small syntax change --- ATMHud.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ATMHud.m b/ATMHud.m index 665e040..76b222d 100644 --- a/ATMHud.m +++ b/ATMHud.m @@ -252,7 +252,7 @@ - (void)showQueueAtIndex:(NSInteger)index { #pragma mark Controlling - (void)show { if (autocenter) { - CGRect svb = [self.view superView].bounds; + CGRect svb = self.view.superView.bounds; self.view.center = CGPointMake(svb.origin.x + svb.size.width / 2, svb.origin.y + svb.size.height / 2); } From f6f42ecb3dcfea53b65e6439cf7997c78e72b5f0 Mon Sep 17 00:00:00 2001 From: "bushuev.m" Date: Wed, 24 Aug 2011 11:34:19 +0400 Subject: [PATCH 8/8] added autoBringToFront(YES) property --- ATMHud.h | 1 + ATMHud.m | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/ATMHud.h b/ATMHud.h index 103165f..a1958d0 100644 --- a/ATMHud.h +++ b/ATMHud.h @@ -68,6 +68,7 @@ typedef enum { @property (nonatomic, assign) BOOL blockTouches; @property (nonatomic, assign) BOOL allowSuperviewInteraction; @property (nonatomic, assign) BOOL autocenter; // YES +@property (nonatomic, assign) BOOL autoBringToFront; // YES @property (nonatomic, retain) NSString *showSound; @property (nonatomic, retain) NSString *updateSound; diff --git a/ATMHud.m b/ATMHud.m index 76b222d..c664ef9 100644 --- a/ATMHud.m +++ b/ATMHud.m @@ -31,6 +31,7 @@ @implementation ATMHud @synthesize showSound, updateSound, hideSound; @synthesize __view, sound, displayQueue, queuePosition; @synthesize autocenter; +@synthesize autoBringToFront; - (id)init { if ((self = [super init])) { @@ -257,6 +258,9 @@ - (void)show { svb.origin.y + svb.size.height / 2); } + if (autoBringToFront) + [self.superView bringSubviewToFront:self.view]; + [__view show]; } @@ -307,6 +311,7 @@ - (void)construct { blockTouches = NO; allowSuperviewInteraction = NO; autocenter = YES; + autoBringToFront = YES; } - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {