📄 extended.m
字号:
/***************************************************************************** * extended.m: MacOS X Extended interface panel ***************************************************************************** * Copyright (C) 2005 the VideoLAN team * $Id: extended.m 15209 2006-04-14 09:37:39Z zorglub $ * * Authors: Felix Kühne <fkuehne@users.sf.net> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************//***************************************************************************** * 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 views was inspired by intf.m, * written by Derk-Jan Hartman and Benjamin Pracht. * (all 3 are members of the VideoLAN team) *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#import "extended.h"#import "intf.h"#import "vout.h"#import <vlc/aout.h>#import <aout_internal.h>#import <vlc/vout.h>#import <vlc/intf.h>/***************************************************************************** * VLCExtended implementation *****************************************************************************/@implementation VLCExtendedstatic VLCExtended *_o_sharedInstance = nil;+ (VLCExtended *)sharedInstance{ return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];}- (id)init{ if (_o_sharedInstance) { [self dealloc]; } else { _o_sharedInstance = [super init]; } 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("Image adjustment")]; [o_btn_vidFlts_mrInfo setTitle: _NS("More Info")]; [o_ckb_blur setTitle: _NS("Blurring")]; [o_ckb_blur setToolTip: _NS("Adds motion blurring to the image")]; [o_ckb_distortion setTitle: _NS("Distortion")]; [o_ckb_distortion setToolTip: _NS("Adds distortion effects")]; [o_ckb_imgClone setTitle: _NS("Image clone")]; [o_ckb_imgClone setToolTip: _NS("Creates several copies of the Video " \ "output window" )]; [o_ckb_imgCrop setTitle: _NS("Image cropping")]; [o_ckb_imgCrop setToolTip: _NS("Crops a defined part of the image")]; [o_ckb_imgInvers setTitle: _NS("Image inversion")]; [o_ckb_imgInvers setToolTip: _NS("Inverts the colors of the image")]; [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("Prevents the audio output from going " \ "over a predefined value.")]; [o_ckb_hdphnVirt setTitle: _NS("Headphone virtualization")]; [o_ckb_hdphnVirt setToolTip: _NS("Imitates the effect of surround sound " \ "when using headphones.")]; [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{ /* set the adjust-filter-sliders to the values from the prefs and enable * them, if wanted */ char * psz_vfilters; intf_thread_t * p_intf = VLCIntf; psz_vfilters = config_GetPsz( p_intf, "vout-filter" ); if( psz_vfilters && strstr( psz_vfilters, "adjust" ) ) { [o_ckb_enblAdjustImg setState: NSOnState]; [o_btn_rstrDefaults setEnabled: YES]; [o_sld_brightness setEnabled: YES]; [o_sld_contrast setEnabled: YES]; [o_sld_gamma setEnabled: YES]; [o_sld_hue setEnabled: YES]; [o_sld_saturation setEnabled: YES]; } else { [o_ckb_enblAdjustImg setState: NSOffState]; [o_btn_rstrDefaults setEnabled: NO]; [o_sld_brightness setEnabled: NO]; [o_sld_contrast setEnabled: NO]; [o_sld_gamma setEnabled: NO]; [o_sld_hue setEnabled: NO]; [o_sld_saturation setEnabled: NO]; } /* 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)collapsAll{ /* collaps all views so Cocoa saves the window position correctly */ if( o_adjImg_expanded ) { [self extWin_exp_adjImg: nil]; } if( o_audFlts_expanded ) { [self extWin_exp_audFlts: nil]; } if( o_vidFlts_expanded ) { [self extWin_exp_vidFlts: nil]; }}- (BOOL)getConfigChanged{ return o_config_changed;}- (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" ); if( f_value > 0 && f_value < 5 ) { [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) ]; } f_value = config_GetFloat( p_intf, "norm-max-level" ); if( f_value > 0 && f_value < 10 ) { [o_sld_maxLevel setFloatValue: f_value ]; } [o_sld_opaque setFloatValue: (config_GetFloat( p_intf, \ "macosx-opaqueness") * 100)]; /* show the window */ [o_extended_window displayIfNeeded]; [o_extended_window makeKeyAndOrderFront:nil];}- (IBAction)adjImg_Enbl:(id)sender{ /* en-/disable the sliders */ if ([o_ckb_enblAdjustImg state] == NSOnState) { [o_btn_rstrDefaults setEnabled: YES]; [o_sld_brightness setEnabled: YES]; [o_sld_contrast setEnabled: YES]; [o_sld_gamma setEnabled: YES]; [o_sld_hue setEnabled: YES]; [o_sld_saturation setEnabled: YES]; [self changeVFiltersString: "adjust" onOrOff: VLC_TRUE]; }else{ [o_btn_rstrDefaults setEnabled: NO]; [o_sld_brightness setEnabled: NO]; [o_sld_contrast setEnabled: NO]; [o_sld_gamma setEnabled: NO]; [o_sld_hue setEnabled: NO]; [o_sld_saturation setEnabled: NO]; [self changeVFiltersString: "adjust" onOrOff: VLC_FALSE]; }}- (IBAction)adjImg_rstrDefaults:(id)sender{ /* reset the sliders */ [o_sld_brightness setIntValue: 100]; [o_sld_contrast setIntValue: 100]; [o_sld_gamma setIntValue: 10]; [o_sld_hue setIntValue: 0]; [o_sld_saturation setIntValue: 100]; /* transmit the values */ [self adjImg_sliders: o_sld_brightness]; [self adjImg_sliders: o_sld_contrast]; [self adjImg_sliders: o_sld_gamma]; [self adjImg_sliders: o_sld_hue]; [self adjImg_sliders: o_sld_saturation];}- (IBAction)adjImg_sliders:(id)sender{ /* read-out the sliders' values and apply them */ intf_thread_t * p_intf = VLCIntf; vout_thread_t *p_vout = (vout_thread_t *)vlc_object_find(p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE); if( p_vout == NULL ) { if (sender == o_sld_brightness) { config_PutFloat( p_intf , "brightness" , [o_sld_brightness floatValue] / 100); } else if (sender == o_sld_contrast) { config_PutFloat( p_intf , "contrast" , [o_sld_contrast floatValue] / 100); } else if (sender == o_sld_gamma) { config_PutFloat( p_intf , "gamma" , [o_sld_gamma floatValue] / 10); } else if (sender == o_sld_hue) { config_PutInt( p_intf , "hue" , [o_sld_hue intValue]); } else if (sender == o_sld_saturation) { config_PutFloat( p_intf , "saturation" , [o_sld_saturation floatValue] / 100); } else { msg_Warn( p_intf, "the corresponding subfilter coundn't be found" ); } } else { vlc_value_t val; if (sender == o_sld_brightness) { val.f_float = [o_sld_brightness floatValue] / 100; var_Set( p_vout, "brightness", val ); config_PutFloat( p_intf , "brightness" , [o_sld_brightness floatValue] / 100); } else if (sender == o_sld_contrast) { val.f_float = [o_sld_contrast floatValue] / 100; var_Set( p_vout, "contrast", val ); config_PutFloat( p_intf , "contrast" , [o_sld_contrast floatValue] / 100); } else if (sender == o_sld_gamma) { val.f_float = [o_sld_gamma floatValue] / 10; var_Set( p_vout, "gamma", val ); config_PutFloat( p_intf , "gamma" , [o_sld_gamma floatValue] / 10); } else if (sender == o_sld_hue) { val.i_int = [o_sld_hue intValue]; var_Set( p_vout, "hue", val ); config_PutInt( p_intf , "hue" , [o_sld_hue intValue]); } else if (sender == o_sld_saturation) { 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, "the corresponding subfilter coundn't be found" ); } vlc_object_release( p_vout ); } o_config_changed = YES;}/* 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 ) { p_real_vout = [VLCVoutView getRealVout: p_vout]; var_Set( p_real_vout, "macosx-opaqueness", val ); while ((o_window = [o_enumerator nextObject])) { if( [[o_window className] isEqualToString: @"VLCWindow"] || [[[VLCMain sharedInstance] getEmbeddedList] windowContainsEmbedded: o_window]) { [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 ); o_config_changed = YES;}- (IBAction)audFtls_hdphnVirt:(id)sender{ /* en-/disable headphone virtualisation */ if ([o_ckb_hdphnVirt state] == NSOnState) { [self changeAFiltersString: "headphone_channel_mixer" onOrOff: VLC_TRUE ]; }else{ [self changeAFiltersString: "headphone_channel_mixer" onOrOff: VLC_FALSE ]; }}- (IBAction)audFtls_maxLevelSld:(id)sender{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -