[vlc-commits] macosx/tracking view: add API to animate transitions
Felix Paul Kühne
git at videolan.org
Sun Nov 3 19:32:44 CET 2019
vlc | branch: master | Felix Paul Kühne <felix at feepk.net> | Sun Nov 3 19:12:50 2019 +0100| [096145ee1df4fc5ce40ba95daf73efc683678cab] | committer: Felix Paul Kühne
macosx/tracking view: add API to animate transitions
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=096145ee1df4fc5ce40ba95daf73efc683678cab
---
modules/gui/macosx/views/VLCTrackingView.h | 1 +
modules/gui/macosx/views/VLCTrackingView.m | 25 +++++++++++++++++++++++--
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/modules/gui/macosx/views/VLCTrackingView.h b/modules/gui/macosx/views/VLCTrackingView.h
index 2c4a6976ed..c115a7f17c 100644
--- a/modules/gui/macosx/views/VLCTrackingView.h
+++ b/modules/gui/macosx/views/VLCTrackingView.h
@@ -26,6 +26,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface VLCTrackingView : NSView
+ at property (readwrite) BOOL animatesTransition;
@property (readwrite, assign, nullable) NSView *viewToHide;
@end
diff --git a/modules/gui/macosx/views/VLCTrackingView.m b/modules/gui/macosx/views/VLCTrackingView.m
index 01fb4cf7f1..bc07fa830b 100644
--- a/modules/gui/macosx/views/VLCTrackingView.m
+++ b/modules/gui/macosx/views/VLCTrackingView.m
@@ -32,12 +32,33 @@
- (void)mouseExited:(NSEvent *)event
{
- self.viewToHide.hidden = YES;
+ if (self.animatesTransition) {
+ [self.viewToHide setAlphaValue:1.0];
+ __weak typeof(self.viewToHide) weakViewToHide = self.viewToHide;
+ [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){
+ [[NSAnimationContext currentContext] setDuration:0.9];
+ [[weakViewToHide animator] setAlphaValue:0.0];
+ } completionHandler:^{
+ [weakViewToHide setHidden:YES];
+ }];
+ } else {
+ self.viewToHide.hidden = YES;
+ }
}
- (void)mouseEntered:(NSEvent *)event
{
- self.viewToHide.hidden = NO;
+ if (self.animatesTransition) {
+ [self.viewToHide setAlphaValue:.0];
+ [self.viewToHide setHidden:NO];
+ __weak typeof(self.viewToHide) weakViewToHide = self.viewToHide;
+ [NSAnimationContext runAnimationGroup:^(NSAnimationContext *context){
+ [[NSAnimationContext currentContext] setDuration:0.9];
+ [[weakViewToHide animator] setAlphaValue:1.0];
+ } completionHandler:nil];
+ } else {
+ self.viewToHide.hidden = NO;
+ }
}
- (void)updateTrackingAreas
More information about the vlc-commits
mailing list