Commit c1881faf authored by Tony Castley's avatar Tony Castley

New simple playlist.

Enable/disable controls depending on what is in the playlist.
parent 9bc943b9
This diff is collapsed.
......@@ -2,7 +2,7 @@
* InterfaceWindow.h: BeOS interface window class prototype
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: InterfaceWindow.h,v 1.10 2001/06/03 12:47:21 sam Exp $
* $Id: InterfaceWindow.h,v 1.11 2001/06/15 09:07:10 tcastley Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Tony Castley <tcastley@mail.powerup.com.au>
......@@ -22,9 +22,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
*****************************************************************************/
class SeekSlider;
class MediaSlider;
class MediaControlView;
class CDMenu : public BMenu
{
......@@ -39,7 +37,8 @@ private:
class LanguageMenu : public BMenu
{
public:
LanguageMenu(const char *name, int menu_kind, intf_thread_t *p_interface);
LanguageMenu(const char *name, int menu_kind,
intf_thread_t *p_interface);
~LanguageMenu();
void AttachedToWindow(void);
private:
......@@ -51,7 +50,8 @@ private:
class InterfaceWindow : public BWindow
{
public:
InterfaceWindow( BRect frame, const char *name, intf_thread_t *p_intf );
InterfaceWindow( BRect frame, const char *name,
intf_thread_t *p_interface );
~InterfaceWindow();
// standard window member
......@@ -59,57 +59,14 @@ public:
virtual void MessageReceived(BMessage *message);
void updateInterface();
SeekSlider * p_seek;
sem_id fScrubSem;
bool fSeeking;
MediaControlView *p_mediaControl;
private:
intf_thread_t *p_intf;
MediaSlider * p_vol;
BCheckBox * p_mute;
bool b_empty_playlist;
BFilePanel *file_panel;
es_descriptor_t * p_audio_es;
es_descriptor_t * p_spu_es;
};
class InterfaceView : public BView
{
public:
InterfaceView();
~InterfaceView();
virtual void MessageReceived(BMessage *message);
};
class MediaSlider : public BSlider
{
public:
MediaSlider(BRect frame,
BMessage *message,
int32 minValue,
int32 maxValue);
~MediaSlider();
virtual void DrawThumb(void);
};
class SeekSlider : public MediaSlider
{
public:
SeekSlider(BRect frame,
InterfaceWindow *owner,
int32 minValue,
int32 maxValue,
thumb_style thumbType = B_TRIANGLE_THUMB);
~SeekSlider();
virtual void MouseDown(BPoint);
virtual void MouseUp(BPoint pt);
virtual void MouseMoved(BPoint pt, uint32 c, const BMessage *m);
private:
InterfaceWindow* fOwner;
bool fMouseDown;
};
......@@ -7,7 +7,7 @@
# Objects
#
PLUGIN_CPP = beos.o aout_beos.o vout_beos.o intf_beos.o InterfaceWindow.o DrawingTidbits.o TransportButton.o
PLUGIN_CPP = beos.o aout_beos.o vout_beos.o intf_beos.o InterfaceWindow.o DrawingTidbits.o TransportButton.o PlayListWindow.o MediaControlView.o
BUILTIN_CPP = $(PLUGIN_CPP:%.o=BUILTIN_%.o)
ALL_OBJ = $(PLUGIN_CPP) $(BUILTIN_CPP)
......
/*****************************************************************************
* MediaControlView.cpp: beos interface
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: MediaControlView.cpp,v 1.1 2001/06/15 09:07:10 tcastley Exp $
*
* Authors: Tony Castley <tony@castley.net>
*
* 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 "defs.h"
/* System headers */
#include <InterfaceKit.h>
#include <AppKit.h>
/* VLC headers */
extern "C"
{
#include "config.h"
#include "common.h"
#include "threads.h"
#include "mtime.h"
#include "main.h"
#include "tests.h"
#include "stream_control.h"
#include "input_ext-intf.h"
#include "interface.h"
#include "intf_msg.h"
#include "intf_playlist.h"
}
/* BeOS interface headers */
#include "MsgVals.h"
#include "Bitmaps.h"
#include "TransportButton.h"
#include "MediaControlView.h"
MediaControlView::MediaControlView( BRect frame )
: BBox( frame, NULL, B_FOLLOW_ALL, B_WILL_DRAW, B_PLAIN_BORDER )
{
float xStart = HORZ_SPACE;
float yStart = VERT_SPACE;
fScrubSem = B_ERROR;
BRect controlRect = BRect(xStart,yStart,
frame.Width() - (HORZ_SPACE * 2), 15);
/* Seek Status */
rgb_color fill_color = {0,255,0};
p_seek = new SeekSlider(controlRect, this, 0, 100, B_TRIANGLE_THUMB);
p_seek->SetValue(0);
p_seek->UseFillColor(true, &fill_color);
AddChild( p_seek );
yStart += 15 + VERT_SPACE;
/* Buttons */
/* Slow play */
controlRect.SetLeftTop(BPoint(xStart, yStart));
controlRect.SetRightBottom(controlRect.LeftTop() + kSkipButtonSize);
xStart += kRewindBitmapWidth;
p_slow = new TransportButton(controlRect, B_EMPTY_STRING,
kSkipBackBitmapBits,
kPressedSkipBackBitmapBits,
kDisabledSkipBackBitmapBits,
new BMessage(SLOWER_PLAY));
AddChild( p_slow );
/* Play Pause */
controlRect.SetLeftTop(BPoint(xStart, yStart));
controlRect.SetRightBottom(controlRect.LeftTop() + kPlayButtonSize);
xStart += kPlayPauseBitmapWidth + 1.0;
p_play = new PlayPauseButton(controlRect, B_EMPTY_STRING,
kPlayButtonBitmapBits,
kPressedPlayButtonBitmapBits,
kDisabledPlayButtonBitmapBits,
kPlayingPlayButtonBitmapBits,
kPressedPlayingPlayButtonBitmapBits,
kPausedPlayButtonBitmapBits,
kPressedPausedPlayButtonBitmapBits,
new BMessage(START_PLAYBACK));
AddChild( p_play );
/* Fast Foward */
controlRect.SetLeftTop(BPoint(xStart, yStart));
controlRect.SetRightBottom(controlRect.LeftTop() + kSkipButtonSize);
xStart += kRewindBitmapWidth;
p_fast = new TransportButton(controlRect, B_EMPTY_STRING,
kSkipForwardBitmapBits,
kPressedSkipForwardBitmapBits,
kDisabledSkipForwardBitmapBits,
new BMessage(FASTER_PLAY));
AddChild( p_fast );
/* Stop */
controlRect.SetLeftTop(BPoint(xStart, yStart));
controlRect.SetRightBottom(controlRect.LeftTop() + kStopButtonSize);
xStart += kStopBitmapWidth;
p_stop = new TransportButton(controlRect, B_EMPTY_STRING,
kStopButtonBitmapBits,
kPressedStopButtonBitmapBits,
kDisabledStopButtonBitmapBits,
new BMessage(STOP_PLAYBACK));
AddChild( p_stop );
controlRect.SetLeftTop(BPoint(xStart + 5, yStart + 6));
controlRect.SetRightBottom(controlRect.LeftTop() + kSpeakerButtonSize);
xStart += kSpeakerIconBitmapWidth;
p_mute = new TransportButton(controlRect, B_EMPTY_STRING,
kSpeakerIconBits,
kPressedSpeakerIconBits,
kSpeakerIconBits,
new BMessage(VOLUME_MUTE));
AddChild( p_mute );
/* Volume Slider */
p_vol = new MediaSlider(BRect(xStart,20,255,30), new BMessage(VOLUME_CHG),
0, VOLUME_MAX);
p_vol->SetValue(VOLUME_DEFAULT);
p_vol->UseFillColor(true, &fill_color);
AddChild( p_vol );
}
MediaControlView::~MediaControlView()
{
}
void MediaControlView::MessageReceived(BMessage *message)
{
}
void MediaControlView::SetProgress(float position)
{
p_seek->SetValue(position);
}
void MediaControlView::SetStatus(int status, int rate)
{
}
void MediaControlView::SetEnabled(bool enabled)
{
p_slow->SetEnabled(enabled);
p_play->SetEnabled(enabled);
p_fast->SetEnabled(enabled);
p_stop->SetEnabled(enabled);
p_mute->SetEnabled(enabled);
p_vol->SetEnabled(enabled);
p_seek->SetEnabled(enabled);
}
int32 MediaControlView::GetSeekTo()
{
return p_seek->seekTo;
}
int32 MediaControlView::GetVolume()
{
return p_vol->Value();
}
/*****************************************************************************
* MediaSlider
*****************************************************************************/
MediaSlider::MediaSlider( BRect frame, BMessage *p_message,
int32 i_min, int32 i_max )
:BSlider(frame, NULL, NULL, p_message, i_min, i_max )
{
}
MediaSlider::~MediaSlider()
{
}
void MediaSlider::DrawThumb(void)
{
BRect r;
BView *v;
rgb_color black = {0,0,0};
r = ThumbFrame();
v = OffscreenView();
if(IsEnabled())
{
v->SetHighColor(black);
}
else
{
v->SetHighColor(tint_color(black, B_LIGHTEN_2_TINT));
}
r.InsetBy(r.IntegerWidth()/4, r.IntegerHeight()/(4 * r.IntegerWidth() / r.IntegerHeight()));
v->StrokeEllipse(r);
if(IsEnabled())
{
v->SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
}
else
{
v->SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_LIGHTEN_2_TINT));
}
r.InsetBy(1,1);
v->FillEllipse(r);
}
/*****************************************************************************
* SeekSlider
*****************************************************************************/
SeekSlider::SeekSlider( BRect frame, MediaControlView *p_owner, int32 i_min,
int32 i_max, thumb_style thumbType = B_TRIANGLE_THUMB )
:MediaSlider( frame, NULL, i_min, i_max )
{
fOwner = p_owner;
fMouseDown = false;
}
SeekSlider::~SeekSlider()
{
}
/*****************************************************************************
* SeekSlider::MouseDown
*****************************************************************************/
void SeekSlider::MouseDown(BPoint where)
{
BSlider::MouseDown(where);
fOwner->fScrubSem = create_sem(0, "Vlc::fScrubSem");
fMouseDown = true;
}
/*****************************************************************************
* SeekSlider::MouseUp
*****************************************************************************/
void SeekSlider::MouseMoved(BPoint where, uint32 code, const BMessage *message)
{
BSlider::MouseMoved(where, code, message);
if (!fMouseDown)
return;
seekTo = ValueForPoint(where);
release_sem(fOwner->fScrubSem);
}
/*****************************************************************************
* SeekSlider::MouseUp
*****************************************************************************/
void SeekSlider::MouseUp(BPoint where)
{
BSlider::MouseUp(where);
seekTo = ValueForPoint(where);
delete_sem(fOwner->fScrubSem);
fOwner->fScrubSem = B_ERROR;
fMouseDown = false;
}
/*****************************************************************************
* MediaControlView.h: beos interface
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: MediaControlView.h,v 1.1 2001/06/15 09:07:10 tcastley Exp $
*
* Authors: Tony Castley <tony@castley.net>
*
* 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.
*****************************************************************************/
#define HORZ_SPACE 5.0
#define VERT_SPACE 5.0
class TransportButton;
class PlayPauseButton;
class MediaSlider;
class SeekSlider;
class MediaControlView : public BBox
{
public:
MediaControlView( BRect frame );
~MediaControlView();
virtual void MessageReceived(BMessage *message);
void SetProgress(float position);
void SetStatus(int status, int rate);
void SetEnabled(bool);
int32 GetSeekTo();
int32 GetVolume();
sem_id fScrubSem;
bool fSeeking;
private:
MediaSlider * p_vol;
SeekSlider * p_seek;
TransportButton* p_slow;
PlayPauseButton* p_play;
TransportButton* p_fast;
TransportButton* p_stop;
TransportButton* p_mute;
int current_rate;
int current_status;
};
class MediaSlider : public BSlider
{
public:
MediaSlider(BRect frame,
BMessage *message,
int32 minValue,
int32 maxValue);
~MediaSlider();
virtual void DrawThumb(void);
};
class SeekSlider : public MediaSlider
{
public:
SeekSlider(BRect frame,
MediaControlView *owner,
int32 minValue,
int32 maxValue,
thumb_style thumbType = B_TRIANGLE_THUMB);
~SeekSlider();
int32 seekTo;
virtual void MouseDown(BPoint);
virtual void MouseUp(BPoint pt);
virtual void MouseMoved(BPoint pt, uint32 c, const BMessage *m);
private:
MediaControlView* fOwner;
bool fMouseDown;
};
......@@ -2,7 +2,7 @@
* MsgVals.h
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: MsgVals.h,v 1.5 2001/03/25 17:09:14 richards Exp $
* $Id: MsgVals.h,v 1.6 2001/06/15 09:07:10 tcastley Exp $
*
* Authors: Tony Castley <tcastley@mail.powerup.com.au>
*
......@@ -27,6 +27,7 @@
const uint32 OPEN_FILE = 'OPFL';
const uint32 OPEN_DVD = 'OPDV';
const uint32 OPEN_PLAYLIST = 'OPPL';
const uint32 STOP_PLAYBACK = 'STPL';
const uint32 START_PLAYBACK = 'PLAY';
const uint32 PAUSE_PLAYBACK = 'PAPL';
......
/*****************************************************************************
* PlayListWindow.cpp: beos interface
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: PlayListWindow.cpp,v 1.1 2001/06/15 09:07:10 tcastley Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
* Tony Castley <tony@castley.net>
* Richard Shepherd <richard@rshepherd.demon.co.uk>
*
* 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 "defs.h"
/* System headers */
#include <InterfaceKit.h>
#include <StorageKit.h>
/* VLC headers */
extern "C"
{
#include "config.h"
#include "common.h"
#include "threads.h"
#include "mtime.h"
#include "main.h"
#include "tests.h"
#include "stream_control.h"
#include "input_ext-intf.h"
#include "interface.h"
#include "intf_msg.h"
#include "intf_playlist.h"
}
/* BeOS interface headers */
#include "InterfaceWindow.h"
#include "PlayListWindow.h"
#include "MsgVals.h"
/*****************************************************************************
* PlayListWindow
*****************************************************************************/
PlayListWindow::PlayListWindow( BRect frame, const char *name,
playlist_t *p_pl)
: BWindow( frame, name, B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
B_WILL_ACCEPT_FIRST_CLICK | B_ASYNCHRONOUS_CONTROLS )
{
SetName( "playlist" );
SetTitle(name);
p_playlist = p_pl;
/* set up the main menu */
BMenuBar *menu_bar;
menu_bar = new BMenuBar(BRect(0,0,0,0), "main menu");
AddChild( menu_bar );
BMenu *mFile;
/* Add the file Menu */
BMenuItem *mItem;
menu_bar->AddItem( mFile = new BMenu( "File" ) );
menu_bar->ResizeToPreferred();
mFile->AddItem( mItem = new BMenuItem( "Open File" B_UTF8_ELLIPSIS,
new BMessage(OPEN_FILE), 'O') );
CDMenu *cd_menu = new CDMenu( "Open Disc" );
mFile->AddItem( cd_menu );
BRect rect = Bounds();
rect.top += menu_bar->Bounds().IntegerHeight() + 1;
BView *p_view = new BView(rect, NULL, B_FOLLOW_ALL_SIDES, B_WILL_DRAW);
p_listview = new BListView(rect, "PlayList",
B_MULTIPLE_SELECTION_LIST);
for (int i=0; i < p_playlist->i_size; i++)
{
p_listview->AddItem(new BStringItem(p_playlist->p_item[i].psz_name));
}
p_view->AddChild(new BScrollView("scroll_playlist", p_listview,
B_FOLLOW_LEFT | B_FOLLOW_TOP, 0, false, true));
AddChild(p_view);
}
PlayListWindow::~PlayListWindow()
{
}
/*****************************************************************************
* PlayListWindow::MessageReceived
*****************************************************************************/
void PlayListWindow::MessageReceived( BMessage * p_message )
{
Activate();
switch( p_message->what )
{
case OPEN_FILE:
if( file_panel )
{
file_panel->Show();
break;
}
file_panel = new BFilePanel();
file_panel->SetTarget( this );
file_panel->Show();
break;
case OPEN_DVD:
const char *psz_device;
char psz_source[ B_FILE_NAME_LENGTH + 4 ];
if( p_message->FindString("device", &psz_device) != B_ERROR )
{
snprintf( psz_source, B_FILE_NAME_LENGTH + 4,
"dvd:%s", psz_device );
psz_source[ strlen(psz_source) ] = '\0';
intf_PlaylistAdd( p_playlist, PLAYLIST_END, (char*)psz_source );
p_listview->AddItem(new BStringItem((char*)psz_source));
}
case B_REFS_RECEIVED:
case B_SIMPLE_DATA:
{
entry_ref ref;
if( p_message->FindRef( "refs", &ref ) == B_OK )
{
BPath path( &ref );
intf_PlaylistAdd( p_playlist,
PLAYLIST_END, (char*)path.Path() );
p_listview->AddItem(new BStringItem((char*)path.Path()));
}
}
break;
default:
BWindow::MessageReceived( p_message );
break;
}
}
/*****************************************************************************
* PlayListWindow.h: BeOS interface window class prototype
*****************************************************************************
* Copyright (C) 1999, 2000, 2001 VideoLAN
* $Id: PlayListWindow.h,v 1.1 2001/06/15 09:07:10 tcastley Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Tony Castley <tcastley@mail.powerup.com.au>
* Richard Shepherd <richard@rshepherd.demon.co.uk>
*
* 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.
*****************************************************************************/
class CDMenu;
class PlayListWindow : public BWindow
{
public:
PlayListWindow( BRect frame, const char *name, playlist_t *p_pl);
~PlayListWindow();
// standard window member
virtual void MessageReceived(BMessage *message);
private:
playlist_t *p_playlist;
BListView *p_listview;
BFilePanel *file_panel;
};
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