Commit 254f695e authored by Eric Petit's avatar Eric Petit

+ src/libvlc.h: use KEY_SPACE instead of ' '

 + gui/beos/*: got rid of the VlcWrapper thing which is unneccessaraly
               complex now that we have variables

 Language/subtitle selection works again in the BeOS UI, but there's
 still a lot to fix :|
parent 4632a220
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* intf_beos.cpp: beos interface * intf_beos.cpp: beos interface
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: Interface.cpp,v 1.16 2004/01/26 16:52:31 zorglub Exp $ * $Id$
* *
* 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>
...@@ -41,10 +41,17 @@ ...@@ -41,10 +41,17 @@
#include <vlc/aout.h> #include <vlc/aout.h>
#include <aout_internal.h> #include <aout_internal.h>
#include "VlcWrapper.h"
#include "InterfaceWindow.h" #include "InterfaceWindow.h"
#include "MsgVals.h" #include "MsgVals.h"
/*****************************************************************************
* intf_sys_t: internal variables of the BeOS interface
*****************************************************************************/
struct intf_sys_t
{
InterfaceWindow * p_window;
};
/***************************************************************************** /*****************************************************************************
* Local prototype * Local prototype
*****************************************************************************/ *****************************************************************************/
...@@ -59,44 +66,36 @@ int E_(OpenIntf) ( vlc_object_t *p_this ) ...@@ -59,44 +66,36 @@ int E_(OpenIntf) ( vlc_object_t *p_this )
/* Allocate instance and initialize some members */ /* Allocate instance and initialize some members */
p_intf->p_sys = (intf_sys_t*) malloc( sizeof( intf_sys_t ) ); p_intf->p_sys = (intf_sys_t*) malloc( sizeof( intf_sys_t ) );
if( p_intf->p_sys == NULL ) if( !p_intf->p_sys )
{ {
msg_Err( p_intf, "out of memory" ); msg_Err( p_intf, "out of memory" );
return( 1 ); return VLC_EGENERIC;
} }
p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
p_intf->p_sys->p_wrapper = new VlcWrapper( p_intf );
p_intf->pf_run = Run; p_intf->pf_run = Run;
/* Create the interface window */ /* Create the interface window */
BScreen screen(B_MAIN_SCREEN_ID); BScreen screen( B_MAIN_SCREEN_ID );
BRect rect = screen.Frame(); BRect rect = screen.Frame();
rect.top = rect.bottom-100; rect.top = rect.bottom - 100;
rect.bottom -= 50; rect.bottom -= 50;
rect.left += 50; rect.left += 50;
rect.right = rect.left + 350; rect.right = rect.left + 350;
p_intf->p_sys->p_window = p_intf->p_sys->p_window =
new InterfaceWindow( rect, new InterfaceWindow( p_intf, rect, "VLC " VERSION );
"VLC " PACKAGE_VERSION, if( !p_intf->p_sys->p_window )
p_intf );
if( p_intf->p_sys->p_window == 0 )
{ {
free( p_intf->p_sys ); free( p_intf->p_sys );
msg_Err( p_intf, "cannot allocate InterfaceWindow" ); msg_Err( p_intf, "cannot allocate InterfaceWindow" );
return( 1 ); return VLC_EGENERIC;
}
else
{
/* Make the be_app aware the interface has been created */
BMessage message(INTERFACE_CREATED);
message.AddPointer("window", p_intf->p_sys->p_window);
be_app->PostMessage(&message);
} }
p_intf->p_sys->b_loop = 0;
p_intf->p_sys->b_mute = 0; /* Make the be_app aware the interface has been created */
BMessage message( INTERFACE_CREATED );
return( 0 ); message.AddPointer( "window", p_intf->p_sys->p_window );
be_app->PostMessage( &message );
return VLC_SUCCESS;
} }
/***************************************************************************** /*****************************************************************************
...@@ -106,14 +105,11 @@ void E_(CloseIntf) ( vlc_object_t *p_this ) ...@@ -106,14 +105,11 @@ void E_(CloseIntf) ( vlc_object_t *p_this )
{ {
intf_thread_t *p_intf = (intf_thread_t*) p_this; intf_thread_t *p_intf = (intf_thread_t*) p_this;
msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
/* Destroy the interface window */ /* Destroy the interface window */
if( p_intf->p_sys->p_window->Lock() ) if( p_intf->p_sys->p_window->Lock() )
p_intf->p_sys->p_window->Quit(); p_intf->p_sys->p_window->Quit();
/* Destroy structure */ /* Destroy structure */
delete p_intf->p_sys->p_wrapper;
free( p_intf->p_sys ); free( p_intf->p_sys );
} }
...@@ -125,13 +121,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -125,13 +121,7 @@ static void Run( intf_thread_t *p_intf )
{ {
while( !p_intf->b_die ) while( !p_intf->b_die )
{ {
/* Update VlcWrapper internals (p_input, etc) */
p_intf->p_sys->p_wrapper->UpdateInput();
/* Manage the slider */
p_intf->p_sys->p_window->UpdateInterface(); p_intf->p_sys->p_window->UpdateInterface();
/* Wait a bit */
msleep( INTF_IDLE_SLEEP ); msleep( INTF_IDLE_SLEEP );
} }
} }
...@@ -44,7 +44,6 @@ ...@@ -44,7 +44,6 @@
#include <vlc/input.h> #include <vlc/input.h>
/* BeOS interface headers */ /* BeOS interface headers */
#include "VlcWrapper.h"
#include "MsgVals.h" #include "MsgVals.h"
#include "MediaControlView.h" #include "MediaControlView.h"
#include "PlayListWindow.h" #include "PlayListWindow.h"
...@@ -52,34 +51,34 @@ ...@@ -52,34 +51,34 @@
#include "MessagesWindow.h" #include "MessagesWindow.h"
#include "InterfaceWindow.h" #include "InterfaceWindow.h"
#define INTERFACE_UPDATE_TIMEOUT 80000 // 2 frames if at 25 fps #define INTERFACE_UPDATE_TIMEOUT 80000 // 2 frames if at 25 fps
#define INTERFACE_LOCKING_TIMEOUT 5000 #define INTERFACE_LOCKING_TIMEOUT 5000
// make_sure_frame_is_on_screen // make_sure_frame_is_on_screen
bool bool
make_sure_frame_is_on_screen( BRect& frame ) make_sure_frame_is_on_screen( BRect& frame )
{ {
BScreen screen( B_MAIN_SCREEN_ID ); BScreen screen( B_MAIN_SCREEN_ID );
if (frame.IsValid() && screen.IsValid()) { if (frame.IsValid() && screen.IsValid()) {
if (!screen.Frame().Contains(frame)) { if (!screen.Frame().Contains(frame)) {
// make sure frame fits in the screen // make sure frame fits in the screen
if (frame.Width() > screen.Frame().Width()) if (frame.Width() > screen.Frame().Width())
frame.right -= frame.Width() - screen.Frame().Width() + 10.0; frame.right -= frame.Width() - screen.Frame().Width() + 10.0;
if (frame.Height() > screen.Frame().Height()) if (frame.Height() > screen.Frame().Height())
frame.bottom -= frame.Height() - screen.Frame().Height() + 30.0; frame.bottom -= frame.Height() - screen.Frame().Height() + 30.0;
// frame is now at the most the size of the screen // frame is now at the most the size of the screen
if (frame.right > screen.Frame().right) if (frame.right > screen.Frame().right)
frame.OffsetBy(-(frame.right - screen.Frame().right), 0.0); frame.OffsetBy(-(frame.right - screen.Frame().right), 0.0);
if (frame.bottom > screen.Frame().bottom) if (frame.bottom > screen.Frame().bottom)
frame.OffsetBy(0.0, -(frame.bottom - screen.Frame().bottom)); frame.OffsetBy(0.0, -(frame.bottom - screen.Frame().bottom));
if (frame.left < screen.Frame().left) if (frame.left < screen.Frame().left)
frame.OffsetBy((screen.Frame().left - frame.left), 0.0); frame.OffsetBy((screen.Frame().left - frame.left), 0.0);
if (frame.top < screen.Frame().top) if (frame.top < screen.Frame().top)
frame.OffsetBy(0.0, (screen.Frame().top - frame.top)); frame.OffsetBy(0.0, (screen.Frame().top - frame.top));
} }
return true; return true;
} }
return false; return false;
} }
// make_sure_frame_is_within_limits // make_sure_frame_is_within_limits
...@@ -101,78 +100,78 @@ make_sure_frame_is_within_limits( BRect& frame, float minWidth, float minHeight, ...@@ -101,78 +100,78 @@ make_sure_frame_is_within_limits( BRect& frame, float minWidth, float minHeight,
bool bool
get_volume_info( BVolume& volume, BString& volumeName, bool& isCDROM, BString& deviceName ) get_volume_info( BVolume& volume, BString& volumeName, bool& isCDROM, BString& deviceName )
{ {
bool success = false; bool success = false;
isCDROM = false; isCDROM = false;
deviceName = ""; deviceName = "";
volumeName = ""; volumeName = "";
char name[B_FILE_NAME_LENGTH]; char name[B_FILE_NAME_LENGTH];
if ( volume.GetName( name ) >= B_OK ) // disk is currently mounted if ( volume.GetName( name ) >= B_OK ) // disk is currently mounted
{ {
volumeName = name; volumeName = name;
dev_t dev = volume.Device(); dev_t dev = volume.Device();
fs_info info; fs_info info;
if ( fs_stat_dev( dev, &info ) == B_OK ) if ( fs_stat_dev( dev, &info ) == B_OK )
{ {
success = true; success = true;
deviceName = info.device_name; deviceName = info.device_name;
if ( volume.IsReadOnly() ) if ( volume.IsReadOnly() )
{ {
int i_dev = open( info.device_name, O_RDONLY ); int i_dev = open( info.device_name, O_RDONLY );
if ( i_dev >= 0 ) if ( i_dev >= 0 )
{ {
device_geometry g; device_geometry g;
if ( ioctl( i_dev, B_GET_GEOMETRY, &g, sizeof( g ) ) >= 0 ) if ( ioctl( i_dev, B_GET_GEOMETRY, &g, sizeof( g ) ) >= 0 )
isCDROM = ( g.device_type == B_CD ); isCDROM = ( g.device_type == B_CD );
close( i_dev ); close( i_dev );
} }
} }
} }
} }
return success; return success;
} }
// collect_folder_contents // collect_folder_contents
void void
collect_folder_contents( BDirectory& dir, BList& list, bool& deep, bool& asked, BEntry& entry ) collect_folder_contents( BDirectory& dir, BList& list, bool& deep, bool& asked, BEntry& entry )
{ {
while ( dir.GetNextEntry( &entry, true ) == B_OK ) while ( dir.GetNextEntry( &entry, true ) == B_OK )
{ {
if ( !entry.IsDirectory() ) if ( !entry.IsDirectory() )
{ {
BPath path; BPath path;
// since the directory will give us the entries in reverse order, // since the directory will give us the entries in reverse order,
// we put them each at the same index, effectively reversing the // we put them each at the same index, effectively reversing the
// items while adding them // items while adding them
if ( entry.GetPath( &path ) == B_OK ) if ( entry.GetPath( &path ) == B_OK )
{ {
BString* string = new BString( path.Path() ); BString* string = new BString( path.Path() );
if ( !list.AddItem( string, 0 ) ) if ( !list.AddItem( string, 0 ) )
delete string; // at least don't leak delete string; // at least don't leak
} }
} }
else else
{ {
if ( !asked ) if ( !asked )
{ {
// ask user if we should parse sub-folders as well // ask user if we should parse sub-folders as well
BAlert* alert = new BAlert( "sub-folders?", BAlert* alert = new BAlert( "sub-folders?",
_("Open files from all sub-folders as well?"), _("Open files from all sub-folders as well?"),
_("Cancel"), _("Open"), NULL, B_WIDTH_AS_USUAL, _("Cancel"), _("Open"), NULL, B_WIDTH_AS_USUAL,
B_IDEA_ALERT ); B_IDEA_ALERT );
int32 buttonIndex = alert->Go(); int32 buttonIndex = alert->Go();
deep = buttonIndex == 1; deep = buttonIndex == 1;
asked = true; asked = true;
// never delete BAlerts!! // never delete BAlerts!!
} }
if ( deep ) if ( deep )
{ {
BDirectory subDir( &entry ); BDirectory subDir( &entry );
if ( subDir.InitCheck() == B_OK ) if ( subDir.InitCheck() == B_OK )
collect_folder_contents( subDir, list, collect_folder_contents( subDir, list,
deep, asked, entry ); deep, asked, entry );
} }
} }
} }
} }
...@@ -180,18 +179,25 @@ collect_folder_contents( BDirectory& dir, BList& list, bool& deep, bool& asked, ...@@ -180,18 +179,25 @@ collect_folder_contents( BDirectory& dir, BList& list, bool& deep, bool& asked,
* InterfaceWindow * InterfaceWindow
*****************************************************************************/ *****************************************************************************/
InterfaceWindow::InterfaceWindow( BRect frame, const char* name, InterfaceWindow::InterfaceWindow( intf_thread_t * _p_intf, BRect frame,
intf_thread_t* p_interface ) const char * name )
: BWindow( frame, name, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, : BWindow( frame, name, B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK | B_ASYNCHRONOUS_CONTROLS ), B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK | B_ASYNCHRONOUS_CONTROLS ),
p_intf( p_interface ),
/* Initializations */
p_intf( _p_intf ),
p_input( NULL ),
p_playlist( NULL ),
fFilePanel( NULL ), fFilePanel( NULL ),
fLastUpdateTime( system_time() ), fLastUpdateTime( system_time() ),
fSettings( new BMessage( 'sett' ) ), fSettings( new BMessage( 'sett' ) )
p_wrapper( p_intf->p_sys->p_wrapper )
{ {
fPlaylistIsEmpty = !( p_wrapper->PlaylistSize() > 0 ); char psz_tmp[1024];
#define ADD_ELLIPSIS( a ) \
memset( psz_tmp, 0, 1024 ); \
snprintf( psz_tmp, 1024, "%s%s", a, B_UTF8_ELLIPSIS );
BScreen screen; BScreen screen;
BRect screen_rect = screen.Frame(); BRect screen_rect = screen.Frame();
BRect window_rect; BRect window_rect;
...@@ -212,8 +218,7 @@ InterfaceWindow::InterfaceWindow( BRect frame, const char* name, ...@@ -212,8 +218,7 @@ InterfaceWindow::InterfaceWindow( BRect frame, const char* name,
fMessagesWindow = new MessagesWindow( p_intf, window_rect, _("Messages") ); fMessagesWindow = new MessagesWindow( p_intf, window_rect, _("Messages") );
// the media control view // the media control view
p_mediaControl = new MediaControlView( BRect( 0.0, 0.0, 250.0, 50.0 ), p_mediaControl = new MediaControlView( p_intf, BRect( 0.0, 0.0, 250.0, 50.0 ) );
p_intf );
p_mediaControl->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) ); p_mediaControl->SetViewColor( ui_color( B_PANEL_BACKGROUND_COLOR ) );
float width, height; float width, height;
...@@ -234,26 +239,25 @@ InterfaceWindow::InterfaceWindow( BRect frame, const char* name, ...@@ -234,26 +239,25 @@ InterfaceWindow::InterfaceWindow( BRect frame, const char* name,
p_mediaControl->MoveTo( fMenuBar->Bounds().LeftBottom() + BPoint(0.0, 1.0) ); p_mediaControl->MoveTo( fMenuBar->Bounds().LeftBottom() + BPoint(0.0, 1.0) );
AddChild( fMenuBar ); AddChild( fMenuBar );
// Add the file Menu // Add the file Menu
BMenu* fileMenu = new BMenu( _("File") ); BMenu* fileMenu = new BMenu( _("File") );
fMenuBar->AddItem( fileMenu ); fMenuBar->AddItem( fileMenu );
fileMenu->AddItem( new BMenuItem( _AddEllipsis(_("Open File")), ADD_ELLIPSIS( _("Open File") );
new BMessage( OPEN_FILE ), 'O') ); fileMenu->AddItem( new BMenuItem( psz_tmp, new BMessage( OPEN_FILE ), 'O') );
fileMenu->AddItem( new CDMenu( _("Open Disc") ) ); fileMenu->AddItem( new CDMenu( _("Open Disc") ) );
ADD_ELLIPSIS( _("Open Subtitles") );
fileMenu->AddItem( new BMenuItem( _AddEllipsis(_("Open Subtitles")), fileMenu->AddItem( new BMenuItem( psz_tmp, new BMessage( LOAD_SUBFILE ) ) );
new BMessage( LOAD_SUBFILE ) ) );
fileMenu->AddSeparatorItem(); fileMenu->AddSeparatorItem();
BMenuItem* item = new BMenuItem( _AddEllipsis(_("About")), ADD_ELLIPSIS( _("About") );
new BMessage( B_ABOUT_REQUESTED ), 'A'); BMenuItem* item = new BMenuItem( psz_tmp, new BMessage( B_ABOUT_REQUESTED ), 'A');
item->SetTarget( be_app ); item->SetTarget( be_app );
fileMenu->AddItem( item ); fileMenu->AddItem( item );
fileMenu->AddItem( new BMenuItem( _("Quit"), new BMessage( B_QUIT_REQUESTED ), 'Q') ); fileMenu->AddItem( new BMenuItem( _("Quit"), new BMessage( B_QUIT_REQUESTED ), 'Q') );
fLanguageMenu = new LanguageMenu( _("Language"), AUDIO_ES, p_wrapper); fLanguageMenu = new LanguageMenu( p_intf, _("Language"), "audio-es" );
fSubtitlesMenu = new LanguageMenu( _("Subtitles"), SPU_ES, p_wrapper); fSubtitlesMenu = new LanguageMenu( p_intf, _("Subtitles"), "spu-es" );
/* Add the Audio menu */ /* Add the Audio menu */
fAudioMenu = new BMenu( _("Audio") ); fAudioMenu = new BMenu( _("Audio") );
...@@ -301,17 +305,17 @@ InterfaceWindow::InterfaceWindow( BRect frame, const char* name, ...@@ -301,17 +305,17 @@ InterfaceWindow::InterfaceWindow( BRect frame, const char* name,
/* Add the Show menu */ /* Add the Show menu */
fShowMenu = new BMenu( _("Window") ); fShowMenu = new BMenu( _("Window") );
fShowMenu->AddItem( new BMenuItem( _AddEllipsis(_("Playlist")), ADD_ELLIPSIS( _("Playlist") );
new BMessage( OPEN_PLAYLIST ), 'P') ); fShowMenu->AddItem( new BMenuItem( psz_tmp, new BMessage( OPEN_PLAYLIST ), 'P') );
fShowMenu->AddItem( new BMenuItem( _AddEllipsis(_("Messages")), ADD_ELLIPSIS( _("Messages") );
new BMessage( OPEN_MESSAGES ), 'M' ) ); fShowMenu->AddItem( new BMenuItem( psz_tmp, new BMessage( OPEN_MESSAGES ), 'M' ) );
fShowMenu->AddItem( new BMenuItem( _AddEllipsis(_("Preferences")), ADD_ELLIPSIS( _("Preferences") );
new BMessage( OPEN_PREFERENCES ), 'S' ) ); fShowMenu->AddItem( new BMenuItem( psz_tmp, new BMessage( OPEN_PREFERENCES ), 'S' ) );
fMenuBar->AddItem( fShowMenu ); fMenuBar->AddItem( fShowMenu );
// add the media control view after the menubar is complete // add the media control view after the menubar is complete
// because it will set the window size limits in AttachedToWindow() // because it will set the window size limits in AttachedToWindow()
// and the menubar needs to report the correct PreferredSize() // and the menubar needs to report the correct PreferredSize()
AddChild( p_mediaControl ); AddChild( p_mediaControl );
/* Prepare fow showing */ /* Prepare fow showing */
...@@ -325,17 +329,28 @@ InterfaceWindow::InterfaceWindow( BRect frame, const char* name, ...@@ -325,17 +329,28 @@ InterfaceWindow::InterfaceWindow( BRect frame, const char* name,
InterfaceWindow::~InterfaceWindow() InterfaceWindow::~InterfaceWindow()
{ {
if( p_input )
{
vlc_object_release( p_input );
}
if( p_playlist )
{
vlc_object_release( p_playlist );
}
if( fPlaylistWindow ) if( fPlaylistWindow )
{
fPlaylistWindow->ReallyQuit(); fPlaylistWindow->ReallyQuit();
fPlaylistWindow = NULL; }
if( fMessagesWindow ) if( fMessagesWindow )
{
fMessagesWindow->ReallyQuit(); fMessagesWindow->ReallyQuit();
fMessagesWindow = NULL; }
if( fPreferencesWindow ) if( fPreferencesWindow )
{
fPreferencesWindow->ReallyQuit(); fPreferencesWindow->ReallyQuit();
fPreferencesWindow = NULL; }
delete fFilePanel; delete fFilePanel;
delete fSettings; delete fSettings;
} }
/***************************************************************************** /*****************************************************************************
...@@ -357,16 +372,16 @@ InterfaceWindow::FrameResized(float width, float height) ...@@ -357,16 +372,16 @@ InterfaceWindow::FrameResized(float width, float height)
*****************************************************************************/ *****************************************************************************/
void InterfaceWindow::MessageReceived( BMessage * p_message ) void InterfaceWindow::MessageReceived( BMessage * p_message )
{ {
int playback_status; // remember playback state
playback_status = p_wrapper->InputStatus();
switch( p_message->what ) switch( p_message->what )
{ {
case B_ABOUT_REQUESTED: case B_ABOUT_REQUESTED:
{ {
BAlert* alert = new BAlert( "VLC " PACKAGE_VERSION, BAlert * alert;
"VLC " PACKAGE_VERSION " for BeOS"
"\n\n<www.videolan.org>", _("OK")); alert = new BAlert( "VLC media player" VERSION,
"VLC media player" VERSION " (BeOS interface)\n\n"
"The VideoLAN team <videolan@videolan.org>\n"
"http://www.videolan.org/", _("OK") );
alert->Go(); alert->Go();
break; break;
} }
...@@ -374,11 +389,11 @@ void InterfaceWindow::MessageReceived( BMessage * p_message ) ...@@ -374,11 +389,11 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
break; break;
case OPEN_FILE: case OPEN_FILE:
_ShowFilePanel( B_REFS_RECEIVED, _("VLC media player: Open Media Files") ); _ShowFilePanel( B_REFS_RECEIVED, _("VLC media player: Open Media Files") );
break; break;
case LOAD_SUBFILE: case LOAD_SUBFILE:
_ShowFilePanel( SUBFILE_RECEIVED, _("VLC media player: Open Subtitle File") ); _ShowFilePanel( SUBFILE_RECEIVED, _("VLC media player: Open Subtitle File") );
break; break;
case OPEN_PLAYLIST: case OPEN_PLAYLIST:
...@@ -391,14 +406,18 @@ void InterfaceWindow::MessageReceived( BMessage * p_message ) ...@@ -391,14 +406,18 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
fPlaylistWindow->Unlock(); fPlaylistWindow->Unlock();
} }
break; break;
case OPEN_DVD: case OPEN_DVD:
{ {
const char *psz_device; const char * psz_device;
BString type( "dvd" ); if( p_playlist &&
if( p_message->FindString( "device", &psz_device ) == B_OK ) p_message->FindString( "device", &psz_device ) == B_OK )
{ {
BString device( psz_device ); char psz_uri[1024];
p_wrapper->OpenDisc( type, device, 0, 0 ); memset( psz_uri, 0, 1024 );
snprintf( psz_uri, 1024, "dvdnav:%s", psz_device );
playlist_Add( p_playlist, psz_uri, psz_device,
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
} }
_UpdatePlaylist(); _UpdatePlaylist();
} }
...@@ -411,280 +430,324 @@ void InterfaceWindow::MessageReceived( BMessage * p_message ) ...@@ -411,280 +430,324 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
{ {
BPath path( &ref ); BPath path( &ref );
if ( path.InitCheck() == B_OK ) if ( path.InitCheck() == B_OK )
p_wrapper->LoadSubFile( path.Path() ); config_PutPsz( p_intf, "sub-file", path.Path() );
} }
break; break;
} }
case STOP_PLAYBACK: case STOP_PLAYBACK:
// this currently stops playback not nicely if( p_playlist )
if (playback_status != -1)
{ {
p_wrapper->PlaylistStop(); playlist_Stop( p_playlist );
p_mediaControl->SetStatus(-1, INPUT_RATE_DEFAULT);
} }
p_mediaControl->SetStatus(-1, INPUT_RATE_DEFAULT);
break; break;
case START_PLAYBACK: case START_PLAYBACK:
/* starts playing in normal mode */ /* starts playing in normal mode */
case PAUSE_PLAYBACK: case PAUSE_PLAYBACK:
/* toggle between pause and play */ if( p_input )
if (playback_status > -1)
{ {
/* pause if currently playing */ if( var_GetInteger( p_input, "state" ) == PAUSE_S )
if ( playback_status == PLAYING_S )
{ {
p_wrapper->PlaylistPause(); if( p_playlist )
{
playlist_Play( p_playlist );
}
} }
else else
{ {
p_wrapper->PlaylistPlay(); var_SetInteger( p_input, "state", PAUSE_S );
} }
} }
else
{
/* Play a new file */
p_wrapper->PlaylistPlay();
}
break; break;
case HEIGHTH_PLAY: case HEIGHTH_PLAY:
p_wrapper->InputSetRate( INPUT_RATE_DEFAULT * 8 ); if( p_input )
{
var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT * 8 );
}
break; break;
case QUARTER_PLAY: case QUARTER_PLAY:
p_wrapper->InputSetRate( INPUT_RATE_DEFAULT * 4 ); if( p_input )
{
var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT * 4 );
}
break; break;
case HALF_PLAY: case HALF_PLAY:
p_wrapper->InputSetRate( INPUT_RATE_DEFAULT * 2 ); if( p_input )
{
var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT * 2 );
}
break; break;
case NORMAL_PLAY: case NORMAL_PLAY:
p_wrapper->InputSetRate( INPUT_RATE_DEFAULT ); if( p_input )
{
var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT );
}
break; break;
case TWICE_PLAY: case TWICE_PLAY:
p_wrapper->InputSetRate( INPUT_RATE_DEFAULT / 2 ); if( p_input )
{
var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT / 2 );
}
break; break;
case FOUR_PLAY: case FOUR_PLAY:
p_wrapper->InputSetRate( INPUT_RATE_DEFAULT / 4 ); if( p_input )
{
var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT / 4 );
}
break; break;
case HEIGHT_PLAY: case HEIGHT_PLAY:
p_wrapper->InputSetRate( INPUT_RATE_DEFAULT / 8 ); if( p_input )
{
var_SetInteger( p_input, "rate", INPUT_RATE_DEFAULT / 8 );
}
break; break;
case SEEK_PLAYBACK: case SEEK_PLAYBACK:
/* handled by semaphores */ /* handled by semaphores */
break; break;
// volume related messages
case VOLUME_CHG: case VOLUME_CHG:
/* adjust the volume */ aout_VolumeSet( p_intf, p_mediaControl->GetVolume() );
if (playback_status > -1)
{
p_wrapper->SetVolume( p_mediaControl->GetVolume() );
p_mediaControl->SetMuted( p_wrapper->IsMuted() );
}
break; break;
case VOLUME_MUTE: case VOLUME_MUTE:
// toggle muting aout_VolumeMute( p_intf, NULL );
if( p_wrapper->IsMuted() )
p_wrapper->VolumeRestore();
else
p_wrapper->VolumeMute();
p_mediaControl->SetMuted( p_wrapper->IsMuted() );
break; break;
case SELECT_CHANNEL: case SELECT_CHANNEL:
if ( playback_status > -1 ) {
int32 channel;
if( p_input )
{ {
int32 channel; if( p_message->FindInt32( "audio-es", &channel ) == B_OK )
if ( p_message->FindInt32( "channel", &channel ) == B_OK ) {
var_SetInteger( p_input, "audio-es", channel );
}
else if( p_message->FindInt32( "spu-es", &channel ) == B_OK )
{ {
p_wrapper->ToggleLanguage( channel ); var_SetInteger( p_input, "spu-es", channel );
} }
} }
break; break;
}
case SELECT_SUBTITLE: case PREV_TITLE:
if ( playback_status > -1 ) if( p_input )
{ {
int32 subtitle; var_SetVoid( p_input, "prev-title" );
if ( p_message->FindInt32( "subtitle", &subtitle ) == B_OK )
p_wrapper->ToggleSubtitle( subtitle );
} }
break; break;
// specific navigation messages
case PREV_TITLE:
{
p_wrapper->PrevTitle();
break;
}
case NEXT_TITLE: case NEXT_TITLE:
{ if( p_input )
p_wrapper->NextTitle(); {
var_SetVoid( p_input, "next-title" );
}
break; break;
}
case NAVIGATE_MENU: case NAVIGATE_MENU:
p_wrapper->ToggleTitle( 0 ); if( p_input )
break;
case TOGGLE_TITLE:
if ( playback_status > -1 )
{ {
int32 index; var_SetInteger( p_input, "title", 0 );
if( p_message->FindInt32( "index", &index ) == B_OK )
p_wrapper->ToggleTitle( index );
} }
break; break;
case PREV_CHAPTER:
case TOGGLE_TITLE:
{ {
p_wrapper->PrevChapter(); int32 index;
if( p_input &&
p_message->FindInt32( "index", &index ) == B_OK )
{
var_SetInteger( p_input, "title", index );
}
break; break;
} }
case PREV_CHAPTER:
if( p_input )
{
var_SetVoid( p_input, "prev-chapter" );
}
break;
case NEXT_CHAPTER: case NEXT_CHAPTER:
{ if( p_input )
p_wrapper->NextChapter(); {
var_SetVoid( p_input, "next-chapter" );
}
break; break;
}
case TOGGLE_CHAPTER: case TOGGLE_CHAPTER:
if ( playback_status > -1 ) {
int32 index;
if( p_input &&
p_message->FindInt32( "index", &index ) == B_OK )
{ {
int32 index; var_SetInteger( p_input, "chapter", index );
if( p_message->FindInt32( "index", &index ) == B_OK )
p_wrapper->ToggleChapter( index );
} }
break; break;
}
case PREV_FILE: case PREV_FILE:
p_wrapper->PlaylistPrev(); if( p_playlist )
{
playlist_Prev( p_playlist );
}
break; break;
case NEXT_FILE: case NEXT_FILE:
p_wrapper->PlaylistNext(); if( p_playlist )
{
playlist_Next( p_playlist );
}
break; break;
// general next/prev functionality (skips to whatever makes most sense)
case NAVIGATE_PREV: case NAVIGATE_PREV:
p_wrapper->NavigatePrev(); if( p_input )
{
vlc_value_t val;
/* First try to go to previous chapter */
if( !var_Get( p_input, "chapter", &val ) )
{
if( val.i_int > 1 )
{
var_SetVoid( p_input, "prev-chapter" );
break;
}
}
/* Try to go to previous title */
if( !var_Get( p_input, "title", &val ) )
{
if( val.i_int > 1 )
{
var_SetVoid( p_input, "prev-title" );
break;
}
}
/* Try to go to previous file */
if( p_playlist )
{
playlist_Prev( p_playlist );
}
}
break; break;
case NAVIGATE_NEXT: case NAVIGATE_NEXT:
p_wrapper->NavigateNext(); if( p_input )
{
vlc_value_t val, val_list;
/* First try to go to next chapter */
if( !var_Get( p_input, "chapter", &val ) )
{
var_Change( p_input, "chapter", VLC_VAR_GETCHOICES,
&val_list, NULL );
if( val_list.p_list->i_count > val.i_int )
{
var_Change( p_input, "chapter", VLC_VAR_FREELIST,
&val_list, NULL );
var_SetVoid( p_input, "next-chapter" );
break;
}
var_Change( p_input, "chapter", VLC_VAR_FREELIST,
&val_list, NULL );
}
/* Try to go to next title */
if( !var_Get( p_input, "title", &val ) )
{
var_Change( p_input, "title", VLC_VAR_GETCHOICES,
&val_list, NULL );
if( val_list.p_list->i_count > val.i_int )
{
var_Change( p_input, "title", VLC_VAR_FREELIST,
&val_list, NULL );
var_SetVoid( p_input, "next-title" );
break;
}
var_Change( p_input, "title", VLC_VAR_FREELIST,
&val_list, NULL );
}
/* Try to go to next file */
if( p_playlist )
{
playlist_Next( p_playlist );
}
}
break; break;
// drag'n'drop and system messages // drag'n'drop and system messages
case MSG_SOUNDPLAY: case MSG_SOUNDPLAY:
// convert soundplay drag'n'drop message (containing paths) // convert soundplay drag'n'drop message (containing paths)
// to normal message (containing refs) // to normal message (containing refs)
{ {
const char* path; const char* path;
for ( int32 i = 0; p_message->FindString( "path", i, &path ) == B_OK; i++ ) for ( int32 i = 0; p_message->FindString( "path", i, &path ) == B_OK; i++ )
{ {
entry_ref ref; entry_ref ref;
if ( get_ref_for_path( path, &ref ) == B_OK ) if ( get_ref_for_path( path, &ref ) == B_OK )
p_message->AddRef( "refs", &ref ); p_message->AddRef( "refs", &ref );
} }
} }
// fall through // fall through
case B_REFS_RECEIVED: case B_REFS_RECEIVED:
case B_SIMPLE_DATA: case B_SIMPLE_DATA:
{
/* file(s) opened by the File menu -> append to the playlist;
file(s) opened by drag & drop -> replace playlist;
file(s) opened by 'shift' + drag & drop -> append */
int32 count;
type_code dummy;
if( p_message->GetInfo( "refs", &dummy, &count ) != B_OK ||
count < 1 )
{ {
/* file(s) opened by the File menu -> append to the playlist; break;
* file(s) opened by drag & drop -> replace playlist; }
* file(s) opened by 'shift' + drag & drop -> append */
bool replace = false; vlc_bool_t b_remove = ( p_message->WasDropped() &&
bool reverse = false; !( modifiers() & B_SHIFT_KEY ) );
if ( p_message->WasDropped() )
if( b_remove && p_playlist )
{
/* Empty playlist */
while( p_playlist->i_size > 0 )
{ {
replace = !( modifiers() & B_SHIFT_KEY ); playlist_Delete( p_playlist, 0 );
reverse = true;
} }
// build list of files to be played from message contents
entry_ref ref;
BList files;
// if we should parse sub-folders as well
bool askedAlready = false;
bool parseSubFolders = askedAlready;
// traverse refs in reverse order
int32 count;
type_code dummy;
if ( p_message->GetInfo( "refs", &dummy, &count ) == B_OK && count > 0 )
{
int32 i = reverse ? count - 1 : 0;
int32 increment = reverse ? -1 : 1;
for ( ; p_message->FindRef( "refs", i, &ref ) == B_OK; i += increment )
{
BPath path( &ref );
if ( path.InitCheck() == B_OK )
{
bool add = true;
// has the user dropped a folder?
BDirectory dir( &ref );
if ( dir.InitCheck() == B_OK)
{
// has the user dropped a dvd disk icon?
if ( dir.IsRootDirectory() )
{
BVolumeRoster volRoster;
BVolume vol;
BDirectory volumeRoot;
status_t status = volRoster.GetNextVolume( &vol );
while ( status == B_NO_ERROR )
{
if ( vol.GetRootDirectory( &volumeRoot ) == B_OK
&& dir == volumeRoot )
{
BString volumeName;
BString deviceName;
bool isCDROM;
if ( get_volume_info( vol, volumeName, isCDROM, deviceName )
&& isCDROM )
{
BMessage msg( OPEN_DVD );
msg.AddString( "device", deviceName.String() );
PostMessage( &msg );
add = false;
}
break;
}
else
{
vol.Unset();
status = volRoster.GetNextVolume( &vol );
}
}
}
if ( add )
{
add = false;
dir.Rewind(); // defensive programming
BEntry entry;
collect_folder_contents( dir, files,
parseSubFolders,
askedAlready,
entry );
}
}
if ( add )
{
BString* string = new BString( path.Path() );
if ( !files.AddItem( string, 0 ) )
delete string; // at least don't leak
}
}
}
// give the list to VLC
// BString objects allocated here will be deleted there
int32 index;
if ( p_message->FindInt32("drop index", &index) != B_OK )
index = -1;
p_wrapper->OpenFiles( &files, replace, index );
_UpdatePlaylist();
}
} }
entry_ref ref;
for( int i = 0; p_message->FindRef( "refs", i, &ref ) == B_OK; i++ )
{
BPath path( &ref );
/* TODO: find out if this is a DVD icon */
if( p_playlist )
{
playlist_Add( p_playlist, path.Path(), path.Path(),
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
}
}
_UpdatePlaylist();
break; break;
}
case OPEN_PREFERENCES: case OPEN_PREFERENCES:
{ {
...@@ -712,13 +775,12 @@ void InterfaceWindow::MessageReceived( BMessage * p_message ) ...@@ -712,13 +775,12 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
break; break;
} }
case MSG_UPDATE: case MSG_UPDATE:
UpdateInterface(); UpdateInterface();
break; break;
default: default:
BWindow::MessageReceived( p_message ); BWindow::MessageReceived( p_message );
break; break;
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -726,10 +788,13 @@ void InterfaceWindow::MessageReceived( BMessage * p_message ) ...@@ -726,10 +788,13 @@ void InterfaceWindow::MessageReceived( BMessage * p_message )
*****************************************************************************/ *****************************************************************************/
bool InterfaceWindow::QuitRequested() bool InterfaceWindow::QuitRequested()
{ {
p_wrapper->PlaylistStop(); if( p_playlist )
{
playlist_Stop( p_playlist );
}
p_mediaControl->SetStatus(-1, INPUT_RATE_DEFAULT); p_mediaControl->SetStatus(-1, INPUT_RATE_DEFAULT);
_StoreSettings(); _StoreSettings();
p_intf->b_die = 1; p_intf->b_die = 1;
...@@ -741,41 +806,57 @@ bool InterfaceWindow::QuitRequested() ...@@ -741,41 +806,57 @@ bool InterfaceWindow::QuitRequested()
*****************************************************************************/ *****************************************************************************/
void InterfaceWindow::UpdateInterface() void InterfaceWindow::UpdateInterface()
{ {
if( p_wrapper->HasInput() ) /* Manage the input part */
if( !p_playlist )
{ {
if ( acquire_sem( p_mediaControl->fScrubSem ) == B_OK ) p_playlist = (playlist_t *)
{ vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
p_wrapper->SetTimeAsFloat( p_mediaControl->GetSeekTo() ); }
} if( !p_input )
else if ( LockWithTimeout( INTERFACE_LOCKING_TIMEOUT ) == B_OK ) {
{ p_input = (input_thread_t *)
p_mediaControl->SetEnabled( true ); vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
bool hasTitles = p_wrapper->HasTitles(); }
bool hasChapters = p_wrapper->HasChapters(); else if( p_input->b_dead )
p_mediaControl->SetStatus( p_wrapper->InputStatus(), {
p_wrapper->InputRate() ); vlc_object_release( p_input );
p_mediaControl->SetProgress( p_wrapper->GetTimeAsFloat() ); p_input = NULL;
_SetMenusEnabled( true, hasChapters, hasTitles ); }
_UpdateSpeedMenu( p_wrapper->InputRate() );
// enable/disable skip buttons
bool canSkipPrev;
bool canSkipNext;
p_wrapper->GetNavCapabilities( &canSkipPrev, &canSkipNext );
p_mediaControl->SetSkippable( canSkipPrev, canSkipNext );
if ( p_wrapper->HasInput() ) /* Get ready to update the interface */
{ if( LockWithTimeout( INTERFACE_LOCKING_TIMEOUT ) != B_OK )
p_mediaControl->SetAudioEnabled( true ); {
p_mediaControl->SetMuted( p_wrapper->IsMuted() ); return;
} else }
p_mediaControl->SetAudioEnabled( false );
if( p_input )
{
vlc_value_t val;
p_mediaControl->SetEnabled( true );
bool hasTitles = var_Get( p_input, "title", &val );
bool hasChapters = var_Get( p_input, "chapter", &val );
p_mediaControl->SetStatus( var_GetInteger( p_input, "state" ),
var_GetInteger( p_input, "rate" ) );
var_Get( p_input, "position", &val );
p_mediaControl->SetProgress( val.f_float );
_SetMenusEnabled( true, hasChapters, hasTitles );
_UpdateSpeedMenu( var_GetInteger( p_input, "rate" ) );
// enable/disable skip buttons
#if 0
bool canSkipPrev;
bool canSkipNext;
p_wrapper->GetNavCapabilities( &canSkipPrev, &canSkipNext );
p_mediaControl->SetSkippable( canSkipPrev, canSkipNext );
#endif
audio_volume_t i_volume;
aout_VolumeGet( p_input, &i_volume );
p_mediaControl->SetAudioEnabled( true );
p_mediaControl->SetMuted( i_volume );
Unlock();
}
// update playlist as well // update playlist as well
if ( fPlaylistWindow->LockWithTimeout( INTERFACE_LOCKING_TIMEOUT ) == B_OK ) if( fPlaylistWindow->LockWithTimeout( INTERFACE_LOCKING_TIMEOUT ) == B_OK )
{ {
fPlaylistWindow->UpdatePlaylist(); fPlaylistWindow->UpdatePlaylist();
fPlaylistWindow->Unlock(); fPlaylistWindow->Unlock();
...@@ -783,24 +864,29 @@ void InterfaceWindow::UpdateInterface() ...@@ -783,24 +864,29 @@ void InterfaceWindow::UpdateInterface()
} }
else else
{ {
if ( LockWithTimeout(INTERFACE_LOCKING_TIMEOUT) == B_OK ) p_mediaControl->SetAudioEnabled( false );
{
_SetMenusEnabled( false ); _SetMenusEnabled( false );
if( !( p_wrapper->PlaylistSize() > 0 ) )
p_mediaControl->SetEnabled( false ); if( !p_playlist || p_playlist->i_size <= 0 )
else {
{ p_mediaControl->SetProgress( 0 );
p_mediaControl->SetProgress( 0 );
// enable/disable skip buttons #if 0
bool canSkipPrev; // enable/disable skip buttons
bool canSkipNext; bool canSkipPrev;
p_wrapper->GetNavCapabilities( &canSkipPrev, &canSkipNext ); bool canSkipNext;
p_mediaControl->SetSkippable( canSkipPrev, canSkipNext ); p_wrapper->GetNavCapabilities( &canSkipPrev, &canSkipNext );
} p_mediaControl->SetSkippable( canSkipPrev, canSkipNext );
Unlock(); #endif
}
else
{
p_mediaControl->SetEnabled( false );
} }
} }
Unlock();
fLastUpdateTime = system_time(); fLastUpdateTime = system_time();
} }
...@@ -819,12 +905,12 @@ InterfaceWindow::IsStopped() const ...@@ -819,12 +905,12 @@ InterfaceWindow::IsStopped() const
void void
InterfaceWindow::_UpdatePlaylist() InterfaceWindow::_UpdatePlaylist()
{ {
if ( fPlaylistWindow->Lock() ) if( fPlaylistWindow->Lock() )
{ {
fPlaylistWindow->UpdatePlaylist( true ); fPlaylistWindow->UpdatePlaylist( true );
fPlaylistWindow->Unlock(); fPlaylistWindow->Unlock();
p_mediaControl->SetEnabled( p_wrapper->PlaylistSize() );
} }
p_mediaControl->SetEnabled( p_playlist->i_size );
} }
/***************************************************************************** /*****************************************************************************
...@@ -862,10 +948,7 @@ InterfaceWindow::_SetMenusEnabled(bool hasFile, bool hasChapters, bool hasTitles ...@@ -862,10 +948,7 @@ InterfaceWindow::_SetMenusEnabled(bool hasFile, bool hasChapters, bool hasTitles
fSubtitlesMenu->SetEnabled( hasFile ); fSubtitlesMenu->SetEnabled( hasFile );
if ( fSpeedMenu->IsEnabled() != hasFile ) if ( fSpeedMenu->IsEnabled() != hasFile )
fSpeedMenu->SetEnabled( hasFile ); fSpeedMenu->SetEnabled( hasFile );
// "goto menu" menu item fGotoMenuMI->SetEnabled( true );
bool hasMenu = p_wrapper->IsUsingMenus();
if ( fGotoMenuMI->IsEnabled() != hasMenu )
fGotoMenuMI->SetEnabled( hasMenu );
Unlock(); Unlock();
} }
} }
...@@ -909,8 +992,10 @@ InterfaceWindow::_UpdateSpeedMenu( int rate ) ...@@ -909,8 +992,10 @@ InterfaceWindow::_UpdateSpeedMenu( int rate )
break; break;
} }
if ( !toMark->IsMarked() ) if ( toMark && !toMark->IsMarked() )
{
toMark->SetMarked( true ); toMark->SetMarked( true );
}
} }
/***************************************************************************** /*****************************************************************************
...@@ -919,58 +1004,58 @@ InterfaceWindow::_UpdateSpeedMenu( int rate ) ...@@ -919,58 +1004,58 @@ InterfaceWindow::_UpdateSpeedMenu( int rate )
void void
InterfaceWindow::_ShowFilePanel( uint32 command, const char* windowTitle ) InterfaceWindow::_ShowFilePanel( uint32 command, const char* windowTitle )
{ {
if( !fFilePanel ) if( !fFilePanel )
{ {
fFilePanel = new BFilePanel( B_OPEN_PANEL, NULL, NULL, fFilePanel = new BFilePanel( B_OPEN_PANEL, NULL, NULL,
B_FILE_NODE | B_DIRECTORY_NODE ); B_FILE_NODE | B_DIRECTORY_NODE );
fFilePanel->SetTarget( this ); fFilePanel->SetTarget( this );
} }
fFilePanel->Window()->SetTitle( windowTitle ); fFilePanel->Window()->SetTitle( windowTitle );
BMessage message( command ); BMessage message( command );
fFilePanel->SetMessage( &message ); fFilePanel->SetMessage( &message );
if ( !fFilePanel->IsShowing() ) if ( !fFilePanel->IsShowing() )
{ {
fFilePanel->Refresh(); fFilePanel->Refresh();
fFilePanel->Show(); fFilePanel->Show();
} }
} }
// set_window_pos // set_window_pos
void void
set_window_pos( BWindow* window, BRect frame ) set_window_pos( BWindow* window, BRect frame )
{ {
// sanity checks: make sure window is not too big/small // sanity checks: make sure window is not too big/small
// and that it's not off-screen // and that it's not off-screen
float minWidth, maxWidth, minHeight, maxHeight; float minWidth, maxWidth, minHeight, maxHeight;
window->GetSizeLimits( &minWidth, &maxWidth, &minHeight, &maxHeight ); window->GetSizeLimits( &minWidth, &maxWidth, &minHeight, &maxHeight );
make_sure_frame_is_within_limits( frame, make_sure_frame_is_within_limits( frame,
minWidth, minHeight, maxWidth, maxHeight ); minWidth, minHeight, maxWidth, maxHeight );
if ( make_sure_frame_is_on_screen( frame ) ) if ( make_sure_frame_is_on_screen( frame ) )
{ {
window->MoveTo( frame.LeftTop() ); window->MoveTo( frame.LeftTop() );
window->ResizeTo( frame.Width(), frame.Height() ); window->ResizeTo( frame.Width(), frame.Height() );
} }
} }
// set_window_pos // set_window_pos
void void
launch_window( BWindow* window, bool showing ) launch_window( BWindow* window, bool showing )
{ {
if ( window->Lock() ) if ( window->Lock() )
{ {
if ( showing ) if ( showing )
{ {
if ( window->IsHidden() ) if ( window->IsHidden() )
window->Show(); window->Show();
} }
else else
{ {
if ( !window->IsHidden() ) if ( !window->IsHidden() )
window->Hide(); window->Hide();
} }
window->Unlock(); window->Unlock();
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -979,35 +1064,35 @@ launch_window( BWindow* window, bool showing ) ...@@ -979,35 +1064,35 @@ launch_window( BWindow* window, bool showing )
void void
InterfaceWindow::_RestoreSettings() InterfaceWindow::_RestoreSettings()
{ {
if ( load_settings( fSettings, "interface_settings", "VideoLAN Client" ) == B_OK ) if ( load_settings( fSettings, "interface_settings", "VideoLAN Client" ) == B_OK )
{ {
BRect frame; BRect frame;
if ( fSettings->FindRect( "main frame", &frame ) == B_OK ) if ( fSettings->FindRect( "main frame", &frame ) == B_OK )
set_window_pos( this, frame ); set_window_pos( this, frame );
if (fSettings->FindRect( "playlist frame", &frame ) == B_OK ) if (fSettings->FindRect( "playlist frame", &frame ) == B_OK )
set_window_pos( fPlaylistWindow, frame ); set_window_pos( fPlaylistWindow, frame );
if (fSettings->FindRect( "messages frame", &frame ) == B_OK ) if (fSettings->FindRect( "messages frame", &frame ) == B_OK )
set_window_pos( fMessagesWindow, frame ); set_window_pos( fMessagesWindow, frame );
if (fSettings->FindRect( "settings frame", &frame ) == B_OK ) if (fSettings->FindRect( "settings frame", &frame ) == B_OK )
{ {
/* FIXME: Preferences resizing doesn't work correctly yet */ /* FIXME: Preferences resizing doesn't work correctly yet */
frame.right = frame.left + fPreferencesWindow->Frame().Width(); frame.right = frame.left + fPreferencesWindow->Frame().Width();
frame.bottom = frame.top + fPreferencesWindow->Frame().Height(); frame.bottom = frame.top + fPreferencesWindow->Frame().Height();
set_window_pos( fPreferencesWindow, frame ); set_window_pos( fPreferencesWindow, frame );
} }
bool showing; bool showing;
if ( fSettings->FindBool( "playlist showing", &showing ) == B_OK ) if ( fSettings->FindBool( "playlist showing", &showing ) == B_OK )
launch_window( fPlaylistWindow, showing ); launch_window( fPlaylistWindow, showing );
if ( fSettings->FindBool( "messages showing", &showing ) == B_OK ) if ( fSettings->FindBool( "messages showing", &showing ) == B_OK )
launch_window( fMessagesWindow, showing ); launch_window( fMessagesWindow, showing );
if ( fSettings->FindBool( "settings showing", &showing ) == B_OK ) if ( fSettings->FindBool( "settings showing", &showing ) == B_OK )
launch_window( fPreferencesWindow, showing ); launch_window( fPreferencesWindow, showing );
uint32 displayMode; uint32 displayMode;
if ( fSettings->FindInt32( "playlist display mode", (int32*)&displayMode ) == B_OK ) if ( fSettings->FindInt32( "playlist display mode", (int32*)&displayMode ) == B_OK )
fPlaylistWindow->SetDisplayMode( displayMode ); fPlaylistWindow->SetDisplayMode( displayMode );
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -1021,37 +1106,37 @@ InterfaceWindow::_StoreSettings() ...@@ -1021,37 +1106,37 @@ InterfaceWindow::_StoreSettings()
config_SaveConfigFile( p_intf, "main" ); config_SaveConfigFile( p_intf, "main" );
/* Save the windows positions */ /* Save the windows positions */
if ( fSettings->ReplaceRect( "main frame", Frame() ) != B_OK ) if ( fSettings->ReplaceRect( "main frame", Frame() ) != B_OK )
fSettings->AddRect( "main frame", Frame() ); fSettings->AddRect( "main frame", Frame() );
if ( fPlaylistWindow->Lock() ) if ( fPlaylistWindow->Lock() )
{ {
if (fSettings->ReplaceRect( "playlist frame", fPlaylistWindow->Frame() ) != B_OK) if (fSettings->ReplaceRect( "playlist frame", fPlaylistWindow->Frame() ) != B_OK)
fSettings->AddRect( "playlist frame", fPlaylistWindow->Frame() ); fSettings->AddRect( "playlist frame", fPlaylistWindow->Frame() );
if (fSettings->ReplaceBool( "playlist showing", !fPlaylistWindow->IsHidden() ) != B_OK) if (fSettings->ReplaceBool( "playlist showing", !fPlaylistWindow->IsHidden() ) != B_OK)
fSettings->AddBool( "playlist showing", !fPlaylistWindow->IsHidden() ); fSettings->AddBool( "playlist showing", !fPlaylistWindow->IsHidden() );
fPlaylistWindow->Unlock(); fPlaylistWindow->Unlock();
} }
if ( fMessagesWindow->Lock() ) if ( fMessagesWindow->Lock() )
{ {
if (fSettings->ReplaceRect( "messages frame", fMessagesWindow->Frame() ) != B_OK) if (fSettings->ReplaceRect( "messages frame", fMessagesWindow->Frame() ) != B_OK)
fSettings->AddRect( "messages frame", fMessagesWindow->Frame() ); fSettings->AddRect( "messages frame", fMessagesWindow->Frame() );
if (fSettings->ReplaceBool( "messages showing", !fMessagesWindow->IsHidden() ) != B_OK) if (fSettings->ReplaceBool( "messages showing", !fMessagesWindow->IsHidden() ) != B_OK)
fSettings->AddBool( "messages showing", !fMessagesWindow->IsHidden() ); fSettings->AddBool( "messages showing", !fMessagesWindow->IsHidden() );
fMessagesWindow->Unlock(); fMessagesWindow->Unlock();
} }
if ( fPreferencesWindow->Lock() ) if ( fPreferencesWindow->Lock() )
{ {
if (fSettings->ReplaceRect( "settings frame", fPreferencesWindow->Frame() ) != B_OK) if (fSettings->ReplaceRect( "settings frame", fPreferencesWindow->Frame() ) != B_OK)
fSettings->AddRect( "settings frame", fPreferencesWindow->Frame() ); fSettings->AddRect( "settings frame", fPreferencesWindow->Frame() );
if (fSettings->ReplaceBool( "settings showing", !fPreferencesWindow->IsHidden() ) != B_OK) if (fSettings->ReplaceBool( "settings showing", !fPreferencesWindow->IsHidden() ) != B_OK)
fSettings->AddBool( "settings showing", !fPreferencesWindow->IsHidden() ); fSettings->AddBool( "settings showing", !fPreferencesWindow->IsHidden() );
fPreferencesWindow->Unlock(); fPreferencesWindow->Unlock();
} }
uint32 displayMode = fPlaylistWindow->DisplayMode(); uint32 displayMode = fPlaylistWindow->DisplayMode();
if (fSettings->ReplaceInt32( "playlist display mode", displayMode ) != B_OK ) if (fSettings->ReplaceInt32( "playlist display mode", displayMode ) != B_OK )
fSettings->AddInt32( "playlist display mode", displayMode ); fSettings->AddInt32( "playlist display mode", displayMode );
save_settings( fSettings, "interface_settings", "VideoLAN Client" ); save_settings( fSettings, "interface_settings", "VideoLAN Client" );
} }
...@@ -1087,38 +1172,38 @@ void CDMenu::AttachedToWindow(void) ...@@ -1087,38 +1172,38 @@ void CDMenu::AttachedToWindow(void)
*****************************************************************************/ *****************************************************************************/
int CDMenu::GetCD( const char *directory ) int CDMenu::GetCD( const char *directory )
{ {
BVolumeRoster volRoster; BVolumeRoster volRoster;
BVolume vol; BVolume vol;
BDirectory dir; BDirectory dir;
status_t status = volRoster.GetNextVolume( &vol ); status_t status = volRoster.GetNextVolume( &vol );
while ( status == B_NO_ERROR ) while ( status == B_NO_ERROR )
{ {
BString deviceName; BString deviceName;
BString volumeName; BString volumeName;
bool isCDROM; bool isCDROM;
if ( get_volume_info( vol, volumeName, isCDROM, deviceName ) if ( get_volume_info( vol, volumeName, isCDROM, deviceName )
&& isCDROM ) && isCDROM )
{ {
BMessage* msg = new BMessage( OPEN_DVD ); BMessage* msg = new BMessage( OPEN_DVD );
msg->AddString( "device", deviceName.String() ); msg->AddString( "device", deviceName.String() );
BMenuItem* item = new BMenuItem( volumeName.String(), msg ); BMenuItem* item = new BMenuItem( volumeName.String(), msg );
AddItem( item ); AddItem( item );
} }
vol.Unset(); vol.Unset();
status = volRoster.GetNextVolume( &vol ); status = volRoster.GetNextVolume( &vol );
} }
return 0; return 0;
} }
/***************************************************************************** /*****************************************************************************
* LanguageMenu::LanguageMenu * LanguageMenu::LanguageMenu
*****************************************************************************/ *****************************************************************************/
LanguageMenu::LanguageMenu( const char *name, int menu_kind, LanguageMenu::LanguageMenu( intf_thread_t * _p_intf, const char * psz_name,
VlcWrapper *p_wrapper ) char * _psz_variable )
:BMenu(name) : BMenu( psz_name )
{ {
kind = menu_kind; p_intf = _p_intf;
this->p_wrapper = p_wrapper; psz_variable = strdup( _psz_variable );
} }
/***************************************************************************** /*****************************************************************************
...@@ -1126,6 +1211,7 @@ LanguageMenu::LanguageMenu( const char *name, int menu_kind, ...@@ -1126,6 +1211,7 @@ LanguageMenu::LanguageMenu( const char *name, int menu_kind,
*****************************************************************************/ *****************************************************************************/
LanguageMenu::~LanguageMenu() LanguageMenu::~LanguageMenu()
{ {
free( psz_variable );
} }
/***************************************************************************** /*****************************************************************************
...@@ -1133,19 +1219,44 @@ LanguageMenu::~LanguageMenu() ...@@ -1133,19 +1219,44 @@ LanguageMenu::~LanguageMenu()
*****************************************************************************/ *****************************************************************************/
void LanguageMenu::AttachedToWindow() void LanguageMenu::AttachedToWindow()
{ {
BMenuItem * item;
// remove all items // remove all items
while ( BMenuItem* item = RemoveItem( 0L ) ) while( ( item = RemoveItem( 0L ) ) )
{
delete item; delete item;
}
SetRadioMode( true ); SetRadioMode( true );
if ( BList *list = p_wrapper->GetChannels( kind ) )
{ input_thread_t * p_input = (input_thread_t *)
for ( int32 i = 0; BMenuItem* item = (BMenuItem*)list->ItemAt( i ); i++ ) vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
AddItem( item ); if( !p_input )
{
if ( list->CountItems() > 1 ) return;
AddItem( new BSeparatorItem(), 1 ); }
}
vlc_value_t val_list, text_list;
BMessage * message;
int i_current;
i_current = var_GetInteger( p_input, psz_variable );
var_Change( p_input, psz_variable, VLC_VAR_GETLIST, &val_list, &text_list );
for( int i = 0; i < val_list.p_list->i_count; i++ )
{
message = new BMessage( SELECT_CHANNEL );
message->AddInt32( psz_variable, val_list.p_list->p_values[i].i_int );
item = new BMenuItem( text_list.p_list->p_values[i].psz_string, message );
if( val_list.p_list->p_values[i].i_int == i_current )
{
item->SetMarked( true );
}
AddItem( item );
}
var_Change( p_input, psz_variable, VLC_VAR_FREELIST, &val_list, &text_list );
vlc_object_release( p_input );
BMenu::AttachedToWindow(); BMenu::AttachedToWindow();
} }
...@@ -1170,14 +1281,41 @@ TitleMenu::~TitleMenu() ...@@ -1170,14 +1281,41 @@ TitleMenu::~TitleMenu()
*****************************************************************************/ *****************************************************************************/
void TitleMenu::AttachedToWindow() void TitleMenu::AttachedToWindow()
{ {
while( BMenuItem* item = RemoveItem( 0L ) ) BMenuItem * item;
while( ( item = RemoveItem( 0L ) ) )
{
delete item; delete item;
}
if ( BList *list = p_intf->p_sys->p_wrapper->GetTitles() ) input_thread_t * p_input;
{ p_input = (input_thread_t *)
for( int i = 0; BMenuItem* item = (BMenuItem*)list->ItemAt( i ); i++ ) vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
AddItem( item ); if( !p_input )
} {
return;
}
vlc_value_t val;
if( !var_Get( p_input, "title", &val ) )
{
vlc_value_t val_list, text_list;
var_Change( p_input, "title", VLC_VAR_GETCHOICES,
&val_list, &text_list );
for( int i = 0; i < val_list.p_list->i_count; i++ )
{
item = new BMenuItem( text_list.p_list->p_values[i].psz_string,
NULL );
if( val_list.p_list->p_values[i].i_int == val.i_int )
{
item->SetMarked( true );
}
AddItem( item );
}
var_Change( p_input, "title", VLC_VAR_FREELIST,
&val_list, &text_list );
}
BMenu::AttachedToWindow(); BMenu::AttachedToWindow();
} }
...@@ -1203,24 +1341,43 @@ ChapterMenu::~ChapterMenu() ...@@ -1203,24 +1341,43 @@ ChapterMenu::~ChapterMenu()
*****************************************************************************/ *****************************************************************************/
void ChapterMenu::AttachedToWindow() void ChapterMenu::AttachedToWindow()
{ {
while( BMenuItem* item = RemoveItem( 0L ) ) BMenuItem * item;
while( ( item = RemoveItem( 0L ) ) )
{
delete item; delete item;
}
if ( BList* list = p_intf->p_sys->p_wrapper->GetChapters() ) input_thread_t * p_input;
{ p_input = (input_thread_t *)
for( int i = 0; BMenuItem* item = (BMenuItem*)list->ItemAt( i ); i++ ) vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
AddItem( item ); if( !p_input )
} {
return;
BMenu::AttachedToWindow(); }
}
vlc_value_t val;
if( !var_Get( p_input, "chapter", &val ) )
{
vlc_value_t val_list, text_list;
var_Change( p_input, "chapter", VLC_VAR_GETCHOICES,
&val_list, &text_list );
for( int i = 0; i < val_list.p_list->i_count; i++ )
{
item = new BMenuItem( text_list.p_list->p_values[i].psz_string,
NULL );
if( val_list.p_list->p_values[i].i_int == val.i_int )
{
item->SetMarked( true );
}
AddItem( item );
}
var_Change( p_input, "chapter", VLC_VAR_FREELIST,
&val_list, &text_list );
}
BMenu::AttachedToWindow();
}
/***************************************************************************** /*****************************************************************************
...@@ -1229,27 +1386,27 @@ void ChapterMenu::AttachedToWindow() ...@@ -1229,27 +1386,27 @@ void ChapterMenu::AttachedToWindow()
status_t status_t
load_settings( BMessage* message, const char* fileName, const char* folder ) load_settings( BMessage* message, const char* fileName, const char* folder )
{ {
status_t ret = B_BAD_VALUE; status_t ret = B_BAD_VALUE;
if ( message ) if ( message )
{ {
BPath path; BPath path;
if ( ( ret = find_directory( B_USER_SETTINGS_DIRECTORY, &path ) ) == B_OK ) if ( ( ret = find_directory( B_USER_SETTINGS_DIRECTORY, &path ) ) == B_OK )
{ {
// passing folder is optional // passing folder is optional
if ( folder ) if ( folder )
ret = path.Append( folder ); ret = path.Append( folder );
if ( ret == B_OK && ( ret = path.Append( fileName ) ) == B_OK ) if ( ret == B_OK && ( ret = path.Append( fileName ) ) == B_OK )
{ {
BFile file( path.Path(), B_READ_ONLY ); BFile file( path.Path(), B_READ_ONLY );
if ( ( ret = file.InitCheck() ) == B_OK ) if ( ( ret = file.InitCheck() ) == B_OK )
{ {
ret = message->Unflatten( &file ); ret = message->Unflatten( &file );
file.Unset(); file.Unset();
} }
} }
} }
} }
return ret; return ret;
} }
/***************************************************************************** /*****************************************************************************
...@@ -1258,25 +1415,25 @@ load_settings( BMessage* message, const char* fileName, const char* folder ) ...@@ -1258,25 +1415,25 @@ load_settings( BMessage* message, const char* fileName, const char* folder )
status_t status_t
save_settings( BMessage* message, const char* fileName, const char* folder ) save_settings( BMessage* message, const char* fileName, const char* folder )
{ {
status_t ret = B_BAD_VALUE; status_t ret = B_BAD_VALUE;
if ( message ) if ( message )
{ {
BPath path; BPath path;
if ( ( ret = find_directory( B_USER_SETTINGS_DIRECTORY, &path ) ) == B_OK ) if ( ( ret = find_directory( B_USER_SETTINGS_DIRECTORY, &path ) ) == B_OK )
{ {
// passing folder is optional // passing folder is optional
if ( folder && ( ret = path.Append( folder ) ) == B_OK ) if ( folder && ( ret = path.Append( folder ) ) == B_OK )
ret = create_directory( path.Path(), 0777 ); ret = create_directory( path.Path(), 0777 );
if ( ret == B_OK && ( ret = path.Append( fileName ) ) == B_OK ) if ( ret == B_OK && ( ret = path.Append( fileName ) ) == B_OK )
{ {
BFile file( path.Path(), B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE ); BFile file( path.Path(), B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE );
if ( ( ret = file.InitCheck() ) == B_OK ) if ( ( ret = file.InitCheck() ) == B_OK )
{ {
ret = message->Flatten( &file ); ret = message->Flatten( &file );
file.Unset(); file.Unset();
} }
} }
} }
} }
return ret; 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.15 2004/01/26 16:52:31 zorglub Exp $ * $Id$
* *
* 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>
...@@ -36,7 +36,6 @@ class PlayListWindow; ...@@ -36,7 +36,6 @@ class PlayListWindow;
class BFilePanel; class BFilePanel;
class PreferencesWindow; class PreferencesWindow;
class MessagesWindow; class MessagesWindow;
class VlcWrapper;
class CDMenu : public BMenu class CDMenu : public BMenu
{ {
...@@ -53,16 +52,16 @@ class CDMenu : public BMenu ...@@ -53,16 +52,16 @@ class CDMenu : public BMenu
class LanguageMenu : public BMenu class LanguageMenu : public BMenu
{ {
public: public:
LanguageMenu( const char* name, LanguageMenu( intf_thread_t * p_intf,
int menu_kind, const char * psz_name,
VlcWrapper *p_wrapper ); char * psz_variable );
virtual ~LanguageMenu(); virtual ~LanguageMenu();
virtual void AttachedToWindow(); virtual void AttachedToWindow();
private: private:
VlcWrapper * p_wrapper; intf_thread_t * p_intf;
int kind; char * psz_variable;
}; };
class TitleMenu : public BMenu class TitleMenu : public BMenu
...@@ -91,9 +90,9 @@ class ChapterMenu : public BMenu ...@@ -91,9 +90,9 @@ class ChapterMenu : public BMenu
class InterfaceWindow : public BWindow class InterfaceWindow : public BWindow
{ {
public: public:
InterfaceWindow( BRect frame, InterfaceWindow( intf_thread_t * p_intf,
const char* name, BRect frame,
intf_thread_t* p_interface ); const char * name );
virtual ~InterfaceWindow(); virtual ~InterfaceWindow();
// BWindow // BWindow
...@@ -119,10 +118,11 @@ class InterfaceWindow : public BWindow ...@@ -119,10 +118,11 @@ class InterfaceWindow : public BWindow
void _RestoreSettings(); void _RestoreSettings();
void _StoreSettings(); void _StoreSettings();
intf_thread_t* p_intf; intf_thread_t * p_intf;
es_descriptor_t* p_spu_es; input_thread_t * p_input;
playlist_t * p_playlist;
es_descriptor_t * p_spu_es;
bool fPlaylistIsEmpty;
BFilePanel* fFilePanel; BFilePanel* fFilePanel;
PlayListWindow* fPlaylistWindow; PlayListWindow* fPlaylistWindow;
PreferencesWindow* fPreferencesWindow; PreferencesWindow* fPreferencesWindow;
...@@ -151,7 +151,6 @@ class InterfaceWindow : public BWindow ...@@ -151,7 +151,6 @@ class InterfaceWindow : public BWindow
bigtime_t fLastUpdateTime; bigtime_t fLastUpdateTime;
BMessage* fSettings; // we keep the message arround BMessage* fSettings; // we keep the message arround
// for forward compatibility // for forward compatibility
VlcWrapper* p_wrapper;
}; };
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ListViews.h: BeOS interface list view class implementation * ListViews.h: BeOS interface list view class implementation
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: ListViews.cpp,v 1.6 2004/01/26 16:52:31 zorglub Exp $ * $Id$
* *
* Authors: Stephan Aßmus <stippi@yellowbites.com> * Authors: Stephan Aßmus <stippi@yellowbites.com>
* *
...@@ -32,25 +32,24 @@ ...@@ -32,25 +32,24 @@
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/intf.h> #include <vlc/intf.h>
#include "VlcWrapper.h"
#include "InterfaceWindow.h" #include "InterfaceWindow.h"
#include "ListViews.h" #include "ListViews.h"
#include "MsgVals.h" #include "MsgVals.h"
#define MAX_DRAG_HEIGHT 200.0 #define MAX_DRAG_HEIGHT 200.0
#define ALPHA 170 #define ALPHA 170
#define TEXT_OFFSET 20.0 #define TEXT_OFFSET 20.0
/***************************************************************************** /*****************************************************************************
* PlaylistItem class * PlaylistItem class
*****************************************************************************/ *****************************************************************************/
PlaylistItem::PlaylistItem( const char *name ) PlaylistItem::PlaylistItem( const char *name )
: BStringItem( name ), : BStringItem( name ),
fName( "" ) fName( "" )
{ {
entry_ref ref; entry_ref ref;
if ( get_ref_for_path( name, &ref) == B_OK ) if ( get_ref_for_path( name, &ref) == B_OK )
fName.SetTo( ref.name ); fName.SetTo( ref.name );
} }
PlaylistItem::~PlaylistItem() PlaylistItem::~PlaylistItem()
...@@ -62,93 +61,93 @@ PlaylistItem::~PlaylistItem() ...@@ -62,93 +61,93 @@ PlaylistItem::~PlaylistItem()
*****************************************************************************/ *****************************************************************************/
void void
PlaylistItem::Draw( BView *owner, BRect frame, bool tintedLine, PlaylistItem::Draw( BView *owner, BRect frame, bool tintedLine,
uint32 mode, bool active, bool playing ) uint32 mode, bool active, bool playing )
{ {
rgb_color color = (rgb_color){ 255, 255, 255, 255 }; rgb_color color = (rgb_color){ 255, 255, 255, 255 };
if ( tintedLine ) if ( tintedLine )
color = tint_color( color, 1.04 ); color = tint_color( color, 1.04 );
// background // background
if ( IsSelected() ) if ( IsSelected() )
color = tint_color( color, B_DARKEN_2_TINT ); color = tint_color( color, B_DARKEN_2_TINT );
owner->SetLowColor( color ); owner->SetLowColor( color );
owner->FillRect( frame, B_SOLID_LOW ); owner->FillRect( frame, B_SOLID_LOW );
// label // label
owner->SetHighColor( 0, 0, 0, 255 ); owner->SetHighColor( 0, 0, 0, 255 );
font_height fh; font_height fh;
owner->GetFontHeight( &fh ); owner->GetFontHeight( &fh );
const char* text = Text(); const char* text = Text();
switch ( mode ) switch ( mode )
{ {
case DISPLAY_NAME: case DISPLAY_NAME:
if ( fName.CountChars() > 0 ) if ( fName.CountChars() > 0 )
text = fName.String(); text = fName.String();
break; break;
case DISPLAY_PATH: case DISPLAY_PATH:
default: default:
break; break;
} }
BString truncatedString( text ); BString truncatedString( text );
owner->TruncateString( &truncatedString, B_TRUNCATE_MIDDLE, owner->TruncateString( &truncatedString, B_TRUNCATE_MIDDLE,
frame.Width() - TEXT_OFFSET - 4.0 ); frame.Width() - TEXT_OFFSET - 4.0 );
owner->DrawString( truncatedString.String(), owner->DrawString( truncatedString.String(),
BPoint( frame.left + TEXT_OFFSET, BPoint( frame.left + TEXT_OFFSET,
frame.top + fh.ascent + 1.0 ) ); frame.top + fh.ascent + 1.0 ) );
// playmark // playmark
if ( active ) if ( active )
{ {
rgb_color black = (rgb_color){ 0, 0, 0, 255 }; rgb_color black = (rgb_color){ 0, 0, 0, 255 };
rgb_color green = (rgb_color){ 0, 255, 0, 255 }; rgb_color green = (rgb_color){ 0, 255, 0, 255 };
BRect r( 0.0, 0.0, 10.0, 10.0 ); BRect r( 0.0, 0.0, 10.0, 10.0 );
r.OffsetTo( frame.left + 4.0, r.OffsetTo( frame.left + 4.0,
ceilf( ( frame.top + frame.bottom ) / 2.0 ) - 5.0 ); ceilf( ( frame.top + frame.bottom ) / 2.0 ) - 5.0 );
if ( !playing ) if ( !playing )
green = tint_color( color, B_DARKEN_1_TINT ); green = tint_color( color, B_DARKEN_1_TINT );
rgb_color lightGreen = tint_color( green, B_LIGHTEN_2_TINT ); rgb_color lightGreen = tint_color( green, B_LIGHTEN_2_TINT );
rgb_color darkGreen = tint_color( green, B_DARKEN_2_TINT ); rgb_color darkGreen = tint_color( green, B_DARKEN_2_TINT );
BPoint arrow[3]; BPoint arrow[3];
arrow[0] = r.LeftTop(); arrow[0] = r.LeftTop();
arrow[1] = r.LeftBottom(); arrow[1] = r.LeftBottom();
arrow[2].x = r.right; arrow[2].x = r.right;
arrow[2].y = ( r.top + r.bottom ) / 2.0; arrow[2].y = ( r.top + r.bottom ) / 2.0;
owner->BeginLineArray( 6 ); owner->BeginLineArray( 6 );
// black outline // black outline
owner->AddLine( arrow[0], arrow[1], black ); owner->AddLine( arrow[0], arrow[1], black );
owner->AddLine( BPoint( arrow[1].x + 1.0, arrow[1].y - 1.0 ), owner->AddLine( BPoint( arrow[1].x + 1.0, arrow[1].y - 1.0 ),
arrow[2], black ); arrow[2], black );
owner->AddLine( arrow[0], arrow[2], black ); owner->AddLine( arrow[0], arrow[2], black );
// inset arrow // inset arrow
arrow[0].x += 1.0; arrow[0].x += 1.0;
arrow[0].y += 2.0; arrow[0].y += 2.0;
arrow[1].x += 1.0; arrow[1].x += 1.0;
arrow[1].y -= 2.0; arrow[1].y -= 2.0;
arrow[2].x -= 2.0; arrow[2].x -= 2.0;
// highlights and shadow // highlights and shadow
owner->AddLine( arrow[1], arrow[2], darkGreen ); owner->AddLine( arrow[1], arrow[2], darkGreen );
owner->AddLine( arrow[0], arrow[2], lightGreen ); owner->AddLine( arrow[0], arrow[2], lightGreen );
owner->AddLine( arrow[0], arrow[1], lightGreen ); owner->AddLine( arrow[0], arrow[1], lightGreen );
owner->EndLineArray(); owner->EndLineArray();
// fill green // fill green
arrow[0].x += 1.0; arrow[0].x += 1.0;
arrow[0].y += 1.0; arrow[0].y += 1.0;
arrow[1].x += 1.0; arrow[1].x += 1.0;
arrow[1].y -= 1.0; arrow[1].y -= 1.0;
arrow[2].x -= 2.0; arrow[2].x -= 2.0;
owner->SetHighColor( green ); owner->SetHighColor( green );
owner->FillPolygon( arrow, 3 ); owner->FillPolygon( arrow, 3 );
} }
} }
/***************************************************************************** /*****************************************************************************
* DragSortableListView class * DragSortableListView class
*****************************************************************************/ *****************************************************************************/
DragSortableListView::DragSortableListView( BRect frame, const char* name, DragSortableListView::DragSortableListView( BRect frame, const char* name,
list_view_type type, uint32 resizingMode, list_view_type type, uint32 resizingMode,
uint32 flags ) uint32 flags )
: BListView( frame, name, type, resizingMode, flags ), : BListView( frame, name, type, resizingMode, flags ),
fDropRect( 0.0, 0.0, -1.0, -1.0 ), fDropRect( 0.0, 0.0, -1.0, -1.0 ),
fDropIndex( -1 ) fDropIndex( -1 )
{ {
SetViewColor( B_TRANSPARENT_32_BIT ); SetViewColor( B_TRANSPARENT_32_BIT );
} }
DragSortableListView::~DragSortableListView() DragSortableListView::~DragSortableListView()
...@@ -161,37 +160,37 @@ DragSortableListView::~DragSortableListView() ...@@ -161,37 +160,37 @@ DragSortableListView::~DragSortableListView()
void void
DragSortableListView::Draw( BRect updateRect ) DragSortableListView::Draw( BRect updateRect )
{ {
int32 firstIndex = IndexOf( updateRect.LeftTop() ); int32 firstIndex = IndexOf( updateRect.LeftTop() );
int32 lastIndex = IndexOf( updateRect.RightBottom() ); int32 lastIndex = IndexOf( updateRect.RightBottom() );
if ( firstIndex >= 0 ) if ( firstIndex >= 0 )
{ {
if ( lastIndex < firstIndex ) if ( lastIndex < firstIndex )
lastIndex = CountItems() - 1; lastIndex = CountItems() - 1;
// update rect contains items // update rect contains items
BRect r( updateRect ); BRect r( updateRect );
for ( int32 i = firstIndex; i <= lastIndex; i++) for ( int32 i = firstIndex; i <= lastIndex; i++)
{ {
r = ItemFrame( i ); r = ItemFrame( i );
DrawListItem( this, i, r ); DrawListItem( this, i, r );
} }
updateRect.top = r.bottom + 1.0; updateRect.top = r.bottom + 1.0;
if ( updateRect.IsValid() ) if ( updateRect.IsValid() )
{ {
SetLowColor( 255, 255, 255, 255 ); SetLowColor( 255, 255, 255, 255 );
FillRect( updateRect, B_SOLID_LOW ); FillRect( updateRect, B_SOLID_LOW );
} }
} }
else else
{ {
SetLowColor( 255, 255, 255, 255 ); SetLowColor( 255, 255, 255, 255 );
FillRect( updateRect, B_SOLID_LOW ); FillRect( updateRect, B_SOLID_LOW );
} }
// drop anticipation indication // drop anticipation indication
if ( fDropRect.IsValid() ) if ( fDropRect.IsValid() )
{ {
SetHighColor( 255, 0, 0, 255 ); SetHighColor( 255, 0, 0, 255 );
StrokeRect( fDropRect ); StrokeRect( fDropRect );
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -200,91 +199,91 @@ DragSortableListView::Draw( BRect updateRect ) ...@@ -200,91 +199,91 @@ DragSortableListView::Draw( BRect updateRect )
bool bool
DragSortableListView::InitiateDrag( BPoint point, int32 index, bool ) DragSortableListView::InitiateDrag( BPoint point, int32 index, bool )
{ {
bool success = false; bool success = false;
BListItem* item = ItemAt( CurrentSelection( 0 ) ); BListItem* item = ItemAt( CurrentSelection( 0 ) );
if ( !item ) if ( !item )
{ {
// workarround a timing problem // workarround a timing problem
Select( index ); Select( index );
item = ItemAt( index ); item = ItemAt( index );
} }
if ( item ) if ( item )
{ {
// create drag message // create drag message
BMessage msg( B_SIMPLE_DATA ); BMessage msg( B_SIMPLE_DATA );
MakeDragMessage( &msg ); MakeDragMessage( &msg );
// figure out drag rect // figure out drag rect
float width = Bounds().Width(); float width = Bounds().Width();
BRect dragRect(0.0, 0.0, width, -1.0); BRect dragRect(0.0, 0.0, width, -1.0);
// figure out, how many items fit into our bitmap // figure out, how many items fit into our bitmap
int32 numItems; int32 numItems;
bool fade = false; bool fade = false;
for (numItems = 0; BListItem* item = ItemAt( CurrentSelection( numItems ) ); numItems++) { for (numItems = 0; BListItem* item = ItemAt( CurrentSelection( numItems ) ); numItems++) {
dragRect.bottom += ceilf( item->Height() ) + 1.0; dragRect.bottom += ceilf( item->Height() ) + 1.0;
if ( dragRect.Height() > MAX_DRAG_HEIGHT ) { if ( dragRect.Height() > MAX_DRAG_HEIGHT ) {
fade = true; fade = true;
dragRect.bottom = MAX_DRAG_HEIGHT; dragRect.bottom = MAX_DRAG_HEIGHT;
numItems++; numItems++;
break; break;
} }
} }
BBitmap* dragBitmap = new BBitmap( dragRect, B_RGB32, true ); BBitmap* dragBitmap = new BBitmap( dragRect, B_RGB32, true );
if ( dragBitmap && dragBitmap->IsValid() ) { if ( dragBitmap && dragBitmap->IsValid() ) {
if ( BView *v = new BView( dragBitmap->Bounds(), "helper", B_FOLLOW_NONE, B_WILL_DRAW ) ) { if ( BView *v = new BView( dragBitmap->Bounds(), "helper", B_FOLLOW_NONE, B_WILL_DRAW ) ) {
dragBitmap->AddChild( v ); dragBitmap->AddChild( v );
dragBitmap->Lock(); dragBitmap->Lock();
BRect itemBounds( dragRect) ; BRect itemBounds( dragRect) ;
itemBounds.bottom = 0.0; itemBounds.bottom = 0.0;
// let all selected items, that fit into our drag_bitmap, draw // let all selected items, that fit into our drag_bitmap, draw
for ( int32 i = 0; i < numItems; i++ ) { for ( int32 i = 0; i < numItems; i++ ) {
int32 index = CurrentSelection( i ); int32 index = CurrentSelection( i );
BListItem* item = ItemAt( index ); BListItem* item = ItemAt( index );
itemBounds.bottom = itemBounds.top + ceilf( item->Height() ); itemBounds.bottom = itemBounds.top + ceilf( item->Height() );
if ( itemBounds.bottom > dragRect.bottom ) if ( itemBounds.bottom > dragRect.bottom )
itemBounds.bottom = dragRect.bottom; itemBounds.bottom = dragRect.bottom;
DrawListItem( v, index, itemBounds ); DrawListItem( v, index, itemBounds );
itemBounds.top = itemBounds.bottom + 1.0; itemBounds.top = itemBounds.bottom + 1.0;
} }
// make a black frame arround the edge // make a black frame arround the edge
v->SetHighColor( 0, 0, 0, 255 ); v->SetHighColor( 0, 0, 0, 255 );
v->StrokeRect( v->Bounds() ); v->StrokeRect( v->Bounds() );
v->Sync(); v->Sync();
uint8 *bits = (uint8 *)dragBitmap->Bits(); uint8 *bits = (uint8 *)dragBitmap->Bits();
int32 height = (int32)dragBitmap->Bounds().Height() + 1; int32 height = (int32)dragBitmap->Bounds().Height() + 1;
int32 width = (int32)dragBitmap->Bounds().Width() + 1; int32 width = (int32)dragBitmap->Bounds().Width() + 1;
int32 bpr = dragBitmap->BytesPerRow(); int32 bpr = dragBitmap->BytesPerRow();
if (fade) { if (fade) {
for ( int32 y = 0; y < height - ALPHA / 2; y++, bits += bpr ) { for ( int32 y = 0; y < height - ALPHA / 2; y++, bits += bpr ) {
uint8 *line = bits + 3; uint8 *line = bits + 3;
for (uint8 *end = line + 4 * width; line < end; line += 4) for (uint8 *end = line + 4 * width; line < end; line += 4)
*line = ALPHA; *line = ALPHA;
} }
for ( int32 y = height - ALPHA / 2; y < height; y++, bits += bpr ) { for ( int32 y = height - ALPHA / 2; y < height; y++, bits += bpr ) {
uint8 *line = bits + 3; uint8 *line = bits + 3;
for (uint8 *end = line + 4 * width; line < end; line += 4) for (uint8 *end = line + 4 * width; line < end; line += 4)
*line = (height - y) << 1; *line = (height - y) << 1;
} }
} else { } else {
for ( int32 y = 0; y < height; y++, bits += bpr ) { for ( int32 y = 0; y < height; y++, bits += bpr ) {
uint8 *line = bits + 3; uint8 *line = bits + 3;
for (uint8 *end = line + 4 * width; line < end; line += 4) for (uint8 *end = line + 4 * width; line < end; line += 4)
*line = ALPHA; *line = ALPHA;
} }
} }
dragBitmap->Unlock(); dragBitmap->Unlock();
success = true; success = true;
} }
} }
if (success) if (success)
DragMessage( &msg, dragBitmap, B_OP_ALPHA, BPoint( 0.0, 0.0 ) ); DragMessage( &msg, dragBitmap, B_OP_ALPHA, BPoint( 0.0, 0.0 ) );
else { else {
delete dragBitmap; delete dragBitmap;
DragMessage( &msg, dragRect.OffsetToCopy( point ), this ); DragMessage( &msg, dragRect.OffsetToCopy( point ), this );
} }
} }
return success; return success;
} }
/***************************************************************************** /*****************************************************************************
...@@ -293,9 +292,9 @@ DragSortableListView::InitiateDrag( BPoint point, int32 index, bool ) ...@@ -293,9 +292,9 @@ DragSortableListView::InitiateDrag( BPoint point, int32 index, bool )
void void
DragSortableListView::WindowActivated( bool active ) DragSortableListView::WindowActivated( bool active )
{ {
// workarround for buggy focus indication of BScrollView // workarround for buggy focus indication of BScrollView
if ( BView* view = Parent() ) if ( BView* view = Parent() )
view->Invalidate(); view->Invalidate();
} }
/***************************************************************************** /*****************************************************************************
...@@ -304,40 +303,40 @@ DragSortableListView::WindowActivated( bool active ) ...@@ -304,40 +303,40 @@ DragSortableListView::WindowActivated( bool active )
void void
DragSortableListView::MessageReceived(BMessage* message) DragSortableListView::MessageReceived(BMessage* message)
{ {
switch ( message->what ) switch ( message->what )
{ {
case B_MODIFIERS_CHANGED: case B_MODIFIERS_CHANGED:
ModifiersChanged(); ModifiersChanged();
break; break;
case B_SIMPLE_DATA: case B_SIMPLE_DATA:
{ {
DragSortableListView *list = NULL; DragSortableListView *list = NULL;
if ( message->FindPointer( "list", (void **)&list ) == B_OK if ( message->FindPointer( "list", (void **)&list ) == B_OK
&& list == this ) && list == this )
{ {
int32 count = CountItems(); int32 count = CountItems();
if ( fDropIndex < 0 || fDropIndex > count ) if ( fDropIndex < 0 || fDropIndex > count )
fDropIndex = count; fDropIndex = count;
BList items; BList items;
int32 index; int32 index;
for ( int32 i = 0; message->FindInt32( "index", i, &index ) == B_OK; i++ ) for ( int32 i = 0; message->FindInt32( "index", i, &index ) == B_OK; i++ )
if ( BListItem* item = ItemAt(index) ) if ( BListItem* item = ItemAt(index) )
items.AddItem( (void*)item ); items.AddItem( (void*)item );
if ( items.CountItems() > 0 ) if ( items.CountItems() > 0 )
{ {
if ( modifiers() & B_SHIFT_KEY ) if ( modifiers() & B_SHIFT_KEY )
CopyItems( items, fDropIndex ); CopyItems( items, fDropIndex );
else else
MoveItems( items, fDropIndex ); MoveItems( items, fDropIndex );
} }
fDropIndex = -1; fDropIndex = -1;
} }
break; break;
} }
default: default:
BListView::MessageReceived( message ); BListView::MessageReceived( message );
break; break;
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -346,51 +345,51 @@ DragSortableListView::MessageReceived(BMessage* message) ...@@ -346,51 +345,51 @@ DragSortableListView::MessageReceived(BMessage* message)
void void
DragSortableListView::MouseMoved(BPoint where, uint32 transit, const BMessage *msg) DragSortableListView::MouseMoved(BPoint where, uint32 transit, const BMessage *msg)
{ {
if ( msg && ( msg->what == B_SIMPLE_DATA || msg->what == MSG_SOUNDPLAY ) ) if ( msg && ( msg->what == B_SIMPLE_DATA || msg->what == MSG_SOUNDPLAY ) )
{ {
bool replaceAll = !msg->HasPointer("list") && !(modifiers() & B_SHIFT_KEY); bool replaceAll = !msg->HasPointer("list") && !(modifiers() & B_SHIFT_KEY);
switch ( transit ) switch ( transit )
{ {
case B_ENTERED_VIEW: case B_ENTERED_VIEW:
// remember drag message // remember drag message
// this is needed to react on modifier changes // this is needed to react on modifier changes
fDragMessageCopy = *msg; fDragMessageCopy = *msg;
case B_INSIDE_VIEW: case B_INSIDE_VIEW:
{ {
if ( replaceAll ) if ( replaceAll )
{ {
BRect r( Bounds() ); BRect r( Bounds() );
r.bottom--; // compensate for scrollbar offset r.bottom--; // compensate for scrollbar offset
_SetDropAnticipationRect( r ); _SetDropAnticipationRect( r );
fDropIndex = -1; fDropIndex = -1;
} }
else else
{ {
// offset where by half of item height // offset where by half of item height
BRect r( ItemFrame( 0 ) ); BRect r( ItemFrame( 0 ) );
where.y += r.Height() / 2.0; where.y += r.Height() / 2.0;
int32 index = IndexOf( where ); int32 index = IndexOf( where );
if ( index < 0 ) if ( index < 0 )
index = CountItems(); index = CountItems();
_SetDropIndex( index ); _SetDropIndex( index );
} }
break; break;
} }
case B_EXITED_VIEW: case B_EXITED_VIEW:
// forget drag message // forget drag message
fDragMessageCopy.what = 0; fDragMessageCopy.what = 0;
case B_OUTSIDE_VIEW: case B_OUTSIDE_VIEW:
_RemoveDropAnticipationRect(); _RemoveDropAnticipationRect();
break; break;
} }
} }
else else
{ {
_RemoveDropAnticipationRect(); _RemoveDropAnticipationRect();
BListView::MouseMoved(where, transit, msg); BListView::MouseMoved(where, transit, msg);
fDragMessageCopy.what = 0; fDragMessageCopy.what = 0;
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -399,11 +398,11 @@ DragSortableListView::MouseMoved(BPoint where, uint32 transit, const BMessage *m ...@@ -399,11 +398,11 @@ DragSortableListView::MouseMoved(BPoint where, uint32 transit, const BMessage *m
void void
DragSortableListView::MouseUp( BPoint where ) DragSortableListView::MouseUp( BPoint where )
{ {
// remove drop mark // remove drop mark
_SetDropAnticipationRect( BRect( 0.0, 0.0, -1.0, -1.0 ) ); _SetDropAnticipationRect( BRect( 0.0, 0.0, -1.0, -1.0 ) );
// be sure to forget drag message // be sure to forget drag message
fDragMessageCopy.what = 0; fDragMessageCopy.what = 0;
BListView::MouseUp( where ); BListView::MouseUp( where );
} }
/***************************************************************************** /*****************************************************************************
...@@ -412,7 +411,7 @@ DragSortableListView::MouseUp( BPoint where ) ...@@ -412,7 +411,7 @@ DragSortableListView::MouseUp( BPoint where )
void void
DragSortableListView::DrawItem( BListItem *item, BRect itemFrame, bool complete ) DragSortableListView::DrawItem( BListItem *item, BRect itemFrame, bool complete )
{ {
DrawListItem( this, IndexOf( item ), itemFrame ); DrawListItem( this, IndexOf( item ), itemFrame );
} }
/***************************************************************************** /*****************************************************************************
...@@ -421,11 +420,11 @@ DragSortableListView::DrawItem( BListItem *item, BRect itemFrame, bool complete ...@@ -421,11 +420,11 @@ DragSortableListView::DrawItem( BListItem *item, BRect itemFrame, bool complete
void void
DragSortableListView::ModifiersChanged() DragSortableListView::ModifiersChanged()
{ {
BPoint where; BPoint where;
uint32 buttons; uint32 buttons;
GetMouse( &where, &buttons, false ); GetMouse( &where, &buttons, false );
uint32 transit = Bounds().Contains( where ) ? B_INSIDE_VIEW : B_OUTSIDE_VIEW; uint32 transit = Bounds().Contains( where ) ? B_INSIDE_VIEW : B_OUTSIDE_VIEW;
MouseMoved( where, transit, &fDragMessageCopy ); MouseMoved( where, transit, &fDragMessageCopy );
} }
/***************************************************************************** /*****************************************************************************
...@@ -434,35 +433,35 @@ DragSortableListView::ModifiersChanged() ...@@ -434,35 +433,35 @@ DragSortableListView::ModifiersChanged()
void void
DragSortableListView::MoveItems( BList& items, int32 index ) DragSortableListView::MoveItems( BList& items, int32 index )
{ {
DeselectAll(); DeselectAll();
// we remove the items while we look at them, the insertion index is decreased // we remove the items while we look at them, the insertion index is decreased
// when the items index is lower, so that we insert at the right spot after // when the items index is lower, so that we insert at the right spot after
// removal // removal
BList removedItems; BList removedItems;
int32 count = items.CountItems(); int32 count = items.CountItems();
for ( int32 i = 0; i < count; i++ ) for ( int32 i = 0; i < count; i++ )
{ {
BListItem* item = (BListItem*)items.ItemAt( i ); BListItem* item = (BListItem*)items.ItemAt( i );
int32 removeIndex = IndexOf( item ); int32 removeIndex = IndexOf( item );
if ( RemoveItem( item ) && removedItems.AddItem( (void*)item ) ) if ( RemoveItem( item ) && removedItems.AddItem( (void*)item ) )
{ {
if ( removeIndex < index ) if ( removeIndex < index )
index--; index--;
} }
// else ??? -> blow up // else ??? -> blow up
} }
for ( int32 i = 0; BListItem* item = (BListItem*)removedItems.ItemAt( i ); i++ ) for ( int32 i = 0; BListItem* item = (BListItem*)removedItems.ItemAt( i ); i++ )
{ {
if ( AddItem( item, index ) ) if ( AddItem( item, index ) )
{ {
// after we're done, the newly inserted items will be selected // after we're done, the newly inserted items will be selected
Select( index, true ); Select( index, true );
// next items will be inserted after this one // next items will be inserted after this one
index++; index++;
} }
else else
delete item; delete item;
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -471,31 +470,31 @@ DragSortableListView::MoveItems( BList& items, int32 index ) ...@@ -471,31 +470,31 @@ DragSortableListView::MoveItems( BList& items, int32 index )
void void
DragSortableListView::CopyItems( BList& items, int32 index ) DragSortableListView::CopyItems( BList& items, int32 index )
{ {
DeselectAll(); DeselectAll();
// by inserting the items after we copied all items first, we avoid // by inserting the items after we copied all items first, we avoid
// cloning an item we already inserted and messing everything up // cloning an item we already inserted and messing everything up
// in other words, don't touch the list before we know which items // in other words, don't touch the list before we know which items
// need to be cloned // need to be cloned
BList clonedItems; BList clonedItems;
int32 count = items.CountItems(); int32 count = items.CountItems();
for ( int32 i = 0; i < count; i++ ) for ( int32 i = 0; i < count; i++ )
{ {
BListItem* item = CloneItem( IndexOf( (BListItem*)items.ItemAt( i ) ) ); BListItem* item = CloneItem( IndexOf( (BListItem*)items.ItemAt( i ) ) );
if ( item && !clonedItems.AddItem( (void*)item ) ) if ( item && !clonedItems.AddItem( (void*)item ) )
delete item; delete item;
} }
for ( int32 i = 0; BListItem* item = (BListItem*)clonedItems.ItemAt( i ); i++ ) for ( int32 i = 0; BListItem* item = (BListItem*)clonedItems.ItemAt( i ); i++ )
{ {
if ( AddItem( item, index ) ) if ( AddItem( item, index ) )
{ {
// after we're done, the newly inserted items will be selected // after we're done, the newly inserted items will be selected
Select( index, true ); Select( index, true );
// next items will be inserted after this one // next items will be inserted after this one
index++; index++;
} }
else else
delete item; delete item;
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -504,13 +503,13 @@ DragSortableListView::CopyItems( BList& items, int32 index ) ...@@ -504,13 +503,13 @@ DragSortableListView::CopyItems( BList& items, int32 index )
void void
DragSortableListView::RemoveItemList( BList& items ) DragSortableListView::RemoveItemList( BList& items )
{ {
int32 count = items.CountItems(); int32 count = items.CountItems();
for ( int32 i = 0; i < count; i++ ) for ( int32 i = 0; i < count; i++ )
{ {
BListItem* item = (BListItem*)items.ItemAt( i ); BListItem* item = (BListItem*)items.ItemAt( i );
if ( RemoveItem( item ) ) if ( RemoveItem( item ) )
delete item; delete item;
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -519,10 +518,10 @@ DragSortableListView::RemoveItemList( BList& items ) ...@@ -519,10 +518,10 @@ DragSortableListView::RemoveItemList( BList& items )
void void
DragSortableListView::RemoveSelected() DragSortableListView::RemoveSelected()
{ {
BList items; BList items;
for ( int32 i = 0; BListItem* item = ItemAt( CurrentSelection( i ) ); i++ ) for ( int32 i = 0; BListItem* item = ItemAt( CurrentSelection( i ) ); i++ )
items.AddItem( (void*)item ); items.AddItem( (void*)item );
RemoveItemList( items ); RemoveItemList( items );
} }
/***************************************************************************** /*****************************************************************************
...@@ -531,10 +530,10 @@ DragSortableListView::RemoveSelected() ...@@ -531,10 +530,10 @@ DragSortableListView::RemoveSelected()
int32 int32
DragSortableListView::CountSelectedItems() const DragSortableListView::CountSelectedItems() const
{ {
int32 count = 0; int32 count = 0;
while ( CurrentSelection( count ) >= 0 ) while ( CurrentSelection( count ) >= 0 )
count++; count++;
return count; return count;
} }
/***************************************************************************** /*****************************************************************************
...@@ -543,14 +542,14 @@ DragSortableListView::CountSelectedItems() const ...@@ -543,14 +542,14 @@ DragSortableListView::CountSelectedItems() const
void void
DragSortableListView::_SetDropAnticipationRect( BRect r ) DragSortableListView::_SetDropAnticipationRect( BRect r )
{ {
if ( fDropRect != r ) if ( fDropRect != r )
{ {
if ( fDropRect.IsValid() ) if ( fDropRect.IsValid() )
Invalidate( fDropRect ); Invalidate( fDropRect );
fDropRect = r; fDropRect = r;
if ( fDropRect.IsValid() ) if ( fDropRect.IsValid() )
Invalidate( fDropRect ); Invalidate( fDropRect );
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -559,38 +558,38 @@ DragSortableListView::_SetDropAnticipationRect( BRect r ) ...@@ -559,38 +558,38 @@ DragSortableListView::_SetDropAnticipationRect( BRect r )
void void
DragSortableListView::_SetDropIndex( int32 index ) DragSortableListView::_SetDropIndex( int32 index )
{ {
if ( fDropIndex != index ) if ( fDropIndex != index )
{ {
fDropIndex = index; fDropIndex = index;
if ( fDropIndex == -1 ) if ( fDropIndex == -1 )
_SetDropAnticipationRect( BRect( 0.0, 0.0, -1.0, -1.0 ) ); _SetDropAnticipationRect( BRect( 0.0, 0.0, -1.0, -1.0 ) );
else else
{ {
int32 count = CountItems(); int32 count = CountItems();
if ( fDropIndex == count ) if ( fDropIndex == count )
{ {
BRect r; BRect r;
if ( BListItem* item = ItemAt( count - 1 ) ) if ( BListItem* item = ItemAt( count - 1 ) )
{ {
r = ItemFrame( count - 1 ); r = ItemFrame( count - 1 );
r.top = r.bottom + 1.0; r.top = r.bottom + 1.0;
r.bottom = r.top + 1.0; r.bottom = r.top + 1.0;
} }
else else
{ {
r = Bounds(); r = Bounds();
r.bottom--; // compensate for scrollbars moved slightly out of window r.bottom--; // compensate for scrollbars moved slightly out of window
} }
_SetDropAnticipationRect( r ); _SetDropAnticipationRect( r );
} }
else else
{ {
BRect r = ItemFrame( fDropIndex ); BRect r = ItemFrame( fDropIndex );
r.bottom = r.top + 1.0; r.bottom = r.top + 1.0;
_SetDropAnticipationRect( r ); _SetDropAnticipationRect( r );
} }
} }
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -599,34 +598,34 @@ DragSortableListView::_SetDropIndex( int32 index ) ...@@ -599,34 +598,34 @@ DragSortableListView::_SetDropIndex( int32 index )
void void
DragSortableListView::_RemoveDropAnticipationRect() DragSortableListView::_RemoveDropAnticipationRect()
{ {
_SetDropAnticipationRect( BRect( 0.0, 0.0, -1.0, -1.0 ) ); _SetDropAnticipationRect( BRect( 0.0, 0.0, -1.0, -1.0 ) );
_SetDropIndex( -1 ); _SetDropIndex( -1 );
} }
/***************************************************************************** /*****************************************************************************
* PlaylistView class * PlaylistView class
*****************************************************************************/ *****************************************************************************/
PlaylistView::PlaylistView( BRect frame, InterfaceWindow* mainWindow, PlaylistView::PlaylistView( intf_thread_t * _p_intf,
VlcWrapper* wrapper, BRect frame, InterfaceWindow* mainWindow,
BMessage* selectionChangeMessage ) BMessage* selectionChangeMessage )
: DragSortableListView( frame, "playlist listview", : DragSortableListView( frame, "playlist listview",
B_MULTIPLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES, B_MULTIPLE_SELECTION_LIST, B_FOLLOW_ALL_SIDES,
B_WILL_DRAW | B_NAVIGABLE | B_PULSE_NEEDED B_WILL_DRAW | B_NAVIGABLE | B_PULSE_NEEDED
| B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE ), | B_FRAME_EVENTS | B_FULL_UPDATE_ON_RESIZE ),
fCurrentIndex( -1 ), p_intf( _p_intf ),
fPlaying( false ), fCurrentIndex( -1 ),
fDisplayMode( DISPLAY_PATH ), fPlaying( false ),
fMainWindow( mainWindow ), fDisplayMode( DISPLAY_PATH ),
fSelectionChangeMessage( selectionChangeMessage ), fMainWindow( mainWindow ),
fLastClickedItem( NULL ), fSelectionChangeMessage( selectionChangeMessage ),
fVlcWrapper( wrapper ) fLastClickedItem( NULL )
{ {
} }
PlaylistView::~PlaylistView() PlaylistView::~PlaylistView()
{ {
delete fSelectionChangeMessage; delete fSelectionChangeMessage;
} }
/***************************************************************************** /*****************************************************************************
...@@ -635,8 +634,8 @@ PlaylistView::~PlaylistView() ...@@ -635,8 +634,8 @@ PlaylistView::~PlaylistView()
void void
PlaylistView::AttachedToWindow() PlaylistView::AttachedToWindow()
{ {
// get pulse message every two frames // get pulse message every two frames
Window()->SetPulseRate( 80000 ); Window()->SetPulseRate( 80000 );
} }
/***************************************************************************** /*****************************************************************************
...@@ -645,26 +644,26 @@ PlaylistView::AttachedToWindow() ...@@ -645,26 +644,26 @@ PlaylistView::AttachedToWindow()
void void
PlaylistView::MessageReceived( BMessage* message) PlaylistView::MessageReceived( BMessage* message)
{ {
switch ( message->what ) switch ( message->what )
{ {
case MSG_SOUNDPLAY: case MSG_SOUNDPLAY:
case B_SIMPLE_DATA: case B_SIMPLE_DATA:
if ( message->HasPointer( "list" ) ) if ( message->HasPointer( "list" ) )
{ {
// message comes from ourself // message comes from ourself
DragSortableListView::MessageReceived( message ); DragSortableListView::MessageReceived( message );
} }
else else
{ {
// message comes from another app (for example Tracker) // message comes from another app (for example Tracker)
message->AddInt32( "drop index", fDropIndex ); message->AddInt32( "drop index", fDropIndex );
fMainWindow->PostMessage( message, fMainWindow ); fMainWindow->PostMessage( message, fMainWindow );
} }
break; break;
default: default:
DragSortableListView::MessageReceived( message ); DragSortableListView::MessageReceived( message );
break; break;
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -673,43 +672,50 @@ PlaylistView::MessageReceived( BMessage* message) ...@@ -673,43 +672,50 @@ PlaylistView::MessageReceived( BMessage* message)
void void
PlaylistView::MouseDown( BPoint where ) PlaylistView::MouseDown( BPoint where )
{ {
int32 clicks = 1; int32 clicks = 1;
Window()->CurrentMessage()->FindInt32( "clicks", &clicks ); Window()->CurrentMessage()->FindInt32( "clicks", &clicks );
bool handled = false; bool handled = false;
for ( int32 i = 0; PlaylistItem* item = (PlaylistItem*)ItemAt( i ); i++ ) for ( int32 i = 0; PlaylistItem* item = (PlaylistItem*)ItemAt( i ); i++ )
{ {
BRect r = ItemFrame( i ); BRect r = ItemFrame( i );
if ( r.Contains( where ) ) if ( r.Contains( where ) )
{ {
if ( clicks == 2 ) if ( clicks == 2 )
{ {
// only do something if user clicked the same item twice // only do something if user clicked the same item twice
if ( fLastClickedItem == item ) if ( fLastClickedItem == item )
{ {
fVlcWrapper->PlaylistJumpTo( i ); playlist_t * p_playlist;
handled = true; p_playlist = (playlist_t *) vlc_object_find( p_intf,
} VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
} if( p_playlist )
else {
{ playlist_Goto( p_playlist, i );
// remember last clicked item vlc_object_release( p_playlist );
fLastClickedItem = item; }
if ( i == fCurrentIndex ) handled = true;
{ }
r.right = r.left + TEXT_OFFSET; }
if ( r.Contains ( where ) ) else
{ {
fMainWindow->PostMessage( PAUSE_PLAYBACK ); // remember last clicked item
InvalidateItem( i ); fLastClickedItem = item;
handled = true; if ( i == fCurrentIndex )
} {
} r.right = r.left + TEXT_OFFSET;
} if ( r.Contains ( where ) )
break; {
} fMainWindow->PostMessage( PAUSE_PLAYBACK );
} InvalidateItem( i );
if ( !handled ) handled = true;
DragSortableListView::MouseDown(where); }
}
}
break;
}
}
if ( !handled )
DragSortableListView::MouseDown(where);
} }
/***************************************************************************** /*****************************************************************************
...@@ -718,14 +724,14 @@ PlaylistView::MouseDown( BPoint where ) ...@@ -718,14 +724,14 @@ PlaylistView::MouseDown( BPoint where )
void void
PlaylistView::KeyDown( const char* bytes, int32 numBytes ) PlaylistView::KeyDown( const char* bytes, int32 numBytes )
{ {
if ( numBytes < 1 ) if ( numBytes < 1 )
return; return;
if ( ( bytes[0] == B_BACKSPACE ) || ( bytes[0] == B_DELETE ) ) if ( ( bytes[0] == B_BACKSPACE ) || ( bytes[0] == B_DELETE ) )
{ {
RemoveSelected(); RemoveSelected();
} }
DragSortableListView::KeyDown( bytes, numBytes ); DragSortableListView::KeyDown( bytes, numBytes );
} }
/***************************************************************************** /*****************************************************************************
...@@ -734,8 +740,8 @@ PlaylistView::KeyDown( const char* bytes, int32 numBytes ) ...@@ -734,8 +740,8 @@ PlaylistView::KeyDown( const char* bytes, int32 numBytes )
void void
PlaylistView::Pulse() PlaylistView::Pulse()
{ {
if ( fMainWindow->IsStopped() ) if ( fMainWindow->IsStopped() )
SetPlaying( false ); SetPlaying( false );
} }
/***************************************************************************** /*****************************************************************************
...@@ -744,12 +750,12 @@ PlaylistView::Pulse() ...@@ -744,12 +750,12 @@ PlaylistView::Pulse()
void void
PlaylistView::SelectionChanged() PlaylistView::SelectionChanged()
{ {
BLooper* looper = Looper(); BLooper* looper = Looper();
if ( fSelectionChangeMessage && looper ) if ( fSelectionChangeMessage && looper )
{ {
BMessage message( *fSelectionChangeMessage ); BMessage message( *fSelectionChangeMessage );
looper->PostMessage( &message ); looper->PostMessage( &message );
} }
} }
...@@ -759,55 +765,57 @@ PlaylistView::SelectionChanged() ...@@ -759,55 +765,57 @@ PlaylistView::SelectionChanged()
void void
PlaylistView::MoveItems( BList& items, int32 index ) PlaylistView::MoveItems( BList& items, int32 index )
{ {
DeselectAll(); #if 0
// we remove the items while we look at them, the insertion index is decreased DeselectAll();
// when the items index is lower, so that we insert at the right spot after // we remove the items while we look at them, the insertion index is decreased
// removal // when the items index is lower, so that we insert at the right spot after
if ( fVlcWrapper->PlaylistLock() ) // removal
{ if ( fVlcWrapper->PlaylistLock() )
BList removedItems; {
BList removeItems; BList removedItems;
int32 count = items.CountItems(); BList removeItems;
int32 indexOriginal = index; int32 count = items.CountItems();
// remember currently playing item int32 indexOriginal = index;
BListItem* playingItem = _PlayingItem(); // remember currently playing item
// collect item pointers for removal by index BListItem* playingItem = _PlayingItem();
for ( int32 i = 0; i < count; i++ ) // collect item pointers for removal by index
{ for ( int32 i = 0; i < count; i++ )
int32 removeIndex = IndexOf( (BListItem*)items.ItemAt( i ) ); {
void* item = fVlcWrapper->PlaylistItemAt( removeIndex ); int32 removeIndex = IndexOf( (BListItem*)items.ItemAt( i ) );
if ( item && removeItems.AddItem( item ) ) void* item = fVlcWrapper->PlaylistItemAt( removeIndex );
{ if ( item && removeItems.AddItem( item ) )
if ( removeIndex < index ) {
index--; if ( removeIndex < index )
} index--;
// else ??? -> blow up }
} // else ??? -> blow up
// actually remove items using pointers }
for ( int32 i = 0; i < count; i++ ) // actually remove items using pointers
{ for ( int32 i = 0; i < count; i++ )
void* item = fVlcWrapper->PlaylistRemoveItem( removeItems.ItemAt( i ) ); {
if ( item && !removedItems.AddItem( item ) ) void* item = fVlcWrapper->PlaylistRemoveItem( removeItems.ItemAt( i ) );
free( item ); if ( item && !removedItems.AddItem( item ) )
} free( item );
// add items at index }
for ( int32 i = 0; void* item = removedItems.ItemAt( i ); i++ ) // add items at index
{ for ( int32 i = 0; void* item = removedItems.ItemAt( i ); i++ )
if ( fVlcWrapper->PlaylistAddItem( item, index ) ) {
// next items will be inserted after this one if ( fVlcWrapper->PlaylistAddItem( item, index ) )
index++; // next items will be inserted after this one
else index++;
free( item ); else
} free( item );
// update GUI }
DragSortableListView::MoveItems( items, indexOriginal ); // update GUI
// restore currently playing item DragSortableListView::MoveItems( items, indexOriginal );
_SetPlayingIndex( playingItem ); // restore currently playing item
// update interface (in case it isn't playing, _SetPlayingIndex( playingItem );
// there is a chance that it needs to update) // update interface (in case it isn't playing,
fMainWindow->PostMessage( MSG_UPDATE ); // there is a chance that it needs to update)
fVlcWrapper->PlaylistUnlock(); fMainWindow->PostMessage( MSG_UPDATE );
} fVlcWrapper->PlaylistUnlock();
}
#endif
} }
/***************************************************************************** /*****************************************************************************
...@@ -816,45 +824,47 @@ PlaylistView::MoveItems( BList& items, int32 index ) ...@@ -816,45 +824,47 @@ PlaylistView::MoveItems( BList& items, int32 index )
void void
PlaylistView::CopyItems( BList& items, int32 toIndex ) PlaylistView::CopyItems( BList& items, int32 toIndex )
{ {
DeselectAll(); #if 0
// we remove the items while we look at them, the insertion index is decreased DeselectAll();
// when the items index is lower, so that we insert at the right spot after // we remove the items while we look at them, the insertion index is decreased
// removal // when the items index is lower, so that we insert at the right spot after
if ( fVlcWrapper->PlaylistLock() ) // removal
{ if ( fVlcWrapper->PlaylistLock() )
BList clonedItems; {
int32 count = items.CountItems(); BList clonedItems;
// remember currently playing item int32 count = items.CountItems();
BListItem* playingItem = _PlayingItem(); // remember currently playing item
// collect cloned item pointers BListItem* playingItem = _PlayingItem();
for ( int32 i = 0; i < count; i++ ) // collect cloned item pointers
{ for ( int32 i = 0; i < count; i++ )
int32 index = IndexOf( (BListItem*)items.ItemAt( i ) ); {
void* item = fVlcWrapper->PlaylistItemAt( index ); int32 index = IndexOf( (BListItem*)items.ItemAt( i ) );
void* cloned = fVlcWrapper->PlaylistCloneItem( item ); void* item = fVlcWrapper->PlaylistItemAt( index );
if ( cloned && !clonedItems.AddItem( cloned ) ) void* cloned = fVlcWrapper->PlaylistCloneItem( item );
free( cloned ); if ( cloned && !clonedItems.AddItem( cloned ) )
free( cloned );
}
// add cloned items at index }
int32 index = toIndex; // add cloned items at index
for ( int32 i = 0; void* item = clonedItems.ItemAt( i ); i++ ) int32 index = toIndex;
{ for ( int32 i = 0; void* item = clonedItems.ItemAt( i ); i++ )
if ( fVlcWrapper->PlaylistAddItem( item, index ) ) {
// next items will be inserted after this one if ( fVlcWrapper->PlaylistAddItem( item, index ) )
index++; // next items will be inserted after this one
else index++;
free( item ); else
} free( item );
// update GUI }
DragSortableListView::CopyItems( items, toIndex ); // update GUI
// restore currently playing item DragSortableListView::CopyItems( items, toIndex );
_SetPlayingIndex( playingItem ); // restore currently playing item
// update interface (in case it isn't playing, _SetPlayingIndex( playingItem );
// there is a chance that it needs to update) // update interface (in case it isn't playing,
fMainWindow->PostMessage( MSG_UPDATE ); // there is a chance that it needs to update)
fVlcWrapper->PlaylistUnlock(); fMainWindow->PostMessage( MSG_UPDATE );
} fVlcWrapper->PlaylistUnlock();
}
#endif
} }
/***************************************************************************** /*****************************************************************************
...@@ -863,35 +873,37 @@ PlaylistView::CopyItems( BList& items, int32 toIndex ) ...@@ -863,35 +873,37 @@ PlaylistView::CopyItems( BList& items, int32 toIndex )
void void
PlaylistView::RemoveItemList( BList& items ) PlaylistView::RemoveItemList( BList& items )
{ {
if ( fVlcWrapper->PlaylistLock() ) #if 0
{ if ( fVlcWrapper->PlaylistLock() )
// remember currently playing item {
BListItem* playingItem = _PlayingItem(); // remember currently playing item
// collect item pointers for removal BListItem* playingItem = _PlayingItem();
BList removeItems; // collect item pointers for removal
int32 count = items.CountItems(); BList removeItems;
for ( int32 i = 0; i < count; i++ ) int32 count = items.CountItems();
{ for ( int32 i = 0; i < count; i++ )
int32 index = IndexOf( (BListItem*)items.ItemAt( i ) ); {
void* item = fVlcWrapper->PlaylistItemAt( index ); int32 index = IndexOf( (BListItem*)items.ItemAt( i ) );
if ( item && !removeItems.AddItem( item ) ) void* item = fVlcWrapper->PlaylistItemAt( index );
free( item ); if ( item && !removeItems.AddItem( item ) )
} free( item );
// remove items from playlist }
count = removeItems.CountItems(); // remove items from playlist
for ( int32 i = 0; void* item = removeItems.ItemAt( i ); i++ ) count = removeItems.CountItems();
{ for ( int32 i = 0; void* item = removeItems.ItemAt( i ); i++ )
fVlcWrapper->PlaylistRemoveItem( item ); {
} fVlcWrapper->PlaylistRemoveItem( item );
// update GUI }
DragSortableListView::RemoveItemList( items ); // update GUI
// restore currently playing item DragSortableListView::RemoveItemList( items );
_SetPlayingIndex( playingItem ); // restore currently playing item
// update interface (in case it isn't playing, _SetPlayingIndex( playingItem );
// there is a chance that it needs to update) // update interface (in case it isn't playing,
fMainWindow->PostMessage( MSG_UPDATE ); // there is a chance that it needs to update)
fVlcWrapper->PlaylistUnlock(); fMainWindow->PostMessage( MSG_UPDATE );
} fVlcWrapper->PlaylistUnlock();
}
#endif
} }
/***************************************************************************** /*****************************************************************************
...@@ -900,10 +912,10 @@ PlaylistView::RemoveItemList( BList& items ) ...@@ -900,10 +912,10 @@ PlaylistView::RemoveItemList( BList& items )
BListItem* BListItem*
PlaylistView::CloneItem( int32 atIndex ) const PlaylistView::CloneItem( int32 atIndex ) const
{ {
BListItem* clone = NULL; BListItem* clone = NULL;
if ( PlaylistItem* item = dynamic_cast<PlaylistItem*>( ItemAt( atIndex ) ) ) if ( PlaylistItem* item = dynamic_cast<PlaylistItem*>( ItemAt( atIndex ) ) )
clone = new PlaylistItem( item->Text() ); clone = new PlaylistItem( item->Text() );
return clone; return clone;
} }
/***************************************************************************** /*****************************************************************************
...@@ -912,9 +924,9 @@ PlaylistView::CloneItem( int32 atIndex ) const ...@@ -912,9 +924,9 @@ PlaylistView::CloneItem( int32 atIndex ) const
void void
PlaylistView::DrawListItem( BView* owner, int32 index, BRect frame ) const PlaylistView::DrawListItem( BView* owner, int32 index, BRect frame ) const
{ {
if ( PlaylistItem* item = dynamic_cast<PlaylistItem*>( ItemAt( index ) ) ) if ( PlaylistItem* item = dynamic_cast<PlaylistItem*>( ItemAt( index ) ) )
item->Draw( owner, frame, index % 2, item->Draw( owner, frame, index % 2,
fDisplayMode, index == fCurrentIndex, fPlaying ); fDisplayMode, index == fCurrentIndex, fPlaying );
} }
/***************************************************************************** /*****************************************************************************
...@@ -923,22 +935,22 @@ PlaylistView::DrawListItem( BView* owner, int32 index, BRect frame ) const ...@@ -923,22 +935,22 @@ PlaylistView::DrawListItem( BView* owner, int32 index, BRect frame ) const
void void
PlaylistView::MakeDragMessage( BMessage* message ) const PlaylistView::MakeDragMessage( BMessage* message ) const
{ {
if ( message ) if ( message )
{ {
message->AddPointer( "list", (void*)this ); message->AddPointer( "list", (void*)this );
int32 index; int32 index;
for ( int32 i = 0; ( index = CurrentSelection( i ) ) >= 0; i++ ) for ( int32 i = 0; ( index = CurrentSelection( i ) ) >= 0; i++ )
{ {
message->AddInt32( "index", index ); message->AddInt32( "index", index );
// add refs to message (inter application communication) // add refs to message (inter application communication)
if ( BStringItem* item = dynamic_cast<BStringItem*>( ItemAt( index ) ) ) if ( BStringItem* item = dynamic_cast<BStringItem*>( ItemAt( index ) ) )
{ {
entry_ref ref; entry_ref ref;
if ( get_ref_for_path( item->Text(), &ref ) == B_OK ) if ( get_ref_for_path( item->Text(), &ref ) == B_OK )
message->AddRef( "refs", &ref ); message->AddRef( "refs", &ref );
} }
} }
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -947,12 +959,12 @@ PlaylistView::MakeDragMessage( BMessage* message ) const ...@@ -947,12 +959,12 @@ PlaylistView::MakeDragMessage( BMessage* message ) const
void void
PlaylistView::SetCurrent( int32 index ) PlaylistView::SetCurrent( int32 index )
{ {
if ( fCurrentIndex != index ) if ( fCurrentIndex != index )
{ {
InvalidateItem( fCurrentIndex ); InvalidateItem( fCurrentIndex );
fCurrentIndex = index; fCurrentIndex = index;
InvalidateItem( fCurrentIndex ); InvalidateItem( fCurrentIndex );
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -961,11 +973,11 @@ PlaylistView::SetCurrent( int32 index ) ...@@ -961,11 +973,11 @@ PlaylistView::SetCurrent( int32 index )
void void
PlaylistView::SetPlaying( bool playing ) PlaylistView::SetPlaying( bool playing )
{ {
if ( fPlaying != playing ) if ( fPlaying != playing )
{ {
fPlaying = playing; fPlaying = playing;
InvalidateItem( fCurrentIndex ); InvalidateItem( fCurrentIndex );
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -974,14 +986,28 @@ PlaylistView::SetPlaying( bool playing ) ...@@ -974,14 +986,28 @@ PlaylistView::SetPlaying( bool playing )
void void
PlaylistView::RebuildList() PlaylistView::RebuildList()
{ {
// remove all items playlist_t * p_playlist;
int32 count = CountItems(); p_playlist = (playlist_t *) vlc_object_find( p_intf,
while ( BListItem* item = RemoveItem( --count ) ) VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
delete item;
if( !p_playlist )
// rebuild listview from VLC's playlist {
for ( int i = 0; i < fVlcWrapper->PlaylistSize(); i++ ) return;
AddItem( new PlaylistItem( fVlcWrapper->PlaylistItemName( i ) ) ); }
// remove all items
BListItem * item;
int32 count = CountItems();
while( ( item = RemoveItem( --count ) ) )
delete item;
// rebuild listview from VLC's playlist
vlc_mutex_lock( &p_playlist->object_lock );
for( int i = 0; i < p_playlist->i_size; i++ )
AddItem( new PlaylistItem( p_playlist->pp_items[i]->input.psz_name ) );
vlc_mutex_unlock( &p_playlist->object_lock );
vlc_object_release( p_playlist );
} }
...@@ -991,29 +1017,31 @@ PlaylistView::RebuildList() ...@@ -991,29 +1017,31 @@ PlaylistView::RebuildList()
void void
PlaylistView::SortReverse() PlaylistView::SortReverse()
{ {
if ( int32 count = CountSelectedItems() ) #if 0
{ if ( int32 count = CountSelectedItems() )
int32 last = count - 1; {
// remember currently playing item int32 last = count - 1;
BListItem* playingItem = _PlayingItem(); // remember currently playing item
for ( int32 first = 0; first < count / 2; first++, last-- ) BListItem* playingItem = _PlayingItem();
{ for ( int32 first = 0; first < count / 2; first++, last-- )
int32 index1 = CurrentSelection( first); {
int32 index2 = CurrentSelection( last); int32 index1 = CurrentSelection( first);
if ( SwapItems( index1, index2 ) ) int32 index2 = CurrentSelection( last);
{ if ( SwapItems( index1, index2 ) )
// index2 > index1, so the list won't get messed up {
// if we remove the items in that order // index2 > index1, so the list won't get messed up
// TODO: Error checking + handling! // if we remove the items in that order
void* item2 = fVlcWrapper->PlaylistRemoveItem( index2 ); // TODO: Error checking + handling!
void* item1 = fVlcWrapper->PlaylistRemoveItem( index1 ); void* item2 = fVlcWrapper->PlaylistRemoveItem( index2 );
fVlcWrapper->PlaylistAddItem( item2, index1 ); void* item1 = fVlcWrapper->PlaylistRemoveItem( index1 );
fVlcWrapper->PlaylistAddItem( item1, index2 ); fVlcWrapper->PlaylistAddItem( item2, index1 );
} fVlcWrapper->PlaylistAddItem( item1, index2 );
} }
// restore currently playing item }
_SetPlayingIndex( playingItem ); // restore currently playing item
} _SetPlayingIndex( playingItem );
}
#endif
} }
/***************************************************************************** /*****************************************************************************
...@@ -1022,7 +1050,7 @@ PlaylistView::SortReverse() ...@@ -1022,7 +1050,7 @@ PlaylistView::SortReverse()
void void
PlaylistView::SortByPath() PlaylistView::SortByPath()
{ {
} }
/***************************************************************************** /*****************************************************************************
...@@ -1039,11 +1067,11 @@ PlaylistView::SortByName() ...@@ -1039,11 +1067,11 @@ PlaylistView::SortByName()
void void
PlaylistView::SetDisplayMode( uint32 mode ) PlaylistView::SetDisplayMode( uint32 mode )
{ {
if ( mode != fDisplayMode ) if ( mode != fDisplayMode )
{ {
fDisplayMode = mode; fDisplayMode = mode;
Invalidate(); Invalidate();
} }
} }
/***************************************************************************** /*****************************************************************************
...@@ -1052,9 +1080,18 @@ PlaylistView::SetDisplayMode( uint32 mode ) ...@@ -1052,9 +1080,18 @@ PlaylistView::SetDisplayMode( uint32 mode )
BListItem* BListItem*
PlaylistView::_PlayingItem() const PlaylistView::_PlayingItem() const
{ {
int32 currentIndex, size; playlist_t * p_playlist;
fVlcWrapper->GetPlaylistInfo( currentIndex, size ); p_playlist = (playlist_t *) vlc_object_find( p_intf,
return ItemAt( currentIndex ); VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( !p_playlist )
{
return NULL;
}
BListItem * item = ItemAt( p_playlist->i_index );
vlc_object_release( p_playlist );
return item;
} }
/***************************************************************************** /*****************************************************************************
...@@ -1063,13 +1100,24 @@ PlaylistView::_PlayingItem() const ...@@ -1063,13 +1100,24 @@ PlaylistView::_PlayingItem() const
void void
PlaylistView::_SetPlayingIndex( BListItem* playingItem ) PlaylistView::_SetPlayingIndex( BListItem* playingItem )
{ {
for ( int32 i = 0; BListItem* item = ItemAt( i ); i++ ) for ( int32 i = 0; BListItem* item = ItemAt( i ); i++ )
{ {
if ( item == playingItem ) if ( item == playingItem )
{ {
fVlcWrapper->PlaylistSetPlaying( i ); playlist_t * p_playlist;
SetCurrent( i ); p_playlist = (playlist_t *) vlc_object_find( p_intf,
break; VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
}
} if( !p_playlist )
{
return;
}
playlist_Goto( p_playlist, i );
SetCurrent( i );
vlc_object_release( p_playlist );
break;
}
}
} }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* ListViews.h: BeOS interface list view class prototype * ListViews.h: BeOS interface list view class prototype
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: ListViews.h,v 1.5 2004/01/26 16:52:31 zorglub Exp $ * $Id$
* *
* Authors: Stephan Aßmus <stippi@yellowbites.com> * Authors: Stephan Aßmus <stippi@yellowbites.com>
* *
...@@ -113,9 +113,9 @@ class DragSortableListView : public BListView ...@@ -113,9 +113,9 @@ class DragSortableListView : public BListView
class PlaylistView : public DragSortableListView class PlaylistView : public DragSortableListView
{ {
public: public:
PlaylistView( BRect frame, PlaylistView( intf_thread_t * p_intf,
BRect frame,
InterfaceWindow* mainWindow, InterfaceWindow* mainWindow,
VlcWrapper* wrapper,
BMessage* selectionChangeMessage = NULL ); BMessage* selectionChangeMessage = NULL );
~PlaylistView(); ~PlaylistView();
...@@ -154,14 +154,14 @@ class PlaylistView : public DragSortableListView ...@@ -154,14 +154,14 @@ class PlaylistView : public DragSortableListView
BListItem* _PlayingItem() const; BListItem* _PlayingItem() const;
void _SetPlayingIndex( BListItem* item ); void _SetPlayingIndex( BListItem* item );
intf_thread_t * p_intf;
int32 fCurrentIndex; int32 fCurrentIndex;
bool fPlaying; bool fPlaying;
uint32 fDisplayMode; uint32 fDisplayMode;
InterfaceWindow* fMainWindow; InterfaceWindow* fMainWindow;
BMessage* fSelectionChangeMessage; BMessage* fSelectionChangeMessage;
PlaylistItem* fLastClickedItem; PlaylistItem* fLastClickedItem;
VlcWrapper* fVlcWrapper;
}; };
#endif // LIST_VIEWS_H #endif // LIST_VIEWS_H
...@@ -38,7 +38,6 @@ extern "C" ...@@ -38,7 +38,6 @@ extern "C"
} }
/* BeOS interface headers */ /* BeOS interface headers */
#include "VlcWrapper.h"
#include "Bitmaps.h" #include "Bitmaps.h"
#include "DrawingTidbits.h" #include "DrawingTidbits.h"
#include "InterfaceWindow.h" #include "InterfaceWindow.h"
...@@ -67,6 +66,7 @@ const rgb_color kSeekRedLight = (rgb_color){ 255, 152, 152, 255 }; ...@@ -67,6 +66,7 @@ const rgb_color kSeekRedLight = (rgb_color){ 255, 152, 152, 255 };
const rgb_color kSeekRedShadow = (rgb_color){ 178, 0, 0, 255 }; const rgb_color kSeekRedShadow = (rgb_color){ 178, 0, 0, 255 };
#define DISABLED_SEEK_MESSAGE _("Drop files to play") #define DISABLED_SEEK_MESSAGE _("Drop files to play")
#define SEEKSLIDER_RANGE 2048
enum enum
{ {
...@@ -77,17 +77,16 @@ enum ...@@ -77,17 +77,16 @@ enum
}; };
// constructor // constructor
MediaControlView::MediaControlView(BRect frame, intf_thread_t *p_interface) MediaControlView::MediaControlView( intf_thread_t * _p_intf, BRect frame)
: BBox(frame, NULL, B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS | B_PULSE_NEEDED, : BBox(frame, NULL, B_FOLLOW_NONE, B_WILL_DRAW | B_FRAME_EVENTS | B_PULSE_NEEDED,
B_PLAIN_BORDER), B_PLAIN_BORDER),
p_intf( _p_intf ),
fScrubSem(B_ERROR), fScrubSem(B_ERROR),
fCurrentRate(INPUT_RATE_DEFAULT), fCurrentRate(INPUT_RATE_DEFAULT),
fCurrentStatus(-1), fCurrentStatus(-1),
fBottomControlHeight(0.0), fBottomControlHeight(0.0),
fIsEnabled( true ) fIsEnabled( true )
{ {
p_intf = p_interface;
BRect frame(0.0, 0.0, 10.0, 10.0); BRect frame(0.0, 0.0, 10.0, 10.0);
// Seek Slider // Seek Slider
...@@ -1335,6 +1334,7 @@ PositionInfoView::Pulse() ...@@ -1335,6 +1334,7 @@ PositionInfoView::Pulse()
bigtime_t now = system_time(); bigtime_t now = system_time();
if ( now - fLastPulseUpdate > 900000 ) if ( now - fLastPulseUpdate > 900000 )
{ {
#if 0
int32 index, size; int32 index, size;
p_intf->p_sys->p_wrapper->GetPlaylistInfo( index, size ); p_intf->p_sys->p_wrapper->GetPlaylistInfo( index, size );
SetFile( index + 1, size ); SetFile( index + 1, size );
...@@ -1344,6 +1344,7 @@ PositionInfoView::Pulse() ...@@ -1344,6 +1344,7 @@ PositionInfoView::Pulse()
SetChapter( index, size ); SetChapter( index, size );
SetTime( p_intf->p_sys->p_wrapper->GetTimeAsString() ); SetTime( p_intf->p_sys->p_wrapper->GetTimeAsString() );
fLastPulseUpdate = now; fLastPulseUpdate = now;
#endif
} }
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* MediaControlView.h: beos interface * MediaControlView.h: beos interface
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: MediaControlView.h,v 1.5 2003/01/25 01:03:44 titer Exp $ * $Id$
* *
* Authors: Tony Castley <tony@castley.net> * Authors: Tony Castley <tony@castley.net>
* Stephan Aßmus <stippi@yellowbites.com> * Stephan Aßmus <stippi@yellowbites.com>
...@@ -38,7 +38,7 @@ class VolumeSlider; ...@@ -38,7 +38,7 @@ class VolumeSlider;
class MediaControlView : public BBox class MediaControlView : public BBox
{ {
public: public:
MediaControlView( BRect frame, intf_thread_t *p_intf ); MediaControlView( intf_thread_t * p_intf, BRect frame );
virtual ~MediaControlView(); virtual ~MediaControlView();
// BBox // BBox
...@@ -70,6 +70,7 @@ class MediaControlView : public BBox ...@@ -70,6 +70,7 @@ class MediaControlView : public BBox
bool resizeWidth = false, bool resizeWidth = false,
bool resizeHeight = false) const; bool resizeHeight = false) const;
intf_thread_t * p_intf;
VolumeSlider* fVolumeSlider; VolumeSlider* fVolumeSlider;
SeekSlider* fSeekSlider; SeekSlider* fSeekSlider;
...@@ -88,7 +89,6 @@ class MediaControlView : public BBox ...@@ -88,7 +89,6 @@ class MediaControlView : public BBox
BRect fOldBounds; BRect fOldBounds;
bool fIsEnabled; bool fIsEnabled;
intf_thread_t * p_intf;
}; };
class SeekSlider : public BControl class SeekSlider : public BControl
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* MessagesWindow.cpp: beos interface * MessagesWindow.cpp: beos interface
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: MessagesWindow.cpp,v 1.12 2004/01/26 16:52:31 zorglub Exp $ * $Id$
* *
* Authors: Eric Petit <titer@videolan.org> * Authors: Eric Petit <titer@videolan.org>
* *
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include <vlc/intf.h> #include <vlc/intf.h>
/* BeOS module headers */ /* BeOS module headers */
#include "VlcWrapper.h"
#include "InterfaceWindow.h" #include "InterfaceWindow.h"
#include "MessagesWindow.h" #include "MessagesWindow.h"
...@@ -39,6 +38,7 @@ ...@@ -39,6 +38,7 @@
*****************************************************************************/ *****************************************************************************/
void MessagesView::Pulse() void MessagesView::Pulse()
{ {
#if 0
bool isScrolling = false; bool isScrolling = false;
if( fScrollBar->LockLooper() ) if( fScrollBar->LockLooper() )
{ {
...@@ -123,6 +123,7 @@ void MessagesView::Pulse() ...@@ -123,6 +123,7 @@ void MessagesView::Pulse()
} }
BTextView::Pulse(); BTextView::Pulse();
#endif
} }
/***************************************************************************** /*****************************************************************************
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* MessagesWindow.h * MessagesWindow.h
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: MessagesWindow.h,v 1.4 2003/05/17 18:30:41 titer Exp $ * $Id$
* *
* Authors: Eric Petit <titer@videolan.org> * Authors: Eric Petit <titer@videolan.org>
* *
...@@ -36,7 +36,6 @@ class MessagesView : public BTextView ...@@ -36,7 +36,6 @@ class MessagesView : public BTextView
resizingMode, flags ) resizingMode, flags )
{ {
p_intf = _p_intf; p_intf = _p_intf;
p_sub = ((intf_sys_t*)p_intf->p_sys)->p_sub;
} }
virtual void Pulse(); virtual void Pulse();
......
...@@ -19,8 +19,6 @@ SOURCES_beos = \ ...@@ -19,8 +19,6 @@ SOURCES_beos = \
MessagesWindow.h \ MessagesWindow.h \
MediaControlView.cpp \ MediaControlView.cpp \
MediaControlView.h \ MediaControlView.h \
VlcWrapper.cpp \
VlcWrapper.h \
Bitmaps.h \ Bitmaps.h \
MsgVals.h \ MsgVals.h \
VideoWindow.h \ VideoWindow.h \
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* PlayListWindow.cpp: beos interface * PlayListWindow.cpp: beos interface
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: PlayListWindow.cpp,v 1.10 2004/01/26 16:52:31 zorglub Exp $ * $Id$
* *
* 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>
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include <vlc/intf.h> #include <vlc/intf.h>
/* BeOS interface headers */ /* BeOS interface headers */
#include "VlcWrapper.h"
#include "InterfaceWindow.h" #include "InterfaceWindow.h"
#include "ListViews.h" #include "ListViews.h"
#include "MsgVals.h" #include "MsgVals.h"
...@@ -67,8 +66,12 @@ PlayListWindow::PlayListWindow( BRect frame, const char* name, ...@@ -67,8 +66,12 @@ PlayListWindow::PlayListWindow( BRect frame, const char* name,
B_WILL_ACCEPT_FIRST_CLICK | B_ASYNCHRONOUS_CONTROLS ), B_WILL_ACCEPT_FIRST_CLICK | B_ASYNCHRONOUS_CONTROLS ),
fMainWindow( mainWindow ) fMainWindow( mainWindow )
{ {
char psz_tmp[1024];
#define ADD_ELLIPSIS( a ) \
memset( psz_tmp, 0, 1024 ); \
snprintf( psz_tmp, 1024, "%s%s", a, B_UTF8_ELLIPSIS );
p_intf = p_interface; p_intf = p_interface;
p_wrapper = p_intf->p_sys->p_wrapper;
SetName( _("playlist") ); SetName( _("playlist") );
...@@ -81,8 +84,8 @@ PlayListWindow::PlayListWindow( BRect frame, const char* name, ...@@ -81,8 +84,8 @@ PlayListWindow::PlayListWindow( BRect frame, const char* name,
// Add the File menu // Add the File menu
BMenu *fileMenu = new BMenu( _("File") ); BMenu *fileMenu = new BMenu( _("File") );
fMenuBar->AddItem( fileMenu ); fMenuBar->AddItem( fileMenu );
BMenuItem* item = new BMenuItem( _AddEllipsis(_("Open File")), ADD_ELLIPSIS( _("Open File") );
new BMessage( OPEN_FILE ), 'O' ); BMenuItem* item = new BMenuItem( psz_tmp, new BMessage( OPEN_FILE ), 'O' );
item->SetTarget( fMainWindow ); item->SetTarget( fMainWindow );
fileMenu->AddItem( item ); fileMenu->AddItem( item );
...@@ -154,7 +157,7 @@ fRandomizeMI->SetEnabled( false ); ...@@ -154,7 +157,7 @@ fRandomizeMI->SetEnabled( false );
frame.top += fMenuBar->Bounds().IntegerHeight() + 1; frame.top += fMenuBar->Bounds().IntegerHeight() + 1;
frame.right -= B_V_SCROLL_BAR_WIDTH; frame.right -= B_V_SCROLL_BAR_WIDTH;
fListView = new PlaylistView( frame, fMainWindow, p_wrapper, fListView = new PlaylistView( p_intf, frame, fMainWindow,
new BMessage( MSG_SELECTION_CHANGED ) ); new BMessage( MSG_SELECTION_CHANGED ) );
fBackgroundView = new BScrollView( "playlist scrollview", fBackgroundView = new BScrollView( "playlist scrollview",
fListView, B_FOLLOW_ALL_SIDES, fListView, B_FOLLOW_ALL_SIDES,
...@@ -282,9 +285,10 @@ PlayListWindow::UpdatePlaylist( bool rebuild ) ...@@ -282,9 +285,10 @@ PlayListWindow::UpdatePlaylist( bool rebuild )
{ {
if ( rebuild ) if ( rebuild )
fListView->RebuildList(); fListView->RebuildList();
#if 0
fListView->SetCurrent( p_wrapper->PlaylistCurrent() ); fListView->SetCurrent( p_wrapper->PlaylistCurrent() );
fListView->SetPlaying( p_wrapper->IsPlaying() ); fListView->SetPlaying( p_wrapper->IsPlaying() );
#endif
_CheckItemsEnableState(); _CheckItemsEnableState();
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* PlayListWindow.h: BeOS interface window class prototype * PlayListWindow.h: BeOS interface window class prototype
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN * Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: PlayListWindow.h,v 1.8 2004/01/26 16:52:31 zorglub Exp $ * $Id$
* *
* 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>
...@@ -75,7 +75,6 @@ class PlayListWindow : public BWindow ...@@ -75,7 +75,6 @@ class PlayListWindow : public BWindow
BMenu* fViewMenu; BMenu* fViewMenu;
intf_thread_t * p_intf; intf_thread_t * p_intf;
VlcWrapper * p_wrapper;
}; };
#endif // BEOS_PLAY_LIST_WINDOW_H #endif // BEOS_PLAY_LIST_WINDOW_H
......
/*****************************************************************************
* VlcWrapper.cpp: BeOS plugin for vlc (derived from MacOS X port)
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id$
*
* Authors: Florian G. Pflug <fgp@phlo.org>
* Jon Lech Johansen <jon-vl@nanocrew.net>
* Tony Casltey <tony@castley.net>
* Stephan Aßmus <stippi@yellowbites.com>
* Eric Petit <titer@videolan.org>
*
* This program is free software{} you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation{} either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY{} without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program{} if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#include <AppKit.h>
#include <InterfaceKit.h>
#include <SupportKit.h>
#include <vlc/vlc.h>
#include <vlc/intf.h>
#include <vlc/vout.h>
#include <vlc/input.h>
extern "C"
{
#include <audio_output.h>
#include <aout_internal.h>
}
#include "VlcWrapper.h"
#include "MsgVals.h"
const char * _AddEllipsis( char * string )
{
char * temp;
temp = (char*) calloc( strlen( string ) + 4, 1 );
sprintf( temp, "%s%s", string, B_UTF8_ELLIPSIS );
return temp;
}
/* constructor */
VlcWrapper::VlcWrapper( intf_thread_t *p_interface )
{
p_intf = p_interface;
p_input = NULL;
p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
}
/* destructor */
VlcWrapper::~VlcWrapper()
{
if( p_input )
vlc_object_release( p_input );
if( p_playlist )
vlc_object_release( p_playlist );
}
/* UpdateInput: updates p_input */
void VlcWrapper::UpdateInput()
{
if( !p_input )
p_input = (input_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_INPUT,
FIND_ANYWHERE );
if( p_input )
if( p_input->b_dead )
{
vlc_object_release( p_input );
p_input = NULL;
}
}
/***************************
* input infos and control *
***************************/
bool VlcWrapper::HasInput()
{
return ( p_input != NULL );
}
int VlcWrapper::InputStatus()
{
if( !p_input )
{
return -1;
}
return var_GetInteger( p_input, "state" );
}
int VlcWrapper::InputRate()
{
if( !p_input )
{
return INPUT_RATE_DEFAULT;
}
return var_GetInteger( p_input, "rate" );
}
void VlcWrapper::InputSetRate( int rate )
{
if( !p_input )
{
return;
}
var_SetInteger( p_input, "rate", rate );
}
BList * VlcWrapper::GetChannels( int i_cat )
{
if( p_input )
{
unsigned int i;
uint32 what;
const char* fieldName;
switch( i_cat )
{
case AUDIO_ES:
{
what = SELECT_CHANNEL;
fieldName = "channel";
break;
}
case SPU_ES:
{
what = SELECT_SUBTITLE;
fieldName = "subtitle";
break;
}
default:
return NULL;
}
BList *list = new BList();
#if 0
vlc_mutex_lock( &p_input->stream.stream_lock );
/* find which track is currently playing */
es_descriptor_t *p_es = NULL;
for( i = 0; i < p_input->stream.i_selected_es_number; i++ )
{
if( p_input->stream.pp_selected_es[i]->i_cat == i_cat )
p_es = p_input->stream.pp_selected_es[i];
}
/* build a list of all tracks */
BMenuItem *menuItem;
BMessage *message;
char *trackName;
/* "None" */
message = new BMessage( what );
message->AddInt32( fieldName, -1 );
menuItem = new BMenuItem( _("None"), message );
if( !p_es )
menuItem->SetMarked( true );
list->AddItem( menuItem );
for( i = 0; i < p_input->stream.i_es_number; i++ )
{
if( p_input->stream.pp_es[i]->i_cat == i_cat )
{
message = new BMessage( what );
message->AddInt32( fieldName, i );
if( !p_input->stream.pp_es[i]->psz_desc ||
!*p_input->stream.pp_es[i]->psz_desc )
trackName = _("<unknown>");
else
trackName = strdup( p_input->stream.pp_es[i]->psz_desc );
menuItem = new BMenuItem( trackName, message );
if( p_input->stream.pp_es[i] == p_es )
menuItem->SetMarked( true );
list->AddItem( menuItem );
}
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
#endif
return list;
}
return NULL;
}
void VlcWrapper::ToggleLanguage( int i_language )
{
if( i_language < 0 )
var_SetInteger( p_input, "audio-es", -1 ); /* Disable audio */
else
var_SetInteger( p_input, "audio-es", i_language );
}
void VlcWrapper::ToggleSubtitle( int i_subtitle )
{
if( i_subtitle < 0 )
var_SetInteger( p_input, "spu-es", -1 ); /* Disable SPU */
else
var_SetInteger( p_input, "spu-es", i_subtitle );
}
const char * VlcWrapper::GetTimeAsString()
{
static char psz_time[ MSTRTIME_MAX_SIZE ];
if( !p_input )
{
return ("-:--:--");
}
vlc_value_t time;
var_Get( p_input, "time", &time );
mtime_t seconds = time.i_time / 1000000;
sprintf( psz_time, "%d:%02d:%02d",
(int) ( seconds / (60 * 60 ) ),
(int) ( ( seconds / 60 ) % 60 ),
(int) ( seconds % 60 ) );
return psz_time;
}
float VlcWrapper::GetTimeAsFloat()
{
if( !p_input )
{
return 0.0;
}
vlc_value_t pos;
var_Get( p_input, "position", &pos );
return pos.f_float;
}
void VlcWrapper::SetTimeAsFloat( float f_position )
{
if( !p_input )
{
return;
}
vlc_value_t pos;
pos.f_float = f_position / SEEKSLIDER_RANGE;
var_Set( p_input, "position", pos );
}
bool VlcWrapper::IsPlaying()
{
bool playing = false;
if( p_input )
{
switch( var_GetInteger( p_input, "state" ) )
{
case INIT_S:
case PLAYING_S:
playing = true;
break;
default:
break;
}
}
return playing;
}
/************
* playlist *
************/
void VlcWrapper::OpenFiles( BList* o_files, bool replace, int32 index )
{
if ( o_files && o_files->CountItems() > 0)
{
int size = PlaylistSize();
bool wasEmpty = ( size < 1 );
if ( index == -1 )
index = PLAYLIST_END;
int mode = index == PLAYLIST_END ? PLAYLIST_APPEND : PLAYLIST_INSERT;
/* delete current playlist */
if( replace )
{
for( int i = 0; i < size; i++ )
{
playlist_Delete( p_playlist, 0 );
}
}
/* insert files */
int32 count = o_files->CountItems();
for ( int32 i = count - 1; i >= 0; i-- )
{
if ( BString* o_file = (BString *)o_files->RemoveItem( i ) )
{
playlist_Add( p_playlist, o_file->String(),
o_file->String(), mode, index );
if ( mode == PLAYLIST_INSERT )
index++;
delete o_file;
}
}
// TODO: implement a user setting
// if to start automatically
/* eventually restart playing */
if( replace || wasEmpty )
{
playlist_Stop( p_playlist );
playlist_Play( p_playlist );
}
}
}
void VlcWrapper::OpenDisc(BString o_type, BString o_device, int i_title, int i_chapter)
{
if( config_GetInt( p_intf, "beos-dvdmenus" ) )
o_device.Prepend( "dvdplay:" );
else
o_device.Prepend( "dvdold:" );
playlist_Add( p_playlist, o_device.String(), o_device.String(),
PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END );
}
int VlcWrapper::PlaylistSize()
{
vlc_mutex_lock( &p_playlist->object_lock );
int i_size = p_playlist->i_size;
vlc_mutex_unlock( &p_playlist->object_lock );
return i_size;
}
char * VlcWrapper::PlaylistItemName( int i )
{
return p_playlist->pp_items[i]->input.psz_name;
}
int VlcWrapper::PlaylistCurrent()
{
return p_playlist->i_index;
}
bool VlcWrapper::PlaylistPlay()
{
if( PlaylistSize() )
{
playlist_Play( p_playlist );
}
return( true );
}
void VlcWrapper::PlaylistPause()
{
if( p_input )
{
var_SetInteger( p_input, "state", PAUSE_S );
}
}
void VlcWrapper::PlaylistStop()
{
playlist_Stop( p_playlist );
}
void VlcWrapper::PlaylistNext()
{
playlist_Next( p_playlist );
}
void VlcWrapper::PlaylistPrev()
{
playlist_Prev( p_playlist );
}
void VlcWrapper::GetPlaylistInfo( int32& currentIndex, int32& maxIndex )
{
currentIndex = -1;
maxIndex = -1;
if ( p_playlist )
{
vlc_mutex_lock( &p_playlist->object_lock );
maxIndex = p_playlist->i_size;
if ( maxIndex > 0 )
currentIndex = p_playlist->i_index/* + 1 -> why?!?*/;
else
maxIndex = -1;
vlc_mutex_unlock( &p_playlist->object_lock );
}
}
void VlcWrapper::PlaylistJumpTo( int pos )
{
playlist_Goto( p_playlist, pos );
}
void VlcWrapper::GetNavCapabilities( bool *canSkipPrev, bool *canSkipNext )
{
if ( canSkipPrev && canSkipNext )
{
// init the parameters
*canSkipPrev = false;
*canSkipNext = false;
// get playlist info
int pos = PlaylistCurrent();
int size = PlaylistSize();
// see if we have got a stream going
if ( p_input )
{
#if 0
vlc_mutex_lock( &p_input->stream.stream_lock );
bool hasTitles = p_input->stream.i_area_nb > 1;
int numChapters = p_input->stream.p_selected_area->i_part_nb;
bool hasChapters = numChapters > 1;
// first, look for chapters
if ( hasChapters )
{
*canSkipPrev = p_input->stream.p_selected_area->i_part > 0;
*canSkipNext = p_input->stream.p_selected_area->i_part <
p_input->stream.p_selected_area->i_part_nb - 1;
}
// if one of the skip capabilities is false,
// make it depend on titles instead
if ( !*canSkipPrev && hasTitles )
*canSkipPrev = p_input->stream.p_selected_area->i_id > 1;
if ( !*canSkipNext && hasTitles )
*canSkipNext = p_input->stream.p_selected_area->i_id <
p_input->stream.i_area_nb - 1;
vlc_mutex_unlock( &p_input->stream.stream_lock );
#endif
}
// last but not least, make capabilities depend on playlist
if ( !*canSkipPrev )
*canSkipPrev = pos > 0;
if ( !*canSkipNext )
*canSkipNext = pos < size - 1;
}
}
void VlcWrapper::NavigatePrev()
{
bool hasSkiped = false;
// see if we have got a stream going
if ( p_input )
{
#if 0
// get information from stream (lock it while looking at it)
vlc_mutex_lock( &p_input->stream.stream_lock );
int currentTitle = p_input->stream.p_selected_area->i_id;
int currentChapter = p_input->stream.p_selected_area->i_part;
int numTitles = p_input->stream.i_area_nb;
bool hasTitles = numTitles > 1;
int numChapters = p_input->stream.p_selected_area->i_part_nb;
bool hasChapters = numChapters > 1;
vlc_mutex_unlock( &p_input->stream.stream_lock );
// first, look for chapters
if ( hasChapters )
{
// skip to the previous chapter
currentChapter--;
if ( currentChapter >= 0 )
{
ToggleChapter( currentChapter );
hasSkiped = true;
}
}
// if we couldn't skip chapters, try titles instead
if ( !hasSkiped && hasTitles )
{
// skip to the previous title
currentTitle--;
// disallow area 0 since it is used for video_ts.vob
if( currentTitle > 0 )
{
ToggleTitle(currentTitle);
hasSkiped = true;
}
}
#endif
}
// last but not least, skip to previous file
if ( !hasSkiped )
PlaylistPrev();
}
void VlcWrapper::NavigateNext()
{
bool hasSkiped = false;
// see if we have got a stream going
if ( p_input )
{
#if 0
// get information from stream (lock it while looking at it)
vlc_mutex_lock( &p_input->stream.stream_lock );
int currentTitle = p_input->stream.p_selected_area->i_id;
int currentChapter = p_input->stream.p_selected_area->i_part;
int numTitles = p_input->stream.i_area_nb;
bool hasTitles = numTitles > 1;
int numChapters = p_input->stream.p_selected_area->i_part_nb;
bool hasChapters = numChapters > 1;
vlc_mutex_unlock( &p_input->stream.stream_lock );
// first, look for chapters
if ( hasChapters )
{
// skip to the next chapter
currentChapter++;
if ( currentChapter < numChapters )
{
ToggleChapter( currentChapter );
hasSkiped = true;
}
}
// if we couldn't skip chapters, try titles instead
if ( !hasSkiped && hasTitles )
{
// skip to the next title
currentTitle++;
// disallow area 0 since it is used for video_ts.vob
if ( currentTitle < numTitles - 1 )
{
ToggleTitle(currentTitle);
hasSkiped = true;
}
}
#endif
}
// last but not least, skip to next file
if ( !hasSkiped )
PlaylistNext();
}
/*************************
* Playlist manipulation *
*************************/
// PlaylistLock
bool
VlcWrapper::PlaylistLock() const
{
// TODO: search and destroy -> deadlock!
return true;
if ( p_playlist )
{
vlc_mutex_lock( &p_playlist->object_lock );
return true;
}
return false;
}
// PlaylistUnlock
void
VlcWrapper::PlaylistUnlock() const
{
// TODO: search and destroy -> deadlock!
return;
vlc_mutex_unlock( &p_playlist->object_lock );
}
// PlaylistItemAt
void*
VlcWrapper::PlaylistItemAt( int index ) const
{
playlist_item_t* item = NULL;
if ( index >= 0 && index < p_playlist->i_size )
item = p_playlist->pp_items[index];
return (void*)item;
}
// PlaylistRemoveItem
void*
VlcWrapper::PlaylistRemoveItem( int index ) const
{
playlist_item_t* copy = NULL;
// check if item exists at the provided index
if ( index >= 0 && index < p_playlist->i_size )
{
playlist_item_t* item = p_playlist->pp_items[index];
if ( item )
{
// make a copy of the removed item
copy = (playlist_item_t*)PlaylistCloneItem( (void*)item );
// remove item from playlist (unfortunately, this frees it)
playlist_Delete( p_playlist, index );
}
}
return (void*)copy;
}
// PlaylistRemoveItem
void*
VlcWrapper::PlaylistRemoveItem( void* item ) const
{
playlist_item_t* copy = NULL;
for ( int32 i = 0; i < p_playlist->i_size; i++ )
{
if ( p_playlist->pp_items[i] == item )
{
copy = (playlist_item_t*)PlaylistRemoveItem( i );
break;
}
}
return (void*)copy;
}
// PlaylistAddItem
bool
VlcWrapper::PlaylistAddItem( void* item, int index ) const
{
if ( item )
{
playlist_AddItem( p_playlist, (playlist_item_t*)item,
PLAYLIST_INSERT, index );
}
// TODO: once playlist is returning useful info, return that instead
return true;
}
// PlaylistCloneItem
void*
VlcWrapper::PlaylistCloneItem( void* castToItem ) const
{
playlist_item_t* copy = NULL;
playlist_item_t* item = (playlist_item_t*)castToItem;
if ( item )
{
copy = (playlist_item_t*)malloc( sizeof( playlist_item_t ) );
if ( copy )
{
// make a copy of the item at index
*copy = *item;
copy->input.psz_name = strdup( item->input.psz_name );
copy->input.psz_uri = strdup( item->input.psz_uri );
}
}
return (void*)copy;
}
// Careful! You need to know what you're doing here!
// The reason for having it, is to be able to deal with
// the rather lame list implementation of the playlist.
// It is meant to help manipulate the playlist with the above
// methods while keeping it valid.
//
// PlaylistSetPlaying
void
VlcWrapper::PlaylistSetPlaying( int index ) const
{
if ( index < 0 )
index = 0;
if ( index >= p_playlist->i_size )
index = p_playlist->i_size - 1;
p_playlist->i_index = index;
}
/*********
* audio *
*********/
unsigned short VlcWrapper::GetVolume()
{
unsigned short i_volume;
aout_VolumeGet( p_intf, (audio_volume_t*)&i_volume );
return i_volume;
}
void VlcWrapper::SetVolume( int value )
{
if ( p_intf->p_sys->b_mute )
{
p_intf->p_sys->b_mute = 0;
}
aout_VolumeSet( p_intf, value );
}
void VlcWrapper::VolumeMute()
{
aout_VolumeMute( p_intf, NULL );
p_intf->p_sys->b_mute = 1;
}
void VlcWrapper::VolumeRestore()
{
audio_volume_t dummy;
aout_VolumeMute( p_intf, &dummy );
p_intf->p_sys->b_mute = 0;
}
bool VlcWrapper::IsMuted()
{
return p_intf->p_sys->b_mute;
}
/*******
* DVD *
*******/
bool VlcWrapper::IsUsingMenus()
{
if( !p_input )
return false;
vlc_mutex_lock( &p_playlist->object_lock );
if( p_playlist->i_index < 0 )
{
vlc_mutex_unlock( &p_playlist->object_lock );
return false;
}
char * psz_name = p_playlist->pp_items[p_playlist->i_index]->input.psz_name;
if( !strncmp( psz_name, "dvdplay:", 8 ) )
{
vlc_mutex_unlock( &p_playlist->object_lock );
return true;
}
vlc_mutex_unlock( &p_playlist->object_lock );
return false;
}
bool VlcWrapper::HasTitles()
{
if( !p_input )
return false;
/* FIXME */
return false;
}
BList * VlcWrapper::GetTitles()
{
if( p_input )
{
BList *list = new BList();
#if 0
vlc_mutex_lock( &p_input->stream.stream_lock );
BMenuItem *menuItem;
BMessage *message;
for( unsigned int i = 1; i < p_input->stream.i_area_nb; i++ )
{
message = new BMessage( TOGGLE_TITLE );
message->AddInt32( "index", i );
BString helper( "" );
helper << i;
menuItem = new BMenuItem( helper.String(), message );
menuItem->SetMarked( p_input->stream.p_selected_area->i_id == i );
list->AddItem( menuItem );
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
#endif
return list;
}
return NULL;
}
void VlcWrapper::PrevTitle()
{
var_SetVoid( p_input, "prev-title" );
}
void VlcWrapper::NextTitle()
{
var_SetVoid( p_input, "next-title" );
}
void VlcWrapper::ToggleTitle(int i_title)
{
if( p_input != NULL )
{
var_SetInteger( p_input, "title", i_title );
}
}
void VlcWrapper::TitleInfo( int32 &currentIndex, int32 &maxIndex )
{
currentIndex = -1;
maxIndex = -1;
if ( p_input )
{
#if 0
vlc_mutex_lock( &p_input->stream.stream_lock );
maxIndex = p_input->stream.i_area_nb - 1;
if ( maxIndex > 0)
currentIndex = p_input->stream.p_selected_area->i_id;
else
maxIndex = -1;
vlc_mutex_unlock( &p_input->stream.stream_lock );
#endif
}
}
bool VlcWrapper::HasChapters()
{
if( !p_input )
{
return false;
}
/* FIXME */
return false;
}
BList * VlcWrapper::GetChapters()
{
if( p_input )
{
BList *list = new BList();
#if 0
vlc_mutex_lock( &p_input->stream.stream_lock );
BMenuItem *menuItem;
BMessage *message;
for( unsigned int i = 1;
i < p_input->stream.p_selected_area->i_part_nb + 1; i++ )
{
message = new BMessage( TOGGLE_CHAPTER );
message->AddInt32( "index", i );
BString helper( "" );
helper << i;
menuItem = new BMenuItem( helper.String(), message );
menuItem->SetMarked( p_input->stream.p_selected_area->i_part == i );
list->AddItem( menuItem );
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
#endif
return list;
}
return NULL;
}
void VlcWrapper::PrevChapter()
{
var_SetVoid( p_input, "prev-chapter" );
}
void VlcWrapper::NextChapter()
{
var_SetVoid( p_input, "next-chapter" );
}
void VlcWrapper::ToggleChapter(int i_chapter)
{
if( p_input != NULL )
{
var_SetInteger( p_input, "chapter", i_chapter );
}
}
void VlcWrapper::ChapterInfo( int32 &currentIndex, int32 &maxIndex )
{
currentIndex = -1;
maxIndex = -1;
if ( p_input )
{
#if 0
vlc_mutex_lock( &p_input->stream.stream_lock );
maxIndex = p_input->stream.p_selected_area->i_part_nb - 1;
if ( maxIndex > 0)
currentIndex = p_input->stream.p_selected_area->i_part;
else
maxIndex = -1;
vlc_mutex_unlock( &p_input->stream.stream_lock );
#endif
}
}
/****************
* Miscellanous *
****************/
void VlcWrapper::LoadSubFile( const char * psz_file )
{
config_PutPsz( p_intf, "sub-file", strdup( psz_file ) );
}
void VlcWrapper::FilterChange()
{
if( !p_input )
return;
#if 0
vout_thread_t * p_vout;
vlc_mutex_lock( &p_input->stream.stream_lock );
// Warn the vout we are about to change the filter chain
p_vout = (vout_thread_t*)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
FIND_ANYWHERE );
if( p_vout )
{
p_vout->b_filter_change = VLC_TRUE;
vlc_object_release( p_vout );
}
// restart all video stream
for( unsigned int i = 0; i < p_input->stream.i_es_number; i++ )
{
if( ( p_input->stream.pp_es[i]->i_cat == VIDEO_ES ) &&
( p_input->stream.pp_es[i]->p_dec != NULL ) )
{
input_UnselectES( p_input, p_input->stream.pp_es[i] );
input_SelectES( p_input, p_input->stream.pp_es[i] );
}
}
vlc_mutex_unlock( &p_input->stream.stream_lock );
#endif
}
/*****************************************************************************
* VlcWrapper.h: BeOS plugin for vlc (derived from MacOS X port)
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: VlcWrapper.h,v 1.26 2003/06/22 00:40:18 titer Exp $
*
* Authors: Florian G. Pflug <fgp@phlo.org>
* Jon Lech Johansen <jon-vl@nanocrew.net>
* Tony Castley <tony@castley.net>
* Stephan Aßmus <stippi@yellowbites.com>
* Eric Petit <titer@videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
#include <SupportKit.h>
#define SEEKSLIDER_RANGE 2048
class InterfaceWindow;
class VlcWrapper;
/*****************************************************************************
* intf_sys_t: internal variables of the BeOS interface
*****************************************************************************/
struct intf_sys_t
{
msg_subscription_t * p_sub;
InterfaceWindow * p_window;
vlc_bool_t b_loop;
vlc_bool_t b_mute;
int i_part;
int i_channel;
VlcWrapper * p_wrapper;
};
/* Necessary because of i18n */
const char * _AddEllipsis( char * string );
/*****************************************************************************
* VlcWrapper
*****************************************************************************
* This class makes the link between the BeOS interface and the vlc core.
* There is only one VlcWrapper instance at any time, which is stored
* in p_intf->p_sys->p_wrapper
*****************************************************************************/
class VlcWrapper
{
public:
VlcWrapper( intf_thread_t *p_intf );
~VlcWrapper();
/* Input */
void UpdateInput();
bool HasInput();
int InputStatus();
int InputRate();
void InputSetRate( int rate );
BList * GetChannels( int i_cat );
void ToggleLanguage( int i_language );
void ToggleSubtitle( int i_subtitle );
const char * GetTimeAsString();
float GetTimeAsFloat();
void SetTimeAsFloat( float i_offset );
bool IsPlaying();
/* Playlist */
void OpenFiles( BList *o_files, bool replace = true,
int32 index = -1 );
void OpenDisc( BString o_type, BString o_device,
int i_title, int i_chapter );
int PlaylistSize();
char * PlaylistItemName( int );
int PlaylistCurrent();
bool PlaylistPlay();
void PlaylistPause();
void PlaylistStop();
void PlaylistNext();
void PlaylistPrev();
bool PlaylistPlaying();
void GetPlaylistInfo( int32& currentIndex,
int32& maxIndex );
void PlaylistJumpTo( int );
void GetNavCapabilities( bool * canSkipPrev,
bool * canSkipNext );
void NavigatePrev();
void NavigateNext();
/* Playlist manipulation */
bool PlaylistLock() const;
void PlaylistUnlock() const;
// playlist must be locked prior to calling all of these!
void* PlaylistItemAt( int index ) const;
// both functions return a copy of the removed item
// so that it can be added at another index
void* PlaylistRemoveItem( int index ) const;
void* PlaylistRemoveItem( void* item ) const;
// uses playlist_AddItem()
bool PlaylistAddItem( void* item, int index ) const;
void* PlaylistCloneItem( void* item ) const;
// only modifies playlist, doesn't effect playback
void PlaylistSetPlaying( int index ) const;
/* Audio */
unsigned short GetVolume();
void SetVolume( int value );
void VolumeMute();
void VolumeRestore();
bool IsMuted();
/* DVD */
bool IsUsingMenus();
bool HasTitles();
BList * GetTitles();
void PrevTitle();
void NextTitle();
void ToggleTitle( int i_title );
void TitleInfo( int32& currentIndex, int32& maxIndex );
bool HasChapters();
BList * GetChapters();
void PrevChapter();
void NextChapter();
void ToggleChapter( int i_chapter );
void ChapterInfo( int32& currentIndex, int32& maxIndex );
/* Miscellanous */
void LoadSubFile( const char * psz_file );
void FilterChange();
private:
intf_thread_t * p_intf;
input_thread_t * p_input;
playlist_t * p_playlist;
};
...@@ -1065,7 +1065,7 @@ vlc_module_begin(); ...@@ -1065,7 +1065,7 @@ vlc_module_begin();
#else #else
# define KEY_FULLSCREEN 'f' # define KEY_FULLSCREEN 'f'
# define KEY_PLAY_PAUSE ' ' # define KEY_PLAY_PAUSE KEY_SPACE
# define KEY_PAUSE KEY_UNSET # define KEY_PAUSE KEY_UNSET
# define KEY_PLAY KEY_UNSET # define KEY_PLAY KEY_UNSET
# define KEY_FASTER '+' # define KEY_FASTER '+'
......
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