Commit d073ae07 authored by Eric Petit's avatar Eric Petit

* enhanced BeOS preferences window (post-processing, brightness,

   contrast, hue and saturation are adjustable)
parent 434b2322
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* InterfaceWindow.cpp: beos interface * InterfaceWindow.cpp: beos interface
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: InterfaceWindow.cpp,v 1.7 2002/10/30 06:12:27 titer Exp $ * $Id: InterfaceWindow.cpp,v 1.8 2002/11/23 15:00:54 titer Exp $
* *
* Authors: Jean-Marc Dressler <polux@via.ecp.fr> * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org> * Samuel Hocevar <sam@zoy.org>
...@@ -77,7 +77,15 @@ InterfaceWindow::InterfaceWindow( BRect frame, const char *name, ...@@ -77,7 +77,15 @@ InterfaceWindow::InterfaceWindow( BRect frame, const char *name,
p_playlist, p_playlist,
this, this,
p_intf ); p_intf );
fPreferencesWindow = new PreferencesWindow( BRect( 100, 400, 500, 595 ), BScreen *p_screen = new BScreen();
BRect screen_rect = p_screen->Frame();
delete p_screen;
BRect window_rect;
window_rect.Set( ( screen_rect.right - PREFS_WINDOW_WIDTH ) / 2,
( screen_rect.bottom - PREFS_WINDOW_HEIGHT ) / 2,
( screen_rect.right + PREFS_WINDOW_WIDTH ) / 2,
( screen_rect.bottom + PREFS_WINDOW_HEIGHT ) / 2 );
fPreferencesWindow = new PreferencesWindow( window_rect,
"Preferences", "Preferences",
p_intf ); p_intf );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* PreferencesWindow.cpp: beos interface * PreferencesWindow.cpp: beos interface
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: PreferencesWindow.cpp,v 1.1 2002/10/28 17:18:18 titer Exp $ * $Id: PreferencesWindow.cpp,v 1.2 2002/11/23 15:00:54 titer Exp $
* *
* Authors: Eric Petit <titer@videolan.org> * Authors: Eric Petit <titer@videolan.org>
* *
...@@ -40,57 +40,112 @@ ...@@ -40,57 +40,112 @@
PreferencesWindow::PreferencesWindow( BRect frame, const char* name, PreferencesWindow::PreferencesWindow( BRect frame, const char* name,
intf_thread_t *p_interface ) intf_thread_t *p_interface )
: BWindow( frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, : BWindow( frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_NOT_ZOOMABLE | B_NOT_RESIZABLE ) B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_NOT_CLOSABLE )
{ {
p_intf = p_interface; p_intf = p_interface;
BRect rect;
BRect rect = Bounds(); /* "background" view */
p_preferences_view = new BView( rect, "preferences view", p_prefs_view = new BView( Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW );
B_FOLLOW_ALL, B_WILL_DRAW ); p_prefs_view->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
p_preferences_view->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) ); AddChild( p_prefs_view );
/* add the tabs */
rect = Bounds();
rect.top += 10;
rect.bottom -= 65;
p_tabview = new BTabView( rect, "preferences view" );
p_tabview->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
/* Create the "OK" button */ p_ffmpeg_view = new BView( p_tabview->Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW );
rect.Set( 320, 160, 390, 185); p_ffmpeg_view->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
BButton *p_button = new BButton( rect, NULL, "OK", new BMessage( PREFS_OK ) ); p_adjust_view = new BView( p_tabview->Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW );
p_preferences_view->AddChild( p_button ); p_adjust_view->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
/* Create the "Cancel" button */ p_ffmpeg_tab = new BTab();
rect.OffsetBy( -80, 0 ); p_tabview->AddTab( p_ffmpeg_view, p_ffmpeg_tab );
p_button = new BButton( rect, NULL, "Cancel", new BMessage( PREFS_CANCEL ) ); p_ffmpeg_tab->SetLabel( "Ffmpeg" );
p_preferences_view->AddChild( p_button );
/* Create the box */ p_adjust_tab = new BTab();
rect.Set( 10, 10, 390, 150 ); p_tabview->AddTab( p_adjust_view, p_adjust_tab );
BBox *p_box = new BBox( rect, "preferences box", B_FOLLOW_ALL ); p_adjust_tab->SetLabel( "Adjust" );
/* Create the post-processing slider */ /* fills the tabs */
rect.Set( 10, 10, 370, 50 ); /* ffmpeg tab */
rect = p_ffmpeg_view->Bounds();
rect.InsetBy( 10, 10 );
rect.bottom = rect.top + 30;
p_pp_slider = new BSlider( rect, "post-processing", "MPEG4 post-processing level", p_pp_slider = new BSlider( rect, "post-processing", "MPEG4 post-processing level",
new BMessage( SLIDER_UPDATE ), new BMessage( SLIDER_UPDATE ),
0, 6, B_TRIANGLE_THUMB, B_FOLLOW_LEFT, B_WILL_DRAW ); 0, 6, B_TRIANGLE_THUMB,
B_FOLLOW_LEFT, B_WILL_DRAW );
p_pp_slider->SetHashMarks(B_HASH_MARKS_BOTTOM); p_pp_slider->SetHashMarks(B_HASH_MARKS_BOTTOM);
p_pp_slider->SetHashMarkCount( 7 ); p_pp_slider->SetHashMarkCount( 7 );
p_pp_slider->SetLimitLabels("None","Maximum"); p_pp_slider->SetLimitLabels( "None", "Maximum" );
p_pp_slider->SetValue( config_GetInt( p_intf, "ffmpeg-pp-q" ) ); p_ffmpeg_view->AddChild( p_pp_slider );
p_box->AddChild( p_pp_slider );
/* Create the luminence slider */
rect.Set( 10, 65, 370, 90 );
p_lum_slider = new BSlider( rect, "luminence", "Luminence",
new BMessage( SLIDER_UPDATE ),
0, 255, B_TRIANGLE_THUMB, B_FOLLOW_LEFT, B_WILL_DRAW );
p_lum_slider->SetValue( config_GetInt( p_intf, "Y plan" ) );
p_box->AddChild( p_lum_slider );
rect.Set( 55, 110, 370, 120 ); /* adjust tab */
p_restart_string = new BStringView( rect, "restart", "", rect = p_adjust_view->Bounds();
B_FOLLOW_ALL, B_WILL_DRAW); rect.InsetBy( 10, 10 );
p_box->AddChild( p_restart_string ); rect.bottom = rect.top + 30;
p_brightness_slider = new BSlider( rect, "brightness", "Brightness",
new BMessage( SLIDER_UPDATE ),
0, 200, B_TRIANGLE_THUMB,
B_FOLLOW_LEFT, B_WILL_DRAW );
p_brightness_slider->SetValue( 100 * config_GetFloat( p_intf, "Brightness" ) );
rect.OffsetBy( 0, 40 );
p_contrast_slider = new BSlider( rect, "contrast", "Contrast",
new BMessage( SLIDER_UPDATE ),
0, 200, B_TRIANGLE_THUMB,
B_FOLLOW_LEFT, B_WILL_DRAW );
p_contrast_slider->SetValue( 100 * config_GetFloat( p_intf, "Contrast" ) );
rect.OffsetBy( 0, 40 );
p_hue_slider = new BSlider( rect, "hue", "Hue",
new BMessage( SLIDER_UPDATE ),
0, 360, B_TRIANGLE_THUMB,
B_FOLLOW_LEFT, B_WILL_DRAW );
p_hue_slider->SetValue( config_GetInt( p_intf, "Hue" ) );
rect.OffsetBy( 0, 40 );
p_saturation_slider = new BSlider( rect, "saturation", "Saturation",
new BMessage( SLIDER_UPDATE ),
0, 200, B_TRIANGLE_THUMB,
B_FOLLOW_LEFT, B_WILL_DRAW );
p_saturation_slider->SetValue( 100 * config_GetFloat( p_intf, "Saturation" ) );
p_adjust_view->AddChild( p_brightness_slider );
p_adjust_view->AddChild( p_contrast_slider );
p_adjust_view->AddChild( p_hue_slider );
p_adjust_view->AddChild( p_saturation_slider );
p_preferences_view-> AddChild( p_box ); p_prefs_view->AddChild( p_tabview );
AddChild( p_preferences_view ); /* restart message */
rect = p_prefs_view->Bounds();
rect.bottom -= 43;
rect.top = rect.bottom - 10;
p_restart_string = new BStringView( rect, NULL, "" );
rgb_color redColor = {255, 0, 0, 255};
p_restart_string->SetHighColor(redColor);
p_restart_string->SetAlignment( B_ALIGN_CENTER );
p_prefs_view->AddChild( p_restart_string );
/* buttons */
BButton *p_button;
rect = Bounds();
rect.InsetBy( 10, 10 );
rect.top = rect.bottom - 25;
rect.left = rect.right - 80;
p_button = new BButton( rect, NULL, "OK", new BMessage( PREFS_OK ) );
p_prefs_view->AddChild( p_button );
rect.OffsetBy( -90, 0 );
p_button = new BButton( rect, NULL, "Cancel", new BMessage( PREFS_CANCEL ) );
p_prefs_view->AddChild( p_button );
rect.OffsetBy( -90, 0 );
p_button = new BButton( rect, NULL, "Defaults", new BMessage( PREFS_DEFAULTS ) );
p_prefs_view->AddChild( p_button );
// start window thread in hidden state // start window thread in hidden state
Hide(); Hide();
Show(); Show();
...@@ -103,16 +158,6 @@ PreferencesWindow::~PreferencesWindow() ...@@ -103,16 +158,6 @@ PreferencesWindow::~PreferencesWindow()
{ {
} }
/*****************************************************************************
* PreferencesWindow::QuitRequested
*****************************************************************************/
bool PreferencesWindow::QuitRequested()
{
CancelChanges();
Hide();
return false;
}
/***************************************************************************** /*****************************************************************************
* PreferencesWindow::MessageReceived * PreferencesWindow::MessageReceived
*****************************************************************************/ *****************************************************************************/
...@@ -122,19 +167,20 @@ void PreferencesWindow::MessageReceived( BMessage * p_message ) ...@@ -122,19 +167,20 @@ void PreferencesWindow::MessageReceived( BMessage * p_message )
{ {
case SLIDER_UPDATE: case SLIDER_UPDATE:
{ {
p_restart_string->SetText( "Changes will take effect when you restart playback" ); ApplyChanges();
break; break;
} }
case PREFS_CANCEL: case PREFS_DEFAULTS:
{ {
CancelChanges(); SetDefaults();
Hide();
break; break;
} }
case PREFS_OK: case PREFS_OK:
{ {
ApplyChanges(); config_PutInt( p_intf, "ffmpeg-pp-q", p_pp_slider->Value() );
Hide(); config_PutPsz( p_intf, "filter", "adjust" );
ApplyChanges();
Hide();
} }
default: default:
BWindow::MessageReceived( p_message ); BWindow::MessageReceived( p_message );
...@@ -142,13 +188,6 @@ void PreferencesWindow::MessageReceived( BMessage * p_message ) ...@@ -142,13 +188,6 @@ void PreferencesWindow::MessageReceived( BMessage * p_message )
} }
} }
/*****************************************************************************
* PreferencesWindow::FrameResized
*****************************************************************************/
void PreferencesWindow::FrameResized(float width, float height)
{
}
/***************************************************************************** /*****************************************************************************
* PreferencesWindow::ReallyQuit * PreferencesWindow::ReallyQuit
*****************************************************************************/ *****************************************************************************/
...@@ -159,13 +198,23 @@ void PreferencesWindow::ReallyQuit() ...@@ -159,13 +198,23 @@ void PreferencesWindow::ReallyQuit()
} }
/***************************************************************************** /*****************************************************************************
* PreferencesWindow::CancelChanges * PreferencesWindow::SetDefaults
*****************************************************************************/ *****************************************************************************/
void PreferencesWindow::CancelChanges() void PreferencesWindow::SetDefaults()
{ {
p_pp_slider->SetValue( 0 ); p_pp_slider->SetValue( 0 );
p_lum_slider->SetValue( 255 ); p_brightness_slider->SetValue( 100 );
p_restart_string->SetText( "" ); p_contrast_slider->SetValue( 100 );
p_hue_slider->SetValue( 0 );
p_saturation_slider->SetValue( 100 );
p_restart_string->SetText( config_GetInt( p_intf, "ffmpeg-pp-q" ) ?
"Changes will take effect after you restart playback" : "" );
config_PutPsz( p_intf, "filter", NULL );
config_PutInt( p_intf, "ffmpeg-pp-q", 0 );
ApplyChanges();
} }
/***************************************************************************** /*****************************************************************************
...@@ -173,15 +222,33 @@ void PreferencesWindow::CancelChanges() ...@@ -173,15 +222,33 @@ void PreferencesWindow::CancelChanges()
*****************************************************************************/ *****************************************************************************/
void PreferencesWindow::ApplyChanges() void PreferencesWindow::ApplyChanges()
{ {
config_PutInt( p_intf, "ffmpeg-pp-q", p_pp_slider->Value() ); bool b_restart_needed = false;
config_PutInt( p_intf, "Y plan", p_lum_slider->Value() );
if( p_lum_slider->Value() < 255 ) if( ( !config_GetPsz( p_intf, "filter" ) ||
strncmp( config_GetPsz( p_intf, "filter" ), "adjust", 6 ) ) &&
( p_brightness_slider->Value() != 100 ||
p_contrast_slider->Value() != 100 ||
p_hue_slider->Value() ||
p_saturation_slider->Value() != 100 ) )
{ {
config_PutPsz( p_intf, "filter", "yuv" ); b_restart_needed = true;
} }
else
if( p_pp_slider->Value() != config_GetInt( p_intf, "ffmpeg-pp-q" ) )
{ {
config_PutPsz( p_intf, "filter", NULL ); b_restart_needed = true;
} }
p_restart_string->SetText( "" );
config_PutFloat( p_intf, "Brightness",
(float)p_brightness_slider->Value() / 100 );
config_PutFloat( p_intf, "Contrast",
(float)p_contrast_slider->Value() / 100 );
config_PutInt( p_intf, "Hue", p_hue_slider->Value() );
config_PutFloat( p_intf, "Saturation",
(float)p_saturation_slider->Value() / 100 );
p_restart_string->LockLooper();
p_restart_string->SetText( b_restart_needed ?
"Changes will take effect after you restart playback" : "" );
p_restart_string->UnlockLooper();
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* PreferencesWindow.h * PreferencesWindow.h
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: PreferencesWindow.h,v 1.1 2002/10/28 17:18:18 titer Exp $ * $Id: PreferencesWindow.h,v 1.2 2002/11/23 15:00:54 titer Exp $
* *
* Authors: Eric Petit <titer@videolan.org> * Authors: Eric Petit <titer@videolan.org>
* *
...@@ -26,9 +26,13 @@ ...@@ -26,9 +26,13 @@
#include <Window.h> #include <Window.h>
#define PREFS_OK 'prok' #define PREFS_WINDOW_WIDTH 400
#define PREFS_CANCEL 'prca' #define PREFS_WINDOW_HEIGHT 280
#define SLIDER_UPDATE 'slup'
#define PREFS_OK 'prok'
#define PREFS_CANCEL 'prca'
#define PREFS_DEFAULTS 'prde'
#define SLIDER_UPDATE 'slup'
class PreferencesWindow : public BWindow class PreferencesWindow : public BWindow
{ {
...@@ -37,19 +41,26 @@ class PreferencesWindow : public BWindow ...@@ -37,19 +41,26 @@ class PreferencesWindow : public BWindow
const char* name, const char* name,
intf_thread_t *p_interface ); intf_thread_t *p_interface );
virtual ~PreferencesWindow(); virtual ~PreferencesWindow();
virtual bool QuitRequested();
virtual void MessageReceived(BMessage *message); virtual void MessageReceived(BMessage *message);
virtual void FrameResized(float width, float height);
void ReallyQuit(); void ReallyQuit();
private: private:
void CancelChanges(); void SetDefaults();
void ApplyChanges(); void ApplyChanges();
intf_thread_t * p_intf; BView * p_prefs_view;
BView * p_preferences_view; BTabView * p_tabview;
BView * p_ffmpeg_view;
BView * p_adjust_view;
BTab * p_ffmpeg_tab;
BTab * p_adjust_tab;
BSlider * p_pp_slider; BSlider * p_pp_slider;
BSlider * p_lum_slider; BSlider * p_contrast_slider;
BSlider * p_brightness_slider;
BSlider * p_hue_slider;
BSlider * p_saturation_slider;
BStringView * p_restart_string; BStringView * p_restart_string;
intf_thread_t * p_intf;
}; };
#endif // BEOS_PREFERENCES_WINDOW_H #endif // BEOS_PREFERENCES_WINDOW_H
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment