1 /*****************************************************************************
2 * PreferencesWindow.cpp: beos interface
3 *****************************************************************************
4 * Copyright (C) 1999, 2000, 2001 VideoLAN
5 * $Id: PreferencesWindow.cpp,v 1.4 2003/01/08 02:32:50 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 | B_NOT_CLOSABLE )
48 /* "background" view */
49 fPrefsView = new BView( Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW );
50 fPrefsView->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
51 AddChild( fPrefsView );
57 fTabView = new BTabView( rect, "preferences view" );
58 fTabView->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
60 fFfmpegView = new BView( fTabView->Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW );
61 fFfmpegView->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
62 fAdjustView = new BView( fTabView->Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW );
63 fAdjustView->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
65 fFfmpegTab = new BTab();
66 fTabView->AddTab( fFfmpegView, fFfmpegTab );
67 fFfmpegTab->SetLabel( "Ffmpeg" );
69 fAdjustTab = new BTab();
70 fTabView->AddTab( fAdjustView, fAdjustTab );
71 fAdjustTab->SetLabel( "Adjust" );
75 rect = fFfmpegView->Bounds();
76 rect.InsetBy( 10, 10 );
77 rect.bottom = rect.top + 30;
78 fPpSlider = new BSlider( rect, "post-processing", "MPEG4 post-processing level",
79 new BMessage( SLIDER_UPDATE ),
80 0, 6, B_TRIANGLE_THUMB,
81 B_FOLLOW_LEFT, B_WILL_DRAW );
82 fPpSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
83 fPpSlider->SetHashMarkCount( 7 );
84 fPpSlider->SetLimitLabels( "None", "Maximum" );
85 fFfmpegView->AddChild( fPpSlider );
89 rect = fAdjustView->Bounds();
90 rect.InsetBy( 10, 10 );
91 rect.bottom = rect.top + 30;
92 fBrightnessSlider = new BSlider( rect, "brightness", "Brightness",
93 new BMessage( SLIDER_UPDATE ),
94 0, 200, B_TRIANGLE_THUMB,
95 B_FOLLOW_LEFT, B_WILL_DRAW );
96 fBrightnessSlider->SetValue( 100 * config_GetFloat( p_intf, "Brightness" ) );
97 rect.OffsetBy( 0, 40 );
98 fContrastSlider = new BSlider( rect, "contrast", "Contrast",
99 new BMessage( SLIDER_UPDATE ),
100 0, 200, B_TRIANGLE_THUMB,
101 B_FOLLOW_LEFT, B_WILL_DRAW );
102 fContrastSlider->SetValue( 100 * config_GetFloat( p_intf, "Contrast" ) );
103 rect.OffsetBy( 0, 40 );
104 fHueSlider = new BSlider( rect, "hue", "Hue",
105 new BMessage( SLIDER_UPDATE ),
106 0, 360, B_TRIANGLE_THUMB,
107 B_FOLLOW_LEFT, B_WILL_DRAW );
108 fHueSlider->SetValue( config_GetInt( p_intf, "Hue" ) );
109 rect.OffsetBy( 0, 40 );
110 fSaturationSlider = new BSlider( rect, "saturation", "Saturation",
111 new BMessage( SLIDER_UPDATE ),
112 0, 200, B_TRIANGLE_THUMB,
113 B_FOLLOW_LEFT, B_WILL_DRAW );
114 fSaturationSlider->SetValue( 100 * config_GetFloat( p_intf, "Saturation" ) );
115 fAdjustView->AddChild( fBrightnessSlider );
116 fAdjustView->AddChild( fContrastSlider );
117 fAdjustView->AddChild( fHueSlider );
118 fAdjustView->AddChild( fSaturationSlider );
120 fPrefsView->AddChild( fTabView );
122 /* restart message */
123 rect = fPrefsView->Bounds();
125 rect.top = rect.bottom - 10;
126 fRestartString = new BStringView( rect, NULL,
127 "Warning: changing settings after starting playback may have no effect." );
128 /*rgb_color redColor = {255, 0, 0, 255};
129 fRestartString->SetHighColor(redColor);*/
130 fRestartString->SetAlignment( B_ALIGN_CENTER );
131 fPrefsView->AddChild( fRestartString );
136 rect.InsetBy( 10, 10 );
137 rect.top = rect.bottom - 25;
138 rect.left = rect.right - 80;
139 button = new BButton( rect, NULL, "OK", new BMessage( PREFS_OK ) );
140 fPrefsView->AddChild( button );
142 rect.OffsetBy( -90, 0 );
143 button = new BButton( rect, NULL, "Defaults", new BMessage( PREFS_DEFAULTS ) );
144 fPrefsView->AddChild( button );
146 // start window thread in hidden state
151 /*****************************************************************************
152 * PreferencesWindow::~PreferencesWindow
153 *****************************************************************************/
154 PreferencesWindow::~PreferencesWindow()
158 /*****************************************************************************
159 * PreferencesWindow::MessageReceived
160 *****************************************************************************/
161 void PreferencesWindow::MessageReceived( BMessage * p_message )
163 switch ( p_message->what )
182 BWindow::MessageReceived( p_message );
187 /*****************************************************************************
188 * PreferencesWindow::ReallyQuit
189 *****************************************************************************/
190 void PreferencesWindow::ReallyQuit()
196 /*****************************************************************************
197 * PreferencesWindow::SetDefaults
198 *****************************************************************************/
199 void PreferencesWindow::SetDefaults()
201 fPpSlider->SetValue( 0 );
202 fBrightnessSlider->SetValue( 100 );
203 fContrastSlider->SetValue( 100 );
204 fHueSlider->SetValue( 0 );
205 fSaturationSlider->SetValue( 100 );
208 /*****************************************************************************
209 * PreferencesWindow::ApplyChanges
210 *****************************************************************************/
211 void PreferencesWindow::ApplyChanges()
213 config_PutInt( p_intf, "ffmpeg-pp-q", fPpSlider->Value() );
214 config_PutFloat( p_intf, "Brightness",
215 (float)fBrightnessSlider->Value() / 100 );
216 config_PutFloat( p_intf, "Contrast",
217 (float)fContrastSlider->Value() / 100 );
218 config_PutInt( p_intf, "Hue", fHueSlider->Value() );
219 config_PutFloat( p_intf, "Saturation",
220 (float)fSaturationSlider->Value() / 100 );
222 if( config_GetFloat( p_intf, "Brightness" ) != 1 ||
223 config_GetFloat( p_intf, "Contrast" ) != 1 ||
224 config_GetInt( p_intf, "Hue" ) != 0 ||
225 config_GetFloat( p_intf, "Saturation" ) != 1 )
227 config_PutPsz( p_intf, "filter", "adjust" );
231 config_PutPsz( p_intf, "filter", NULL );