1 /*****************************************************************************
2 * PreferencesWindow.cpp: beos interface
3 *****************************************************************************
4 * Copyright (C) 1999, 2000, 2001 VideoLAN
5 * $Id: PreferencesWindow.cpp,v 1.1 2002/10/28 17:18:18 titer Exp $
7 * Authors: Eric Petit <titer@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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
22 *****************************************************************************/
25 #include <InterfaceKit.h>
31 /* BeOS module headers */
32 #include "VlcWrapper.h"
34 #include "PreferencesWindow.h"
37 /*****************************************************************************
38 * Preferences::PreferencesWindow
39 *****************************************************************************/
40 PreferencesWindow::PreferencesWindow( BRect frame, const char* name,
41 intf_thread_t *p_interface )
42 : BWindow( frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
43 B_NOT_ZOOMABLE | B_NOT_RESIZABLE )
47 BRect rect = Bounds();
48 p_preferences_view = new BView( rect, "preferences view",
49 B_FOLLOW_ALL, B_WILL_DRAW );
50 p_preferences_view->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
52 /* Create the "OK" button */
53 rect.Set( 320, 160, 390, 185);
54 BButton *p_button = new BButton( rect, NULL, "OK", new BMessage( PREFS_OK ) );
55 p_preferences_view->AddChild( p_button );
57 /* Create the "Cancel" button */
58 rect.OffsetBy( -80, 0 );
59 p_button = new BButton( rect, NULL, "Cancel", new BMessage( PREFS_CANCEL ) );
60 p_preferences_view->AddChild( p_button );
63 rect.Set( 10, 10, 390, 150 );
64 BBox *p_box = new BBox( rect, "preferences box", B_FOLLOW_ALL );
66 /* Create the post-processing slider */
67 rect.Set( 10, 10, 370, 50 );
68 p_pp_slider = new BSlider( rect, "post-processing", "MPEG4 post-processing level",
69 new BMessage( SLIDER_UPDATE ),
70 0, 6, B_TRIANGLE_THUMB, B_FOLLOW_LEFT, B_WILL_DRAW );
71 p_pp_slider->SetHashMarks(B_HASH_MARKS_BOTTOM);
72 p_pp_slider->SetHashMarkCount( 7 );
73 p_pp_slider->SetLimitLabels("None","Maximum");
74 p_pp_slider->SetValue( config_GetInt( p_intf, "ffmpeg-pp-q" ) );
75 p_box->AddChild( p_pp_slider );
77 /* Create the luminence slider */
78 rect.Set( 10, 65, 370, 90 );
79 p_lum_slider = new BSlider( rect, "luminence", "Luminence",
80 new BMessage( SLIDER_UPDATE ),
81 0, 255, B_TRIANGLE_THUMB, B_FOLLOW_LEFT, B_WILL_DRAW );
82 p_lum_slider->SetValue( config_GetInt( p_intf, "Y plan" ) );
83 p_box->AddChild( p_lum_slider );
85 rect.Set( 55, 110, 370, 120 );
86 p_restart_string = new BStringView( rect, "restart", "",
87 B_FOLLOW_ALL, B_WILL_DRAW);
88 p_box->AddChild( p_restart_string );
90 p_preferences_view-> AddChild( p_box );
92 AddChild( p_preferences_view );
94 // start window thread in hidden state
99 /*****************************************************************************
100 * PreferencesWindow::~PreferencesWindow
101 *****************************************************************************/
102 PreferencesWindow::~PreferencesWindow()
106 /*****************************************************************************
107 * PreferencesWindow::QuitRequested
108 *****************************************************************************/
109 bool PreferencesWindow::QuitRequested()
116 /*****************************************************************************
117 * PreferencesWindow::MessageReceived
118 *****************************************************************************/
119 void PreferencesWindow::MessageReceived( BMessage * p_message )
121 switch ( p_message->what )
125 p_restart_string->SetText( "Changes will take effect when you restart playback" );
140 BWindow::MessageReceived( p_message );
145 /*****************************************************************************
146 * PreferencesWindow::FrameResized
147 *****************************************************************************/
148 void PreferencesWindow::FrameResized(float width, float height)
152 /*****************************************************************************
153 * PreferencesWindow::ReallyQuit
154 *****************************************************************************/
155 void PreferencesWindow::ReallyQuit()
161 /*****************************************************************************
162 * PreferencesWindow::CancelChanges
163 *****************************************************************************/
164 void PreferencesWindow::CancelChanges()
166 p_pp_slider->SetValue( 0 );
167 p_lum_slider->SetValue( 255 );
168 p_restart_string->SetText( "" );
171 /*****************************************************************************
172 * PreferencesWindow::ApplyChanges
173 *****************************************************************************/
174 void PreferencesWindow::ApplyChanges()
176 config_PutInt( p_intf, "ffmpeg-pp-q", p_pp_slider->Value() );
177 config_PutInt( p_intf, "Y plan", p_lum_slider->Value() );
178 if( p_lum_slider->Value() < 255 )
180 config_PutPsz( p_intf, "filter", "yuv" );
184 config_PutPsz( p_intf, "filter", NULL );
186 p_restart_string->SetText( "" );