* Note:
* the code used to bind with VLC's modules is heavily based upon
* ../wxwidgets/extrapanel.cpp, written by Clément Stenac.
- * the code used to insert/remove the view and resize/remove the other stuff
- * was inspired by intf.m, written by Derk-Jan Hartman.
- * (both are members of the VideoLAN team)
+ * the code used to insert/remove the views was inspired by intf.m,
+ * written by Derk-Jan Hartman and Benjamin Pracht.
+ * (all 3 are members of the VideoLAN team)
*****************************************************************************/
#import "extended.h"
#import "intf.h"
-#import <vlc/vlc.h>
+#import "vout.h"
#import <vlc/aout.h>
#import <aout_internal.h>
#import <vlc/vout.h>
return _o_sharedInstance;
}
+/*****************************************************************************
+ * GUI methods
+ *****************************************************************************/
+
- (void)initStrings
{
/* localise GUI-strings */
/* method is called from intf.m (in method showExtended) */
+ [o_extended_window setTitle: _NS("Extended controls")];
+ [o_lbl_video setStringValue: _NS("Video")];
+ [o_lbl_audio setStringValue: _NS("Audio")];
+ [o_lbl_audioFlts setStringValue: _NS("Audio filters")];
+ [o_lbl_videoFlts setStringValue: _NS("Video filters")];
+ [o_lbl_adjustImage setStringValue: _NS("Adjust Image")];
+ [o_btn_vidFlts_mrInfo setTitle: _NS("More Info")];
+ [o_ckb_blur setTitle: _NS("Blurring")];
+ [o_ckb_blur setToolTip: _NS("Creates a motion blurring on the image")];
+ [o_ckb_distortion setTitle: _NS("Distortion")];
+ [o_ckb_distortion setToolTip: _NS("Adds distorsion effects")];
+ [o_ckb_imgClone setTitle: _NS("Image clone")];
+ [o_ckb_imgClone setToolTip: _NS("Creates several clones of the image")];
+ [o_ckb_imgCrop setTitle: _NS("Image cropping")];
+ [o_ckb_imgCrop setToolTip: _NS("Crops the image")];
+ [o_ckb_imgInvers setTitle: _NS("Image inversion")];
+ [o_ckb_imgInvers setToolTip: _NS("Inverts the image colors")];
+ [o_ckb_trnsform setTitle: _NS("Transformation")];
+ [o_ckb_trnsform setToolTip: _NS("Rotates or flips the image")];
+ [o_ckb_vlme_norm setTitle: _NS("Volume normalization")];
+ [o_ckb_vlme_norm setToolTip: _NS("This filters prevents the audio output " \
+ "power from going over a defined value.")];
+ [o_ckb_hdphnVirt setTitle: _NS("Headphone virtualization")];
+ [o_ckb_hdphnVirt setToolTip: _NS("This filter gives the feeling of a " \
+ "5.1 speaker set when using a headphone.")];
+ [o_lbl_maxLevel setStringValue: _NS("Maximum level")];
+ [o_btn_rstrDefaults setTitle: _NS("Restore Defaults")];
+ [o_ckb_enblAdjustImg setTitle: _NS("Enable")];
+ [o_lbl_brightness setStringValue: _NS("Brightness")];
+ [o_lbl_contrast setStringValue: _NS("Contrast")];
+ [o_lbl_gamma setStringValue: _NS("Gamma")];
+ [o_lbl_hue setStringValue: _NS("Hue")];
+ [o_lbl_saturation setStringValue: _NS("Saturation")];
+ [o_lbl_opaque setStringValue: _NS("Opaqueness")];
+
}
- (void)awakeFromNib
[o_sld_hue setEnabled: NO];
[o_sld_saturation setEnabled: NO];
}
- if( psz_vfilters ) free( psz_vfilters );
+
+ /* set the other video-filter-checkboxes to the correct values */
+ if( psz_vfilters )
+ {
+ [o_ckb_blur setState: (int)strstr( psz_vfilters, "motionblur")];
+ [o_ckb_distortion setState: (int)strstr( psz_vfilters, "distort")];
+ [o_ckb_imgClone setState: (int)strstr( psz_vfilters, "clone")];
+ [o_ckb_imgCrop setState: (int)strstr( psz_vfilters, "crop")];
+ [o_ckb_imgInvers setState: (int)strstr( psz_vfilters, "invert")];
+ [o_ckb_trnsform setState: (int)strstr( psz_vfilters, "transform")];
+
+ free( psz_vfilters );
+ }
+
+ /* set the audio-filter-checkboxes to the values taken from the prefs */
+ char * psz_afilters;
+ psz_afilters = config_GetPsz( p_intf, "audio-filter" );
+ if( psz_afilters )
+ {
+ [o_ckb_hdphnVirt setState: (int)strstr( psz_afilters, "headphone" ) ];
+ [o_ckb_vlme_norm setState: (int)strstr( psz_afilters, "normvol" ) ];
+
+ free( psz_afilters );
+ }
+}
+
+- (void)showPanel
+{
+ /* get the correct slider values from the prefs, in case they were changed
+ * elsewhere */
+ intf_thread_t * p_intf = VLCIntf;
int i_value = config_GetInt( p_intf, "hue" );
if( i_value > 0 && i_value < 360 )
{
[o_sld_hue setIntValue: i_value];
}
-
+
float f_value;
f_value = config_GetFloat( p_intf, "saturation" );
{
[o_sld_saturation setIntValue: (int)(100 * f_value) ];
}
-
+
f_value = config_GetFloat( p_intf, "contrast" );
if( f_value > 0 && f_value < 4 )
{
[o_sld_contrast setIntValue: (int)(100 * f_value) ];
}
-
+
f_value = config_GetFloat( p_intf, "brightness" );
if( f_value > 0 && f_value < 2 )
{
[o_sld_brightness setIntValue: (int)(100 * f_value) ];
}
-
+
f_value = config_GetFloat( p_intf, "gamma" );
if( f_value > 0 && f_value < 10 )
{
[o_sld_gamma setIntValue: (int)(10 * f_value) ];
}
-
-
- /* set the audio-filter-checkboxes to the values taken from the prefs */
- char * psz_afilters;
- psz_afilters = config_GetPsz( p_intf, "audio-filter" );
- if( psz_afilters )
- {
- [o_ckb_hdphnVirt setState: (int)strstr( psz_afilters, "headphone" ) ];
- [o_ckb_vlme_norm setState: (int)strstr( psz_afilters, "normvol" ) ];
- free( psz_afilters );
- }
-}
-- (void)showPanel
-{
+ [o_sld_maxLevel setFloatValue: (config_GetFloat(p_intf, "norm-max-level") \
+ * 10)];
+
+ [o_sld_opaque setFloatValue: (config_GetFloat( p_intf, \
+ "macosx-opaqueness") * 100)];
+
+
/* show the window */
[o_extended_window displayIfNeeded];
[o_extended_window makeKeyAndOrderFront:nil];
[o_sld_gamma setEnabled: YES];
[o_sld_hue setEnabled: YES];
[o_sld_saturation setEnabled: YES];
- [self changeVFiltersString: "adjust" onOrOff: YES];
+ [self changeVFiltersString: "adjust" onOrOff: VLC_TRUE];
}else{
[o_btn_rstrDefaults setEnabled: NO];
[o_sld_brightness setEnabled: NO];
[o_sld_gamma setEnabled: NO];
[o_sld_hue setEnabled: NO];
[o_sld_saturation setEnabled: NO];
- [self changeVFiltersString: "adjust" onOrOff: NO];
+ [self changeVFiltersString: "adjust" onOrOff: VLC_FALSE];
}
}
} else if (sender == o_sld_saturation)
{
config_PutFloat( p_intf , "saturation" , [o_sld_saturation floatValue] / 100);
+ } else {
+ msg_Warn( p_intf, "cannot find adjust-image-subfilter related to " \
+ "moved slider");
}
} else {
vlc_value_t val;
val.f_float = [o_sld_saturation floatValue] / 100;
var_Set( p_vout, "saturation", val );
config_PutFloat( p_intf , "saturation" , [o_sld_saturation floatValue] / 100);
+ } else {
+ msg_Warn( p_intf, "cannot find adjust-image-subfilter related to " \
+ "moved slider");
}
+ vlc_object_release( p_vout );
}
}
+/* change the opaqueness of the vouts */
+- (IBAction)adjImg_opaque:(id)sender
+{
+ vlc_value_t val;
+ id o_window = [NSApp keyWindow];
+ NSArray *o_windows = [NSApp orderedWindows];
+ NSEnumerator *o_enumerator = [o_windows objectEnumerator];
+ playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST, \
+ FIND_ANYWHERE );
+ vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
+ vout_thread_t *p_real_vout;
+
+ val.f_float = [o_sld_opaque floatValue] / 100;
+
+ if( p_vout != NULL )
+ {
+ if( p_vout->i_object_type == VLC_OBJECT_OPENGL )
+ {
+ p_real_vout = (vout_thread_t *) p_vout->p_parent;
+ }
+ else
+ {
+ p_real_vout = p_vout;
+ }
+ var_Set( p_real_vout, "macosx-opaqueness", val );
+
+ while ((o_window = [o_enumerator nextObject]))
+ {
+ if( [[o_window className] isEqualToString: @"VLCWindow"] )
+ {
+ [o_window setAlphaValue: val.f_float];
+ }
+ break;
+ }
+ vlc_object_release( p_vout );
+ }
+
+ /* store to prefs */
+ config_PutFloat( p_playlist , "macosx-opaqueness" , val.f_float );
+
+ vlc_object_release( p_playlist );
+}
+
- (IBAction)audFtls_hdphnVirt:(id)sender
{
/* en-/disable headphone virtualisation */
if ([o_ckb_hdphnVirt state] == NSOnState)
{
- [self changeAFiltersString: "headphone" onOrOff: YES ];
+ [self changeAFiltersString: "headphone" onOrOff: VLC_TRUE ];
}else{
- [self changeAFiltersString: "headphone" onOrOff: NO ];
+ [self changeAFiltersString: "headphone" onOrOff: VLC_FALSE ];
}
}
{
/* move the window contents upwards (partially done through settings
* inside the nib) and resize the window */
- o_win_rect.size.height = o_win_rect.size.height - 151;
- o_win_rect.origin.y = [o_extended_window frame].origin.y + 151;
- o_box_audFlts_rect.origin.y = o_box_audFlts_rect.origin.y + 151;
- o_box_vidFlts_rect.origin.y = o_box_vidFlts_rect.origin.y + 151;
+ o_win_rect.size.height = o_win_rect.size.height - 171;
+ o_win_rect.origin.y = [o_extended_window frame].origin.y + 171;
+ o_box_audFlts_rect.origin.y = o_box_audFlts_rect.origin.y + 171;
+ o_box_vidFlts_rect.origin.y = o_box_vidFlts_rect.origin.y + 171;
/* remove the inserted view */
[o_adjustImg_view removeFromSuperviewWithoutNeedingDisplay];
}else{
/* move the window contents downwards and resize the window */
- o_win_rect.size.height = o_win_rect.size.height + 151;
- o_win_rect.origin.y = [o_extended_window frame].origin.y - 151;
- o_box_audFlts_rect.origin.y = o_box_audFlts_rect.origin.y - 151;
- o_box_vidFlts_rect.origin.y = o_box_vidFlts_rect.origin.y - 151;
+ o_win_rect.size.height = o_win_rect.size.height + 171;
+ o_win_rect.origin.y = [o_extended_window frame].origin.y - 171;
+ o_box_audFlts_rect.origin.y = o_box_audFlts_rect.origin.y - 171;
+ o_box_vidFlts_rect.origin.y = o_box_vidFlts_rect.origin.y - 171;
}
[o_box_audFlts setFrameFromContentFrame: o_box_audFlts_rect];
if (o_adjImg_expanded)
{
- o_box_adjImg_rect.size.height = [o_box_adjImg frame].size.height - 151;
+ o_box_adjImg_rect.size.height = [o_box_adjImg frame].size.height - 171;
+ msg_Dbg( VLCIntf, "collapsed adjust-image section");
o_adjImg_expanded = NO;
} else {
/* insert view */
- o_box_adjImg_rect.size.height = [o_box_adjImg frame].size.height + 151;
- [o_adjustImg_view setFrame: NSMakeRect( 20, -10, 370, 161)];
+ o_box_adjImg_rect.size.height = [o_box_adjImg frame].size.height + 171;
+ [o_adjustImg_view setFrame: NSMakeRect( 20, -10, 370, 181)];
[o_adjustImg_view setNeedsDisplay:YES];
[o_adjustImg_view setAutoresizesSubviews: YES];
[[o_box_adjImg contentView] addSubview: o_adjustImg_view];
+ msg_Dbg( VLCIntf, "expanded adjust-image section");
o_adjImg_expanded = YES;
}
[o_box_adjImg setFrameFromContentFrame: o_box_adjImg_rect];
if (o_audFlts_expanded)
{
o_box_audFlts_rect.size.height = [o_box_audFlts frame].size.height - 66;
+ msg_Dbg( VLCIntf, "collapsed audio-filters section");
o_audFlts_expanded = NO;
} else {
/* insert view */
[o_audioFlts_view setNeedsDisplay:YES];
[o_audioFlts_view setAutoresizesSubviews: YES];
[[o_box_audFlts contentView] addSubview: o_audioFlts_view];
+ msg_Dbg( VLCIntf, "expanded audio-filters section");
o_audFlts_expanded = YES;
}
[o_box_audFlts setFrameFromContentFrame: o_box_audFlts_rect];
if (o_vidFlts_expanded)
{
o_box_vidFlts_rect.size.height = [o_box_vidFlts frame].size.height - 134;
+ msg_Dbg( VLCIntf, "collapsed video-filters section");
o_vidFlts_expanded = NO;
} else {
/* insert view */
[o_videoFilters_view setNeedsDisplay:YES];
[o_videoFilters_view setAutoresizesSubviews: YES];
[[o_box_vidFlts contentView] addSubview: o_videoFilters_view];
+ msg_Dbg( VLCIntf, "expanded video-filters section");
o_vidFlts_expanded = YES;
}
[o_box_vidFlts setFrameFromContentFrame: o_box_vidFlts_rect];
- (IBAction)vidFlts:(id)sender
{
/* en-/disable video filters */
+ if (sender == o_ckb_blur)
+ {
+ [self changeVFiltersString: "motionblur" onOrOff: [o_ckb_blur state]];
+ }
+ else if (sender == o_ckb_distortion)
+ {
+ [self changeVFiltersString: "distort" onOrOff: [o_ckb_distortion state]];
+ }
+ else if (sender == o_ckb_imgClone)
+ {
+ [self changeVFiltersString: "clone" onOrOff: [o_ckb_imgClone state]];
+ }
+ else if (sender == o_ckb_imgCrop)
+ {
+ [self changeVFiltersString: "crop" onOrOff: [o_ckb_imgCrop state]];
+ }
+ else if (sender == o_ckb_imgInvers)
+ {
+ [self changeVFiltersString: "invert" onOrOff: [o_ckb_imgInvers state]];
+ }
+ else if (sender == o_ckb_trnsform)
+ {
+ [self changeVFiltersString: "transform" onOrOff: [o_ckb_trnsform state]];
+ } else {
+ /* this shouldn't happen */
+ msg_Warn (VLCIntf, "cannot find selected video-filter");
+ }
}
- (IBAction)vidFlts_mrInfo:(id)sender
"string (Preferences / Video / Filters)."));
}
-- (void)changeVFiltersString:(char *)psz_name onOrOff:(BOOL)o_onOrOff
+
+/*****************************************************************************
+ * methods to communicate changes to VLC's core
+ *****************************************************************************/
+
+- (void)changeVFiltersString:(char *)psz_name onOrOff:(vlc_bool_t )b_add
{
/* copied from ../wxwidgets/extrapanel.cpp
* renamed to conform with Cocoa's rules */
psz_parser = strstr( psz_string, psz_name );
- if( o_onOrOff )
+ if( b_add )
{
if( !psz_parser )
{
}
free( psz_string );
+
+ [self savePrefs];
}
-- (void)changeAFiltersString: (char *)psz_name onOrOff: (BOOL)o_onOrOff;
+- (void)changeAFiltersString: (char *)psz_name onOrOff: (vlc_bool_t )b_add;
{
char *psz_parser, *psz_string;
intf_thread_t * p_intf = VLCIntf;
psz_parser = strstr( psz_string, psz_name );
- if( o_onOrOff )
+ if( b_add )
{
if( !psz_parser )
{
vlc_object_release( p_aout );
}
free( psz_string );
+
+ [self savePrefs];
+}
+
+- (void)savePrefs
+{
+ /* save the preferences to make sure that our module-changes will up on
+ * next launch again */
+ playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST, \
+ FIND_ANYWHERE );
+ int returnedValue;
+
+ returnedValue = config_SaveConfigFile( p_playlist, NULL);
+ if (returnedValue == 0)
+ {
+ msg_Dbg(p_playlist, "VLCExtended: saved preferences successfully");
+ } else {
+ msg_Dbg(p_playlist, "VLCExtended: error while saving the preferences " \
+ "(%i)" , returnedValue);
+ }
+ vlc_object_release( p_playlist );
+}
+
+
+/*****************************************************************************
+ * delegate method
+ *****************************************************************************/
+
+- (BOOL)applicationShouldTerminate:(NSWindow *)sender
+{
+ /* save the prefs before shutting down */
+ [self savePrefs];
+
+ return YES;
}
@end