Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

extended.m

00001 /*****************************************************************************
00002  * extended.m: MacOS X Extended interface panel
00003  *****************************************************************************
00004  * Copyright (C) 2005 the VideoLAN team
00005  * $Id: extended.m 12767 2005-10-06 16:45:21Z fkuehne $
00006  *
00007  * Authors: Felix Kühne <[email protected]>
00008  *
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00022  *****************************************************************************/
00023 
00024 
00025 /*****************************************************************************
00026  * Note: 
00027  * the code used to bind with VLC's modules is heavily based upon 
00028  * ../wxwidgets/extrapanel.cpp, written by Clément Stenac.
00029  * the code used to insert/remove the views was inspired by intf.m, 
00030  * written by Derk-Jan Hartman and Benjamin Pracht. 
00031  * (all 3 are members of the VideoLAN team) 
00032  *****************************************************************************/
00033 
00034 
00035 /*****************************************************************************
00036  * Preamble
00037  *****************************************************************************/
00038 
00039 #import "extended.h"
00040 #import "intf.h"
00041 #import "vout.h"
00042 #import <vlc/aout.h>
00043 #import <aout_internal.h>
00044 #import <vlc/vout.h>
00045 #import <vlc/intf.h>
00046 
00047 /*****************************************************************************
00048  * VLCExtended implementation
00049  *****************************************************************************/
00050 
00051 @implementation VLCExtended
00052 
00053 static VLCExtended *_o_sharedInstance = nil;
00054 
00055 + (VLCExtended *)sharedInstance
00056 {
00057     return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
00058 }
00059 
00060 - (id)init
00061 {
00062     if (_o_sharedInstance) {
00063         [self dealloc];
00064     } else {
00065         _o_sharedInstance = [super init];
00066     }
00067 
00068     return _o_sharedInstance;
00069 }
00070 
00071 /*****************************************************************************
00072  * GUI methods
00073  *****************************************************************************/
00074 
00075 - (void)initStrings
00076 {
00077     /* localise GUI-strings */
00078     /* method is called from intf.m (in method showExtended) */
00079     [o_extended_window setTitle: _NS("Extended controls")];
00080     [o_lbl_video setStringValue: _NS("Video")];
00081     [o_lbl_audio setStringValue: _NS("Audio")];
00082     [o_lbl_audioFlts setStringValue: _NS("Audio filters")];
00083     [o_lbl_videoFlts setStringValue: _NS("Video filters")];
00084     [o_lbl_adjustImage setStringValue: _NS("Adjust Image")];
00085     [o_btn_vidFlts_mrInfo setTitle: _NS("More Info")];
00086     [o_ckb_blur setTitle: _NS("Blurring")];
00087     [o_ckb_blur setToolTip: _NS("Creates a motion blurring on the image")];
00088     [o_ckb_distortion setTitle: _NS("Distortion")];
00089     [o_ckb_distortion setToolTip: _NS("Adds distorsion effects")];
00090     [o_ckb_imgClone setTitle: _NS("Image clone")];
00091     [o_ckb_imgClone setToolTip: _NS("Creates several clones of the image")];
00092     [o_ckb_imgCrop setTitle: _NS("Image cropping")];
00093     [o_ckb_imgCrop setToolTip: _NS("Crops the image")];
00094     [o_ckb_imgInvers setTitle: _NS("Image inversion")];
00095     [o_ckb_imgInvers setToolTip: _NS("Inverts the image colors")];
00096     [o_ckb_trnsform setTitle: _NS("Transformation")];
00097     [o_ckb_trnsform setToolTip: _NS("Rotates or flips the image")];
00098     [o_ckb_vlme_norm setTitle: _NS("Volume normalization")];
00099     [o_ckb_vlme_norm setToolTip: _NS("This filters prevents the audio output " \
00100         "power from going over a defined value.")];
00101     [o_ckb_hdphnVirt setTitle: _NS("Headphone virtualization")];
00102     [o_ckb_hdphnVirt setToolTip: _NS("This filter gives the feeling of a " \
00103         "5.1 speaker set when using a headphone.")];
00104     [o_lbl_maxLevel setStringValue: _NS("Maximum level")];
00105     [o_btn_rstrDefaults setTitle: _NS("Restore Defaults")];
00106     [o_ckb_enblAdjustImg setTitle: _NS("Enable")];
00107     [o_lbl_brightness setStringValue: _NS("Brightness")];
00108     [o_lbl_contrast setStringValue: _NS("Contrast")];
00109     [o_lbl_gamma setStringValue: _NS("Gamma")];
00110     [o_lbl_hue setStringValue: _NS("Hue")];
00111     [o_lbl_saturation setStringValue: _NS("Saturation")];
00112     [o_lbl_opaque setStringValue: _NS("Opaqueness")];
00113     
00114 }
00115 
00116 - (void)awakeFromNib
00117 {
00118     /* set the adjust-filter-sliders to the values from the prefs and enable
00119      * them, if wanted */
00120     char * psz_vfilters;
00121     intf_thread_t * p_intf = VLCIntf;
00122     psz_vfilters = config_GetPsz( p_intf, "vout-filter" );
00123     if( psz_vfilters && strstr( psz_vfilters, "adjust" ) )
00124     {
00125         [o_ckb_enblAdjustImg setState: NSOnState];
00126         [o_btn_rstrDefaults setEnabled: YES];
00127         [o_sld_brightness setEnabled: YES];
00128         [o_sld_contrast setEnabled: YES];
00129         [o_sld_gamma setEnabled: YES];
00130         [o_sld_hue setEnabled: YES];
00131         [o_sld_saturation setEnabled: YES];
00132     }
00133     else
00134     {
00135         [o_ckb_enblAdjustImg setState: NSOffState];
00136         [o_btn_rstrDefaults setEnabled: NO];
00137         [o_sld_brightness setEnabled: NO];
00138         [o_sld_contrast setEnabled: NO];
00139         [o_sld_gamma setEnabled: NO];
00140         [o_sld_hue setEnabled: NO];
00141         [o_sld_saturation setEnabled: NO];
00142     }
00143     
00144     /* set the other video-filter-checkboxes to the correct values */
00145     if( psz_vfilters )
00146     {
00147         [o_ckb_blur setState: (int)strstr( psz_vfilters, "motionblur")];
00148         [o_ckb_distortion setState: (int)strstr( psz_vfilters, "distort")];
00149         [o_ckb_imgClone setState: (int)strstr( psz_vfilters, "clone")];
00150         [o_ckb_imgCrop setState: (int)strstr( psz_vfilters, "crop")];
00151         [o_ckb_imgInvers setState: (int)strstr( psz_vfilters, "invert")];
00152         [o_ckb_trnsform setState: (int)strstr( psz_vfilters, "transform")];
00153         
00154         free( psz_vfilters );
00155     }
00156     
00157     /* set the audio-filter-checkboxes to the values taken from the prefs */
00158     char * psz_afilters;
00159     psz_afilters = config_GetPsz( p_intf, "audio-filter" );
00160     if( psz_afilters )
00161     {
00162         [o_ckb_hdphnVirt setState: (int)strstr( psz_afilters, "headphone" ) ];
00163         [o_ckb_vlme_norm setState: (int)strstr( psz_afilters, "normvol" ) ];
00164         
00165         free( psz_afilters );
00166     }
00167 }
00168 
00169 - (void)collapsAll
00170 {
00171     /* collaps all views so Cocoa saves the window position correctly */
00172     if( o_adjImg_expanded )
00173     {
00174         [self extWin_exp_adjImg: nil];
00175     }
00176     if( o_audFlts_expanded )
00177     {
00178         [self extWin_exp_audFlts: nil];
00179     }
00180     if( o_vidFlts_expanded )
00181     {
00182         [self extWin_exp_vidFlts: nil];
00183     }
00184 }
00185 
00186 - (BOOL)getConfigChanged
00187 {
00188     return o_config_changed;
00189 }
00190 
00191 - (void)showPanel
00192 {
00193     /* get the correct slider values from the prefs, in case they were changed
00194      * elsewhere */
00195     intf_thread_t * p_intf = VLCIntf;
00196 
00197     int i_value = config_GetInt( p_intf, "hue" );
00198     if( i_value > 0 && i_value < 360 )
00199     {
00200         [o_sld_hue setIntValue: i_value];
00201     }
00202 
00203     float f_value;
00204     
00205     f_value = config_GetFloat( p_intf, "saturation" );
00206     if( f_value > 0 && f_value < 5 )
00207     {
00208         [o_sld_saturation setIntValue: (int)(100 * f_value) ];
00209     }
00210 
00211     f_value = config_GetFloat( p_intf, "contrast" );
00212     if( f_value > 0 && f_value < 4 )
00213     {
00214         [o_sld_contrast setIntValue: (int)(100 * f_value) ];
00215     }
00216 
00217     f_value = config_GetFloat( p_intf, "brightness" );
00218     if( f_value > 0 && f_value < 2 )
00219     {
00220         [o_sld_brightness setIntValue: (int)(100 * f_value) ];
00221     }
00222 
00223     f_value = config_GetFloat( p_intf, "gamma" );
00224     if( f_value > 0 && f_value < 10 )
00225     {
00226         [o_sld_gamma setIntValue: (int)(10 * f_value) ];
00227     }
00228 
00229     f_value = config_GetFloat( p_intf, "norm-max-level" );
00230     if( f_value > 0 && f_value < 10 )
00231     {
00232         [o_sld_maxLevel setFloatValue: f_value ];
00233     }
00234 
00235     [o_sld_opaque setFloatValue: (config_GetFloat( p_intf, \
00236         "macosx-opaqueness") * 100)];
00237 
00238 
00239     /* show the window */
00240     [o_extended_window displayIfNeeded];
00241     [o_extended_window makeKeyAndOrderFront:nil];
00242 }
00243 
00244 - (IBAction)adjImg_Enbl:(id)sender
00245 {
00246     /* en-/disable the sliders */
00247     if ([o_ckb_enblAdjustImg state] == NSOnState)
00248     {
00249         [o_btn_rstrDefaults setEnabled: YES];
00250         [o_sld_brightness setEnabled: YES];
00251         [o_sld_contrast setEnabled: YES];
00252         [o_sld_gamma setEnabled: YES];
00253         [o_sld_hue setEnabled: YES];
00254         [o_sld_saturation setEnabled: YES];
00255         [self changeVFiltersString: "adjust" onOrOff: VLC_TRUE];
00256     }else{
00257         [o_btn_rstrDefaults setEnabled: NO];
00258         [o_sld_brightness setEnabled: NO];
00259         [o_sld_contrast setEnabled: NO];
00260         [o_sld_gamma setEnabled: NO];
00261         [o_sld_hue setEnabled: NO];
00262         [o_sld_saturation setEnabled: NO];
00263         [self changeVFiltersString: "adjust" onOrOff: VLC_FALSE];
00264     }
00265 }
00266 
00267 - (IBAction)adjImg_rstrDefaults:(id)sender
00268 {
00269     /* reset the sliders */
00270     [o_sld_brightness setIntValue: 100];
00271     [o_sld_contrast setIntValue: 100];
00272     [o_sld_gamma setIntValue: 10];
00273     [o_sld_hue setIntValue: 0];
00274     [o_sld_saturation setIntValue: 100];
00275     
00276     /* transmit the values */
00277     [self adjImg_sliders: o_sld_brightness];
00278     [self adjImg_sliders: o_sld_contrast];
00279     [self adjImg_sliders: o_sld_gamma];
00280     [self adjImg_sliders: o_sld_hue];
00281     [self adjImg_sliders: o_sld_saturation];
00282 }
00283 
00284 - (IBAction)adjImg_sliders:(id)sender
00285 {
00286     /* read-out the sliders' values and apply them */
00287     intf_thread_t * p_intf = VLCIntf;
00288     vout_thread_t *p_vout = (vout_thread_t *)vlc_object_find(p_intf,
00289                                  VLC_OBJECT_VOUT, FIND_ANYWHERE);
00290     if( p_vout == NULL )
00291     {
00292         if (sender == o_sld_brightness)
00293         {
00294             config_PutFloat( p_intf , "brightness" , [o_sld_brightness floatValue] / 100);
00295         } else if (sender == o_sld_contrast)
00296         {
00297             config_PutFloat( p_intf , "contrast" , [o_sld_contrast floatValue] / 100);
00298         } else if (sender == o_sld_gamma)
00299         {
00300             config_PutFloat( p_intf , "gamma" , [o_sld_gamma floatValue] / 10);
00301         } else if (sender == o_sld_hue)
00302         {
00303             config_PutInt( p_intf , "hue" , [o_sld_hue intValue]);
00304         } else if (sender == o_sld_saturation)
00305         {
00306             config_PutFloat( p_intf , "saturation" , [o_sld_saturation floatValue] / 100);
00307         } else {
00308             msg_Warn( p_intf, "cannot find adjust-image-subfilter related to " \
00309                 "moved slider");
00310         }
00311     } else {
00312         vlc_value_t val;
00313         if (sender == o_sld_brightness)
00314         {
00315             val.f_float = [o_sld_brightness floatValue] / 100;
00316             var_Set( p_vout, "brightness", val );
00317             config_PutFloat( p_intf , "brightness" , [o_sld_brightness floatValue] / 100);
00318         } else if (sender == o_sld_contrast)
00319         {
00320             val.f_float = [o_sld_contrast floatValue] / 100;
00321             var_Set( p_vout, "contrast", val );
00322             config_PutFloat( p_intf , "contrast" , [o_sld_contrast floatValue] / 100);
00323         } else if (sender == o_sld_gamma)
00324         {
00325             val.f_float = [o_sld_gamma floatValue] / 10;
00326             var_Set( p_vout, "gamma", val );
00327             config_PutFloat( p_intf , "gamma" , [o_sld_gamma floatValue] / 10);
00328         } else if (sender == o_sld_hue)
00329         {
00330             val.i_int = [o_sld_hue intValue];
00331             var_Set( p_vout, "hue", val );
00332             config_PutInt( p_intf , "hue" , [o_sld_hue intValue]);
00333         } else if (sender == o_sld_saturation)
00334         {
00335             val.f_float = [o_sld_saturation floatValue] / 100;
00336             var_Set( p_vout, "saturation", val );
00337             config_PutFloat( p_intf , "saturation" , [o_sld_saturation floatValue] / 100);
00338         } else {
00339             msg_Warn( p_intf, "cannot find adjust-image-subfilter related to " \
00340                 "moved slider");
00341         }
00342         vlc_object_release( p_vout );
00343     }
00344 
00345     o_config_changed = YES;
00346 }
00347 
00348 /* change the opaqueness of the vouts */
00349 - (IBAction)adjImg_opaque:(id)sender
00350 {
00351     vlc_value_t val;
00352     id o_window = [NSApp keyWindow];
00353     NSArray *o_windows = [NSApp orderedWindows];
00354     NSEnumerator *o_enumerator = [o_windows objectEnumerator];
00355     playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST, \
00356         FIND_ANYWHERE );
00357     vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
00358     vout_thread_t *p_real_vout;
00359     
00360     val.f_float = [o_sld_opaque floatValue] / 100;
00361 
00362     if( p_vout != NULL )
00363     {
00364         if( p_vout->i_object_type == VLC_OBJECT_OPENGL )
00365         {
00366             p_real_vout = (vout_thread_t *) p_vout->p_parent;
00367         }
00368         else
00369         {
00370             p_real_vout = p_vout;
00371         }
00372         var_Set( p_real_vout, "macosx-opaqueness", val );
00373     
00374         while ((o_window = [o_enumerator nextObject]))
00375         {
00376             if( [[o_window className] isEqualToString: @"VLCWindow"] )
00377             {
00378                 [o_window setAlphaValue: val.f_float];
00379             }
00380             break;
00381         }
00382         vlc_object_release( p_vout );
00383     }
00384     
00385     /* store to prefs */
00386     config_PutFloat( p_playlist , "macosx-opaqueness" , val.f_float );
00387     
00388     vlc_object_release( p_playlist );
00389 
00390     o_config_changed = YES;
00391 }
00392 
00393 - (IBAction)audFtls_hdphnVirt:(id)sender
00394 {
00395     /* en-/disable headphone virtualisation */
00396     if ([o_ckb_hdphnVirt state] == NSOnState)
00397     {
00398         [self changeAFiltersString: "headphone_channel_mixer" onOrOff: VLC_TRUE ];
00399     }else{
00400         [self changeAFiltersString: "headphone_channel_mixer" onOrOff: VLC_FALSE ];
00401     }
00402 }
00403 
00404 - (IBAction)audFtls_maxLevelSld:(id)sender
00405 {
00406     /* read-out the slider's value and apply it */
00407     intf_thread_t * p_intf = VLCIntf;
00408     aout_instance_t * p_aout= (aout_instance_t *)vlc_object_find(p_intf,
00409                                  VLC_OBJECT_AOUT, FIND_ANYWHERE);
00410     if( p_aout != NULL )
00411     {
00412         var_SetFloat( p_aout, "norm-max-level", [o_sld_maxLevel floatValue] );
00413         vlc_object_release( p_aout );
00414     }
00415     config_PutFloat( p_intf, "norm-max-level", [o_sld_maxLevel floatValue] );
00416 
00417     o_config_changed = YES;
00418 }
00419 
00420 - (IBAction)audFtls_vlmeNorm:(id)sender
00421 {
00422     /* en-/disable volume normalisation */
00423     if ([o_ckb_vlme_norm state] == NSOnState)
00424     {
00425         [self changeAFiltersString: "normvol" onOrOff: YES ];
00426     }else{
00427         [self changeAFiltersString: "normvol" onOrOff: NO ];
00428     }
00429 }
00430 
00431 - (IBAction)extWin_exp_adjImg:(id)sender
00432 {
00433     /* expand or collapse adjImg */
00434     NSRect o_win_rect = [o_extended_window frame];
00435     NSRect o_box_audFlts_rect = [o_box_audFlts frame];
00436     NSRect o_box_vidFlts_rect = [o_box_vidFlts frame];
00437     NSRect o_box_adjImg_rect = [o_box_adjImg frame];
00438     
00439     if (o_adjImg_expanded)
00440     {
00441         /* move the window contents upwards (partially done through settings
00442          * inside the nib) and resize the window */
00443         o_win_rect.size.height = o_win_rect.size.height - 171;
00444         o_win_rect.origin.y = [o_extended_window frame].origin.y + 171;
00445         o_box_audFlts_rect.origin.y = o_box_audFlts_rect.origin.y + 171;
00446         o_box_vidFlts_rect.origin.y = o_box_vidFlts_rect.origin.y + 171;
00447         
00448         /* remove the inserted view */
00449         [o_adjustImg_view removeFromSuperviewWithoutNeedingDisplay];
00450     }else{
00451     
00452         /* move the window contents downwards and resize the window */
00453         o_win_rect.size.height = o_win_rect.size.height + 171;
00454         o_win_rect.origin.y = [o_extended_window frame].origin.y - 171;
00455         o_box_audFlts_rect.origin.y = o_box_audFlts_rect.origin.y - 171;
00456         o_box_vidFlts_rect.origin.y = o_box_vidFlts_rect.origin.y - 171;
00457     }
00458     
00459     [o_box_audFlts setFrameFromContentFrame: o_box_audFlts_rect];
00460     [o_box_vidFlts setFrameFromContentFrame: o_box_vidFlts_rect];
00461     [o_extended_window displayIfNeeded];
00462     [o_extended_window setFrame: o_win_rect display:YES animate: YES];
00463     
00464     if (o_adjImg_expanded)
00465     {
00466         o_box_adjImg_rect.size.height = [o_box_adjImg frame].size.height - 171;
00467         msg_Dbg( VLCIntf, "collapsed adjust-image section");
00468         o_adjImg_expanded = NO;
00469     } else {
00470         /* insert view */
00471         o_box_adjImg_rect.size.height = [o_box_adjImg frame].size.height + 171;
00472         [o_adjustImg_view setFrame: NSMakeRect( 20, -10, 370, 181)];
00473         [o_adjustImg_view setNeedsDisplay:YES];
00474         [o_adjustImg_view setAutoresizesSubviews: YES];
00475         [[o_box_adjImg contentView] addSubview: o_adjustImg_view];
00476         msg_Dbg( VLCIntf, "expanded adjust-image section");
00477         o_adjImg_expanded = YES;
00478     }
00479     [o_box_adjImg setFrameFromContentFrame: o_box_adjImg_rect];
00480 }
00481 
00482 - (IBAction)extWin_exp_audFlts:(id)sender
00483 {
00484     /* expand or collapse audFlts */
00485     NSRect o_win_rect = [o_extended_window frame];
00486     NSRect o_box_audFlts_rect = [o_box_audFlts frame];
00487     
00488     if (o_audFlts_expanded)
00489     {
00490         /* move the window contents upwards (partially done through settings
00491          * inside the nib) and resize the window */
00492         o_win_rect.size.height = o_win_rect.size.height - 66;
00493         o_win_rect.origin.y = [o_extended_window frame].origin.y + 66;
00494         
00495         /* remove the inserted view */
00496         [o_audioFlts_view removeFromSuperviewWithoutNeedingDisplay];
00497     }else{
00498         /* move the window contents downwards and resize the window */
00499         o_win_rect.size.height = o_win_rect.size.height + 66;
00500         o_win_rect.origin.y = [o_extended_window frame].origin.y - 66;
00501     }
00502     [o_extended_window displayIfNeeded];
00503     [o_extended_window setFrame: o_win_rect display:YES animate: YES];
00504     
00505     
00506     if (o_audFlts_expanded)
00507     {
00508         o_box_audFlts_rect.size.height = [o_box_audFlts frame].size.height - 66;
00509         msg_Dbg( VLCIntf, "collapsed audio-filters section");
00510         o_audFlts_expanded = NO;
00511     } else {
00512         /* insert view */
00513         o_box_audFlts_rect.size.height = [o_box_audFlts frame].size.height + 66;
00514         [o_audioFlts_view setFrame: NSMakeRect( 20, -20, 370, 76)];
00515         [o_audioFlts_view setNeedsDisplay:YES];
00516         [o_audioFlts_view setAutoresizesSubviews: YES];
00517         [[o_box_audFlts contentView] addSubview: o_audioFlts_view];
00518         msg_Dbg( VLCIntf, "expanded audio-filters section");
00519         o_audFlts_expanded = YES;
00520     }
00521     [o_box_audFlts setFrameFromContentFrame: o_box_audFlts_rect];
00522 }
00523 
00524 - (IBAction)extWin_exp_vidFlts:(id)sender
00525 {
00526     /* expand or collapse vidFlts */
00527     NSRect o_win_rect = [o_extended_window frame];
00528     NSRect o_box_audFlts_rect = [o_box_audFlts frame];
00529     NSRect o_box_vidFlts_rect = [o_box_vidFlts frame];
00530     
00531     if (o_vidFlts_expanded)
00532     {
00533         /* move the window contents upwards (partially done through settings
00534          * inside the nib) and resize the window */
00535         o_win_rect.size.height = o_win_rect.size.height - 134;
00536         o_win_rect.origin.y = [o_extended_window frame].origin.y + 134;
00537         o_box_audFlts_rect.origin.y = o_box_audFlts_rect.origin.y + 134;
00538         
00539         /* remove the inserted view */
00540         [o_videoFilters_view removeFromSuperviewWithoutNeedingDisplay];
00541     }else{
00542     
00543         /* move the window contents downwards and resize the window */
00544         o_win_rect.size.height = o_win_rect.size.height + 134;
00545         o_win_rect.origin.y = [o_extended_window frame].origin.y - 134;
00546         o_box_audFlts_rect.origin.y = o_box_audFlts_rect.origin.y - 134;
00547     }
00548     
00549     [o_box_audFlts setFrameFromContentFrame: o_box_audFlts_rect];
00550     [o_extended_window displayIfNeeded];
00551     [o_extended_window setFrame: o_win_rect display:YES animate: YES];
00552     
00553     if (o_vidFlts_expanded)
00554     {
00555         o_box_vidFlts_rect.size.height = [o_box_vidFlts frame].size.height - 134;
00556         msg_Dbg( VLCIntf, "collapsed video-filters section");
00557         o_vidFlts_expanded = NO;
00558     } else {
00559         /* insert view */
00560         o_box_vidFlts_rect.size.height = [o_box_vidFlts frame].size.height + 134;
00561         [o_videoFilters_view setFrame: NSMakeRect( 20, -10, 370, 144)];
00562         [o_videoFilters_view setNeedsDisplay:YES];
00563         [o_videoFilters_view setAutoresizesSubviews: YES];
00564         [[o_box_vidFlts contentView] addSubview: o_videoFilters_view];
00565         msg_Dbg( VLCIntf, "expanded video-filters section");
00566         o_vidFlts_expanded = YES;
00567     }
00568     [o_box_vidFlts setFrameFromContentFrame: o_box_vidFlts_rect];
00569 }
00570 
00571 - (IBAction)vidFlts:(id)sender
00572 {
00573     /* en-/disable video filters */
00574     if (sender == o_ckb_blur)
00575     {
00576         [self changeVFiltersString: "motionblur" onOrOff: [o_ckb_blur state]];
00577     }
00578     else if (sender == o_ckb_distortion)
00579     {
00580         [self changeVFiltersString: "distort" onOrOff: [o_ckb_distortion state]];
00581     }
00582     else if (sender == o_ckb_imgClone)
00583     {
00584         [self changeVFiltersString: "clone" onOrOff: [o_ckb_imgClone state]];
00585     }
00586     else if (sender == o_ckb_imgCrop)
00587     {
00588         [self changeVFiltersString: "crop" onOrOff: [o_ckb_imgCrop state]];
00589     }
00590     else if (sender == o_ckb_imgInvers)
00591     {
00592         [self changeVFiltersString: "invert" onOrOff: [o_ckb_imgInvers state]];
00593     }
00594     else if (sender == o_ckb_trnsform)
00595     {
00596         [self changeVFiltersString: "transform" onOrOff: [o_ckb_trnsform state]];
00597     } else {
00598         /* this shouldn't happen */
00599         msg_Warn (VLCIntf, "cannot find selected video-filter");
00600     }
00601 }
00602 
00603 - (IBAction)vidFlts_mrInfo:(id)sender
00604 {
00605     /* show info sheet */
00606     NSBeginInformationalAlertSheet(_NS("More information"), _NS("OK"), @"", @"", \
00607         o_extended_window, nil, nil, nil, nil, _NS("Select the video effects " \
00608         "filters to apply. You must restart the stream for these settings to " \
00609         "take effect.\nTo configure the filters, go to the Preferences, and " \
00610         "go to Modules/Video Filters. You can then configure each filter.\n" \
00611         "If you want fine control over the filters ( to choose the order in " \
00612         "which they are applied ), you need to enter manually a filters " \
00613         "string (Preferences / Video / Filters)."));
00614 }
00615 
00616 
00617 /*****************************************************************************
00618  * methods to communicate changes to VLC's core
00619  *****************************************************************************/
00620 
00621 - (void)changeVFiltersString:(char *)psz_name onOrOff:(vlc_bool_t )b_add 
00622 {
00623     /* copied from ../wxwidgets/extrapanel.cpp
00624      * renamed to conform with Cocoa's rules */
00625      
00626     vout_thread_t *p_vout;
00627     intf_thread_t * p_intf = VLCIntf;
00628     
00629     char *psz_parser, *psz_string;
00630     psz_string = config_GetPsz( p_intf, "vout-filter" );
00631     
00632     if( !psz_string ) psz_string = strdup("");
00633 
00634     psz_parser = strstr( psz_string, psz_name );
00635 
00636     if( b_add )
00637     {
00638         if( !psz_parser )
00639         {
00640             psz_parser = psz_string;
00641             asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
00642                             psz_string, psz_name );
00643             free( psz_parser );
00644         }
00645         else
00646         {
00647             return;
00648         }
00649     }
00650     else
00651     {
00652         if( psz_parser )
00653         {
00654             memmove( psz_parser, psz_parser + strlen(psz_name) +
00655                             (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
00656                             strlen(psz_parser + strlen(psz_name)) + 1 );
00657 
00658             /* Remove trailing : : */
00659             if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
00660             {
00661                 *(psz_string+strlen(psz_string ) -1 ) = '\0';
00662             }
00663          }
00664          else
00665          {
00666              free( psz_string );
00667              return;
00668          }
00669     }
00670     /* Vout is not kept, so put that in the config */
00671     config_PutPsz( p_intf, "vout-filter", psz_string );
00672 
00673     /* Try to set on the fly */
00674     p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
00675                                               FIND_ANYWHERE );
00676     if( p_vout )
00677     {
00678         var_SetString( p_vout, "vout-filter", psz_string );
00679         vlc_object_release( p_vout );
00680     }
00681 
00682     free( psz_string );
00683 
00684     o_config_changed = YES;
00685 }
00686 
00687 
00688 - (void)changeAFiltersString: (char *)psz_name onOrOff: (vlc_bool_t )b_add;
00689 {
00690     /* copied from ../wxwidgets/extrapanel.cpp
00691      * renamed to conform with Cocoa's rules */
00692 
00693     char *psz_parser, *psz_string;
00694     intf_thread_t * p_intf = VLCIntf;
00695     aout_instance_t * p_aout= (aout_instance_t *)vlc_object_find(p_intf,
00696                                  VLC_OBJECT_AOUT, FIND_ANYWHERE);
00697 
00698     if( p_aout )
00699     {
00700         psz_string = var_GetString( p_aout, "audio-filter" );
00701     }
00702     else
00703     {
00704         psz_string = config_GetPsz( p_intf, "audio-filter" );
00705     }
00706 
00707     if( !psz_string ) psz_string = strdup("");
00708 
00709     psz_parser = strstr( psz_string, psz_name );
00710 
00711     if( b_add )
00712     {
00713         if( !psz_parser )
00714         {
00715             psz_parser = psz_string;
00716             asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
00717                             psz_string, psz_name );
00718             free( psz_parser );
00719         }
00720         else
00721         {
00722             return;
00723         }
00724     }
00725     else
00726     {
00727         if( psz_parser )
00728         {
00729             memmove( psz_parser, psz_parser + strlen(psz_name) +
00730                             (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
00731                             strlen(psz_parser + strlen(psz_name)) + 1 );
00732 
00733             if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
00734             {
00735                 *(psz_string+strlen(psz_string ) -1 ) = '\0';
00736             }
00737          }
00738          else
00739          {
00740              free( psz_string );
00741              return;
00742          }
00743     }
00744 
00745     if( p_aout == NULL )
00746     {
00747         config_PutPsz( p_intf, "audio-filter", psz_string );
00748     }
00749     else
00750     {
00751         var_SetString( p_aout, "audio-filter", psz_string );
00752         int i = 0;
00753         while( i < p_aout->i_nb_inputs )
00754         {
00755             p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
00756             i = (i + 1);
00757         }
00758         vlc_object_release( p_aout );
00759     }
00760     free( psz_string );
00761 
00762     o_config_changed = YES;
00763 }
00764 
00765 - (void)savePrefs
00766 {    
00767     /* save the preferences to make sure that our module-changes will up on
00768      * next launch again */
00769     playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST, \
00770         FIND_ANYWHERE );
00771     int returnedValue;
00772     NSArray * theModules;
00773     theModules = [[NSArray alloc] initWithObjects: @"main", @"headphone", \
00774         @"transform", @"adjust", @"invert", @"motionblur", @"distort", \
00775         @"clone", @"crop", @"normvol", @"headphone_channel_mixer", @"macosx", \
00776         nil];
00777     unsigned int x = 0;
00778     
00779     while ( x != [theModules count] )
00780     {
00781         returnedValue = config_SaveConfigFile( p_playlist, [[theModules \
00782             objectAtIndex: x] UTF8String] );
00783 
00784         if (returnedValue != 0)
00785         {
00786             msg_Err(p_playlist, "VLCExtended: error while saving the " \
00787             "preferences of '%s' (%i)", [[theModules objectAtIndex: x] \
00788             UTF8String] , returnedValue);
00789             
00790             [theModules release];
00791             vlc_object_release( p_playlist );
00792             
00793             return;
00794         }
00795 
00796         x = ( x + 1 );
00797     }
00798     
00799     msg_Dbg( p_playlist, "VLCExtended: saved certain preferences successfully" );
00800     
00801     [theModules release];
00802     vlc_object_release( p_playlist );
00803 }
00804 @end

Generated on Tue Dec 20 10:14:38 2005 for vlc-0.8.4a by  doxygen 1.4.2