Commit fda0a7e4 authored by Stephan Assmus's avatar Stephan Assmus

video output has better handling of settings. it remembers flags like...

video output has better handling of settings. it remembers flags like fullscreen, aspect ratio correction and on-top-all-windows fell across multiple files in the playlist and also across program launches
parent 6a6ffd1f
...@@ -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.16.2.6 2002/10/11 00:46:59 stippi Exp $ * $Id: InterfaceWindow.cpp,v 1.16.2.7 2002/10/11 14:18:17 stippi 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>
...@@ -748,64 +748,6 @@ InterfaceWindow::_InputStreamChanged() ...@@ -748,64 +748,6 @@ InterfaceWindow::_InputStreamChanged()
Intf_VLCWrapper::set_volume( p_mediaControl->GetVolume() ); Intf_VLCWrapper::set_volume( p_mediaControl->GetVolume() );
} }
/*****************************************************************************
* InterfaceWindow::_LoadSettings
*****************************************************************************/
status_t
InterfaceWindow::_LoadSettings( BMessage* message, const char* fileName, const char* folder )
{
status_t ret = B_BAD_VALUE;
if ( message )
{
BPath path;
if ( ( ret = find_directory( B_USER_SETTINGS_DIRECTORY, &path ) ) == B_OK )
{
// passing folder is optional
if ( folder )
ret = path.Append( folder );
if ( ret == B_OK && ( ret = path.Append( fileName ) ) == B_OK )
{
BFile file( path.Path(), B_READ_ONLY );
if ( ( ret = file.InitCheck() ) == B_OK )
{
ret = message->Unflatten( &file );
file.Unset();
}
}
}
}
return ret;
}
/*****************************************************************************
* InterfaceWindow::_SaveSettings
*****************************************************************************/
status_t
InterfaceWindow::_SaveSettings( BMessage* message, const char* fileName, const char* folder )
{
status_t ret = B_BAD_VALUE;
if ( message )
{
BPath path;
if ( ( ret = find_directory( B_USER_SETTINGS_DIRECTORY, &path ) ) == B_OK )
{
// passing folder is optional
if ( folder && ( ret = path.Append( folder ) ) == B_OK )
ret = create_directory( path.Path(), 0777 );
if ( ret == B_OK && ( ret = path.Append( fileName ) ) == B_OK )
{
BFile file( path.Path(), B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE );
if ( ( ret = file.InitCheck() ) == B_OK )
{
ret = message->Flatten( &file );
file.Unset();
}
}
}
}
return ret;
}
/***************************************************************************** /*****************************************************************************
* InterfaceWindow::_RestoreSettings * InterfaceWindow::_RestoreSettings
*****************************************************************************/ *****************************************************************************/
...@@ -855,7 +797,7 @@ make_sure_frame_is_within_limits( BRect& frame, float minWidth, float minHeight, ...@@ -855,7 +797,7 @@ make_sure_frame_is_within_limits( BRect& frame, float minWidth, float minHeight,
void void
InterfaceWindow::_RestoreSettings() InterfaceWindow::_RestoreSettings()
{ {
if ( _LoadSettings( fSettings, "interface_settings", "VideoLAN Client" ) == B_OK ) if ( load_settings( fSettings, "interface_settings", "VideoLAN Client" ) == B_OK )
{ {
BRect mainFrame; BRect mainFrame;
if ( fSettings->FindRect( "main frame", &mainFrame ) == B_OK ) if ( fSettings->FindRect( "main frame", &mainFrame ) == B_OK )
...@@ -927,7 +869,7 @@ InterfaceWindow::_StoreSettings() ...@@ -927,7 +869,7 @@ InterfaceWindow::_StoreSettings()
fSettings->AddBool( "playlist showing", !fPlaylistWindow->IsHidden() ); fSettings->AddBool( "playlist showing", !fPlaylistWindow->IsHidden() );
fPlaylistWindow->Unlock(); fPlaylistWindow->Unlock();
} }
_SaveSettings( fSettings, "interface_settings", "VideoLAN Client" ); save_settings( fSettings, "interface_settings", "VideoLAN Client" );
} }
/***************************************************************************** /*****************************************************************************
...@@ -1200,3 +1142,61 @@ void ChapterMenu::AttachedToWindow() ...@@ -1200,3 +1142,61 @@ void ChapterMenu::AttachedToWindow()
BMenu::AttachedToWindow(); BMenu::AttachedToWindow();
} }
/*****************************************************************************
* load_settings
*****************************************************************************/
status_t
load_settings( BMessage* message, const char* fileName, const char* folder )
{
status_t ret = B_BAD_VALUE;
if ( message )
{
BPath path;
if ( ( ret = find_directory( B_USER_SETTINGS_DIRECTORY, &path ) ) == B_OK )
{
// passing folder is optional
if ( folder )
ret = path.Append( folder );
if ( ret == B_OK && ( ret = path.Append( fileName ) ) == B_OK )
{
BFile file( path.Path(), B_READ_ONLY );
if ( ( ret = file.InitCheck() ) == B_OK )
{
ret = message->Unflatten( &file );
file.Unset();
}
}
}
}
return ret;
}
/*****************************************************************************
* save_settings
*****************************************************************************/
status_t
save_settings( BMessage* message, const char* fileName, const char* folder )
{
status_t ret = B_BAD_VALUE;
if ( message )
{
BPath path;
if ( ( ret = find_directory( B_USER_SETTINGS_DIRECTORY, &path ) ) == B_OK )
{
// passing folder is optional
if ( folder && ( ret = path.Append( folder ) ) == B_OK )
ret = create_directory( path.Path(), 0777 );
if ( ret == B_OK && ( ret = path.Append( fileName ) ) == B_OK )
{
BFile file( path.Path(), B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE );
if ( ( ret = file.InitCheck() ) == B_OK )
{
ret = message->Flatten( &file );
file.Unset();
}
}
}
}
return ret;
}
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* InterfaceWindow.h: BeOS interface window class prototype * InterfaceWindow.h: BeOS interface window class prototype
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: InterfaceWindow.h,v 1.12.2.5 2002/10/09 15:29:51 stippi Exp $ * $Id: InterfaceWindow.h,v 1.12.2.6 2002/10/11 14:18:17 stippi Exp $
* *
* Authors: Jean-Marc Dressler <polux@via.ecp.fr> * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Tony Castley <tcastley@mail.powerup.com.au> * Tony Castley <tcastley@mail.powerup.com.au>
...@@ -109,12 +109,6 @@ class InterfaceWindow : public BWindow ...@@ -109,12 +109,6 @@ class InterfaceWindow : public BWindow
bool hasTitles = false ); bool hasTitles = false );
void _UpdateSpeedMenu( int rate ); void _UpdateSpeedMenu( int rate );
void _InputStreamChanged(); void _InputStreamChanged();
status_t _LoadSettings( BMessage* message,
const char* fileName,
const char* subFolder = NULL );
status_t _SaveSettings( BMessage* message,
const char* fileName,
const char* subFolder = NULL );
void _RestoreSettings(); void _RestoreSettings();
void _StoreSettings(); void _StoreSettings();
...@@ -148,4 +142,14 @@ class InterfaceWindow : public BWindow ...@@ -148,4 +142,14 @@ class InterfaceWindow : public BWindow
// for forward compatibility // for forward compatibility
}; };
// some global support functions
status_t load_settings( BMessage* message,
const char* fileName,
const char* folder = NULL );
status_t save_settings( BMessage* message,
const char* fileName,
const char* folder = NULL );
#endif // BEOS_INTERFACE_WINDOW_H #endif // BEOS_INTERFACE_WINDOW_H
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* VideoWindow.h: BeOS video window class prototype * VideoWindow.h: BeOS video window class prototype
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: VideoWindow.h,v 1.19.2.6 2002/09/29 12:04:27 titer Exp $ * $Id: VideoWindow.h,v 1.19.2.7 2002/10/11 14:18:17 stippi Exp $
* *
* Authors: Jean-Marc Dressler <polux@via.ecp.fr> * Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Tony Castley <tcastley@mail.powerup.com.au> * Tony Castley <tcastley@mail.powerup.com.au>
...@@ -55,6 +55,53 @@ colorcombo colspace[]= ...@@ -55,6 +55,53 @@ colorcombo colspace[]=
#define COLOR_COUNT 5 #define COLOR_COUNT 5
#define DEFAULT_COL 4 #define DEFAULT_COL 4
class VideoSettings
{
public:
VideoSettings( const VideoSettings& clone );
virtual ~VideoSettings();
static VideoSettings* DefaultSettings();
enum
{
SIZE_OTHER = 0,
SIZE_50 = 1,
SIZE_100 = 2,
SIZE_200 = 3,
};
void SetVideoSize( uint32 mode );
inline uint32 VideoSize() const
{ return fVideoSize; }
enum
{
FLAG_CORRECT_RATIO = 0x0001,
FLAG_SYNC_RETRACE = 0x0002,
FLAG_ON_TOP_ALL = 0x0004,
FLAG_FULL_SCREEN = 0x0008,
};
inline void SetFlags( uint32 flags )
{ fFlags = flags; }
inline void AddFlags( uint32 flags )
{ fFlags |= flags; }
inline void ClearFlags( uint32 flags )
{ fFlags &= ~flags; }
inline bool HasFlags( uint32 flags ) const
{ return fFlags & flags; }
inline uint32 Flags() const
{ return fFlags; }
private:
VideoSettings(); // reserved for default settings
static VideoSettings fDefaultSettings;
uint32 fVideoSize;
uint32 fFlags;
BMessage* fSettings;
};
class VLCView : public BView class VLCView : public BView
{ {
...@@ -103,8 +150,14 @@ public: ...@@ -103,8 +150,14 @@ public:
void SetInterfaceShowing(bool showIt); void SetInterfaceShowing(bool showIt);
void SetCorrectAspectRatio(bool doIt); void SetCorrectAspectRatio(bool doIt);
inline bool CorrectAspectRatio() const bool CorrectAspectRatio() const;
{ return fCorrectAspect; } void ToggleFullScreen();
void SetFullScreen(bool doIt);
bool IsFullScreen() const;
void SetOnTop(bool doIt);
bool IsOnTop() const;
void SetSyncToRetrace(bool doIt);
bool IsSyncedToRetrace() const;
inline status_t InitCheck() const inline status_t InitCheck() const
{ return fInitStatus; } { return fInitStatus; }
...@@ -113,9 +166,8 @@ public: ...@@ -113,9 +166,8 @@ public:
int32 i_width; // aspect corrected bitmap size int32 i_width; // aspect corrected bitmap size
int32 i_height; int32 i_height;
BRect winSize; // current window size BRect winSize; // current window size
bool is_zoomed, vsync;
BBitmap *bitmap[3]; BBitmap *bitmap[3];
BBitmap *overlaybitmap; // BBitmap *overlaybitmap;
VLCView *view; VLCView *view;
int i_buffer; int i_buffer;
volatile bool teardownwindow; volatile bool teardownwindow;
...@@ -130,6 +182,7 @@ private: ...@@ -130,6 +182,7 @@ private:
void _FreeBuffers(); void _FreeBuffers();
void _BlankBitmap(BBitmap* bitmap) const; void _BlankBitmap(BBitmap* bitmap) const;
void _SetVideoSize(uint32 mode); void _SetVideoSize(uint32 mode);
void _SetToSettings();
void _SaveScreenShot( BBitmap* bitmap, void _SaveScreenShot( BBitmap* bitmap,
char* path, char* path,
...@@ -153,6 +206,7 @@ private: ...@@ -153,6 +206,7 @@ private:
window_feel fCachedFeel; window_feel fCachedFeel;
bool fInterfaceShowing; bool fInterfaceShowing;
status_t fInitStatus; status_t fInitStatus;
VideoSettings* fSettings;
}; };
#endif // BEOS_VIDEO_WINDOW_H #endif // BEOS_VIDEO_WINDOW_H
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* vout_beos.cpp: beos video output display method * vout_beos.cpp: beos video output display method
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN * Copyright (C) 2000, 2001 VideoLAN
* $Id: vout_beos.cpp,v 1.58.2.6 2002/09/29 12:04:27 titer Exp $ * $Id: vout_beos.cpp,v 1.58.2.7 2002/10/11 14:18:17 stippi 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>
...@@ -47,6 +47,8 @@ extern "C" ...@@ -47,6 +47,8 @@ extern "C"
{ {
#include <videolan/vlc.h> #include <videolan/vlc.h>
#include "stream_control.h" // just so that we can include InterfaceWindow.h
#include "input_ext-intf.h" // just so that we can include InterfaceWindow.h
#include "video.h" #include "video.h"
#include "video_output.h" #include "video_output.h"
...@@ -54,10 +56,12 @@ extern "C" ...@@ -54,10 +56,12 @@ extern "C"
} }
#include "VideoWindow.h"
#include "DrawingTidbits.h" #include "DrawingTidbits.h"
#include "InterfaceWindow.h"
#include "MsgVals.h" #include "MsgVals.h"
#include "VideoWindow.h"
/***************************************************************************** /*****************************************************************************
* vout_sys_t: BeOS video output method descriptor * vout_sys_t: BeOS video output method descriptor
***************************************************************************** *****************************************************************************
...@@ -153,6 +157,86 @@ class BackgroundView : public BView ...@@ -153,6 +157,86 @@ class BackgroundView : public BView
VLCView* fVideoView; VLCView* fVideoView;
}; };
/*****************************************************************************
* VideoSettings constructor and destructor
*****************************************************************************/
VideoSettings::VideoSettings()
: fVideoSize( SIZE_100 ),
fFlags( FLAG_CORRECT_RATIO ),
fSettings( new BMessage( 'sett' ) )
{
// read settings from disk
status_t ret = load_settings( fSettings, "video_settings", "VideoLAN Client" );
if ( ret == B_OK )
{
uint32 flags;
if ( fSettings->FindInt32( "flags", (int32*)&flags ) == B_OK )
SetFlags( flags );
uint32 size;
if ( fSettings->FindInt32( "video size", (int32*)&size ) == B_OK )
SetVideoSize( size );
}
else
fprintf( stderr, "error loading video settings: %s\n", strerror( ret ) );
// vlc settings override settings from disk
// if ( config_GetIntVariable( "fullscreen" ) )
// AddFlags( FLAG_FULL_SCREEN );
}
VideoSettings::VideoSettings( const VideoSettings& clone )
: fVideoSize( clone.VideoSize() ),
fFlags( clone.Flags() ),
fSettings( NULL )
{
}
VideoSettings::~VideoSettings()
{
if ( fSettings )
{
// we are the default settings
// and write our settings to disk
if (fSettings->ReplaceInt32( "video size", VideoSize() ) != B_OK)
fSettings->AddInt32( "video size", VideoSize() );
if (fSettings->ReplaceInt32( "flags", Flags() ) != B_OK)
fSettings->AddInt32( "flags", Flags() );
status_t ret = save_settings( fSettings, "video_settings", "VideoLAN Client" );
if ( ret != B_OK )
fprintf( stderr, "error saving video settings: %s\n", strerror( ret ) );
delete fSettings;
}
else
{
// we are just a clone of the default settings
fDefaultSettings.SetVideoSize( VideoSize() );
fDefaultSettings.SetFlags( Flags() );
}
}
/*****************************************************************************
* VideoSettings::DefaultSettings
*****************************************************************************/
VideoSettings*
VideoSettings::DefaultSettings()
{
return &fDefaultSettings;
}
/*****************************************************************************
* VideoSettings::SetVideoSize
*****************************************************************************/
void
VideoSettings::SetVideoSize( uint32 mode )
{
fVideoSize = mode;
}
// static variable initialization
VideoSettings
VideoSettings::fDefaultSettings;
/***************************************************************************** /*****************************************************************************
* VideoWindow constructor and destructor * VideoWindow constructor and destructor
*****************************************************************************/ *****************************************************************************/
...@@ -160,16 +244,15 @@ VideoWindow::VideoWindow(int v_width, int v_height, BRect frame) ...@@ -160,16 +244,15 @@ VideoWindow::VideoWindow(int v_width, int v_height, BRect frame)
: BWindow(frame, NULL, B_TITLED_WINDOW, B_NOT_CLOSABLE | B_NOT_MINIMIZABLE), : BWindow(frame, NULL, B_TITLED_WINDOW, B_NOT_CLOSABLE | B_NOT_MINIMIZABLE),
i_width(frame.IntegerWidth()), i_width(frame.IntegerWidth()),
i_height(frame.IntegerHeight()), i_height(frame.IntegerHeight()),
is_zoomed(false), winSize(frame),
vsync(false),
i_buffer(0), i_buffer(0),
teardownwindow(false), teardownwindow(false),
fTrueWidth(v_width), fTrueWidth(v_width),
fTrueHeight(v_height), fTrueHeight(v_height),
fCorrectAspect(true),
fCachedFeel(B_NORMAL_WINDOW_FEEL), fCachedFeel(B_NORMAL_WINDOW_FEEL),
fInterfaceShowing(false), fInterfaceShowing(false),
fInitStatus(B_ERROR) fInitStatus(B_ERROR),
fSettings(new VideoSettings(*VideoSettings::DefaultSettings()))
{ {
// create the view to do the display // create the view to do the display
view = new VLCView( Bounds() ); view = new VLCView( Bounds() );
...@@ -187,7 +270,7 @@ VideoWindow::VideoWindow(int v_width, int v_height, BRect frame) ...@@ -187,7 +270,7 @@ VideoWindow::VideoWindow(int v_width, int v_height, BRect frame)
screen.GetMode(&mode); screen.GetMode(&mode);
float refresh = (mode.timing.pixel_clock * 1000) float refresh = (mode.timing.pixel_clock * 1000)
/ ((mode.timing.h_total)* (mode.timing.v_total)); / ((mode.timing.h_total)* (mode.timing.v_total));
vsync = (refresh < MIN_AUTO_VSYNC_REFRESH); SetSyncToRetrace(refresh < MIN_AUTO_VSYNC_REFRESH);
} }
// allocate bitmap buffers // allocate bitmap buffers
...@@ -206,6 +289,7 @@ VideoWindow::VideoWindow(int v_width, int v_height, BRect frame) ...@@ -206,6 +289,7 @@ VideoWindow::VideoWindow(int v_width, int v_height, BRect frame)
SetSizeLimits((i_width * r.min_width_scale), i_width * r.max_width_scale, SetSizeLimits((i_width * r.min_width_scale), i_width * r.max_width_scale,
(i_height * r.min_height_scale), i_height * r.max_height_scale); (i_height * r.min_height_scale), i_height * r.max_height_scale);
} }
_SetToSettings();
} }
VideoWindow::~VideoWindow() VideoWindow::~VideoWindow()
...@@ -215,6 +299,7 @@ VideoWindow::~VideoWindow() ...@@ -215,6 +299,7 @@ VideoWindow::~VideoWindow()
teardownwindow = true; teardownwindow = true;
wait_for_thread(fDrawThreadID, &result); wait_for_thread(fDrawThreadID, &result);
_FreeBuffers(); _FreeBuffers();
delete fSettings;
} }
/***************************************************************************** /*****************************************************************************
...@@ -231,12 +316,12 @@ VideoWindow::MessageReceived( BMessage *p_message ) ...@@ -231,12 +316,12 @@ VideoWindow::MessageReceived( BMessage *p_message )
case RESIZE_50: case RESIZE_50:
case RESIZE_100: case RESIZE_100:
case RESIZE_200: case RESIZE_200:
if (is_zoomed) if (IsFullScreen())
BWindow::Zoom(); BWindow::Zoom();
_SetVideoSize(p_message->what); _SetVideoSize(p_message->what);
break; break;
case VERT_SYNC: case VERT_SYNC:
vsync = !vsync; SetSyncToRetrace(!IsSyncedToRetrace());
break; break;
case WINDOW_FEEL: case WINDOW_FEEL:
{ {
...@@ -245,11 +330,15 @@ VideoWindow::MessageReceived( BMessage *p_message ) ...@@ -245,11 +330,15 @@ VideoWindow::MessageReceived( BMessage *p_message )
{ {
SetFeel(winFeel); SetFeel(winFeel);
fCachedFeel = winFeel; fCachedFeel = winFeel;
if (winFeel == B_FLOATING_ALL_WINDOW_FEEL)
fSettings->AddFlags(VideoSettings::FLAG_ON_TOP_ALL);
else
fSettings->ClearFlags(VideoSettings::FLAG_ON_TOP_ALL);
} }
} }
break; break;
case ASPECT_CORRECT: case ASPECT_CORRECT:
SetCorrectAspectRatio(!fCorrectAspect); SetCorrectAspectRatio(!CorrectAspectRatio());
break; break;
case SCREEN_SHOT: case SCREEN_SHOT:
// save a screen shot // save a screen shot
...@@ -263,7 +352,7 @@ VideoWindow::MessageReceived( BMessage *p_message ) ...@@ -263,7 +352,7 @@ VideoWindow::MessageReceived( BMessage *p_message )
BBitmap* temp = new BBitmap( current->Bounds(), current->ColorSpace() ); BBitmap* temp = new BBitmap( current->Bounds(), current->ColorSpace() );
if ( temp && temp->IsValid() ) if ( temp && temp->IsValid() )
{ {
int32 height = current->Bounds().Height(); int32 height = current->Bounds().IntegerHeight() + 1;
uint8* dst = (uint8*)temp->Bits(); uint8* dst = (uint8*)temp->Bits();
uint8* src = (uint8*)current->Bits(); uint8* src = (uint8*)current->Bits();
int32 dstBpr = temp->BytesPerRow(); int32 dstBpr = temp->BytesPerRow();
...@@ -298,24 +387,7 @@ VideoWindow::MessageReceived( BMessage *p_message ) ...@@ -298,24 +387,7 @@ VideoWindow::MessageReceived( BMessage *p_message )
void void
VideoWindow::Zoom(BPoint origin, float width, float height ) VideoWindow::Zoom(BPoint origin, float width, float height )
{ {
if(is_zoomed) ToggleFullScreen();
{
MoveTo(winSize.left, winSize.top);
ResizeTo(winSize.IntegerWidth(), winSize.IntegerHeight());
be_app->ShowCursor();
fInterfaceShowing = true;
}
else
{
BScreen screen(this);
BRect rect = screen.Frame();
Activate();
MoveTo(0.0, 0.0);
ResizeTo(rect.IntegerWidth(), rect.IntegerHeight());
be_app->ObscureCursor();
fInterfaceShowing = false;
}
is_zoomed = !is_zoomed;
} }
/***************************************************************************** /*****************************************************************************
...@@ -324,7 +396,8 @@ VideoWindow::Zoom(BPoint origin, float width, float height ) ...@@ -324,7 +396,8 @@ VideoWindow::Zoom(BPoint origin, float width, float height )
void void
VideoWindow::FrameMoved(BPoint origin) VideoWindow::FrameMoved(BPoint origin)
{ {
if (is_zoomed) return ; if (IsFullScreen())
return ;
winSize = Frame(); winSize = Frame();
} }
...@@ -334,8 +407,8 @@ VideoWindow::FrameMoved(BPoint origin) ...@@ -334,8 +407,8 @@ VideoWindow::FrameMoved(BPoint origin)
void void
VideoWindow::FrameResized( float width, float height ) VideoWindow::FrameResized( float width, float height )
{ {
int32 useWidth = fCorrectAspect ? i_width : fTrueWidth; int32 useWidth = CorrectAspectRatio() ? i_width : fTrueWidth;
int32 useHeight = fCorrectAspect ? i_height : fTrueHeight; int32 useHeight = CorrectAspectRatio() ? i_height : fTrueHeight;
float out_width, out_height; float out_width, out_height;
float out_left, out_top; float out_left, out_top;
float width_scale = width / useWidth; float width_scale = width / useWidth;
...@@ -358,7 +431,7 @@ VideoWindow::FrameResized( float width, float height ) ...@@ -358,7 +431,7 @@ VideoWindow::FrameResized( float width, float height )
view->MoveTo(out_left,out_top); view->MoveTo(out_left,out_top);
view->ResizeTo(out_width, out_height); view->ResizeTo(out_width, out_height);
if (!is_zoomed) if (!IsFullScreen())
winSize = Frame(); winSize = Frame();
} }
...@@ -373,8 +446,7 @@ VideoWindow::ScreenChanged(BRect frame, color_space format) ...@@ -373,8 +446,7 @@ VideoWindow::ScreenChanged(BRect frame, color_space format)
screen.GetMode(&mode); screen.GetMode(&mode);
float refresh = (mode.timing.pixel_clock * 1000) float refresh = (mode.timing.pixel_clock * 1000)
/ ((mode.timing.h_total) * (mode.timing.v_total)); / ((mode.timing.h_total) * (mode.timing.v_total));
if (refresh < MIN_AUTO_VSYNC_REFRESH) SetSyncToRetrace(refresh < MIN_AUTO_VSYNC_REFRESH);
vsync = true;
} }
/***************************************************************************** /*****************************************************************************
...@@ -394,7 +466,7 @@ VideoWindow::drawBuffer(int bufferIndex) ...@@ -394,7 +466,7 @@ VideoWindow::drawBuffer(int bufferIndex)
i_buffer = bufferIndex; i_buffer = bufferIndex;
// sync to the screen if required // sync to the screen if required
if (vsync) if (IsSyncedToRetrace())
{ {
BScreen screen(this); BScreen screen(this);
screen.WaitForRetrace(22000); screen.WaitForRetrace(22000);
...@@ -463,13 +535,92 @@ VideoWindow::SetInterfaceShowing(bool showIt) ...@@ -463,13 +535,92 @@ VideoWindow::SetInterfaceShowing(bool showIt)
void void
VideoWindow::SetCorrectAspectRatio(bool doIt) VideoWindow::SetCorrectAspectRatio(bool doIt)
{ {
if (fCorrectAspect != doIt) if (CorrectAspectRatio() != doIt)
{ {
fCorrectAspect = doIt; if (doIt)
fSettings->AddFlags(VideoSettings::FLAG_CORRECT_RATIO);
else
fSettings->ClearFlags(VideoSettings::FLAG_CORRECT_RATIO);
FrameResized(Bounds().Width(), Bounds().Height()); FrameResized(Bounds().Width(), Bounds().Height());
} }
} }
/*****************************************************************************
* VideoWindow::CorrectAspectRatio
*****************************************************************************/
bool
VideoWindow::CorrectAspectRatio() const
{
return fSettings->HasFlags(VideoSettings::FLAG_CORRECT_RATIO);
}
/*****************************************************************************
* VideoWindow::ToggleFullScreen
*****************************************************************************/
void
VideoWindow::ToggleFullScreen()
{
SetFullScreen(!IsFullScreen());
}
/*****************************************************************************
* VideoWindow::SetFullScreen
*****************************************************************************/
void
VideoWindow::SetFullScreen(bool doIt)
{
if (doIt)
{
BScreen screen(this);
BRect rect = screen.Frame();
Activate();
MoveTo(0.0, 0.0);
ResizeTo(rect.IntegerWidth(), rect.IntegerHeight());
be_app->ObscureCursor();
fInterfaceShowing = false;
fSettings->AddFlags(VideoSettings::FLAG_FULL_SCREEN);
}
else
{
MoveTo(winSize.left, winSize.top);
ResizeTo(winSize.IntegerWidth(), winSize.IntegerHeight());
be_app->ShowCursor();
fInterfaceShowing = true;
fSettings->ClearFlags(VideoSettings::FLAG_FULL_SCREEN);
}
}
/*****************************************************************************
* VideoWindow::IsFullScreen
*****************************************************************************/
bool
VideoWindow::IsFullScreen() const
{
return fSettings->HasFlags(VideoSettings::FLAG_FULL_SCREEN);
}
/*****************************************************************************
* VideoWindow::SetSyncToRetrace
*****************************************************************************/
void
VideoWindow::SetSyncToRetrace(bool doIt)
{
if (doIt)
fSettings->AddFlags(VideoSettings::FLAG_SYNC_RETRACE);
else
fSettings->ClearFlags(VideoSettings::FLAG_SYNC_RETRACE);
}
/*****************************************************************************
* VideoWindow::IsSyncedToRetrace
*****************************************************************************/
bool
VideoWindow::IsSyncedToRetrace() const
{
return fSettings->HasFlags(VideoSettings::FLAG_SYNC_RETRACE);
}
/***************************************************************************** /*****************************************************************************
* VideoWindow::_AllocateBuffers * VideoWindow::_AllocateBuffers
*****************************************************************************/ *****************************************************************************/
...@@ -653,8 +804,8 @@ void ...@@ -653,8 +804,8 @@ void
VideoWindow::_SetVideoSize(uint32 mode) VideoWindow::_SetVideoSize(uint32 mode)
{ {
// let size depend on aspect correction // let size depend on aspect correction
int32 width = fCorrectAspect ? i_width : fTrueWidth; int32 width = CorrectAspectRatio() ? i_width : fTrueWidth;
int32 height = fCorrectAspect ? i_height : fTrueHeight; int32 height = CorrectAspectRatio() ? i_height : fTrueHeight;
switch (mode) switch (mode)
{ {
case RESIZE_50: case RESIZE_50:
...@@ -669,8 +820,42 @@ VideoWindow::_SetVideoSize(uint32 mode) ...@@ -669,8 +820,42 @@ VideoWindow::_SetVideoSize(uint32 mode)
default: default:
break; break;
} }
fSettings->ClearFlags(VideoSettings::FLAG_FULL_SCREEN);
ResizeTo(width, height); ResizeTo(width, height);
is_zoomed = false; }
/*****************************************************************************
* VideoWindow::_SetToSettings
*****************************************************************************/
void
VideoWindow::_SetToSettings()
{
// adjust dimensions
uint32 mode = RESIZE_100;
switch (fSettings->VideoSize())
{
case VideoSettings::SIZE_50:
mode = RESIZE_50;
break;
case VideoSettings::SIZE_200:
mode = RESIZE_200;
break;
case VideoSettings::SIZE_100:
case VideoSettings::SIZE_OTHER:
default:
break;
}
bool fullscreen = IsFullScreen(); // remember settings
_SetVideoSize(mode); // because this will reset settings
// the fullscreen status is reflected in the settings,
// but not yet in the windows state
if (fullscreen)
SetFullScreen(true);
if (fSettings->HasFlags(VideoSettings::FLAG_ON_TOP_ALL))
fCachedFeel = B_FLOATING_ALL_WINDOW_FEEL;
else
fCachedFeel = B_NORMAL_WINDOW_FEEL;
SetFeel(fCachedFeel);
} }
/***************************************************************************** /*****************************************************************************
...@@ -685,8 +870,8 @@ VideoWindow::_SaveScreenShot( BBitmap* bitmap, char* path, ...@@ -685,8 +870,8 @@ VideoWindow::_SaveScreenShot( BBitmap* bitmap, char* path,
info->bitmap = bitmap; info->bitmap = bitmap;
info->path = path; info->path = path;
info->translatorID = translatorID; info->translatorID = translatorID;
info->width = fCorrectAspect ? i_width : fTrueWidth; info->width = CorrectAspectRatio() ? i_width : fTrueWidth;
info->height = fCorrectAspect ? i_height : fTrueHeight; info->height = CorrectAspectRatio() ? i_height : fTrueHeight;
// spawn a new thread to take care of the actual saving to disk // spawn a new thread to take care of the actual saving to disk
thread_id thread = spawn_thread( _save_screen_shot, thread_id thread = spawn_thread( _save_screen_shot,
"screen shot saver", "screen shot saver",
...@@ -933,14 +1118,14 @@ VLCView::MouseDown(BPoint where) ...@@ -933,14 +1118,14 @@ VLCView::MouseDown(BPoint where)
menu->AddItem(doubleItem); menu->AddItem(doubleItem);
// Toggle FullScreen // Toggle FullScreen
BMenuItem *zoomItem = new BMenuItem("Fullscreen", new BMessage(TOGGLE_FULL_SCREEN)); BMenuItem *zoomItem = new BMenuItem("Fullscreen", new BMessage(TOGGLE_FULL_SCREEN));
zoomItem->SetMarked(videoWindow->is_zoomed); zoomItem->SetMarked(videoWindow->IsFullScreen());
menu->AddItem(zoomItem); menu->AddItem(zoomItem);
menu->AddSeparatorItem(); menu->AddSeparatorItem();
// Toggle vSync // Toggle vSync
BMenuItem *vsyncItem = new BMenuItem("Vertical Sync", new BMessage(VERT_SYNC)); BMenuItem *vsyncItem = new BMenuItem("Vertical Sync", new BMessage(VERT_SYNC));
vsyncItem->SetMarked(videoWindow->vsync); vsyncItem->SetMarked(videoWindow->IsSyncedToRetrace());
menu->AddItem(vsyncItem); menu->AddItem(vsyncItem);
// Correct Aspect Ratio // Correct Aspect Ratio
BMenuItem *aspectItem = new BMenuItem("Correct Aspect Ratio", new BMessage(ASPECT_CORRECT)); BMenuItem *aspectItem = new BMenuItem("Correct Aspect Ratio", new BMessage(ASPECT_CORRECT));
...@@ -1021,7 +1206,7 @@ VLCView::Pulse() ...@@ -1021,7 +1206,7 @@ VLCView::Pulse()
fCursorHidden = true; fCursorHidden = true;
VideoWindow *videoWindow = dynamic_cast<VideoWindow*>(Window()); VideoWindow *videoWindow = dynamic_cast<VideoWindow*>(Window());
// hide the interface window as well if full screen // hide the interface window as well if full screen
if (videoWindow && videoWindow->is_zoomed) if (videoWindow && videoWindow->IsFullScreen())
videoWindow->SetInterfaceShowing(false); videoWindow->SetInterfaceShowing(false);
} }
} }
...@@ -1046,7 +1231,7 @@ VLCView::KeyDown(const char *bytes, int32 numBytes) ...@@ -1046,7 +1231,7 @@ VLCView::KeyDown(const char *bytes, int32 numBytes)
break; break;
case B_ESCAPE: case B_ESCAPE:
// go back to window mode // go back to window mode
if (videoWindow->is_zoomed) if (videoWindow->IsFullScreen())
videoWindow->PostMessage(TOGGLE_FULL_SCREEN); videoWindow->PostMessage(TOGGLE_FULL_SCREEN);
break; break;
case B_SPACE: case B_SPACE:
......
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