]> git.sesse.net Git - vlc/blob - modules/gui/beos/PreferencesWindow.cpp
Forgot to add files :|
[vlc] / modules / gui / beos / PreferencesWindow.cpp
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 $
6  *
7  * Authors: Eric Petit <titer@videolan.org>
8  *
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.
13  *
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.
18  *
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  *****************************************************************************/
23
24 /* BeOS headers */
25 #include <InterfaceKit.h>
26
27 /* VLC headers */
28 #include <vlc/vlc.h>
29 #include <vlc/intf.h>
30
31 /* BeOS module headers */
32 #include "VlcWrapper.h"
33 #include "MsgVals.h"
34 #include "PreferencesWindow.h"
35
36
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 )
44 {
45         p_intf = p_interface;
46
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 ) );
51     
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 );
56     
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 );
61     
62     /* Create the box */
63     rect.Set( 10, 10, 390, 150 );
64     BBox *p_box = new BBox( rect, "preferences box", B_FOLLOW_ALL );
65     
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 );
76     
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 );
84     
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 );
89     
90     p_preferences_view-> AddChild( p_box );
91     
92     AddChild( p_preferences_view );
93
94         // start window thread in hidden state
95         Hide();
96         Show();
97 }
98
99 /*****************************************************************************
100  * PreferencesWindow::~PreferencesWindow
101  *****************************************************************************/
102 PreferencesWindow::~PreferencesWindow()
103 {
104 }
105
106 /*****************************************************************************
107  * PreferencesWindow::QuitRequested
108  *****************************************************************************/
109 bool PreferencesWindow::QuitRequested()
110 {
111     CancelChanges();
112         Hide();
113         return false;
114 }
115
116 /*****************************************************************************
117  * PreferencesWindow::MessageReceived
118  *****************************************************************************/
119 void PreferencesWindow::MessageReceived( BMessage * p_message )
120 {
121         switch ( p_message->what )
122         {
123             case SLIDER_UPDATE:
124             {
125                 p_restart_string->SetText( "Changes will take effect when you restart playback" );
126                 break;
127             }
128             case PREFS_CANCEL:
129             {
130                 CancelChanges();
131                 Hide();
132                 break;
133             }
134             case PREFS_OK:
135             {
136                 ApplyChanges();
137                 Hide();
138             }
139                 default:
140                         BWindow::MessageReceived( p_message );
141                         break;
142         }
143 }
144
145 /*****************************************************************************
146  * PreferencesWindow::FrameResized
147  *****************************************************************************/
148 void PreferencesWindow::FrameResized(float width, float height)
149 {
150 }
151
152 /*****************************************************************************
153  * PreferencesWindow::ReallyQuit
154  *****************************************************************************/
155 void PreferencesWindow::ReallyQuit()
156 {
157     Hide();
158     Quit();
159 }
160
161 /*****************************************************************************
162  * PreferencesWindow::CancelChanges
163  *****************************************************************************/
164 void PreferencesWindow::CancelChanges()
165 {
166     p_pp_slider->SetValue( 0 );
167     p_lum_slider->SetValue( 255 );
168     p_restart_string->SetText( "" );
169 }
170
171 /*****************************************************************************
172  * PreferencesWindow::ApplyChanges
173  *****************************************************************************/
174 void PreferencesWindow::ApplyChanges()
175 {
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 )
179     {
180         config_PutPsz( p_intf, "filter", "yuv" );
181     }
182     else
183     {
184         config_PutPsz( p_intf, "filter", NULL );
185     }
186     p_restart_string->SetText( "" );
187 }