macosx: Update VLCControlsBarCommon to use new VLCSlider
authorMarvin Scholz <epirat07@gmail.com>
Tue, 18 Jul 2017 01:02:52 +0000 (03:02 +0200)
committerMarvin Scholz <epirat07@gmail.com>
Tue, 18 Jul 2017 19:51:21 +0000 (21:51 +0200)
modules/gui/macosx/VLCControlsBarCommon.h
modules/gui/macosx/VLCControlsBarCommon.m

index 18a55f1..ed4820d 100644 (file)
@@ -26,6 +26,7 @@
 #import "misc.h"
 
 #import "VLCTimeField.h"
+#import "VLCSlider.h"
 
 /*****************************************************************************
  * VLCControlsBarCommon
@@ -43,7 +44,7 @@
 @property (readwrite, strong) IBOutlet NSButton *forwardButton;
 
 @property (readwrite, strong) IBOutlet VLCProgressView *progressView;
-@property (readwrite, strong) IBOutlet TimeLineSlider *timeSlider;
+@property (readwrite, strong) IBOutlet VLCSlider *timeSlider;
 @property (readwrite, strong) IBOutlet VLCThreePartImageView *timeSliderGradientView;
 @property (readwrite, strong) IBOutlet VLCThreePartImageView *timeSliderBackgroundView;
 @property (readwrite, strong) IBOutlet NSProgressIndicator *progressBar;
@@ -67,7 +68,6 @@
 - (IBAction)fullscreen:(id)sender;
 
 - (void)updateTimeSlider;
-- (void)drawFancyGradientEffectForTimeSlider;
 - (void)updateControls;
 - (void)setPause;
 - (void)setPlay;
index 642a1cc..3fa2009 100644 (file)
 {
     input_thread_t * p_input;
     p_input = pl_CurrentInput(getIntf());
-    if (p_input) {
-        NSString * o_time;
-        vlc_value_t pos;
-        float f_updated;
 
-        var_Get(p_input, "position", &pos);
-        f_updated = 10000. * pos.f_float;
-        [self.timeSlider setFloatValue: f_updated];
+    [self.timeSlider setHidden:NO];
 
-        o_time = [[VLCStringUtility sharedInstance] getCurrentTimeAsString: p_input negative:[self.timeField timeRemaining]];
-
-        mtime_t dur = input_item_GetDuration(input_GetItem(p_input));
-        if (dur == -1) {
-            [self.timeSlider setHidden: YES];
-            [self.timeSliderGradientView setHidden: YES];
-        } else {
-            if ([self.timeSlider isHidden] == YES) {
-                bool b_buffering = false;
-                input_state_e inputState = input_GetState(p_input);
-                if (inputState == INIT_S || inputState == OPENING_S)
-                    b_buffering = YES;
-
-                [self.timeSlider setHidden: b_buffering];
-                [self.timeSliderGradientView setHidden: b_buffering];
-            }
-        }
-        [self.timeField setStringValue: o_time];
-        [self.timeField setNeedsDisplay:YES];
-
-        vlc_object_release(p_input);
-    } else {
+    if (!p_input) {
+        // Nothing playing
         [self.timeSlider setFloatValue: 0.0];
         [self.timeField setStringValue: @"00:00"];
-        [self.timeSlider setHidden: YES];
-        [self.timeSliderGradientView setHidden: YES];
+        [self.timeSlider setIndefinite:NO];
+        [self.timeSlider setEnabled:NO];
+        return;
     }
-}
 
-- (void)drawFancyGradientEffectForTimeSlider
-{
-    CGFloat f_value = [self.timeSlider knobPosition];
-    if (f_value > 7.5) {
-        NSRect oldFrame = [self.timeSliderGradientView frame];
-        if (f_value != oldFrame.size.width) {
-            if ([self.timeSliderGradientView isHidden])
-                [self.timeSliderGradientView setHidden: NO];
-            [self.timeSliderGradientView setFrame: NSMakeRect(oldFrame.origin.x, oldFrame.origin.y, f_value, oldFrame.size.height)];
-        }
+    vlc_value_t pos;
+    var_Get(p_input, "position", &pos);
+    [self.timeSlider setFloatValue:(10000. * pos.f_float)];
+
+    mtime_t dur = input_item_GetDuration(input_GetItem(p_input));
+    if (dur == -1) {
+        // No duration, disable slider
+        [self.timeSlider setEnabled:NO];
     } else {
-        NSRect frame;
-        frame = [self.timeSliderGradientView frame];
-        if (frame.size.width > 0) {
-            frame.size.width = 0;
-            [self.timeSliderGradientView setFrame: frame];
-        }
-        [self.timeSliderGradientView setHidden: YES];
+        input_state_e inputState = input_GetState(p_input);
+        bool buffering = (inputState == INIT_S || inputState == OPENING_S);
+        [self.timeSlider setIndefinite:buffering];
     }
+
+    NSString *time = [[VLCStringUtility sharedInstance] getCurrentTimeAsString:p_input
+                                                                      negative:[self.timeField timeRemaining]];
+    [self.timeField setStringValue:time];
+    [self.timeField setNeedsDisplay:YES];
+
+    vlc_object_release(p_input);
 }
 
 - (void)updateControls
         vlc_object_release(p_input);
     }
 
-    if (b_buffering) {
-        [self.progressBar startAnimation:self];
-        [self.progressBar setIndeterminate:YES];
-        [self.progressBar setHidden:NO];
-    } else {
-        [self.progressBar stopAnimation:self];
-        [self.progressBar setHidden:YES];
-    }
-
     [self.timeSlider setEnabled: b_seekable];
 
     [self.forwardButton setEnabled: (b_seekable || b_plmul || b_chapters)];