1 /*****************************************************************************
2 * extrapanel.cpp : wxWindows plugin for vlc
3 *****************************************************************************
4 * Copyright (C) 2000-2004, 2003 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
34 #include <vlc_interface.h>
38 #include "extrapanel.hpp"
40 /*****************************************************************************
41 * Local class declarations.
42 *****************************************************************************/
44 #define SMOOTH_TIP N_( "Controls the blending of equalizer bands. The higher" \
45 " this value is, the more correlated their movement will be." )
47 static int IntfBandsCallback( vlc_object_t *, char const *,
48 vlc_value_t, vlc_value_t, void * );
49 static int IntfPreampCallback( vlc_object_t *, char const *,
50 vlc_value_t, vlc_value_t, void * );
51 static void ChangeFiltersString( intf_thread_t *, aout_instance_t *,
53 static void ChangeVFiltersString( intf_thread_t *, char *, vlc_bool_t );
56 /* IDs for the controls and the menu commands */
62 RestoreDefaults_Event,
73 Filter0_Event, Filter1_Event, Filter2_Event, Filter3_Event, Filter4_Event,
74 Filter5_Event, Filter6_Event, Filter7_Event, Filter8_Event, Filter9_Event,
84 Band0_Event,Band1_Event,Band2_Event,Band3_Event,Band4_Event,
85 Band5_Event,Band6_Event,Band7_Event,Band8_Event,Band9_Event,
87 NormVol_Event, NVSlider_Event, HeadPhone_Event
90 BEGIN_EVENT_TABLE( ExtraPanel, wxPanel )
91 EVT_IDLE( ExtraPanel::OnIdle )
94 EVT_CHECKBOX( EqEnable_Event, ExtraPanel::OnEnableEqualizer )
95 EVT_CHECKBOX( Eq2Pass_Event, ExtraPanel::OnEq2Pass )
96 EVT_BUTTON( EqRestore_Event, ExtraPanel::OnEqRestore )
98 EVT_COMMAND_SCROLL( Preamp_Event, ExtraPanel::OnPreamp )
99 EVT_COMMAND_SCROLL( Smooth_Event, ExtraPanel::OnEqSmooth )
101 EVT_COMMAND_SCROLL(Band0_Event, ExtraPanel::OnChangeEqualizer)
102 EVT_COMMAND_SCROLL(Band1_Event, ExtraPanel::OnChangeEqualizer)
103 EVT_COMMAND_SCROLL(Band2_Event, ExtraPanel::OnChangeEqualizer)
104 EVT_COMMAND_SCROLL(Band3_Event, ExtraPanel::OnChangeEqualizer)
105 EVT_COMMAND_SCROLL(Band4_Event, ExtraPanel::OnChangeEqualizer)
106 EVT_COMMAND_SCROLL(Band5_Event, ExtraPanel::OnChangeEqualizer)
107 EVT_COMMAND_SCROLL(Band6_Event, ExtraPanel::OnChangeEqualizer)
108 EVT_COMMAND_SCROLL(Band7_Event, ExtraPanel::OnChangeEqualizer)
109 EVT_COMMAND_SCROLL(Band8_Event, ExtraPanel::OnChangeEqualizer)
110 EVT_COMMAND_SCROLL(Band9_Event, ExtraPanel::OnChangeEqualizer)
113 EVT_CHECKBOX( Adjust_Event, ExtraPanel::OnEnableAdjust )
114 EVT_BUTTON( RestoreDefaults_Event, ExtraPanel::OnRestoreDefaults )
116 EVT_COMMAND_SCROLL(Hue_Event, ExtraPanel::OnAdjustUpdate)
117 EVT_COMMAND_SCROLL(Contrast_Event, ExtraPanel::OnAdjustUpdate)
118 EVT_COMMAND_SCROLL(Brightness_Event, ExtraPanel::OnAdjustUpdate)
119 EVT_COMMAND_SCROLL(Saturation_Event, ExtraPanel::OnAdjustUpdate)
120 EVT_COMMAND_SCROLL(Gamma_Event, ExtraPanel::OnAdjustUpdate)
122 EVT_BUTTON( FiltersInfo_Event, ExtraPanel::OnFiltersInfo )
124 EVT_CHECKBOX( Filter0_Event, ExtraPanel::OnSelectFilter )
125 EVT_CHECKBOX( Filter1_Event, ExtraPanel::OnSelectFilter )
126 EVT_CHECKBOX( Filter2_Event, ExtraPanel::OnSelectFilter )
127 EVT_CHECKBOX( Filter3_Event, ExtraPanel::OnSelectFilter )
128 EVT_CHECKBOX( Filter4_Event, ExtraPanel::OnSelectFilter )
129 EVT_CHECKBOX( Filter5_Event, ExtraPanel::OnSelectFilter )
130 EVT_CHECKBOX( Filter6_Event, ExtraPanel::OnSelectFilter )
131 EVT_CHECKBOX( Filter7_Event, ExtraPanel::OnSelectFilter )
132 EVT_CHECKBOX( Filter8_Event, ExtraPanel::OnSelectFilter )
133 EVT_CHECKBOX( Filter9_Event, ExtraPanel::OnSelectFilter )
136 EVT_CHECKBOX( NormVol_Event, ExtraPanel::OnNormvol )
137 EVT_CHECKBOX( HeadPhone_Event, ExtraPanel::OnHeadphone )
139 EVT_COMMAND_SCROLL( NVSlider_Event, ExtraPanel::OnNormvolSlider )
149 static const struct filter vfilters[] =
151 { "clone", N_("Image clone"), N_("Creates several clones of the image") },
152 { "distort", N_("Distortion"), N_("Adds distortion effects") },
153 { "invert", N_("Image inversion") , N_("Inverts the colors of the image") },
154 { "motionblur", N_("Blurring"), N_("Adds motion blurring to the image") },
155 { "transform", N_("Transformation"), N_("Rotates or flips the image") },
156 { "magnify", N_("Magnify"), N_("Magnifies part of the image") },
157 { "puzzle", N_("Puzzle"), N_("Turns the image into a puzzle") },
158 { NULL, NULL, NULL } /* Do not remove this line */
161 /*****************************************************************************
163 *****************************************************************************/
164 ExtraPanel::ExtraPanel( intf_thread_t *_p_intf, wxWindow *_p_parent ):
165 wxPanel( _p_parent , -1, wxDefaultPosition, wxDefaultSize )
169 p_parent = _p_parent;
170 SetAutoLayout( TRUE );
172 wxBoxSizer *extra_sizer = new wxBoxSizer( wxHORIZONTAL );
174 notebook = new wxNotebook( this, Notebook_Event );
176 #if (!wxCHECK_VERSION(2,5,2))
177 wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
180 notebook->AddPage( VideoPanel( notebook ), wxU(_("Video")) );
181 notebook->AddPage( EqzPanel( notebook ), wxU(_("Equalizer")) );
182 notebook->AddPage( AudioPanel( notebook ), wxU(_("Audio")) );
184 #if (!wxCHECK_VERSION(2,5,2))
185 extra_sizer->Add( notebook_sizer, 1, wxEXPAND, 0 );
187 extra_sizer->Add( notebook, 1, wxEXPAND, 0 );
190 SetSizerAndFit( extra_sizer );
191 extra_sizer->Layout();
194 ExtraPanel::~ExtraPanel()
198 /* Video Panel constructor */
199 wxPanel *ExtraPanel::VideoPanel( wxWindow *parent )
203 wxPanel *panel = new wxPanel( parent, -1 );
204 wxBoxSizer *panel_sizer = new wxBoxSizer( wxHORIZONTAL );
206 /* Create static box to surround the adjust controls */
207 wxStaticBox *adjust_box =
208 new wxStaticBox( panel, -1, wxU(_("Image adjustment" )) );
209 wxStaticBoxSizer *adjust_sizer =
210 new wxStaticBoxSizer( adjust_box, wxVERTICAL );
211 adjust_sizer->SetMinSize( -1, 50 );
213 /* Create flex grid */
214 wxFlexGridSizer *adjust_gridsizer =
215 new wxFlexGridSizer( 6, 2, 0, 0);
216 adjust_gridsizer->AddGrowableCol(1);
218 /* Create the adjust button */
219 wxCheckBox * adjust_check = new wxCheckBox( panel, Adjust_Event,
222 /* Create the restore to defaults button */
223 restoredefaults_button =
224 new wxButton( panel, RestoreDefaults_Event,
225 wxU(_("Restore Defaults")), wxDefaultPosition);
227 wxStaticText *hue_text = new wxStaticText( panel, -1,
229 hue_slider = new wxSlider ( panel, Hue_Event, 0, 0,
230 360, wxDefaultPosition, wxDefaultSize );
232 wxStaticText *contrast_text = new wxStaticText( panel, -1,
233 wxU(_("Contrast")) );
234 contrast_slider = new wxSlider ( panel, Contrast_Event, 0, 0,
235 200, wxDefaultPosition, wxDefaultSize);
237 wxStaticText *brightness_text = new wxStaticText( panel, -1,
238 wxU(_("Brightness")) );
239 brightness_slider = new wxSlider ( panel, Brightness_Event, 0, 0,
240 200, wxDefaultPosition, wxDefaultSize) ;
242 wxStaticText *saturation_text = new wxStaticText( panel, -1,
243 wxU(_("Saturation")) );
244 saturation_slider = new wxSlider ( panel, Saturation_Event, 0, 0,
245 300, wxDefaultPosition, wxDefaultSize );
247 wxStaticText *gamma_text = new wxStaticText( panel, -1,
249 gamma_slider = new wxSlider ( panel, Gamma_Event, 0, 0,
250 100, wxDefaultPosition, wxDefaultSize );
252 adjust_gridsizer->Add( adjust_check, 1, wxEXPAND|wxALL, 2 );
253 adjust_gridsizer->Add( restoredefaults_button, 1, wxEXPAND|wxALL, 2 );
254 adjust_gridsizer->Add( hue_text, 1, wxEXPAND|wxALL, 2 );
255 adjust_gridsizer->Add( hue_slider, 1, wxEXPAND|wxALL, 2 );
256 adjust_gridsizer->Add( contrast_text, 1, wxEXPAND|wxALL, 2 );
257 adjust_gridsizer->Add( contrast_slider, 1, wxEXPAND|wxALL, 2 );
258 adjust_gridsizer->Add( brightness_text, 1, wxEXPAND|wxALL, 2 );
259 adjust_gridsizer->Add( brightness_slider, 1, wxEXPAND|wxALL, 2 );
260 adjust_gridsizer->Add( saturation_text, 1, wxEXPAND|wxALL, 2 );
261 adjust_gridsizer->Add( saturation_slider, 1, wxEXPAND|wxALL, 2 );
262 adjust_gridsizer->Add( gamma_text, 1, wxEXPAND|wxALL, 2 );
263 adjust_gridsizer->Add( gamma_slider, 1, wxEXPAND|wxALL, 2 );
265 adjust_sizer->Add( adjust_gridsizer, 1, wxEXPAND|wxALL, 2);
267 panel_sizer->Add( adjust_sizer , 1, wxTOP, 2 );
270 /* Create sizer to surround the other controls */
271 wxBoxSizer *other_sizer = new wxBoxSizer( wxVERTICAL );
273 wxStaticBox *video_box =
274 new wxStaticBox( panel, -1, wxU(_("Video Options")) );
275 /* Create the sizer for the frame */
276 wxStaticBoxSizer *video_sizer =
277 new wxStaticBoxSizer( video_box, wxVERTICAL );
278 video_sizer->SetMinSize( -1, 50 );
280 static const wxString ratio_array[] =
286 wxBoxSizer *ratio_sizer = new wxBoxSizer( wxHORIZONTAL );
287 wxStaticText *ratio_text = new wxStaticText( panel, -1,
288 wxU(_("Aspect Ratio")) );
290 ratio_combo = new wxComboBox( panel, Ratio_Event, wxT(""),
291 wxDefaultPosition, wxSize( 80 , -1),
292 WXSIZEOF(ratio_array), ratio_array,
295 ratio_sizer->Add( ratio_text, 0, wxALL, 2 );
296 ratio_sizer->Add( ratio_combo, 0, wxALL, 2 );
297 ratio_sizer->Layout();
299 video_sizer->Add( ratio_sizer , 0 , wxALL , 2 );
300 video_sizer->Layout();
303 wxStaticBox *filter_box =
304 new wxStaticBox( panel, -1, wxU(_("Video filters")) );
305 wxStaticBoxSizer *filter_sizer =
306 new wxStaticBoxSizer( filter_box, wxHORIZONTAL );
308 wxBoxSizer *t_col_sizer = new wxBoxSizer( wxVERTICAL );
311 for( int i = 0 ; vfilters[i].psz_filter != NULL ; i++ )
313 wxCheckBox *box = new wxCheckBox( panel, Filter0_Event + i,
314 wxU( _( vfilters[i].psz_name ) ) );
315 t_col_sizer->Add( box, 0, wxALL, 2 );
316 box->SetToolTip( wxU( _( vfilters[i].psz_help ) ) );
319 filter_sizer->Add( t_col_sizer );
320 filter_sizer->Add( new wxButton( panel, FiltersInfo_Event,
321 wxU(_("More Info" ) ) ), 0, wxALL, 4 );
323 other_sizer->Add( video_sizer, 0, wxALL | wxEXPAND , 0);
324 other_sizer->Add( filter_sizer, 0, wxALL | wxEXPAND , 0);
325 other_sizer->Layout();
326 panel_sizer->Add(other_sizer , 1 );
329 panel_sizer->Add( filter_sizer, 1, wxTOP|wxLEFT, 2 );
331 panel->SetSizerAndFit( panel_sizer );
333 /* Layout the whole panel */
334 panel_sizer->Layout();
336 panel_sizer->SetSizeHints( panel );
338 /* Write down initial values */
339 psz_filters = config_GetPsz( p_intf, "vout-filter" );
340 if( psz_filters && strstr( psz_filters, "adjust" ) )
342 adjust_check->SetValue( 1 );
343 restoredefaults_button->Enable();
344 saturation_slider->Enable();
345 contrast_slider->Enable();
346 brightness_slider->Enable();
347 hue_slider->Enable();
348 gamma_slider->Enable();
352 adjust_check->SetValue( 0 );
353 restoredefaults_button->Disable();
354 saturation_slider->Disable();
355 contrast_slider->Disable();
356 brightness_slider->Disable();
357 hue_slider->Disable();
358 gamma_slider->Disable();
362 int i_value = config_GetInt( p_intf, "hue" );
363 if( i_value > 0 && i_value < 360 )
364 hue_slider->SetValue( i_value );
366 f_value = config_GetFloat( p_intf, "saturation" );
367 if( f_value > 0 && f_value < 5 )
368 saturation_slider->SetValue( (int)(100 * f_value) );
369 f_value = config_GetFloat( p_intf, "contrast" );
370 if( f_value > 0 && f_value < 4 )
371 contrast_slider->SetValue( (int)(100 * f_value) );
372 f_value = config_GetFloat( p_intf, "brightness" );
373 if( f_value > 0 && f_value < 2 )
374 brightness_slider->SetValue( (int)(100 * f_value) );
375 f_value = config_GetFloat( p_intf, "gamma" );
376 if( f_value > 0 && f_value < 10 )
377 gamma_slider->SetValue( (int)(10 * f_value) );
379 b_update = VLC_FALSE;
384 /* Audio panel constructor */
385 wxPanel *ExtraPanel::AudioPanel( wxWindow *parent )
389 wxPanel *panel = new wxPanel( parent, -1 );
390 wxBoxSizer *panel_sizer = new wxBoxSizer( wxHORIZONTAL );
392 /* Create static box to surround the adjust controls */
393 wxStaticBox *filter_box =
394 new wxStaticBox( panel, -1, wxU(_("Audio filters")) );
395 wxStaticBoxSizer *filter_sizer =
396 new wxStaticBoxSizer( filter_box, wxVERTICAL );
397 filter_sizer->SetMinSize( -1, 50 );
399 wxCheckBox * headphone_check = new wxCheckBox( panel, HeadPhone_Event,
400 wxU(_("Headphone virtualization")));
401 headphone_check->SetToolTip( wxU(_("Imitates the effect of "
402 "surround sound when using headphones." ) ) );
404 wxCheckBox * normvol_check = new wxCheckBox( panel, NormVol_Event,
405 wxU(_("Volume normalization")));
406 normvol_check->SetToolTip( wxU(_("Prevents the audio output "
407 "level from going over a predefined value." ) ) );
409 wxStaticText *normvol_label = new wxStaticText( panel, -1,
410 wxU( _("Maximum level") ) );
412 wxSlider *normvol_slider = new wxSlider ( panel, NVSlider_Event, 20, 5,
413 100, wxDefaultPosition, wxSize( 100, -1 ) );
415 filter_sizer->Add( headphone_check, 0, wxALL, 4 );
416 filter_sizer->Add( normvol_check, 0, wxALL, 4 );
417 filter_sizer->Add( normvol_label, 0, wxALL, 4 );
418 filter_sizer->Add( normvol_slider, 0, wxALL, 4 );
420 panel_sizer->Add( filter_sizer, 1, wxTOP, 2 );
421 panel->SetSizerAndFit( panel_sizer );
422 panel_sizer->Layout();
423 panel_sizer->SetSizeHints( panel );
425 /* Write down initial values */
426 psz_filters = config_GetPsz( p_intf, "audio-filter" );
429 headphone_check->SetValue( strstr( psz_filters, "headphone" ) );
430 normvol_check->SetValue( strstr( psz_filters, "normvol" ) );
435 headphone_check->SetValue( 0 );
436 normvol_check->SetValue( 0 );
443 static const wxString band_frequencies[] =
457 /* Equalizer Panel constructor */
458 wxPanel *ExtraPanel::EqzPanel( wxWindow *parent )
460 wxPanel *panel = new wxPanel( parent, -1 );
461 wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
463 /* Create static box to surround the adjust controls */
464 wxBoxSizer *top_sizer =
465 new wxBoxSizer( wxHORIZONTAL );
467 /* Create the enable button */
468 eq_chkbox = new wxCheckBox( panel, EqEnable_Event,
470 eq_chkbox->SetToolTip( wxU(_("Enable the equalizer. You can either "
471 "manually adjust the bands or use a preset (Audio Menu->Equalizer)." ) ) );
472 top_sizer->Add( eq_chkbox, 0, wxALL, 2 );
474 eq_2p_chkbox = new wxCheckBox( panel, Eq2Pass_Event,
477 eq_2p_chkbox->SetToolTip( wxU(_("Apply the equalizer twice. "
478 "The resulting effect will be sharper.") ) );
480 top_sizer->Add( eq_2p_chkbox, 0, wxALL, 2 );
482 top_sizer->Add( 0, 0, 1, wxALL, 2 );
484 eq_restoredefaults_button = new wxButton( panel, EqRestore_Event,
485 wxU( _("Restore Defaults") ) );
486 top_sizer->Add( eq_restoredefaults_button, 0, wxALL, 2 );
487 top_sizer->Add( 0, 0, 1, wxALL, 2 );
489 smooth_text = new wxStaticText( panel, -1, wxU( _("Smooth :") ));
490 smooth_text->SetToolTip( wxU( _(SMOOTH_TIP) ) );
491 top_sizer->Add( smooth_text, 0, wxALL, 2 );
493 smooth_slider =new wxSlider( panel, Smooth_Event, 0, 0, 10 ,
494 wxDefaultPosition, wxSize( 100, -1 ) );
495 smooth_slider->SetToolTip( wxU( _(SMOOTH_TIP) ) );
496 top_sizer->Add( smooth_slider, 0, wxALL, 2 );
499 /* Create flex grid */
500 wxFlexGridSizer *eq_gridsizer =
501 new wxFlexGridSizer( 2, 12, 0, 0);
502 eq_gridsizer->AddGrowableRow( 0 );
503 eq_gridsizer->AddGrowableCol( 1 );
505 preamp_slider = new wxSlider( panel, Preamp_Event, 80, 0, 400,
506 wxDefaultPosition, wxSize( -1 , 90 ) , wxSL_VERTICAL );
507 eq_gridsizer->Add( preamp_slider, 1, wxEXPAND|wxALL, 2 );
509 eq_gridsizer->Add( 0, 0, 1, wxALL, 2 );
511 for( int i = 0 ; i < 10 ; i++ )
513 band_sliders[i] = new wxSlider( panel, Band0_Event + i, 200, 0, 400,
514 wxDefaultPosition, wxSize( -1 , 90 ) , wxSL_VERTICAL );
517 eq_gridsizer->Add( band_sliders[i], 1, wxEXPAND|wxALL, 2 );
520 preamp_text = new wxStaticText( panel, -1, wxU( _("Preamp\n12.0dB") ) );
521 wxFont font= preamp_text->GetFont();
522 font.SetPointSize(7);
523 preamp_text->SetFont( font );
524 eq_gridsizer->Add( preamp_text, wxALL, 2 );
526 eq_gridsizer->Add( 0, 0, 1 );
528 for( int i = 0 ; i < 10 ; i++ )
530 band_texts[i] = new wxStaticText( panel, -1,
531 band_frequencies[i] + wxU("\n0.0dB" ) ) ;
532 eq_gridsizer->Add( band_texts[i], 1, wxEXPAND|wxALL, 2 );
533 wxFont font= band_texts[i]->GetFont();
534 font.SetPointSize(7);
535 band_texts[i]->SetFont( font );
538 panel_sizer->Add( top_sizer , 0 , wxTOP | wxEXPAND, 5 );
539 panel_sizer->Add( eq_gridsizer , 0 , wxEXPAND, 0 );
541 panel->SetSizer( panel_sizer );
543 panel_sizer->Layout();
545 panel_sizer->SetSizeHints( panel );
549 aout_instance_t *p_aout = (aout_instance_t *)vlc_object_find(p_intf,
550 VLC_OBJECT_AOUT, FIND_ANYWHERE);
554 psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
555 if( var_GetBool( p_aout, "equalizer-2pass" ) )
556 eq_2p_chkbox->SetValue( true );
557 vlc_object_release( p_aout );
561 psz_af = config_GetPsz( p_intf, "audio-filter" );
562 if( config_GetInt( p_intf, "equalizer-2pass" ) )
563 eq_2p_chkbox->SetValue( true );
565 if( psz_af != NULL && strstr( psz_af, "equalizer" ) )
567 eq_chkbox->SetValue( true );
569 eq_2p_chkbox->Disable();
570 eq_restoredefaults_button->Disable();
571 smooth_slider->Disable();
572 smooth_text->Disable();
573 preamp_slider->Disable();
574 preamp_text->Disable();
575 for( int i_index=0; i_index < 10; i_index++ )
577 band_sliders[i_index]->Disable();
578 band_texts[i_index]->Disable();
586 /*******************************************************
588 *******************************************************/
590 /* Keep aout up to date and update the bands if needed */
591 void ExtraPanel::OnIdle( wxIdleEvent &event )
594 if( b_update == VLC_TRUE )
596 if( b_my_update == VLC_TRUE )
598 b_update = b_my_update = VLC_FALSE;
602 for( int i = 0; i < 10; i++ )
609 i_val= (int)( ( f + 20 ) * 10 );
610 band_sliders[i]->SetValue( 400 - i_val );
611 i_values[i] = 400 - i_val;
612 sprintf( psz_val, "%.1f", f );
613 band_texts[i]->SetLabel( band_frequencies[i] + wxT("\n") +
614 wxU( psz_val ) + wxT("dB") );
624 int i_val = (int)( ( f_preamp + 20 ) * 10 );
625 sprintf( psz_val, "%.1f", f_preamp );
626 preamp_slider->SetValue( 400 - i_val );
627 const wxString preamp = wxT("Preamp\n");
628 preamp_text->SetLabel( preamp + wxU( psz_val ) + wxT( "dB" ) );
629 eq_chkbox->SetValue( TRUE );
630 b_update = VLC_FALSE;
634 /*************************
635 * Equalizer Panel events
636 *************************/
637 void ExtraPanel::OnEnableEqualizer( wxCommandEvent &event )
640 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
641 VLC_OBJECT_AOUT, FIND_ANYWHERE);
642 ChangeFiltersString( p_intf,p_aout, "equalizer",
643 event.IsChecked() ? VLC_TRUE : VLC_FALSE );
645 if( event.IsChecked() )
647 eq_2p_chkbox->Enable();
648 eq_restoredefaults_button->Enable();
649 smooth_slider->Enable();
650 smooth_text->Enable();
651 preamp_slider->Enable();
652 preamp_text->Enable();
653 for( i_index=0; i_index < 10; i_index++ )
655 band_sliders[i_index]->Enable();
656 band_texts[i_index]->Enable();
659 eq_2p_chkbox->Disable();
660 eq_restoredefaults_button->Disable();
661 smooth_slider->Disable();
662 smooth_text->Disable();
663 preamp_slider->Disable();
664 preamp_text->Disable();
665 for( i_index=0; i_index < 10; i_index++ )
667 band_sliders[i_index]->Disable();
668 band_texts[i_index]->Disable();
673 vlc_object_release( p_aout );
676 void ExtraPanel::OnEqRestore( wxCommandEvent &event )
678 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
679 VLC_OBJECT_AOUT, FIND_ANYWHERE);
683 vlc_bool_t b_previous = eq_chkbox->IsChecked();
685 IntfPreampCallback( NULL, NULL, val,val, this );
686 config_PutFloat( p_intf, "equalizer-preamp", 12.0 );
687 val.psz_string = strdup( "0 0 0 0 0 0 0 0 0 0" );
688 IntfBandsCallback( NULL, NULL, val,val, this );
689 config_PutPsz( p_intf, "equalizer-bands",
690 "0 0 0 0 0 0 0 0 0 0");
691 config_PutPsz( p_intf, "equalizer-preset","flat" );
692 eq_chkbox->SetValue( b_previous );
696 var_SetFloat( p_aout, "equalizer-preamp", 12.0 );
697 config_PutFloat( p_intf, "equalizer-preamp", 12.0 );
698 var_SetString( p_aout, "equalizer-bands",
699 "0 0 0 0 0 0 0 0 0 0");
700 config_PutPsz( p_intf, "equalizer-bands",
701 "0 0 0 0 0 0 0 0 0 0");
702 var_SetString( p_aout , "equalizer-preset" , "flat" );
703 config_PutPsz( p_intf, "equalizer-preset","flat" );
704 vlc_object_release( p_aout );
708 void ExtraPanel::OnEq2Pass( wxCommandEvent &event )
710 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
711 VLC_OBJECT_AOUT, FIND_ANYWHERE);
713 vlc_bool_t b_2p = event.IsChecked() ? VLC_TRUE : VLC_FALSE;
717 config_PutInt( p_intf, "equalizer-2pass", b_2p );
721 var_SetBool( p_aout, "equalizer-2pass", b_2p );
722 config_PutInt( p_intf, "equalizer-2pass", b_2p );
723 if( eq_chkbox->IsChecked() )
725 for( int i = 0; i < p_aout->i_nb_inputs; i++ )
727 p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
730 vlc_object_release( p_aout );
734 void ExtraPanel::OnEqSmooth( wxScrollEvent &event )
736 /* Max smoothing : 70% */
737 i_smooth = event.GetPosition() * 7;
740 void ExtraPanel::OnPreamp( wxScrollEvent &event )
742 float f= (float)( 400 - event.GetPosition() ) / 10 - 20 ;
745 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
746 VLC_OBJECT_AOUT, FIND_ANYWHERE);
748 sprintf( psz_val, "%.1f", f );
749 const wxString preamp = wxT("Preamp\n");
750 preamp_text->SetLabel( preamp + wxU( psz_val ) + wxT( "dB" ) );
754 config_PutFloat( p_intf, "equalizer-preamp", f );
758 var_SetFloat( p_aout, "equalizer-preamp", f );
759 config_PutFloat( p_intf, "equalizer-preamp", f );
760 b_my_update = VLC_TRUE;
761 vlc_object_release( p_aout );
765 void ExtraPanel::OnChangeEqualizer( wxScrollEvent &event )
767 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
768 VLC_OBJECT_AOUT, FIND_ANYWHERE);
769 char psz_values[102];
770 memset( psz_values, 0, 102 );
774 int i_diff = event.GetPosition() - i_values[ event.GetId() - Band0_Event ];
775 i_values[ event.GetId() - Band0_Event] = event.GetPosition();
777 for( int i = event.GetId() + 1 ; i <= Band9_Event ; i++ )
779 int i_new = band_sliders[ i-Band0_Event ]->GetValue() +
780 (int)( i_diff * pow( (float)i_smooth / 100 , i- event.GetId() ) ) ;
781 if( i_new < 0 ) i_new = 0;
782 if( i_new > 400 ) i_new = 400;
783 band_sliders[ i-Band0_Event ]->SetValue( i_new );
785 for( int i = Band0_Event ; i < event.GetId() ; i++ )
787 int i_new = band_sliders[ i-Band0_Event ]->GetValue() +
788 (int)( i_diff * pow( (float)i_smooth / 100 , event.GetId() - i ) );
789 if( i_new < 0 ) i_new = 0;
790 if( i_new > 400 ) i_new = 400;
791 band_sliders[ i-Band0_Event ]->SetValue( i_new );
794 /* Write the new bands values */
795 for( int i = 0 ; i < 10 ; i++ )
798 float f_val = (float)( 400 - band_sliders[i]->GetValue() ) / 10- 20 ;
799 sprintf( psz_values, "%s %f", psz_values, f_val );
800 sprintf( psz_val, "%.1f", f_val );
801 band_texts[i]->SetLabel( band_frequencies[i] + wxT("\n") +
802 wxU( psz_val ) + wxT("dB" ) );
806 config_PutPsz( p_intf, "equalizer-bands", psz_values );
810 var_SetString( p_aout, "equalizer-bands", psz_values );
811 config_PutPsz( p_intf, "equalizer-bands", psz_values );
812 b_my_update = VLC_TRUE;
813 vlc_object_release( p_aout );
817 /***********************
819 ***********************/
820 void ExtraPanel::OnHeadphone( wxCommandEvent &event )
822 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
823 VLC_OBJECT_AOUT, FIND_ANYWHERE);
824 ChangeFiltersString( p_intf , p_aout, "headphone_channel_mixer",
825 event.IsChecked() ? VLC_TRUE : VLC_FALSE );
827 vlc_object_release( p_aout );
830 void ExtraPanel::OnNormvol( wxCommandEvent &event )
832 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
833 VLC_OBJECT_AOUT, FIND_ANYWHERE);
834 ChangeFiltersString( p_intf , p_aout, "normvol",
835 event.IsChecked() ? VLC_TRUE : VLC_FALSE );
837 vlc_object_release( p_aout );
840 void ExtraPanel::OnNormvolSlider( wxScrollEvent &event )
842 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
843 VLC_OBJECT_AOUT, FIND_ANYWHERE);
846 var_SetFloat( p_aout, "norm-max-level", (float)event.GetPosition()/10 );
847 vlc_object_release( p_aout );
851 config_PutFloat( p_intf, "norm-max-level",
852 (float)event.GetPosition()/10 );
855 /***********************
857 ***********************/
858 void ExtraPanel::OnEnableAdjust(wxCommandEvent& event)
860 ChangeVFiltersString( p_intf, "adjust",
861 event.IsChecked() ? VLC_TRUE : VLC_FALSE );
863 if( event.IsChecked() )
865 restoredefaults_button->Enable();
866 brightness_slider->Enable();
867 saturation_slider->Enable();
868 contrast_slider->Enable();
869 hue_slider->Enable();
870 gamma_slider->Enable();
874 restoredefaults_button->Disable();
875 brightness_slider->Disable();
876 saturation_slider->Disable();
877 contrast_slider->Disable();
878 hue_slider->Disable();
879 gamma_slider->Disable();
883 void ExtraPanel::OnRestoreDefaults( wxCommandEvent &event)
885 hue_slider->SetValue(0);
886 saturation_slider->SetValue(100);
887 brightness_slider->SetValue(100);
888 contrast_slider->SetValue(100),
889 gamma_slider->SetValue(10);
891 wxScrollEvent *hscroll_event = new wxScrollEvent(0, Hue_Event, 0);
892 OnAdjustUpdate(*hscroll_event);
894 wxScrollEvent *sscroll_event = new wxScrollEvent(0, Saturation_Event, 100);
895 OnAdjustUpdate(*sscroll_event);
897 wxScrollEvent *bscroll_event = new wxScrollEvent(0, Brightness_Event, 100);
898 OnAdjustUpdate(*bscroll_event);
900 wxScrollEvent *cscroll_event = new wxScrollEvent(0, Contrast_Event, 100);
901 OnAdjustUpdate(*cscroll_event);
903 wxScrollEvent *gscroll_event = new wxScrollEvent(0, Gamma_Event, 10);
904 OnAdjustUpdate(*gscroll_event);
908 void ExtraPanel::OnAdjustUpdate( wxScrollEvent &event)
910 vout_thread_t *p_vout = (vout_thread_t *)vlc_object_find(p_intf,
911 VLC_OBJECT_VOUT, FIND_ANYWHERE);
914 switch( event.GetId() )
917 config_PutInt( p_intf , "hue" , event.GetPosition() );
920 case Saturation_Event:
921 config_PutFloat( p_intf , "saturation" ,
922 (float)event.GetPosition()/100 );
925 case Brightness_Event:
926 config_PutFloat( p_intf , "brightness" ,
927 (float)event.GetPosition()/100 );
931 config_PutFloat( p_intf , "contrast" ,
932 (float)event.GetPosition()/100 );
936 config_PutFloat( p_intf , "gamma" ,
937 (float)event.GetPosition()/10 );
944 switch( event.GetId() )
947 val.i_int = event.GetPosition();
948 var_Set( p_vout, "hue", val );
949 config_PutInt( p_intf , "hue" , event.GetPosition() );
952 case Saturation_Event:
953 val.f_float = (float)event.GetPosition() / 100;
954 var_Set( p_vout, "saturation", val );
955 config_PutFloat( p_intf , "saturation" ,
956 (float)event.GetPosition()/100 );
959 case Brightness_Event:
960 val.f_float = (float)event.GetPosition() / 100;
961 var_Set( p_vout, "brightness", val );
962 config_PutFloat( p_intf , "brightness" ,
963 (float)event.GetPosition()/100 );
967 val.f_float = (float)event.GetPosition() / 100;
968 var_Set( p_vout, "contrast", val );
969 config_PutFloat( p_intf , "contrast" ,
970 (float)event.GetPosition()/100 );
974 val.f_float = (float)event.GetPosition() / 10;
975 var_Set( p_vout, "gamma", val );
976 config_PutFloat( p_intf , "gamma" ,
977 (float)event.GetPosition()/10 );
980 vlc_object_release(p_vout);
985 void ExtraPanel::OnRatio( wxCommandEvent& event )
987 config_PutPsz( p_intf, "aspect-ratio", ratio_combo->GetValue().mb_str(wxConvUTF8) );
991 void ExtraPanel::OnSelectFilter(wxCommandEvent& event)
993 int i_filter = event.GetId() - Filter0_Event ;
994 if( vfilters[i_filter].psz_filter )
996 ChangeVFiltersString( p_intf, vfilters[i_filter].psz_filter ,
997 event.IsChecked() ? VLC_TRUE : VLC_FALSE );
1001 void ExtraPanel::OnFiltersInfo(wxCommandEvent& event)
1003 wxMessageBox( wxU( _("Filtering effects to apply to the video. "
1004 "You must restart the stream for these settings to "
1006 "To configure these filters, go to Preferences / Video / "
1007 "Filters. In order to control the order in which they "
1008 "are applied, enter a filters string in the Video Filter "
1009 "Module inside the preferences."
1011 wxU( _("More Information" ) ), wxOK | wxICON_INFORMATION,
1014 /**********************************
1016 **********************************/
1017 void ExtraPanel::CheckAout()
1019 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
1020 VLC_OBJECT_AOUT, FIND_ANYWHERE);
1021 if( p_aout != NULL )
1023 if( p_aout != p_intf->p_sys->p_aout )
1025 /* We want to know if someone changes the bands */
1026 if( var_AddCallback( p_aout, "equalizer-bands",
1027 IntfBandsCallback, this ) )
1029 /* The variable does not exist yet, wait */
1030 vlc_object_release( p_aout );
1033 if( var_AddCallback( p_aout, "equalizer-preamp",
1034 IntfPreampCallback, this ) )
1036 vlc_object_release( p_aout );
1039 /* Ok, we have our variables, make a first update round */
1040 p_intf->p_sys->p_aout = p_aout;
1042 f_preamp = var_GetFloat( p_aout, "equalizer-preamp" );
1043 psz_bands = var_GetNonEmptyString( p_aout, "equalizer-bands" );
1044 if( psz_bands == NULL )
1045 psz_bands = strdup("");
1046 b_update = VLC_TRUE;
1048 vlc_object_release( p_aout );
1053 static void ChangeVFiltersString( intf_thread_t *p_intf,
1054 char *psz_name, vlc_bool_t b_add )
1056 vout_thread_t *p_vout;
1057 char *psz_parser, *psz_string;
1059 psz_string = config_GetPsz( p_intf, "vout-filter" );
1061 if( !psz_string ) psz_string = strdup("");
1063 psz_parser = strstr( psz_string, psz_name );
1069 psz_parser = psz_string;
1070 asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
1071 psz_string, psz_name );
1083 memmove( psz_parser, psz_parser + strlen(psz_name) +
1084 (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
1085 strlen(psz_parser + strlen(psz_name)) + 1 );
1087 /* Remove trailing : : */
1088 if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
1090 *(psz_string+strlen(psz_string ) -1 ) = '\0';
1099 /* Vout is not kept, so put that in the config */
1100 config_PutPsz( p_intf, "vout-filter", psz_string );
1102 /* Try to set on the fly */
1103 p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
1107 var_SetString( p_vout, "vout-filter", psz_string );
1108 vlc_object_release( p_vout );
1115 static void ChangeFiltersString( intf_thread_t *p_intf,
1116 aout_instance_t * p_aout,
1117 char *psz_name, vlc_bool_t b_add )
1119 char *psz_parser, *psz_string;
1123 psz_string = var_GetNonEmptyString( p_aout, "audio-filter" );
1127 psz_string = config_GetPsz( p_intf, "audio-filter" );
1130 if( !psz_string ) psz_string = strdup("");
1132 psz_parser = strstr( psz_string, psz_name );
1138 psz_parser = psz_string;
1139 asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
1140 psz_string, psz_name );
1152 memmove( psz_parser, psz_parser + strlen(psz_name) +
1153 (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
1154 strlen(psz_parser + strlen(psz_name)) + 1 );
1156 if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
1158 *(psz_string+strlen(psz_string ) -1 ) = '\0';
1168 if( p_aout == NULL )
1170 config_PutPsz( p_intf, "audio-filter", psz_string );
1174 var_SetString( p_aout, "audio-filter", psz_string );
1175 for( int i = 0; i < p_aout->i_nb_inputs; i++ )
1177 p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
1184 static int IntfBandsCallback( vlc_object_t *p_this, char const *psz_cmd,
1185 vlc_value_t oldval, vlc_value_t newval, void *param )
1187 ExtraPanel *p_panel = (ExtraPanel *)param;
1189 p_panel->psz_bands = strdup( newval.psz_string );
1190 p_panel->b_update = VLC_TRUE;
1195 static int IntfPreampCallback( vlc_object_t *p_this, char const *psz_cmd,
1196 vlc_value_t oldval, vlc_value_t newval, void *param )
1198 ExtraPanel *p_panel = (ExtraPanel *)param;
1200 p_panel->f_preamp = newval.f_float;
1201 p_panel->b_update = VLC_TRUE;
1207 /**********************************************************************
1208 * A small window to contain the extrapanel in its undocked state
1209 **********************************************************************/
1210 BEGIN_EVENT_TABLE(ExtraWindow, wxFrame)
1214 ExtraWindow::ExtraWindow( intf_thread_t *_p_intf, wxWindow *p_parent,
1215 wxPanel *_extra_panel ):
1216 wxFrame( p_parent, -1, wxU(_("Extended controls")), wxDefaultPosition,
1217 wxDefaultSize, wxDEFAULT_FRAME_STYLE )
1220 SetIcon( *p_intf->p_sys->p_icon );
1222 wxBoxSizer *window_sizer = new wxBoxSizer( wxVERTICAL );
1223 SetSizer( window_sizer );
1225 panel = _extra_panel;
1226 window_sizer->Add( panel );
1228 window_sizer->Layout();
1229 window_sizer->Fit( this );
1234 ExtraWindow::~ExtraWindow()