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 *****************************************************************************/
30 #include <vlc_interface.h>
34 #include "extrapanel.hpp"
36 /*****************************************************************************
37 * Local class declarations.
38 *****************************************************************************/
40 #define SMOOTH_TIP N_( "Controls the blending of equalizer bands. The higher" \
41 " this value is, the more correlated their movement will be." )
43 static int IntfBandsCallback( vlc_object_t *, char const *,
44 vlc_value_t, vlc_value_t, void * );
45 static int IntfPreampCallback( vlc_object_t *, char const *,
46 vlc_value_t, vlc_value_t, void * );
47 static void ChangeFiltersString( intf_thread_t *, aout_instance_t *,
49 static void ChangeVFiltersString( intf_thread_t *, char *, vlc_bool_t );
52 /* IDs for the controls and the menu commands */
58 RestoreDefaults_Event,
69 Filter0_Event, Filter1_Event, Filter2_Event, Filter3_Event, Filter4_Event,
70 Filter5_Event, Filter6_Event, Filter7_Event, Filter8_Event, Filter9_Event,
80 Band0_Event,Band1_Event,Band2_Event,Band3_Event,Band4_Event,
81 Band5_Event,Band6_Event,Band7_Event,Band8_Event,Band9_Event,
83 NormVol_Event, NVSlider_Event, HeadPhone_Event
86 BEGIN_EVENT_TABLE( ExtraPanel, wxPanel )
87 EVT_IDLE( ExtraPanel::OnIdle )
90 EVT_CHECKBOX( EqEnable_Event, ExtraPanel::OnEnableEqualizer )
91 EVT_CHECKBOX( Eq2Pass_Event, ExtraPanel::OnEq2Pass )
92 EVT_BUTTON( EqRestore_Event, ExtraPanel::OnEqRestore )
94 EVT_COMMAND_SCROLL( Preamp_Event, ExtraPanel::OnPreamp )
95 EVT_COMMAND_SCROLL( Smooth_Event, ExtraPanel::OnEqSmooth )
97 EVT_COMMAND_SCROLL(Band0_Event, ExtraPanel::OnChangeEqualizer)
98 EVT_COMMAND_SCROLL(Band1_Event, ExtraPanel::OnChangeEqualizer)
99 EVT_COMMAND_SCROLL(Band2_Event, ExtraPanel::OnChangeEqualizer)
100 EVT_COMMAND_SCROLL(Band3_Event, ExtraPanel::OnChangeEqualizer)
101 EVT_COMMAND_SCROLL(Band4_Event, ExtraPanel::OnChangeEqualizer)
102 EVT_COMMAND_SCROLL(Band5_Event, ExtraPanel::OnChangeEqualizer)
103 EVT_COMMAND_SCROLL(Band6_Event, ExtraPanel::OnChangeEqualizer)
104 EVT_COMMAND_SCROLL(Band7_Event, ExtraPanel::OnChangeEqualizer)
105 EVT_COMMAND_SCROLL(Band8_Event, ExtraPanel::OnChangeEqualizer)
106 EVT_COMMAND_SCROLL(Band9_Event, ExtraPanel::OnChangeEqualizer)
109 EVT_CHECKBOX( Adjust_Event, ExtraPanel::OnEnableAdjust )
110 EVT_BUTTON( RestoreDefaults_Event, ExtraPanel::OnRestoreDefaults )
112 EVT_COMMAND_SCROLL(Hue_Event, ExtraPanel::OnAdjustUpdate)
113 EVT_COMMAND_SCROLL(Contrast_Event, ExtraPanel::OnAdjustUpdate)
114 EVT_COMMAND_SCROLL(Brightness_Event, ExtraPanel::OnAdjustUpdate)
115 EVT_COMMAND_SCROLL(Saturation_Event, ExtraPanel::OnAdjustUpdate)
116 EVT_COMMAND_SCROLL(Gamma_Event, ExtraPanel::OnAdjustUpdate)
118 EVT_BUTTON( FiltersInfo_Event, ExtraPanel::OnFiltersInfo )
120 EVT_CHECKBOX( Filter0_Event, ExtraPanel::OnSelectFilter )
121 EVT_CHECKBOX( Filter1_Event, ExtraPanel::OnSelectFilter )
122 EVT_CHECKBOX( Filter2_Event, ExtraPanel::OnSelectFilter )
123 EVT_CHECKBOX( Filter3_Event, ExtraPanel::OnSelectFilter )
124 EVT_CHECKBOX( Filter4_Event, ExtraPanel::OnSelectFilter )
125 EVT_CHECKBOX( Filter5_Event, ExtraPanel::OnSelectFilter )
126 EVT_CHECKBOX( Filter6_Event, ExtraPanel::OnSelectFilter )
127 EVT_CHECKBOX( Filter7_Event, ExtraPanel::OnSelectFilter )
128 EVT_CHECKBOX( Filter8_Event, ExtraPanel::OnSelectFilter )
129 EVT_CHECKBOX( Filter9_Event, ExtraPanel::OnSelectFilter )
132 EVT_CHECKBOX( NormVol_Event, ExtraPanel::OnNormvol )
133 EVT_CHECKBOX( HeadPhone_Event, ExtraPanel::OnHeadphone )
135 EVT_COMMAND_SCROLL( NVSlider_Event, ExtraPanel::OnNormvolSlider )
145 static const struct filter vfilters[] =
147 { "clone", N_("Image clone"), N_("Creates several clones of the image") },
148 { "distort", N_("Distortion"), N_("Adds distortion effects") },
149 { "invert", N_("Image inversion") , N_("Inverts the colors of the image") },
150 { "motionblur", N_("Blurring"), N_("Adds motion blurring to the image") },
151 { "transform", N_("Transformation"), N_("Rotates or flips the image") },
152 { "magnify", N_("Magnify"), N_("Magnifies part of the image") },
153 { "puzzle", N_("Puzzle"), N_("Turns the image into a puzzle") },
154 { NULL, NULL, NULL } /* Do not remove this line */
157 /*****************************************************************************
159 *****************************************************************************/
160 ExtraPanel::ExtraPanel( intf_thread_t *_p_intf, wxWindow *_p_parent ):
161 wxPanel( _p_parent , -1, wxDefaultPosition, wxDefaultSize )
165 p_parent = _p_parent;
166 SetAutoLayout( TRUE );
168 wxBoxSizer *extra_sizer = new wxBoxSizer( wxHORIZONTAL );
170 notebook = new wxNotebook( this, Notebook_Event );
172 #if (!wxCHECK_VERSION(2,5,2))
173 wxNotebookSizer *notebook_sizer = new wxNotebookSizer( notebook );
176 notebook->AddPage( VideoPanel( notebook ), wxU(_("Video")) );
177 notebook->AddPage( EqzPanel( notebook ), wxU(_("Equalizer")) );
178 notebook->AddPage( AudioPanel( notebook ), wxU(_("Audio")) );
180 #if (!wxCHECK_VERSION(2,5,2))
181 extra_sizer->Add( notebook_sizer, 1, wxEXPAND, 0 );
183 extra_sizer->Add( notebook, 1, wxEXPAND, 0 );
186 SetSizerAndFit( extra_sizer );
187 extra_sizer->Layout();
190 ExtraPanel::~ExtraPanel()
194 /* Video Panel constructor */
195 wxPanel *ExtraPanel::VideoPanel( wxWindow *parent )
199 wxPanel *panel = new wxPanel( parent, -1 );
200 wxBoxSizer *panel_sizer = new wxBoxSizer( wxHORIZONTAL );
202 /* Create static box to surround the adjust controls */
203 wxStaticBox *adjust_box =
204 new wxStaticBox( panel, -1, wxU(_("Image adjustment" )) );
205 wxStaticBoxSizer *adjust_sizer =
206 new wxStaticBoxSizer( adjust_box, wxVERTICAL );
207 adjust_sizer->SetMinSize( -1, 50 );
209 /* Create flex grid */
210 wxFlexGridSizer *adjust_gridsizer =
211 new wxFlexGridSizer( 6, 2, 0, 0);
212 adjust_gridsizer->AddGrowableCol(1);
214 /* Create the adjust button */
215 wxCheckBox * adjust_check = new wxCheckBox( panel, Adjust_Event,
218 /* Create the restore to defaults button */
219 restoredefaults_button =
220 new wxButton( panel, RestoreDefaults_Event,
221 wxU(_("Restore Defaults")), wxDefaultPosition);
223 wxStaticText *hue_text = new wxStaticText( panel, -1,
225 hue_slider = new wxSlider ( panel, Hue_Event, 0, 0,
226 360, wxDefaultPosition, wxDefaultSize );
228 wxStaticText *contrast_text = new wxStaticText( panel, -1,
229 wxU(_("Contrast")) );
230 contrast_slider = new wxSlider ( panel, Contrast_Event, 0, 0,
231 200, wxDefaultPosition, wxDefaultSize);
233 wxStaticText *brightness_text = new wxStaticText( panel, -1,
234 wxU(_("Brightness")) );
235 brightness_slider = new wxSlider ( panel, Brightness_Event, 0, 0,
236 200, wxDefaultPosition, wxDefaultSize) ;
238 wxStaticText *saturation_text = new wxStaticText( panel, -1,
239 wxU(_("Saturation")) );
240 saturation_slider = new wxSlider ( panel, Saturation_Event, 0, 0,
241 300, wxDefaultPosition, wxDefaultSize );
243 wxStaticText *gamma_text = new wxStaticText( panel, -1,
245 gamma_slider = new wxSlider ( panel, Gamma_Event, 0, 0,
246 100, wxDefaultPosition, wxDefaultSize );
248 adjust_gridsizer->Add( adjust_check, 1, wxEXPAND|wxALL, 2 );
249 adjust_gridsizer->Add( restoredefaults_button, 1, wxEXPAND|wxALL, 2 );
250 adjust_gridsizer->Add( hue_text, 1, wxEXPAND|wxALL, 2 );
251 adjust_gridsizer->Add( hue_slider, 1, wxEXPAND|wxALL, 2 );
252 adjust_gridsizer->Add( contrast_text, 1, wxEXPAND|wxALL, 2 );
253 adjust_gridsizer->Add( contrast_slider, 1, wxEXPAND|wxALL, 2 );
254 adjust_gridsizer->Add( brightness_text, 1, wxEXPAND|wxALL, 2 );
255 adjust_gridsizer->Add( brightness_slider, 1, wxEXPAND|wxALL, 2 );
256 adjust_gridsizer->Add( saturation_text, 1, wxEXPAND|wxALL, 2 );
257 adjust_gridsizer->Add( saturation_slider, 1, wxEXPAND|wxALL, 2 );
258 adjust_gridsizer->Add( gamma_text, 1, wxEXPAND|wxALL, 2 );
259 adjust_gridsizer->Add( gamma_slider, 1, wxEXPAND|wxALL, 2 );
261 adjust_sizer->Add( adjust_gridsizer, 1, wxEXPAND|wxALL, 2);
263 panel_sizer->Add( adjust_sizer , 1, wxTOP, 2 );
266 /* Create sizer to surround the other controls */
267 wxBoxSizer *other_sizer = new wxBoxSizer( wxVERTICAL );
269 wxStaticBox *video_box =
270 new wxStaticBox( panel, -1, wxU(_("Video Options")) );
271 /* Create the sizer for the frame */
272 wxStaticBoxSizer *video_sizer =
273 new wxStaticBoxSizer( video_box, wxVERTICAL );
274 video_sizer->SetMinSize( -1, 50 );
276 static const wxString ratio_array[] =
282 wxBoxSizer *ratio_sizer = new wxBoxSizer( wxHORIZONTAL );
283 wxStaticText *ratio_text = new wxStaticText( panel, -1,
284 wxU(_("Aspect Ratio")) );
286 ratio_combo = new wxComboBox( panel, Ratio_Event, wxT(""),
287 wxDefaultPosition, wxSize( 80 , -1),
288 WXSIZEOF(ratio_array), ratio_array,
291 ratio_sizer->Add( ratio_text, 0, wxALL, 2 );
292 ratio_sizer->Add( ratio_combo, 0, wxALL, 2 );
293 ratio_sizer->Layout();
295 video_sizer->Add( ratio_sizer , 0 , wxALL , 2 );
296 video_sizer->Layout();
299 wxStaticBox *filter_box =
300 new wxStaticBox( panel, -1, wxU(_("Video filters")) );
301 wxStaticBoxSizer *filter_sizer =
302 new wxStaticBoxSizer( filter_box, wxHORIZONTAL );
304 wxBoxSizer *t_col_sizer = new wxBoxSizer( wxVERTICAL );
307 for( int i = 0 ; vfilters[i].psz_filter != NULL ; i++ )
309 wxCheckBox *box = new wxCheckBox( panel, Filter0_Event + i,
310 wxU( _( vfilters[i].psz_name ) ) );
311 t_col_sizer->Add( box, 0, wxALL, 2 );
312 box->SetToolTip( wxU( _( vfilters[i].psz_help ) ) );
315 filter_sizer->Add( t_col_sizer );
316 filter_sizer->Add( new wxButton( panel, FiltersInfo_Event,
317 wxU(_("More Info" ) ) ), 0, wxALL, 4 );
319 other_sizer->Add( video_sizer, 0, wxALL | wxEXPAND , 0);
320 other_sizer->Add( filter_sizer, 0, wxALL | wxEXPAND , 0);
321 other_sizer->Layout();
322 panel_sizer->Add(other_sizer , 1 );
325 panel_sizer->Add( filter_sizer, 1, wxTOP|wxLEFT, 2 );
327 panel->SetSizerAndFit( panel_sizer );
329 /* Layout the whole panel */
330 panel_sizer->Layout();
332 panel_sizer->SetSizeHints( panel );
334 /* Write down initial values */
335 psz_filters = config_GetPsz( p_intf, "vout-filter" );
336 if( psz_filters && strstr( psz_filters, "adjust" ) )
338 adjust_check->SetValue( 1 );
339 restoredefaults_button->Enable();
340 saturation_slider->Enable();
341 contrast_slider->Enable();
342 brightness_slider->Enable();
343 hue_slider->Enable();
344 gamma_slider->Enable();
348 adjust_check->SetValue( 0 );
349 restoredefaults_button->Disable();
350 saturation_slider->Disable();
351 contrast_slider->Disable();
352 brightness_slider->Disable();
353 hue_slider->Disable();
354 gamma_slider->Disable();
356 if( psz_filters ) free( psz_filters );
358 int i_value = config_GetInt( p_intf, "hue" );
359 if( i_value > 0 && i_value < 360 )
360 hue_slider->SetValue( i_value );
362 f_value = config_GetFloat( p_intf, "saturation" );
363 if( f_value > 0 && f_value < 5 )
364 saturation_slider->SetValue( (int)(100 * f_value) );
365 f_value = config_GetFloat( p_intf, "contrast" );
366 if( f_value > 0 && f_value < 4 )
367 contrast_slider->SetValue( (int)(100 * f_value) );
368 f_value = config_GetFloat( p_intf, "brightness" );
369 if( f_value > 0 && f_value < 2 )
370 brightness_slider->SetValue( (int)(100 * f_value) );
371 f_value = config_GetFloat( p_intf, "gamma" );
372 if( f_value > 0 && f_value < 10 )
373 gamma_slider->SetValue( (int)(10 * f_value) );
375 b_update = VLC_FALSE;
380 /* Audio panel constructor */
381 wxPanel *ExtraPanel::AudioPanel( wxWindow *parent )
385 wxPanel *panel = new wxPanel( parent, -1 );
386 wxBoxSizer *panel_sizer = new wxBoxSizer( wxHORIZONTAL );
388 /* Create static box to surround the adjust controls */
389 wxStaticBox *filter_box =
390 new wxStaticBox( panel, -1, wxU(_("Audio filters")) );
391 wxStaticBoxSizer *filter_sizer =
392 new wxStaticBoxSizer( filter_box, wxVERTICAL );
393 filter_sizer->SetMinSize( -1, 50 );
395 wxCheckBox * headphone_check = new wxCheckBox( panel, HeadPhone_Event,
396 wxU(_("Headphone virtualization")));
397 headphone_check->SetToolTip( wxU(_("Imitates the effect of "
398 "surround sound when using headphones." ) ) );
400 wxCheckBox * normvol_check = new wxCheckBox( panel, NormVol_Event,
401 wxU(_("Volume normalization")));
402 normvol_check->SetToolTip( wxU(_("Prevents the audio output "
403 "level from going over a predefined value." ) ) );
405 wxStaticText *normvol_label = new wxStaticText( panel, -1,
406 wxU( _("Maximum level") ) );
408 wxSlider *normvol_slider = new wxSlider ( panel, NVSlider_Event, 20, 5,
409 100, wxDefaultPosition, wxSize( 100, -1 ) );
411 filter_sizer->Add( headphone_check, 0, wxALL, 4 );
412 filter_sizer->Add( normvol_check, 0, wxALL, 4 );
413 filter_sizer->Add( normvol_label, 0, wxALL, 4 );
414 filter_sizer->Add( normvol_slider, 0, wxALL, 4 );
416 panel_sizer->Add( filter_sizer, 1, wxTOP, 2 );
417 panel->SetSizerAndFit( panel_sizer );
418 panel_sizer->Layout();
419 panel_sizer->SetSizeHints( panel );
421 /* Write down initial values */
422 psz_filters = config_GetPsz( p_intf, "audio-filter" );
425 headphone_check->SetValue( strstr( psz_filters, "headphone" ) );
426 normvol_check->SetValue( strstr( psz_filters, "normvol" ) );
431 headphone_check->SetValue( 0 );
432 normvol_check->SetValue( 0 );
439 static const wxString band_frequencies[] =
453 /* Equalizer Panel constructor */
454 wxPanel *ExtraPanel::EqzPanel( wxWindow *parent )
456 wxPanel *panel = new wxPanel( parent, -1 );
457 wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL );
459 /* Create static box to surround the adjust controls */
460 wxBoxSizer *top_sizer =
461 new wxBoxSizer( wxHORIZONTAL );
463 /* Create the enable button */
464 eq_chkbox = new wxCheckBox( panel, EqEnable_Event,
466 eq_chkbox->SetToolTip( wxU(_("Enable the equalizer. You can either "
467 "manually adjust the bands or use a preset (Audio Menu->Equalizer)." ) ) );
468 top_sizer->Add( eq_chkbox, 0, wxALL, 2 );
470 eq_2p_chkbox = new wxCheckBox( panel, Eq2Pass_Event,
473 eq_2p_chkbox->SetToolTip( wxU(_("Apply the equalizer twice. "
474 "The resulting effect will be sharper.") ) );
476 top_sizer->Add( eq_2p_chkbox, 0, wxALL, 2 );
478 top_sizer->Add( 0, 0, 1, wxALL, 2 );
480 eq_restoredefaults_button = new wxButton( panel, EqRestore_Event,
481 wxU( _("Restore Defaults") ) );
482 top_sizer->Add( eq_restoredefaults_button, 0, wxALL, 2 );
483 top_sizer->Add( 0, 0, 1, wxALL, 2 );
485 smooth_text = new wxStaticText( panel, -1, wxU( _("Smooth :") ));
486 smooth_text->SetToolTip( wxU( _(SMOOTH_TIP) ) );
487 top_sizer->Add( smooth_text, 0, wxALL, 2 );
489 smooth_slider =new wxSlider( panel, Smooth_Event, 0, 0, 10 ,
490 wxDefaultPosition, wxSize( 100, -1 ) );
491 smooth_slider->SetToolTip( wxU( _(SMOOTH_TIP) ) );
492 top_sizer->Add( smooth_slider, 0, wxALL, 2 );
495 /* Create flex grid */
496 wxFlexGridSizer *eq_gridsizer =
497 new wxFlexGridSizer( 2, 12, 0, 0);
498 eq_gridsizer->AddGrowableRow( 0 );
499 eq_gridsizer->AddGrowableCol( 1 );
501 preamp_slider = new wxSlider( panel, Preamp_Event, 80, 0, 400,
502 wxDefaultPosition, wxSize( -1 , 90 ) , wxSL_VERTICAL );
503 eq_gridsizer->Add( preamp_slider, 1, wxEXPAND|wxALL, 2 );
505 eq_gridsizer->Add( 0, 0, 1, wxALL, 2 );
507 for( int i = 0 ; i < 10 ; i++ )
509 band_sliders[i] = new wxSlider( panel, Band0_Event + i, 200, 0, 400,
510 wxDefaultPosition, wxSize( -1 , 90 ) , wxSL_VERTICAL );
513 eq_gridsizer->Add( band_sliders[i], 1, wxEXPAND|wxALL, 2 );
516 preamp_text = new wxStaticText( panel, -1, wxU( _("Preamp\n12.0dB") ) );
517 wxFont font= preamp_text->GetFont();
518 font.SetPointSize(7);
519 preamp_text->SetFont( font );
520 eq_gridsizer->Add( preamp_text, wxALL, 2 );
522 eq_gridsizer->Add( 0, 0, 1 );
524 for( int i = 0 ; i < 10 ; i++ )
526 band_texts[i] = new wxStaticText( panel, -1,
527 band_frequencies[i] + wxU("\n0.0dB" ) ) ;
528 eq_gridsizer->Add( band_texts[i], 1, wxEXPAND|wxALL, 2 );
529 wxFont font= band_texts[i]->GetFont();
530 font.SetPointSize(7);
531 band_texts[i]->SetFont( font );
534 panel_sizer->Add( top_sizer , 0 , wxTOP | wxEXPAND, 5 );
535 panel_sizer->Add( eq_gridsizer , 0 , wxEXPAND, 0 );
537 panel->SetSizer( panel_sizer );
539 panel_sizer->Layout();
541 panel_sizer->SetSizeHints( panel );
545 aout_instance_t *p_aout = (aout_instance_t *)vlc_object_find(p_intf,
546 VLC_OBJECT_AOUT, FIND_ANYWHERE);
550 psz_af = var_GetNonEmptyString( p_aout, "audio-filter" );
551 if( var_GetBool( p_aout, "equalizer-2pass" ) )
552 eq_2p_chkbox->SetValue( true );
553 vlc_object_release( p_aout );
557 psz_af = config_GetPsz( p_intf, "audio-filter" );
558 if( config_GetInt( p_intf, "equalizer-2pass" ) )
559 eq_2p_chkbox->SetValue( true );
561 if( psz_af != NULL && strstr( psz_af, "equalizer" ) )
563 eq_chkbox->SetValue( true );
565 eq_2p_chkbox->Disable();
566 eq_restoredefaults_button->Disable();
567 smooth_slider->Disable();
568 smooth_text->Disable();
569 preamp_slider->Disable();
570 preamp_text->Disable();
571 for( int i_index=0; i_index < 10; i_index++ )
573 band_sliders[i_index]->Disable();
574 band_texts[i_index]->Disable();
582 /*******************************************************
584 *******************************************************/
586 /* Keep aout up to date and update the bands if needed */
587 void ExtraPanel::OnIdle( wxIdleEvent &event )
590 if( b_update == VLC_TRUE )
592 if( b_my_update == VLC_TRUE )
594 b_update = b_my_update = VLC_FALSE;
598 for( int i = 0; i < 10; i++ )
605 i_val= (int)( ( f + 20 ) * 10 );
606 band_sliders[i]->SetValue( 400 - i_val );
607 i_values[i] = 400 - i_val;
608 sprintf( psz_val, "%.1f", f );
609 band_texts[i]->SetLabel( band_frequencies[i] + wxT("\n") +
610 wxU( psz_val ) + wxT("dB") );
620 int i_val = (int)( ( f_preamp + 20 ) * 10 );
621 sprintf( psz_val, "%.1f", f_preamp );
622 preamp_slider->SetValue( 400 - i_val );
623 const wxString preamp = wxT("Preamp\n");
624 preamp_text->SetLabel( preamp + wxU( psz_val ) + wxT( "dB" ) );
625 eq_chkbox->SetValue( TRUE );
626 b_update = VLC_FALSE;
630 /*************************
631 * Equalizer Panel events
632 *************************/
633 void ExtraPanel::OnEnableEqualizer( wxCommandEvent &event )
636 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
637 VLC_OBJECT_AOUT, FIND_ANYWHERE);
638 ChangeFiltersString( p_intf,p_aout, "equalizer",
639 event.IsChecked() ? VLC_TRUE : VLC_FALSE );
641 if( event.IsChecked() )
643 eq_2p_chkbox->Enable();
644 eq_restoredefaults_button->Enable();
645 smooth_slider->Enable();
646 smooth_text->Enable();
647 preamp_slider->Enable();
648 preamp_text->Enable();
649 for( i_index=0; i_index < 10; i_index++ )
651 band_sliders[i_index]->Enable();
652 band_texts[i_index]->Enable();
655 eq_2p_chkbox->Disable();
656 eq_restoredefaults_button->Disable();
657 smooth_slider->Disable();
658 smooth_text->Disable();
659 preamp_slider->Disable();
660 preamp_text->Disable();
661 for( i_index=0; i_index < 10; i_index++ )
663 band_sliders[i_index]->Disable();
664 band_texts[i_index]->Disable();
669 vlc_object_release( p_aout );
672 void ExtraPanel::OnEqRestore( wxCommandEvent &event )
674 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
675 VLC_OBJECT_AOUT, FIND_ANYWHERE);
679 vlc_bool_t b_previous = eq_chkbox->IsChecked();
681 IntfPreampCallback( NULL, NULL, val,val, this );
682 config_PutFloat( p_intf, "equalizer-preamp", 12.0 );
683 val.psz_string = strdup( "0 0 0 0 0 0 0 0 0 0" );
684 IntfBandsCallback( NULL, NULL, val,val, this );
685 config_PutPsz( p_intf, "equalizer-bands",
686 "0 0 0 0 0 0 0 0 0 0");
687 config_PutPsz( p_intf, "equalizer-preset","flat" );
688 eq_chkbox->SetValue( b_previous );
692 var_SetFloat( p_aout, "equalizer-preamp", 12.0 );
693 config_PutFloat( p_intf, "equalizer-preamp", 12.0 );
694 var_SetString( p_aout, "equalizer-bands",
695 "0 0 0 0 0 0 0 0 0 0");
696 config_PutPsz( p_intf, "equalizer-bands",
697 "0 0 0 0 0 0 0 0 0 0");
698 var_SetString( p_aout , "equalizer-preset" , "flat" );
699 config_PutPsz( p_intf, "equalizer-preset","flat" );
700 vlc_object_release( p_aout );
704 void ExtraPanel::OnEq2Pass( wxCommandEvent &event )
706 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
707 VLC_OBJECT_AOUT, FIND_ANYWHERE);
709 vlc_bool_t b_2p = event.IsChecked() ? VLC_TRUE : VLC_FALSE;
713 config_PutInt( p_intf, "equalizer-2pass", b_2p );
717 var_SetBool( p_aout, "equalizer-2pass", b_2p );
718 config_PutInt( p_intf, "equalizer-2pass", b_2p );
719 if( eq_chkbox->IsChecked() )
721 for( int i = 0; i < p_aout->i_nb_inputs; i++ )
723 p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
726 vlc_object_release( p_aout );
730 void ExtraPanel::OnEqSmooth( wxScrollEvent &event )
732 /* Max smoothing : 70% */
733 i_smooth = event.GetPosition() * 7;
736 void ExtraPanel::OnPreamp( wxScrollEvent &event )
738 float f= (float)( 400 - event.GetPosition() ) / 10 - 20 ;
741 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
742 VLC_OBJECT_AOUT, FIND_ANYWHERE);
744 sprintf( psz_val, "%.1f", f );
745 const wxString preamp = wxT("Preamp\n");
746 preamp_text->SetLabel( preamp + wxU( psz_val ) + wxT( "dB" ) );
750 config_PutFloat( p_intf, "equalizer-preamp", f );
754 var_SetFloat( p_aout, "equalizer-preamp", f );
755 config_PutFloat( p_intf, "equalizer-preamp", f );
756 b_my_update = VLC_TRUE;
757 vlc_object_release( p_aout );
761 void ExtraPanel::OnChangeEqualizer( wxScrollEvent &event )
763 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
764 VLC_OBJECT_AOUT, FIND_ANYWHERE);
765 char psz_values[102];
766 memset( psz_values, 0, 102 );
770 int i_diff = event.GetPosition() - i_values[ event.GetId() - Band0_Event ];
771 i_values[ event.GetId() - Band0_Event] = event.GetPosition();
773 for( int i = event.GetId() + 1 ; i <= Band9_Event ; i++ )
775 int i_new = band_sliders[ i-Band0_Event ]->GetValue() +
776 (int)( i_diff * pow( (float)i_smooth / 100 , i- event.GetId() ) ) ;
777 if( i_new < 0 ) i_new = 0;
778 if( i_new > 400 ) i_new = 400;
779 band_sliders[ i-Band0_Event ]->SetValue( i_new );
781 for( int i = Band0_Event ; i < event.GetId() ; i++ )
783 int i_new = band_sliders[ i-Band0_Event ]->GetValue() +
784 (int)( i_diff * pow( (float)i_smooth / 100 , event.GetId() - i ) );
785 if( i_new < 0 ) i_new = 0;
786 if( i_new > 400 ) i_new = 400;
787 band_sliders[ i-Band0_Event ]->SetValue( i_new );
790 /* Write the new bands values */
791 for( int i = 0 ; i < 10 ; i++ )
794 float f_val = (float)( 400 - band_sliders[i]->GetValue() ) / 10- 20 ;
795 sprintf( psz_values, "%s %f", psz_values, f_val );
796 sprintf( psz_val, "%.1f", f_val );
797 band_texts[i]->SetLabel( band_frequencies[i] + wxT("\n") +
798 wxU( psz_val ) + wxT("dB" ) );
802 config_PutPsz( p_intf, "equalizer-bands", psz_values );
806 var_SetString( p_aout, "equalizer-bands", psz_values );
807 config_PutPsz( p_intf, "equalizer-bands", psz_values );
808 b_my_update = VLC_TRUE;
809 vlc_object_release( p_aout );
813 /***********************
815 ***********************/
816 void ExtraPanel::OnHeadphone( wxCommandEvent &event )
818 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
819 VLC_OBJECT_AOUT, FIND_ANYWHERE);
820 ChangeFiltersString( p_intf , p_aout, "headphone_channel_mixer",
821 event.IsChecked() ? VLC_TRUE : VLC_FALSE );
823 vlc_object_release( p_aout );
826 void ExtraPanel::OnNormvol( wxCommandEvent &event )
828 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
829 VLC_OBJECT_AOUT, FIND_ANYWHERE);
830 ChangeFiltersString( p_intf , p_aout, "normvol",
831 event.IsChecked() ? VLC_TRUE : VLC_FALSE );
833 vlc_object_release( p_aout );
836 void ExtraPanel::OnNormvolSlider( wxScrollEvent &event )
838 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
839 VLC_OBJECT_AOUT, FIND_ANYWHERE);
842 var_SetFloat( p_aout, "norm-max-level", (float)event.GetPosition()/10 );
843 vlc_object_release( p_aout );
847 config_PutFloat( p_intf, "norm-max-level",
848 (float)event.GetPosition()/10 );
851 /***********************
853 ***********************/
854 void ExtraPanel::OnEnableAdjust(wxCommandEvent& event)
856 ChangeVFiltersString( p_intf, "adjust",
857 event.IsChecked() ? VLC_TRUE : VLC_FALSE );
859 if( event.IsChecked() )
861 restoredefaults_button->Enable();
862 brightness_slider->Enable();
863 saturation_slider->Enable();
864 contrast_slider->Enable();
865 hue_slider->Enable();
866 gamma_slider->Enable();
870 restoredefaults_button->Disable();
871 brightness_slider->Disable();
872 saturation_slider->Disable();
873 contrast_slider->Disable();
874 hue_slider->Disable();
875 gamma_slider->Disable();
879 void ExtraPanel::OnRestoreDefaults( wxCommandEvent &event)
881 hue_slider->SetValue(0);
882 saturation_slider->SetValue(100);
883 brightness_slider->SetValue(100);
884 contrast_slider->SetValue(100),
885 gamma_slider->SetValue(10);
887 wxScrollEvent *hscroll_event = new wxScrollEvent(0, Hue_Event, 0);
888 OnAdjustUpdate(*hscroll_event);
890 wxScrollEvent *sscroll_event = new wxScrollEvent(0, Saturation_Event, 100);
891 OnAdjustUpdate(*sscroll_event);
893 wxScrollEvent *bscroll_event = new wxScrollEvent(0, Brightness_Event, 100);
894 OnAdjustUpdate(*bscroll_event);
896 wxScrollEvent *cscroll_event = new wxScrollEvent(0, Contrast_Event, 100);
897 OnAdjustUpdate(*cscroll_event);
899 wxScrollEvent *gscroll_event = new wxScrollEvent(0, Gamma_Event, 10);
900 OnAdjustUpdate(*gscroll_event);
904 void ExtraPanel::OnAdjustUpdate( wxScrollEvent &event)
906 vout_thread_t *p_vout = (vout_thread_t *)vlc_object_find(p_intf,
907 VLC_OBJECT_VOUT, FIND_ANYWHERE);
910 switch( event.GetId() )
913 config_PutInt( p_intf , "hue" , event.GetPosition() );
916 case Saturation_Event:
917 config_PutFloat( p_intf , "saturation" ,
918 (float)event.GetPosition()/100 );
921 case Brightness_Event:
922 config_PutFloat( p_intf , "brightness" ,
923 (float)event.GetPosition()/100 );
927 config_PutFloat( p_intf , "contrast" ,
928 (float)event.GetPosition()/100 );
932 config_PutFloat( p_intf , "gamma" ,
933 (float)event.GetPosition()/10 );
940 switch( event.GetId() )
943 val.i_int = event.GetPosition();
944 var_Set( p_vout, "hue", val );
945 config_PutInt( p_intf , "hue" , event.GetPosition() );
948 case Saturation_Event:
949 val.f_float = (float)event.GetPosition() / 100;
950 var_Set( p_vout, "saturation", val );
951 config_PutFloat( p_intf , "saturation" ,
952 (float)event.GetPosition()/100 );
955 case Brightness_Event:
956 val.f_float = (float)event.GetPosition() / 100;
957 var_Set( p_vout, "brightness", val );
958 config_PutFloat( p_intf , "brightness" ,
959 (float)event.GetPosition()/100 );
963 val.f_float = (float)event.GetPosition() / 100;
964 var_Set( p_vout, "contrast", val );
965 config_PutFloat( p_intf , "contrast" ,
966 (float)event.GetPosition()/100 );
970 val.f_float = (float)event.GetPosition() / 10;
971 var_Set( p_vout, "gamma", val );
972 config_PutFloat( p_intf , "gamma" ,
973 (float)event.GetPosition()/10 );
976 vlc_object_release(p_vout);
981 void ExtraPanel::OnRatio( wxCommandEvent& event )
983 config_PutPsz( p_intf, "aspect-ratio", ratio_combo->GetValue().mb_str(wxConvUTF8) );
987 void ExtraPanel::OnSelectFilter(wxCommandEvent& event)
989 int i_filter = event.GetId() - Filter0_Event ;
990 if( vfilters[i_filter].psz_filter )
992 ChangeVFiltersString( p_intf, vfilters[i_filter].psz_filter ,
993 event.IsChecked() ? VLC_TRUE : VLC_FALSE );
997 void ExtraPanel::OnFiltersInfo(wxCommandEvent& event)
999 wxMessageBox( wxU( _("Filtering effects to apply to the video. "
1000 "You must restart the stream for these settings to "
1002 "To configure these filters, go to Preferences / Video / "
1003 "Filters. In order to control the order in which they "
1004 "are applied, enter a filters string in the Video Filter "
1005 "Module inside the preferences."
1007 wxU( _("More Information" ) ), wxOK | wxICON_INFORMATION,
1010 /**********************************
1012 **********************************/
1013 void ExtraPanel::CheckAout()
1015 aout_instance_t *p_aout= (aout_instance_t *)vlc_object_find(p_intf,
1016 VLC_OBJECT_AOUT, FIND_ANYWHERE);
1017 if( p_aout != NULL )
1019 if( p_aout != p_intf->p_sys->p_aout )
1021 /* We want to know if someone changes the bands */
1022 if( var_AddCallback( p_aout, "equalizer-bands",
1023 IntfBandsCallback, this ) )
1025 /* The variable does not exist yet, wait */
1026 vlc_object_release( p_aout );
1029 if( var_AddCallback( p_aout, "equalizer-preamp",
1030 IntfPreampCallback, this ) )
1032 vlc_object_release( p_aout );
1035 /* Ok, we have our variables, make a first update round */
1036 p_intf->p_sys->p_aout = p_aout;
1038 f_preamp = var_GetFloat( p_aout, "equalizer-preamp" );
1039 psz_bands = var_GetString( p_aout, "equalizer-bands" );
1040 b_update = VLC_TRUE;
1042 vlc_object_release( p_aout );
1047 static void ChangeVFiltersString( intf_thread_t *p_intf,
1048 char *psz_name, vlc_bool_t b_add )
1050 vout_thread_t *p_vout;
1051 char *psz_parser, *psz_string;
1053 psz_string = config_GetPsz( p_intf, "vout-filter" );
1055 if( !psz_string ) psz_string = strdup("");
1057 psz_parser = strstr( psz_string, psz_name );
1063 psz_parser = psz_string;
1064 asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
1065 psz_string, psz_name );
1077 memmove( psz_parser, psz_parser + strlen(psz_name) +
1078 (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
1079 strlen(psz_parser + strlen(psz_name)) + 1 );
1081 /* Remove trailing : : */
1082 if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
1084 *(psz_string+strlen(psz_string ) -1 ) = '\0';
1093 /* Vout is not kept, so put that in the config */
1094 config_PutPsz( p_intf, "vout-filter", psz_string );
1096 /* Try to set on the fly */
1097 p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
1101 var_SetString( p_vout, "vout-filter", psz_string );
1102 vlc_object_release( p_vout );
1109 static void ChangeFiltersString( intf_thread_t *p_intf,
1110 aout_instance_t * p_aout,
1111 char *psz_name, vlc_bool_t b_add )
1113 char *psz_parser, *psz_string;
1117 psz_string = var_GetNonEmptyString( p_aout, "audio-filter" );
1121 psz_string = config_GetPsz( p_intf, "audio-filter" );
1124 if( !psz_string ) psz_string = strdup("");
1126 psz_parser = strstr( psz_string, psz_name );
1132 psz_parser = psz_string;
1133 asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
1134 psz_string, psz_name );
1146 memmove( psz_parser, psz_parser + strlen(psz_name) +
1147 (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
1148 strlen(psz_parser + strlen(psz_name)) + 1 );
1150 if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
1152 *(psz_string+strlen(psz_string ) -1 ) = '\0';
1162 if( p_aout == NULL )
1164 config_PutPsz( p_intf, "audio-filter", psz_string );
1168 var_SetString( p_aout, "audio-filter", psz_string );
1169 for( int i = 0; i < p_aout->i_nb_inputs; i++ )
1171 p_aout->pp_inputs[i]->b_restart = VLC_TRUE;
1178 static int IntfBandsCallback( vlc_object_t *p_this, char const *psz_cmd,
1179 vlc_value_t oldval, vlc_value_t newval, void *param )
1181 ExtraPanel *p_panel = (ExtraPanel *)param;
1183 p_panel->psz_bands = strdup( newval.psz_string );
1184 p_panel->b_update = VLC_TRUE;
1189 static int IntfPreampCallback( vlc_object_t *p_this, char const *psz_cmd,
1190 vlc_value_t oldval, vlc_value_t newval, void *param )
1192 ExtraPanel *p_panel = (ExtraPanel *)param;
1194 p_panel->f_preamp = newval.f_float;
1195 p_panel->b_update = VLC_TRUE;
1201 /**********************************************************************
1202 * A small window to contain the extrapanel in its undocked state
1203 **********************************************************************/
1204 BEGIN_EVENT_TABLE(ExtraWindow, wxFrame)
1208 ExtraWindow::ExtraWindow( intf_thread_t *_p_intf, wxWindow *p_parent,
1209 wxPanel *_extra_panel ):
1210 wxFrame( p_parent, -1, wxU(_("Extended controls")), wxDefaultPosition,
1211 wxDefaultSize, wxDEFAULT_FRAME_STYLE )
1214 SetIcon( *p_intf->p_sys->p_icon );
1216 wxBoxSizer *window_sizer = new wxBoxSizer( wxVERTICAL );
1217 SetSizer( window_sizer );
1219 panel = _extra_panel;
1220 window_sizer->Add( panel );
1222 window_sizer->Layout();
1223 window_sizer->Fit( this );
1228 ExtraWindow::~ExtraWindow()