Commit 2d476ce7 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: implemented fancy gradient effect for the time slider (fixes #4945)

parent fb51fe1d
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
IBOutlet id o_volume_down_btn; IBOutlet id o_volume_down_btn;
IBOutlet id o_volume_up_btn; IBOutlet id o_volume_up_btn;
IBOutlet id o_time_sld; IBOutlet id o_time_sld;
IBOutlet id o_time_sld_fancygradient_view;
IBOutlet id o_time_fld; IBOutlet id o_time_fld;
IBOutlet id o_progress_bar; IBOutlet id o_progress_bar;
IBOutlet id o_bottombar_view; IBOutlet id o_bottombar_view;
...@@ -111,4 +112,14 @@ ...@@ -111,4 +112,14 @@
- (void)setRepeatOff; - (void)setRepeatOff;
- (void)setShuffle; - (void)setShuffle;
- (void)drawFancyGradientEffectForTimeSlider;
@end
@interface VLCProgressBarGradientEffect : NSView {
NSImage * o_time_sld_gradient_left_img;
NSImage * o_time_sld_gradient_middle_img;
NSImage * o_time_sld_gradient_right_img;
}
- (void)loadImagesInDarkStyle:(BOOL)b_value;
@end @end
\ No newline at end of file
...@@ -149,6 +149,7 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -149,6 +149,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_effects_btn setAlternateImage: [NSImage imageNamed:@"effects-double-buttons-pressed"]]; [o_effects_btn setAlternateImage: [NSImage imageNamed:@"effects-double-buttons-pressed"]];
[o_fullscreen_btn setImage: [NSImage imageNamed:@"fullscreen-double-buttons"]]; [o_fullscreen_btn setImage: [NSImage imageNamed:@"fullscreen-double-buttons"]];
[o_fullscreen_btn setAlternateImage: [NSImage imageNamed:@"fullscreen-double-buttons-pressed"]]; [o_fullscreen_btn setAlternateImage: [NSImage imageNamed:@"fullscreen-double-buttons-pressed"]];
[o_time_sld_fancygradient_view loadImagesInDarkStyle:NO];
} }
else else
{ {
...@@ -186,7 +187,8 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -186,7 +187,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_effects_btn setImage: [NSImage imageNamed:@"effects-double-buttons_dark"]]; [o_effects_btn setImage: [NSImage imageNamed:@"effects-double-buttons_dark"]];
[o_effects_btn setAlternateImage: [NSImage imageNamed:@"effects-double-buttons-pressed_dark"]]; [o_effects_btn setAlternateImage: [NSImage imageNamed:@"effects-double-buttons-pressed_dark"]];
[o_fullscreen_btn setImage: [NSImage imageNamed:@"fullscreen-double-buttons_dark"]]; [o_fullscreen_btn setImage: [NSImage imageNamed:@"fullscreen-double-buttons_dark"]];
[o_fullscreen_btn setAlternateImage: [NSImage imageNamed:@"fullscreen-double-buttons-pressed_dark"]]; [o_fullscreen_btn setAlternateImage: [NSImage imageNamed:@"fullscreen-double-buttons-pressed_dark"]];
[o_time_sld_fancygradient_view loadImagesInDarkStyle:YES];
} }
[o_repeat_btn setImage: o_repeat_img]; [o_repeat_btn setImage: o_repeat_img];
[o_repeat_btn setAlternateImage: o_repeat_pressed_img]; [o_repeat_btn setAlternateImage: o_repeat_pressed_img];
...@@ -205,6 +207,7 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -205,6 +207,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_playlist_btn setEnabled:NO]; [o_playlist_btn setEnabled:NO];
[self updateVolumeSlider]; [self updateVolumeSlider];
[self updateTimeSlider];
} }
#pragma mark - #pragma mark -
...@@ -423,6 +426,7 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -423,6 +426,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
[[[[VLCMain sharedInstance] controls] fspanel] setStreamPos: f_updated andTime: o_time]; [[[[VLCMain sharedInstance] controls] fspanel] setStreamPos: f_updated andTime: o_time];
vlc_object_release( p_input ); vlc_object_release( p_input );
} }
[self drawFancyGradientEffectForTimeSlider];
} }
- (IBAction)timeFieldWasClicked:(id)sender - (IBAction)timeFieldWasClicked:(id)sender
...@@ -483,6 +487,13 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -483,6 +487,13 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_time_fld setStringValue: o_time]; [o_time_fld setStringValue: o_time];
// [[[[VLCMain sharedInstance] controls] fspanel] setStreamPos: f_updated andTime: o_time]; // [[[[VLCMain sharedInstance] controls] fspanel] setStreamPos: f_updated andTime: o_time];
} }
else
{
[o_time_sld setFloatValue: 0.0];
[o_time_fld setStringValue: @"00:00"];
}
[self performSelectorOnMainThread:@selector(drawFancyGradientEffectForTimeSlider) withObject:nil waitUntilDone:NO];
} }
- (void)updateVolumeSlider - (void)updateVolumeSlider
...@@ -630,6 +641,25 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -630,6 +641,25 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_play_btn setToolTip: _NS("Play")]; [o_play_btn setToolTip: _NS("Play")];
} }
- (void)drawFancyGradientEffectForTimeSlider
{
float f_value = ([o_time_sld_middle_view frame].size.width -5) * ([o_time_sld intValue] / [o_time_sld maxValue]);
if (f_value > 5.0)
{
if (f_value != [o_time_sld_fancygradient_view frame].size.width)
{
[o_time_sld_fancygradient_view setHidden: NO];
[o_time_sld_fancygradient_view setFrame: NSMakeRect( [o_time_sld_fancygradient_view frame].origin.x, [o_time_sld_fancygradient_view frame].origin.y, f_value, [o_time_sld_fancygradient_view frame].size.height )];
[o_time_sld_fancygradient_view setNeedsDisplay:YES];
[o_time_sld_fancygradient_view displayIfNeeded];
}
}
else
{
[o_time_sld_fancygradient_view setHidden: YES];
}
}
#pragma mark - #pragma mark -
#pragma mark Video Output handling #pragma mark Video Output handling
...@@ -653,3 +683,27 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -653,3 +683,27 @@ static VLCMainWindow *_o_sharedInstance = nil;
} }
@end @end
@implementation VLCProgressBarGradientEffect
- (void)loadImagesInDarkStyle: (BOOL)b_value
{
if (b_value)
{
o_time_sld_gradient_left_img = [NSImage imageNamed:@"progressbar-fill-left_dark"];
o_time_sld_gradient_middle_img = [NSImage imageNamed:@"progressbar-fill-middle_dark"];
o_time_sld_gradient_right_img = [NSImage imageNamed:@"progressbar-fill-right_dark"];
}
else
{
o_time_sld_gradient_left_img = [NSImage imageNamed:@"progression-fill-left"];
o_time_sld_gradient_middle_img = [NSImage imageNamed:@"progression-fill-middle"];
o_time_sld_gradient_right_img = [NSImage imageNamed:@"progression-fill-right"];
}
}
- (void)drawRect:(NSRect)rect
{
NSRect bnds = [self bounds];
NSDrawThreePartImage( bnds, o_time_sld_gradient_left_img, o_time_sld_gradient_middle_img, o_time_sld_gradient_right_img, NO, NSCompositeSourceOver, 1, NO );
}
@end
...@@ -278,6 +278,7 @@ static int InputEvent( vlc_object_t *p_this, const char *psz_var, ...@@ -278,6 +278,7 @@ static int InputEvent( vlc_object_t *p_this, const char *psz_var,
case INPUT_EVENT_ITEM_NAME: case INPUT_EVENT_ITEM_NAME:
[[VLCMain sharedInstance] updateName]; [[VLCMain sharedInstance] updateName];
[[VLCMain sharedInstance] playlistUpdated];
break; break;
case INPUT_EVENT_AUDIO_DELAY: case INPUT_EVENT_AUDIO_DELAY:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment