Commit e9947e6f authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: re-implemented the slower/faster menu items as a logarithmic slider...

macosx: re-implemented the slower/faster menu items as a logarithmic slider similar to the Qt interface
parent 95606ba8
......@@ -26,6 +26,7 @@
#import <vlc_interface.h>
@interface VLCCoreInteraction : NSObject {
int i_currentPlaybackRate;
BOOL b_lockAspectRatio;
}
+ (VLCCoreInteraction *)sharedInstance;
......@@ -35,6 +36,8 @@
- (void)faster;
- (void)slower;
- (void)normalSpeed;
- (void)setPlaybackRate:(int)i_value;
- (int)playbackRate;
- (void)next;
- (void)previous;
- (void)forward;
......
......@@ -29,6 +29,7 @@
#import <vlc_input.h>
#import <vlc_keys.h>
#import <vlc_osd.h>
#import <vlc_aout_intf.h>
@implementation VLCCoreInteraction
static VLCCoreInteraction *_o_sharedInstance = nil;
......@@ -112,6 +113,34 @@ static VLCCoreInteraction *_o_sharedInstance = nil;
var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_RATE_NORMAL );
}
- (void)setPlaybackRate:(int)i_value
{
playlist_t * p_playlist = pl_Get( VLCIntf );
double speed = pow( 2, (double)i_value / 17 );
int rate = INPUT_RATE_DEFAULT / speed;
if( i_currentPlaybackRate != rate )
var_SetFloat( p_playlist, "rate", (float)INPUT_RATE_DEFAULT / (float)rate );
i_currentPlaybackRate = rate;
}
- (int)playbackRate
{
playlist_t * p_playlist = pl_Get( VLCIntf );
float rate = var_GetFloat( p_playlist, "rate" );
double value = 17 * log( rate ) / log( 2. );
int returnValue = (int) ( ( value > 0 ) ? value + .5 : value - .5 );
if( returnValue < -34 )
returnValue = -34;
else if( returnValue > 34 )
returnValue = 34;
i_currentPlaybackRate = returnValue;
return returnValue;
}
- (void)previous
{
var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_PREV );
......
......@@ -74,9 +74,15 @@
IBOutlet NSMenu * o_mu_controls;
IBOutlet NSMenuItem * o_mi_play;
IBOutlet NSMenuItem * o_mi_stop;
IBOutlet NSMenuItem * o_mi_faster;
IBOutlet NSMenuItem * o_mi_slower;
IBOutlet NSMenuItem * o_mi_normalSpeed;
IBOutlet NSMenuItem * o_mi_rate;
IBOutlet NSView * o_mi_rate_view;
IBOutlet id o_mi_rate_lbl;
IBOutlet id o_mi_rate_lbl_gray;
IBOutlet id o_mi_rate_slower_lbl;
IBOutlet id o_mi_rate_normal_lbl;
IBOutlet id o_mi_rate_faster_lbl;
IBOutlet id o_mi_rate_sld;
IBOutlet id o_mi_rate_fld;
IBOutlet NSMenuItem * o_mi_trackSynchronization;
IBOutlet NSMenuItem * o_mi_previous;
IBOutlet NSMenuItem * o_mi_next;
......@@ -189,6 +195,7 @@
- (void)setupMenus;
- (void)refreshVoutDeviceMenu:(NSNotification *)o_notification;
- (void)setSubmenusEnabled:(BOOL)b_enabled;
- (void)setRateControlsEnabled:(BOOL)b_enabled;
- (IBAction)clearRecentItems:(id)sender;
- (void)openRecentItem:(id)item;
......@@ -199,6 +206,8 @@
- (IBAction)intfOpenNet:(id)sender;
- (IBAction)intfOpenCapture:(id)sender;
- (IBAction)setPlaybackRate:(id)sender;
- (IBAction)showWizard:(id)sender;
- (IBAction)showVideoEffects:(id)sender;
- (IBAction)showAudioEffects:(id)sender;
......
......@@ -117,15 +117,6 @@ static VLCMainMenu *_o_sharedInstance = nil;
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-stop" )];
[o_mi_stop setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_stop setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-faster" )];
[o_mi_faster setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_faster setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-slower" )];
[o_mi_slower setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_slower setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-rate-normal" )];
[o_mi_normalSpeed setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_normalSpeed setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
o_key = [NSString stringWithFormat:@"%s", config_GetPsz( p_intf, "key-prev" )];
[o_mi_previous setKeyEquivalent: [o_vlcmain VLCKeyToString: o_key]];
[o_mi_previous setKeyEquivalentModifierMask: [o_vlcmain VLCModifiersToCocoa:o_key]];
......@@ -215,9 +206,12 @@ static VLCMainMenu *_o_sharedInstance = nil;
[o_mu_controls setTitle: _NS("Playback")];
[o_mi_play setTitle: _NS("Play")];
[o_mi_stop setTitle: _NS("Stop")];
[o_mi_faster setTitle: _NS("Faster")];
[o_mi_slower setTitle: _NS("Slower")];
[o_mi_normalSpeed setTitle: _NS("Normal rate")];
[o_mi_rate setView: o_mi_rate_view];
[o_mi_rate_lbl setStringValue: _NS("Playback Speed")];
[o_mi_rate_lbl_gray setStringValue: _NS("Playback Speed")];
[o_mi_rate_slower_lbl setStringValue: _NS("Slower")];
[o_mi_rate_normal_lbl setStringValue: _NS("Normal")];
[o_mi_rate_faster_lbl setStringValue: _NS("Faster")];
[o_mi_trackSynchronization setTitle: _NS("Track Synchronization")];
[o_mi_previous setTitle: _NS("Previous")];
[o_mi_next setTitle: _NS("Next")];
......@@ -464,6 +458,25 @@ static VLCMainMenu *_o_sharedInstance = nil;
[o_mi_teletext setEnabled: b_enabled];
}
- (void)setRateControlsEnabled:(BOOL)b_enabled
{
[o_mi_rate_sld setEnabled: b_enabled];
[o_mi_rate_sld setIntValue: [[VLCCoreInteraction sharedInstance] playbackRate]];
int i = [[VLCCoreInteraction sharedInstance] playbackRate];
if (i == 0)
i = 1;
[o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%ix", i]];
if (b_enabled) {
[o_mi_rate_lbl setHidden: NO];
[o_mi_rate_lbl_gray setHidden: YES];
}
else
{
[o_mi_rate_lbl setHidden: YES];
[o_mi_rate_lbl_gray setHidden: NO];
}
}
#pragma mark -
#pragma mark Recent Items
- (void)openRecentItem:(id)item
......@@ -477,6 +490,18 @@ static VLCMainMenu *_o_sharedInstance = nil;
clearRecentDocuments: nil];
}
#pragma mark -
#pragma mark Playback
- (IBAction)setPlaybackRate:(id)sender
{
[[VLCCoreInteraction sharedInstance] setPlaybackRate: [o_mi_rate_sld intValue]];
int i = [[VLCCoreInteraction sharedInstance] playbackRate];
if (i == 0)
i = 1;
[o_mi_rate_fld setStringValue: [NSString stringWithFormat:@"%ix", i]];
}
#pragma mark -
#pragma mark Panels
......@@ -956,19 +981,6 @@ static VLCMainMenu *_o_sharedInstance = nil;
bEnabled = FALSE;
}
}
else if( [o_title isEqualToString: _NS("Faster")] ||
[o_title isEqualToString: _NS("Slower")] ||
[o_title isEqualToString: _NS("Normal rate")] )
{
if( p_input != NULL )
{
bEnabled = var_GetBool( p_input, "can-rate" );
}
else
{
bEnabled = FALSE;
}
}
else if( [o_title isEqualToString: _NS("Stop")] )
{
if( p_input == NULL )
......
......@@ -1428,6 +1428,7 @@ static void manage_cleanup( void * args )
[o_embedded_window setPrev: (b_plmul || b_chapters)];
[o_btn_next setEnabled: (b_plmul || b_chapters)];
[o_embedded_window setNext: (b_plmul || b_chapters)];
[o_mainmenu setRateControlsEnabled: b_control];
[o_timeslider setFloatValue: 0.0];
[o_timeslider setEnabled: b_seekable];
......
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