Applied Patch by Frederik Modeen with some changes by myself:

* Created Settings window similar to R5 MediaPlayer.
* Prepared loading and saving of settings.
* Settings menu entry is hidden for the time being, since these new settings
  do not actually have any effect yet.
* Prepared loading and saving of Playlists.
* ZETA Playlists can be dropped on the Player and should load fine.
Myself:
* Cleanup in MainWindow.cpp for line width limit.

To Frederik: I removed the buttons again from the Playlist window, since they
don't do anything yet, and the features are available from the menu as well.
An icon bar would be better, IMHO.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24715 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus 2008-04-01 07:42:35 +00:00
parent fb16552f1d
commit 1b7f76bcfc
7 changed files with 313 additions and 120 deletions

View File

@ -9,6 +9,7 @@ local sourceDirs =
playlist playlist
supplier supplier
support support
settings
; ;
local sourceDir ; local sourceDir ;
@ -28,6 +29,10 @@ Application MediaPlayer :
PlaylistWindow.cpp PlaylistWindow.cpp
RemovePLItemsCommand.cpp RemovePLItemsCommand.cpp
# supplier
Settings.cpp
SettingsWindow.cpp
# supplier # supplier
AudioSupplier.cpp AudioSupplier.cpp
MediaTrackAudioSupplier.cpp MediaTrackAudioSupplier.cpp
@ -42,6 +47,8 @@ Application MediaPlayer :
ListenerAdapter.cpp ListenerAdapter.cpp
Notifier.cpp Notifier.cpp
RWLocker.cpp RWLocker.cpp
FileReadWrite.cpp
TPreferences.cpp
# . # .
Controller.cpp Controller.cpp
@ -59,7 +66,7 @@ Application MediaPlayer :
VideoView.cpp VideoView.cpp
VolumeSlider.cpp VolumeSlider.cpp
: be media tracker translation $(TARGET_LIBSTDC++) : be media tracker translation textencoding $(TARGET_LIBSTDC++)
: MediaPlayer.rdef : MediaPlayer.rdef
; ;

View File

@ -2,8 +2,8 @@
* MainWin.cpp - Media Player for the Haiku Operating System * MainWin.cpp - Media Player for the Haiku Operating System
* *
* Copyright (C) 2006 Marcus Overhagen <marcus@overhagen.de> * Copyright (C) 2006 Marcus Overhagen <marcus@overhagen.de>
* Copyright (C) 2007 Stephan Aßmus <superstippi@gmx.de> * Copyright (C) 2007-2008 Stephan Aßmus <superstippi@gmx.de> (GPL->MIT ok)
* Copyright (C) 2007 Fredrik Modéen <fredrik@modeen.se> * Copyright (C) 2007-2008 Fredrik Modéen <fredrik@modeen.se>
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -16,7 +16,8 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software * along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
* USA.
* *
*/ */
#include "MainWin.h" #include "MainWin.h"
@ -42,6 +43,7 @@
#include "MainApp.h" #include "MainApp.h"
#include "PlaylistObserver.h" #include "PlaylistObserver.h"
#include "PlaylistWindow.h" #include "PlaylistWindow.h"
#include "SettingsWindow.h"
#define NAME "MediaPlayer" #define NAME "MediaPlayer"
#define MIN_WIDTH 250 #define MIN_WIDTH 250
@ -70,7 +72,7 @@ enum {
M_TOGGLE_NO_BORDER_NO_MENU_NO_CONTROLS, M_TOGGLE_NO_BORDER_NO_MENU_NO_CONTROLS,
M_TOGGLE_ALWAYS_ON_TOP, M_TOGGLE_ALWAYS_ON_TOP,
M_TOGGLE_KEEP_ASPECT_RATIO, M_TOGGLE_KEEP_ASPECT_RATIO,
M_PREFERENCES, M_SETTINGS,
M_VOLUME_UP, M_VOLUME_UP,
M_VOLUME_DOWN, M_VOLUME_DOWN,
M_SKIP_NEXT, M_SKIP_NEXT,
@ -94,10 +96,12 @@ enum {
MainWin::MainWin() MainWin::MainWin()
: BWindow(BRect(100,100,350,300), NAME, B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS /* | B_WILL_ACCEPT_FIRST_CLICK */) : BWindow(BRect(100,100,400,300), NAME, B_TITLED_WINDOW,
B_ASYNCHRONOUS_CONTROLS /* | B_WILL_ACCEPT_FIRST_CLICK */)
, fFilePanel(NULL) , fFilePanel(NULL)
, fInfoWin(NULL) , fInfoWin(NULL)
, fPlaylistWindow(NULL) , fPlaylistWindow(NULL)
, fSettingsWindow(NULL)
, fHasFile(false) , fHasFile(false)
, fHasVideo(false) , fHasVideo(false)
, fHasAudio(false) , fHasAudio(false)
@ -127,7 +131,8 @@ MainWin::MainWin()
BRect rect = Bounds(); BRect rect = Bounds();
// background // background
fBackground = new BView(rect, "background", B_FOLLOW_ALL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE); fBackground = new BView(rect, "background", B_FOLLOW_ALL,
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE);
fBackground->SetViewColor(0,0,0); fBackground->SetViewColor(0,0,0);
AddChild(fBackground); AddChild(fBackground);
@ -141,12 +146,15 @@ MainWin::MainWin()
fMenuBar->SetResizingMode(B_FOLLOW_NONE); fMenuBar->SetResizingMode(B_FOLLOW_NONE);
// video view // video view
rect = BRect(0, fMenuBarHeight, fBackground->Bounds().right, fMenuBarHeight + 10); rect = BRect(0, fMenuBarHeight, fBackground->Bounds().right,
fVideoView = new VideoView(rect, "video display", B_FOLLOW_NONE, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE); fMenuBarHeight + 10);
fVideoView = new VideoView(rect, "video display", B_FOLLOW_NONE,
B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE);
fBackground->AddChild(fVideoView); fBackground->AddChild(fVideoView);
// controls // controls
rect = BRect(0, fMenuBarHeight + 11, fBackground->Bounds().right, fBackground->Bounds().bottom); rect = BRect(0, fMenuBarHeight + 11, fBackground->Bounds().right,
fBackground->Bounds().bottom);
fControls = new ControllerView(rect, fController, fPlaylist); fControls = new ControllerView(rect, fController, fPlaylist);
fBackground->AddChild(fControls); fBackground->AddChild(fControls);
fControls->ResizeToPreferred(); fControls->ResizeToPreferred();
@ -155,7 +163,8 @@ MainWin::MainWin()
fControls->SetResizingMode(B_FOLLOW_BOTTOM | B_FOLLOW_LEFT_RIGHT); fControls->SetResizingMode(B_FOLLOW_BOTTOM | B_FOLLOW_LEFT_RIGHT);
// fControls->MoveTo(0, fBackground->Bounds().bottom - fControlsHeight + 1); // fControls->MoveTo(0, fBackground->Bounds().bottom - fControlsHeight + 1);
// fVideoView->ResizeTo(fBackground->Bounds().Width(), fBackground->Bounds().Height() - fMenuBarHeight - fControlsHeight); // fVideoView->ResizeTo(fBackground->Bounds().Width(),
// fBackground->Bounds().Height() - fMenuBarHeight - fControlsHeight);
fPlaylist->AddListener(fPlaylistObserver); fPlaylist->AddListener(fPlaylistObserver);
fController->SetVideoView(fVideoView); fController->SetVideoView(fVideoView);
@ -168,9 +177,15 @@ MainWin::MainWin()
_SetupWindow(); _SetupWindow();
// setup the settings window now, we need to have it
fSettingsWindow = new SettingsWindow(BRect(150, 150, 450, 520));
fSettingsWindow->Hide();
fSettingsWindow->Show();
// setup the playlist window now, we need to have it // setup the playlist window now, we need to have it
// running for the undo/redo playlist editing // running for the undo/redo playlist editing
fPlaylistWindow = new PlaylistWindow(BRect(150, 150, 400, 500), fPlaylist, fController); fPlaylistWindow = new PlaylistWindow(BRect(150, 150, 500, 600), fPlaylist,
fController);
fPlaylistWindow->Hide(); fPlaylistWindow->Hide();
fPlaylistWindow->Show(); fPlaylistWindow->Show();
// this makes sure the window thread is running without // this makes sure the window thread is running without
@ -200,6 +215,11 @@ MainWin::~MainWin()
fPlaylistWindow->Lock(); fPlaylistWindow->Lock();
fPlaylistWindow->Quit(); fPlaylistWindow->Quit();
} }
if (fSettingsWindow) {
fSettingsWindow->Lock();
fSettingsWindow->Quit();
}
delete fPlaylist; delete fPlaylist;
delete fController; delete fController;
@ -220,10 +240,13 @@ MainWin::FrameResized(float new_width, float new_height)
bool no_menu = fNoMenu || fIsFullscreen; bool no_menu = fNoMenu || fIsFullscreen;
bool no_controls = fNoControls || fIsFullscreen; bool no_controls = fNoControls || fIsFullscreen;
printf("FrameResized enter: new_width %.0f, new_height %.0f\n", new_width, new_height); printf("FrameResized enter: new_width %.0f, new_height %.0f\n",
new_width, new_height);
int max_video_width = int(new_width) + 1; int max_video_width = int(new_width) + 1;
int max_video_height = int(new_height) + 1 - (no_menu ? 0 : fMenuBarHeight) - (no_controls ? 0 : fControlsHeight); int max_video_height = int(new_height) + 1
- (no_menu ? 0 : fMenuBarHeight)
- (no_controls ? 0 : fControlsHeight);
ASSERT(max_video_height >= 0); ASSERT(max_video_height >= 0);
@ -374,7 +397,8 @@ MainWin::MessageReceived(BMessage *msg)
fPlaylist->SetCurrentRefIndex(fPlaylist->CurrentRefIndex() + 1); fPlaylist->SetCurrentRefIndex(fPlaylist->CurrentRefIndex() + 1);
break; break;
case MSG_CONTROLLER_FILE_CHANGED: case MSG_CONTROLLER_FILE_CHANGED:
// TODO: move all other GUI changes as a reaction to this notification // TODO: move all other GUI changes as a reaction to this
// notification
// _UpdatePlaylistMenu(); // _UpdatePlaylistMenu();
break; break;
case MSG_CONTROLLER_VIDEO_TRACK_CHANGED: { case MSG_CONTROLLER_VIDEO_TRACK_CHANGED: {
@ -441,7 +465,7 @@ MainWin::MessageReceived(BMessage *msg)
case B_ABOUT_REQUESTED: case B_ABOUT_REQUESTED:
BAlert *alert; BAlert *alert;
alert = new BAlert("about", NAME"\n\n Written by Marcus Overhagen " alert = new BAlert("about", NAME"\n\n Written by Marcus Overhagen "
"and Stephan Aßmus", "Thanks"); ", Stephan Aßmus and Frederik Modéen", "Thanks");
if (fAlwaysOnTop) { if (fAlwaysOnTop) {
_ToggleAlwaysOnTop(); _ToggleAlwaysOnTop();
alert->Go(); alert->Go();
@ -536,7 +560,7 @@ MainWin::MessageReceived(BMessage *msg)
printf("B_RELEASE_OVERLAY_LOCK\n"); printf("B_RELEASE_OVERLAY_LOCK\n");
fVideoView->OverlayLockRelease(); fVideoView->OverlayLockRelease();
break; break;
case B_MOUSE_WHEEL_CHANGED: case B_MOUSE_WHEEL_CHANGED:
{ {
printf("B_MOUSE_WHEEL_CHANGED\n"); printf("B_MOUSE_WHEEL_CHANGED\n");
@ -593,16 +617,19 @@ MainWin::MessageReceived(BMessage *msg)
case M_ASPECT_544_576: case M_ASPECT_544_576:
VideoFormatChange(544, 576, 1.41176, 1.0); VideoFormatChange(544, 576, 1.41176, 1.0);
break; break;
/*
case M_PREFERENCES: case M_SETTINGS:
ShowSettingsWindow();
break; break;
/*
default: default:
if (msg->what >= M_SELECT_CHANNEL && msg->what <= M_SELECT_CHANNEL_END) { if (msg->what >= M_SELECT_CHANNEL
&& msg->what <= M_SELECT_CHANNEL_END) {
SelectChannel(msg->what - M_SELECT_CHANNEL); SelectChannel(msg->what - M_SELECT_CHANNEL);
break; break;
} }
if (msg->what >= M_SELECT_INTERFACE && msg->what <= M_SELECT_INTERFACE_END) { if (msg->what >= M_SELECT_INTERFACE
&& msg->what <= M_SELECT_INTERFACE_END) {
SelectInterface(msg->what - M_SELECT_INTERFACE - 1); SelectInterface(msg->what - M_SELECT_INTERFACE - 1);
break; break;
} }
@ -647,8 +674,6 @@ MainWin::OpenFile(const entry_ref &ref)
(new BAlert("error", s, "OK"))->Go(); (new BAlert("error", s, "OK"))->Go();
} else { } else {
// just go to the next file and don't bother user // just go to the next file and don't bother user
// TODO: this makes it impossible to skip backwards
// over a non recognized file!
fPlaylist->SetCurrentRefIndex(fPlaylist->CurrentRefIndex() + 1); fPlaylist->SetCurrentRefIndex(fPlaylist->CurrentRefIndex() + 1);
} }
fHasFile = false; fHasFile = false;
@ -664,6 +689,7 @@ MainWin::OpenFile(const entry_ref &ref)
_SetupWindow(); _SetupWindow();
} }
void void
MainWin::ShowFileInfo() MainWin::ShowFileInfo()
{ {
@ -694,16 +720,32 @@ MainWin::ShowPlaylistWindow()
void void
MainWin::VideoFormatChange(int width, int height, float width_scale, float height_scale) MainWin::ShowSettingsWindow()
{
if (fSettingsWindow->Lock()) {
if (fSettingsWindow->IsHidden())
fSettingsWindow->Show();
else
fSettingsWindow->Activate();
fSettingsWindow->Unlock();
}
}
void
MainWin::VideoFormatChange(int width, int height, float width_scale,
float height_scale)
{ {
// called when video format or aspect ratio changes // called when video format or aspect ratio changes
printf("VideoFormatChange enter: width %d, height %d, width_scale %.6f, height_scale %.6f\n", width, height, width_scale, height_scale); printf("VideoFormatChange enter: width %d, height %d, width_scale %.6f, "
"height_scale %.6f\n", width, height, width_scale, height_scale);
if (width_scale < 1.0 && height_scale >= 1.0) { if (width_scale < 1.0 && height_scale >= 1.0) {
width_scale = 1.0 / width_scale; width_scale = 1.0 / width_scale;
height_scale = 1.0 / height_scale; height_scale = 1.0 / height_scale;
printf("inverting! new values: width_scale %.6f, height_scale %.6f\n", width_scale, height_scale); printf("inverting! new values: width_scale %.6f, height_scale %.6f\n",
width_scale, height_scale);
} }
fSourceWidth = width; fSourceWidth = width;
@ -740,7 +782,6 @@ void
MainWin::_SetupWindow() MainWin::_SetupWindow()
{ {
printf("MainWin::_SetupWindow\n"); printf("MainWin::_SetupWindow\n");
// Populate the track menus // Populate the track menus
_SetupTrackMenus(); _SetupTrackMenus();
// Enable both if a file was loaded // Enable both if a file was loaded
@ -752,8 +793,7 @@ MainWin::_SetupWindow()
fVideoMenu->SetEnabled(fHasVideo); fVideoMenu->SetEnabled(fHasVideo);
fAudioMenu->SetEnabled(fHasAudio); fAudioMenu->SetEnabled(fHasAudio);
fDebugMenu->SetEnabled(fHasVideo); // fDebugMenu->SetEnabled(fHasVideo);
if (fHasVideo) { if (fHasVideo) {
fController->GetSize(&fSourceWidth, &fSourceHeight); fController->GetSize(&fSourceWidth, &fSourceHeight);
fWidthScale = 1.0; fWidthScale = 1.0;
@ -764,7 +804,6 @@ MainWin::_SetupWindow()
fWidthScale = 1.0; fWidthScale = 1.0;
fHeightScale = 1.0; fHeightScale = 1.0;
} }
_UpdateControlsEnabledStatus(); _UpdateControlsEnabledStatus();
_ResizeWindow(100); _ResizeWindow(100);
@ -783,7 +822,7 @@ MainWin::_CreateMenu()
fSettingsMenu = new BMenu("Settings"); fSettingsMenu = new BMenu("Settings");
fAudioTrackMenu = new BMenu("Track"); fAudioTrackMenu = new BMenu("Track");
fVideoTrackMenu = new BMenu("Track"); fVideoTrackMenu = new BMenu("Track");
fDebugMenu = new BMenu("Debug"); // fDebugMenu = new BMenu("Debug");
fMenuBar->AddItem(fFileMenu); fMenuBar->AddItem(fFileMenu);
fMenuBar->AddItem(fAudioMenu); fMenuBar->AddItem(fAudioMenu);
@ -791,10 +830,13 @@ MainWin::_CreateMenu()
fMenuBar->AddItem(fSettingsMenu); fMenuBar->AddItem(fSettingsMenu);
// fMenuBar->AddItem(fDebugMenu); // fMenuBar->AddItem(fDebugMenu);
fFileMenu->AddItem(new BMenuItem("New Player"B_UTF8_ELLIPSIS, new BMessage(M_FILE_NEWPLAYER), 'N', B_COMMAND_KEY)); fFileMenu->AddItem(new BMenuItem("New Player"B_UTF8_ELLIPSIS,
new BMessage(M_FILE_NEWPLAYER), 'N'));
fFileMenu->AddSeparatorItem(); fFileMenu->AddSeparatorItem();
fFileMenu->AddItem(new BMenuItem("Open File"B_UTF8_ELLIPSIS, new BMessage(M_FILE_OPEN), 'O', B_COMMAND_KEY)); fFileMenu->AddItem(new BMenuItem("Open File"B_UTF8_ELLIPSIS,
fFileMenu->AddItem(new BMenuItem("File Info"B_UTF8_ELLIPSIS, new BMessage(M_FILE_INFO), 'I', B_COMMAND_KEY)); new BMessage(M_FILE_OPEN), 'O'));
fFileMenu->AddItem(new BMenuItem("File Info"B_UTF8_ELLIPSIS,
new BMessage(M_FILE_INFO), 'I'));
fFileMenu->AddItem(fPlaylistMenu); fFileMenu->AddItem(fPlaylistMenu);
fPlaylistMenu->Superitem()->SetShortcut('P', B_COMMAND_KEY); fPlaylistMenu->Superitem()->SetShortcut('P', B_COMMAND_KEY);
fPlaylistMenu->Superitem()->SetMessage(new BMessage(M_FILE_PLAYLIST)); fPlaylistMenu->Superitem()->SetMessage(new BMessage(M_FILE_PLAYLIST));
@ -803,8 +845,8 @@ MainWin::_CreateMenu()
fFileMenu->AddItem(new BMenuItem("About" NAME B_UTF8_ELLIPSIS, fFileMenu->AddItem(new BMenuItem("About" NAME B_UTF8_ELLIPSIS,
new BMessage(B_ABOUT_REQUESTED))); new BMessage(B_ABOUT_REQUESTED)));
fFileMenu->AddSeparatorItem(); fFileMenu->AddSeparatorItem();
fFileMenu->AddItem(new BMenuItem("Close", new BMessage(M_FILE_CLOSE), 'W', B_COMMAND_KEY)); fFileMenu->AddItem(new BMenuItem("Close", new BMessage(M_FILE_CLOSE), 'W'));
fFileMenu->AddItem(new BMenuItem("Quit", new BMessage(M_FILE_QUIT), 'Q', B_COMMAND_KEY)); fFileMenu->AddItem(new BMenuItem("Quit", new BMessage(M_FILE_QUIT), 'Q'));
fPlaylistMenu->SetRadioMode(true); fPlaylistMenu->SetRadioMode(true);
@ -812,40 +854,51 @@ MainWin::_CreateMenu()
fVideoMenu->AddItem(fVideoTrackMenu); fVideoMenu->AddItem(fVideoTrackMenu);
fVideoMenu->AddSeparatorItem(); fVideoMenu->AddSeparatorItem();
fVideoMenu->AddItem(new BMenuItem("50% scale", new BMessage(M_VIEW_50), '0', B_COMMAND_KEY)); fVideoMenu->AddItem(new BMenuItem("50% scale",
fVideoMenu->AddItem(new BMenuItem("100% scale", new BMessage(M_VIEW_100), '1', B_COMMAND_KEY)); new BMessage(M_VIEW_50), '0'));
fVideoMenu->AddItem(new BMenuItem("200% scale", new BMessage(M_VIEW_200), '2', B_COMMAND_KEY)); fVideoMenu->AddItem(new BMenuItem("100% scale",
fVideoMenu->AddItem(new BMenuItem("300% scale", new BMessage(M_VIEW_300), '3', B_COMMAND_KEY)); new BMessage(M_VIEW_100), '1'));
fVideoMenu->AddItem(new BMenuItem("400% scale", new BMessage(M_VIEW_400), '4', B_COMMAND_KEY)); fVideoMenu->AddItem(new BMenuItem("200% scale",
new BMessage(M_VIEW_200), '2'));
fVideoMenu->AddItem(new BMenuItem("300% scale",
new BMessage(M_VIEW_300), '3'));
fVideoMenu->AddItem(new BMenuItem("400% scale",
new BMessage(M_VIEW_400), '4'));
fVideoMenu->AddSeparatorItem(); fVideoMenu->AddSeparatorItem();
fVideoMenu->AddItem(new BMenuItem("Full Screen", new BMessage(M_TOGGLE_FULLSCREEN), 'F', B_COMMAND_KEY)); fVideoMenu->AddItem(new BMenuItem("Full Screen",
fVideoMenu->AddItem(new BMenuItem("Keep Aspect Ratio", new BMessage(M_TOGGLE_KEEP_ASPECT_RATIO), 'K', B_COMMAND_KEY)); new BMessage(M_TOGGLE_FULLSCREEN), 'F'));
fVideoMenu->AddItem(new BMenuItem("Keep Aspect Ratio",
new BMessage(M_TOGGLE_KEEP_ASPECT_RATIO), 'K'));
fSettingsMenu->AddItem(new BMenuItem("No Menu", new BMessage(M_TOGGLE_NO_MENU), 'M', B_COMMAND_KEY)); fSettingsMenu->AddItem(new BMenuItem("No Menu",
fSettingsMenu->AddItem(new BMenuItem("No Border", new BMessage(M_TOGGLE_NO_BORDER), 'B', B_COMMAND_KEY)); new BMessage(M_TOGGLE_NO_MENU), 'M'));
fSettingsMenu->AddItem(new BMenuItem("No Controls", new BMessage(M_TOGGLE_NO_CONTROLS), 'C', B_COMMAND_KEY)); fSettingsMenu->AddItem(new BMenuItem("No Border",
fSettingsMenu->AddItem(new BMenuItem("Always on Top", new BMessage(M_TOGGLE_ALWAYS_ON_TOP), 'T', B_COMMAND_KEY)); new BMessage(M_TOGGLE_NO_BORDER), 'B'));
fSettingsMenu->AddItem(new BMenuItem("No Controls",
new BMessage(M_TOGGLE_NO_CONTROLS), 'C'));
fSettingsMenu->AddItem(new BMenuItem("Always on Top",
new BMessage(M_TOGGLE_ALWAYS_ON_TOP), 'T'));
// fSettingsMenu->AddSeparatorItem(); // fSettingsMenu->AddSeparatorItem();
// fSettingsMenu->AddItem(new BMenuItem("Preferences"B_UTF8_ELLIPSIS, new BMessage(M_PREFERENCES), 'P', B_COMMAND_KEY)); // fSettingsMenu->AddItem(new BMenuItem("Settings"B_UTF8_ELLIPSIS,
// new BMessage(M_SETTINGS), 'S'));
fDebugMenu->AddItem(new BMenuItem("pixel aspect ratio 1.00000:1", new BMessage(M_ASPECT_100000_1))); // fDebugMenu->AddItem(new BMenuItem("pixel aspect ratio 1.00000:1",
fDebugMenu->AddItem(new BMenuItem("pixel aspect ratio 1.06666:1", new BMessage(M_ASPECT_106666_1))); // new BMessage(M_ASPECT_100000_1)));
fDebugMenu->AddItem(new BMenuItem("pixel aspect ratio 1.09091:1", new BMessage(M_ASPECT_109091_1))); // fDebugMenu->AddItem(new BMenuItem("pixel aspect ratio 1.06666:1",
fDebugMenu->AddItem(new BMenuItem("pixel aspect ratio 1.41176:1", new BMessage(M_ASPECT_141176_1))); // new BMessage(M_ASPECT_106666_1)));
fDebugMenu->AddItem(new BMenuItem("force 720 x 576, display aspect 4:3", new BMessage(M_ASPECT_720_576))); // fDebugMenu->AddItem(new BMenuItem("pixel aspect ratio 1.09091:1",
fDebugMenu->AddItem(new BMenuItem("force 704 x 576, display aspect 4:3", new BMessage(M_ASPECT_704_576))); // new BMessage(M_ASPECT_109091_1)));
fDebugMenu->AddItem(new BMenuItem("force 544 x 576, display aspect 4:3", new BMessage(M_ASPECT_544_576))); // fDebugMenu->AddItem(new BMenuItem("pixel aspect ratio 1.41176:1",
// new BMessage(M_ASPECT_141176_1)));
// fDebugMenu->AddItem(new BMenuItem("force 720 x 576, display aspect 4:3",
// new BMessage(M_ASPECT_720_576)));
// fDebugMenu->AddItem(new BMenuItem("force 704 x 576, display aspect 4:3",
// new BMessage(M_ASPECT_704_576)));
// fDebugMenu->AddItem(new BMenuItem("force 544 x 576, display aspect 4:3",
// new BMessage(M_ASPECT_544_576)));
fAudioTrackMenu->SetRadioMode(true); fAudioTrackMenu->SetRadioMode(true);
fVideoTrackMenu->SetRadioMode(true); fVideoTrackMenu->SetRadioMode(true);
/*
fSettingsMenu->ItemAt(3)->SetMarked(fIsFullscreen);
fSettingsMenu->ItemAt(5)->SetMarked(fNoMenu);
fSettingsMenu->ItemAt(6)->SetMarked(fNoBorder);
fSettingsMenu->ItemAt(7)->SetMarked(fAlwaysOnTop);
fSettingsMenu->ItemAt(8)->SetMarked(fKeepAspectRatio);
fSettingsMenu->ItemAt(10)->SetEnabled(false); // XXX disable unused preference menu
*/
} }
@ -861,7 +914,8 @@ MainWin::_SetupTrackMenus()
c = fController->AudioTrackCount(); c = fController->AudioTrackCount();
for (i = 0; i < c; i++) { for (i = 0; i < c; i++) {
sprintf(s, "Track %d", i + 1); sprintf(s, "Track %d", i + 1);
fAudioTrackMenu->AddItem(new BMenuItem(s, new BMessage(M_SELECT_AUDIO_TRACK + i))); fAudioTrackMenu->AddItem(new BMenuItem(s,
new BMessage(M_SELECT_AUDIO_TRACK + i)));
} }
if (!c) if (!c)
fAudioTrackMenu->AddItem(new BMenuItem("none", new BMessage(M_DUMMY))); fAudioTrackMenu->AddItem(new BMenuItem("none", new BMessage(M_DUMMY)));
@ -869,7 +923,8 @@ MainWin::_SetupTrackMenus()
c = fController->VideoTrackCount(); c = fController->VideoTrackCount();
for (i = 0; i < c; i++) { for (i = 0; i < c; i++) {
sprintf(s, "Track %d", i + 1); sprintf(s, "Track %d", i + 1);
fVideoTrackMenu->AddItem(new BMenuItem(s, new BMessage(M_SELECT_VIDEO_TRACK + i))); fVideoTrackMenu->AddItem(new BMenuItem(s,
new BMessage(M_SELECT_VIDEO_TRACK + i)));
} }
if (!c) if (!c)
fVideoTrackMenu->AddItem(new BMenuItem("none", new BMessage(M_DUMMY))); fVideoTrackMenu->AddItem(new BMenuItem("none", new BMessage(M_DUMMY)));
@ -882,9 +937,11 @@ MainWin::_SetWindowSizeLimits()
int minWidth = fNoControls ? MIN_WIDTH : fControlsWidth; int minWidth = fNoControls ? MIN_WIDTH : fControlsWidth;
if (!fNoMenu) if (!fNoMenu)
minWidth = max_c(minWidth, fMenuBarWidth); minWidth = max_c(minWidth, fMenuBarWidth);
int minHeight = (fNoMenu ? 0 : fMenuBarHeight) + (fNoControls ? 0 : fControlsHeight); int minHeight = (fNoMenu ? 0 : fMenuBarHeight)
+ (fNoControls ? 0 : fControlsHeight);
SetSizeLimits(minWidth - 1, 32000, minHeight - 1, fHasVideo ? 32000 : minHeight - 1); SetSizeLimits(minWidth - 1, 32000, minHeight - 1, fHasVideo ?
32000 : minHeight - 1);
} }
@ -916,7 +973,8 @@ MainWin::_ResizeWindow(int percent)
void void
MainWin::_ResizeVideoView(int x, int y, int width, int height) MainWin::_ResizeVideoView(int x, int y, int width, int height)
{ {
printf("_ResizeVideoView: %d,%d, width %d, height %d\n", x, y, width, height); printf("_ResizeVideoView: %d,%d, width %d, height %d\n", x, y,
width, height);
if (fKeepAspectRatio) { if (fKeepAspectRatio) {
// Keep aspect ratio, place video view inside // Keep aspect ratio, place video view inside
@ -953,7 +1011,8 @@ MainWin::_MouseDown(BMessage *msg, BView* originalHandler)
BPoint screen_where; BPoint screen_where;
uint32 buttons = msg->FindInt32("buttons"); uint32 buttons = msg->FindInt32("buttons");
// On Zeta, only "screen_where" is relyable, "where" and "be:view_where" seem to be broken // On Zeta, only "screen_where" is relyable, "where" and "be:view_where"
// seem to be broken
if (B_OK != msg->FindPoint("screen_where", &screen_where)) { if (B_OK != msg->FindPoint("screen_where", &screen_where)) {
// Workaround for BeOS R5, it has no "screen_where" // Workaround for BeOS R5, it has no "screen_where"
if (!originalHandler || msg->FindPoint("where", &screen_where) < B_OK) if (!originalHandler || msg->FindPoint("where", &screen_where) < B_OK)
@ -966,7 +1025,8 @@ MainWin::_MouseDown(BMessage *msg, BView* originalHandler)
// if (1 == msg->FindInt32("buttons") && msg->FindInt32("clicks") == 1) { // if (1 == msg->FindInt32("buttons") && msg->FindInt32("clicks") == 1) {
if (1 == buttons && msg->FindInt32("clicks") % 2 == 0) { if (1 == buttons && msg->FindInt32("clicks") % 2 == 0) {
BRect r(screen_where.x - 1, screen_where.y - 1, screen_where.x + 1, screen_where.y + 1); BRect r(screen_where.x - 1, screen_where.y - 1, screen_where.x + 1,
screen_where.y + 1);
if (r.Contains(fMouseDownMousePos)) { if (r.Contains(fMouseDownMousePos)) {
PostMessage(M_TOGGLE_FULLSCREEN); PostMessage(M_TOGGLE_FULLSCREEN);
return; return;
@ -974,7 +1034,8 @@ MainWin::_MouseDown(BMessage *msg, BView* originalHandler)
} }
if (2 == buttons && msg->FindInt32("clicks") % 2 == 0) { if (2 == buttons && msg->FindInt32("clicks") % 2 == 0) {
BRect r(screen_where.x - 1, screen_where.y - 1, screen_where.x + 1, screen_where.y + 1); BRect r(screen_where.x - 1, screen_where.y - 1, screen_where.x + 1,
screen_where.y + 1);
if (r.Contains(fMouseDownMousePos)) { if (r.Contains(fMouseDownMousePos)) {
PostMessage(M_TOGGLE_NO_BORDER_NO_MENU_NO_CONTROLS); PostMessage(M_TOGGLE_NO_BORDER_NO_MENU_NO_CONTROLS);
return; return;
@ -983,14 +1044,16 @@ MainWin::_MouseDown(BMessage *msg, BView* originalHandler)
/* /*
// very broken in Zeta: // very broken in Zeta:
fMouseDownMousePos = fVideoView->ConvertToScreen(msg->FindPoint("where")); fMouseDownMousePos = fVideoView->ConvertToScreen(
msg->FindPoint("where"));
*/ */
fMouseDownMousePos = screen_where; fMouseDownMousePos = screen_where;
fMouseDownWindowPos = Frame().LeftTop(); fMouseDownWindowPos = Frame().LeftTop();
if (buttons == 1 && !fIsFullscreen) { if (buttons == 1 && !fIsFullscreen) {
// start mouse tracking // start mouse tracking
fVideoView->SetMouseEventMask(B_POINTER_EVENTS | B_NO_POINTER_HISTORY /* | B_LOCK_WINDOW_FOCUS */); fVideoView->SetMouseEventMask(B_POINTER_EVENTS | B_NO_POINTER_HISTORY
/* | B_LOCK_WINDOW_FOCUS */);
fMouseDownTracking = true; fMouseDownTracking = true;
} }
@ -1061,38 +1124,51 @@ MainWin::_ShowContextMenu(const BPoint &screen_point)
printf("Show context menu\n"); printf("Show context menu\n");
BPopUpMenu *menu = new BPopUpMenu("context menu", false, false); BPopUpMenu *menu = new BPopUpMenu("context menu", false, false);
BMenuItem *item; BMenuItem *item;
menu->AddItem(item = new BMenuItem("Full Screen", new BMessage(M_TOGGLE_FULLSCREEN), 'F', B_COMMAND_KEY)); menu->AddItem(item = new BMenuItem("Full Screen",
new BMessage(M_TOGGLE_FULLSCREEN), 'F'));
item->SetMarked(fIsFullscreen); item->SetMarked(fIsFullscreen);
item->SetEnabled(fHasVideo); item->SetEnabled(fHasVideo);
menu->AddItem(item = new BMenuItem("Keep Aspect Ratio", new BMessage(M_TOGGLE_KEEP_ASPECT_RATIO), 'K', B_COMMAND_KEY)); menu->AddItem(item = new BMenuItem("Keep Aspect Ratio",
new BMessage(M_TOGGLE_KEEP_ASPECT_RATIO), 'K'));
item->SetMarked(fKeepAspectRatio); item->SetMarked(fKeepAspectRatio);
item->SetEnabled(fHasVideo); item->SetEnabled(fHasVideo);
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(item = new BMenuItem("No Menu", new BMessage(M_TOGGLE_NO_MENU), 'M', B_COMMAND_KEY)); menu->AddItem(item = new BMenuItem("No Menu",
new BMessage(M_TOGGLE_NO_MENU), 'M'));
item->SetMarked(fNoMenu); item->SetMarked(fNoMenu);
menu->AddItem(item = new BMenuItem("No Border", new BMessage(M_TOGGLE_NO_BORDER), 'B', B_COMMAND_KEY)); menu->AddItem(item = new BMenuItem("No Border",
new BMessage(M_TOGGLE_NO_BORDER), 'B'));
item->SetMarked(fNoBorder); item->SetMarked(fNoBorder);
menu->AddItem(item = new BMenuItem("Always on Top", new BMessage(M_TOGGLE_ALWAYS_ON_TOP), 'T', B_COMMAND_KEY)); menu->AddItem(item = new BMenuItem("Always on Top",
new BMessage(M_TOGGLE_ALWAYS_ON_TOP), 'T'));
item->SetMarked(fAlwaysOnTop); item->SetMarked(fAlwaysOnTop);
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("About" NAME B_UTF8_ELLIPSIS, menu->AddItem(new BMenuItem("About" NAME B_UTF8_ELLIPSIS,
new BMessage(B_ABOUT_REQUESTED))); new BMessage(B_ABOUT_REQUESTED)));
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("Quit", new BMessage(M_FILE_QUIT), 'Q', B_COMMAND_KEY)); menu->AddItem(new BMenuItem("Quit", new BMessage(M_FILE_QUIT), 'Q'));
menu->AddSeparatorItem(); menu->AddSeparatorItem();
menu->AddItem(new BMenuItem("pixel aspect ratio 1.00000:1", new BMessage(M_ASPECT_100000_1))); menu->AddItem(new BMenuItem("pixel aspect ratio 1.00000:1",
menu->AddItem(new BMenuItem("pixel aspect ratio 1.06666:1", new BMessage(M_ASPECT_106666_1))); new BMessage(M_ASPECT_100000_1)));
menu->AddItem(new BMenuItem("pixel aspect ratio 1.09091:1", new BMessage(M_ASPECT_109091_1))); menu->AddItem(new BMenuItem("pixel aspect ratio 1.06666:1",
menu->AddItem(new BMenuItem("pixel aspect ratio 1.41176:1", new BMessage(M_ASPECT_141176_1))); new BMessage(M_ASPECT_106666_1)));
menu->AddItem(new BMenuItem("force 720 x 576, display aspect 4:3", new BMessage(M_ASPECT_720_576))); menu->AddItem(new BMenuItem("pixel aspect ratio 1.09091:1",
menu->AddItem(new BMenuItem("force 704 x 576, display aspect 4:3", new BMessage(M_ASPECT_704_576))); new BMessage(M_ASPECT_109091_1)));
menu->AddItem(new BMenuItem("force 544 x 576, display aspect 4:3", new BMessage(M_ASPECT_544_576))); menu->AddItem(new BMenuItem("pixel aspect ratio 1.41176:1",
new BMessage(M_ASPECT_141176_1)));
menu->AddItem(new BMenuItem("force 720 x 576, display aspect 4:3",
new BMessage(M_ASPECT_720_576)));
menu->AddItem(new BMenuItem("force 704 x 576, display aspect 4:3",
new BMessage(M_ASPECT_704_576)));
menu->AddItem(new BMenuItem("force 544 x 576, display aspect 4:3",
new BMessage(M_ASPECT_544_576)));
menu->SetTargetForItems(this); menu->SetTargetForItems(this);
BRect r(screen_point.x - 5, screen_point.y - 5, screen_point.x + 5, screen_point.y + 5); BRect r(screen_point.x - 5, screen_point.y - 5, screen_point.x + 5,
screen_point.y + 5);
menu->Go(screen_point, true, true, r, true); menu->Go(screen_point, true, true, r, true);
} }
@ -1109,7 +1185,8 @@ MainWin::_KeyDown(BMessage *msg)
uint32 raw_char = msg->FindInt32("raw_char"); uint32 raw_char = msg->FindInt32("raw_char");
uint32 modifiers = msg->FindInt32("modifiers"); uint32 modifiers = msg->FindInt32("modifiers");
printf("key 0x%lx, raw_char 0x%lx, modifiers 0x%lx\n", key, raw_char, modifiers); printf("key 0x%lx, raw_char 0x%lx, modifiers 0x%lx\n", key, raw_char,
modifiers);
switch (raw_char) { switch (raw_char) {
case B_SPACE: case B_SPACE:
@ -1134,7 +1211,8 @@ MainWin::_KeyDown(BMessage *msg)
break; break;
case B_TAB: case B_TAB:
if ((modifiers & (B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY | B_MENU_KEY)) == 0) { if ((modifiers & (B_COMMAND_KEY | B_CONTROL_KEY | B_OPTION_KEY
| B_MENU_KEY)) == 0) {
PostMessage(M_TOGGLE_FULLSCREEN); PostMessage(M_TOGGLE_FULLSCREEN);
return B_OK; return B_OK;
} else } else
@ -1260,7 +1338,9 @@ MainWin::_ToggleFullscreen()
// switch to fullscreen // switch to fullscreen
fSavedFrame = Frame(); fSavedFrame = Frame();
printf("saving current frame: %d %d %d %d\n", int(fSavedFrame.left), int(fSavedFrame.top), int(fSavedFrame.right), int(fSavedFrame.bottom)); printf("saving current frame: %d %d %d %d\n", int(fSavedFrame.left),
int(fSavedFrame.top), int(fSavedFrame.right),
int(fSavedFrame.bottom));
BScreen screen(this); BScreen screen(this);
BRect rect(screen.Frame()); BRect rect(screen.Frame());

View File

@ -32,10 +32,10 @@
#include "VideoView.h" #include "VideoView.h"
#include "Playlist.h" #include "Playlist.h"
class ControllerObserver; class ControllerObserver;
class PlaylistObserver; class PlaylistObserver;
class PlaylistWindow; class PlaylistWindow;
class SettingsWindow;
class MainWin : public BWindow { class MainWin : public BWindow {
public: public:
@ -54,6 +54,7 @@ public:
void ShowFileInfo(); void ShowFileInfo();
void ShowPlaylistWindow(); void ShowPlaylistWindow();
void ShowSettingsWindow();
void VideoFormatChange(int width, int height, void VideoFormatChange(int width, int height,
float widthScale, float heightScale); float widthScale, float heightScale);
@ -100,6 +101,7 @@ private:
ControllerView* fControls; ControllerView* fControls;
InfoWin* fInfoWin; InfoWin* fInfoWin;
PlaylistWindow* fPlaylistWindow; PlaylistWindow* fPlaylistWindow;
SettingsWindow* fSettingsWindow;
BMenu* fFileMenu; BMenu* fFileMenu;
BMenu* fAudioMenu; BMenu* fAudioMenu;

View File

@ -3,7 +3,7 @@
* *
* Copyright (C) 2006 Marcus Overhagen <marcus@overhagen.de> * Copyright (C) 2006 Marcus Overhagen <marcus@overhagen.de>
* Copyright (C) 2007 Stephan Aßmus <superstippi@gmx.de> * Copyright (C) 2007 Stephan Aßmus <superstippi@gmx.de>
* Copyright (C) 2007 Fredrik Modéen <fredrik@modeen.se> * Copyright (C) 2008 Fredrik Modéen <fredrik@modeen.se> (I have no problem changing my things to MIT)
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -34,6 +34,8 @@
#include <Message.h> #include <Message.h>
#include <Path.h> #include <Path.h>
#include "FileReadWrite.h"
using std::nothrow; using std::nothrow;
// TODO: using BList for objects is bad, replace it with a template // TODO: using BList for objects is bad, replace it with a template
@ -281,8 +283,7 @@ Playlist::AppendRefs(const BMessage* refsReceivedMessage, int32 appendIndex)
entry_ref ref; entry_ref ref;
for (int i = 0; refsReceivedMessage->FindRef("refs", i, &ref) == B_OK; i++) for (int i = 0; refsReceivedMessage->FindRef("refs", i, &ref) == B_OK; i++)
AppendToPlaylistRecursive(ref, playlist); AppendToPlaylistRecursive(ref, playlist);
playlist->Sort(); playlist->Sort();
if (add) if (add)
@ -300,10 +301,17 @@ Playlist::AppendToPlaylistRecursive(const entry_ref& ref, Playlist* playlist)
{ {
// recursively append the ref (dive into folders) // recursively append the ref (dive into folders)
BEntry entry(&ref, true); BEntry entry(&ref, true);
if (entry.InitCheck() < B_OK) if (entry.InitCheck() < B_OK) {
printf("Not OK\n");
return; return;
if (!entry.Exists()) }
if (!entry.Exists()) {
BPath path = BPath(&ref);
//printf("Don't exist - %s\n", path.Path());
return; return;
}
if (entry.IsDirectory()) { if (entry.IsDirectory()) {
BDirectory dir(&entry); BDirectory dir(&entry);
if (dir.InitCheck() < B_OK) if (dir.InitCheck() < B_OK)
@ -313,13 +321,35 @@ Playlist::AppendToPlaylistRecursive(const entry_ref& ref, Playlist* playlist)
while (dir.GetNextRef(&subRef) == B_OK) while (dir.GetNextRef(&subRef) == B_OK)
AppendToPlaylistRecursive(subRef, playlist); AppendToPlaylistRecursive(subRef, playlist);
} else if (entry.IsFile()) { } else if (entry.IsFile()) {
//printf("Is File\n");
BString mimeString = _MIMEString(&ref); BString mimeString = _MIMEString(&ref);
if (_IsMediaFile(mimeString)) if (_IsMediaFile(mimeString)) {
//printf("Adding\n");
playlist->AddRef(ref); playlist->AddRef(ref);
else if (_IsPlaylist(mimeString)) { } else if (_IsPlaylist(mimeString)) {
printf("Playlist::AppendToPlaylistRecursive() - " //printf("RunPlaylist thing\n");
"TODO: implement playlist file loading\n"); BFile file(&ref, B_READ_ONLY);
} FileReadWrite lineReader(&file);
BString str;
entry_ref refPath;
status_t err;
BPath path;
while (lineReader.Next(str)) {
str = str.RemoveFirst("file://");
str = str.RemoveLast("..");
path = BPath(str.String());
printf("Line %s\n", path.Path());
if (path.Path() != NULL) {
if ((err = get_ref_for_path(path.Path(), &refPath)) == B_OK) {
playlist->AddRef(refPath);
} else
printf("Error - %s: [%lx]\n", strerror(err), (int32) err);
} else
printf("Error - No File Found in playlist\n");
}
} else
printf("MIME Type = %s\n", mimeString.String());
} }
} }
@ -331,7 +361,6 @@ int
Playlist::playlist_cmp(const void *p1, const void *p2) Playlist::playlist_cmp(const void *p1, const void *p2)
{ {
// compare complete path // compare complete path
BEntry a(*(const entry_ref **)p1, false); BEntry a(*(const entry_ref **)p1, false);
BEntry b(*(const entry_ref **)p2, false); BEntry b(*(const entry_ref **)p2, false);
@ -342,6 +371,30 @@ Playlist::playlist_cmp(const void *p1, const void *p2)
} }
/*static*/ void
Playlist::_AddPlayListFileToPlayList(const entry_ref& ref, Playlist* playlist)
{
BFile file(&ref, B_READ_ONLY);
FileReadWrite lineReader(&file);
BString str;
while (lineReader.Next(str)) {
BPath path = BPath(str.String());
entry_ref refPath;
status_t err;
if ((err = get_ref_for_path(path.Path(), &refPath)) == B_OK) {
AppendToPlaylistRecursive(refPath, playlist);
} else
printf("Error - %s: [%lx]\n", strerror(err), (int32) err);
}
/*
Read line for x to the end of file (while?)
make a enty_ref and call AppendToPlaylistRecursive(with new entry, playlist)
*/
}
/*static*/ bool /*static*/ bool
Playlist::_IsMediaFile(const BString& mimeString) Playlist::_IsMediaFile(const BString& mimeString)
{ {

View File

@ -1,8 +1,9 @@
/* /*
* Playlist.h - Media Player for the Haiku Operating System * Playlist.h - Media Player for the Haiku Operating System
* *
* Copyright (C) 2006 Marcus Overhagen <marcus@overhagen.de> * Copyright (C) 2006 Marcus Overhagen <marcus@overhagen.de>
* Copyright (C) 2007 Stephan Aßmus <superstippi@gmx.de> * Copyright (C) 2007 Stephan Aßmus <superstippi@gmx.de>
* Copyright (C) 2008 Fredrik Modéen <fredrik@modeen.se> (I have no problem changing my things to MIT)
* *
* This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License * modify it under the terms of the GNU General Public License
@ -88,7 +89,8 @@ private:
static bool _IsMediaFile(const BString& mimeString); static bool _IsMediaFile(const BString& mimeString);
static bool _IsPlaylist(const BString& mimeString); static bool _IsPlaylist(const BString& mimeString);
static BString _MIMEString(const entry_ref* entry); static BString _MIMEString(const entry_ref* entry);
static void _AddPlayListFileToPlayList(const entry_ref& ref,
Playlist* playlist);
void _NotifyRefAdded(const entry_ref& ref, void _NotifyRefAdded(const entry_ref& ref,
int32 index) const; int32 index) const;
void _NotifyRefRemoved(int32 index) const; void _NotifyRefRemoved(int32 index) const;

View File

@ -3,21 +3,40 @@
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Stephan Aßmus <superstippi@gmx.de> * Stephan Aßmus <superstippi@gmx.de>
* Fredrik Modéen <fredrik@modeen.se>
*/ */
#include "PlaylistWindow.h" #include "PlaylistWindow.h"
#include <stdio.h>
#include <Application.h>
#include <Roster.h>
#include <Path.h>
#include <Menu.h> #include <Menu.h>
#include <MenuBar.h> #include <MenuBar.h>
#include <MenuItem.h> #include <MenuItem.h>
#include <ScrollBar.h> #include <ScrollBar.h>
#include <ScrollView.h> #include <ScrollView.h>
#include <String.h> #include <String.h>
#include <Box.h>
#include <Button.h>
#include <FilePanel.h>
#include "CommandStack.h" #include "CommandStack.h"
#include "PlaylistListView.h" #include "PlaylistListView.h"
#include "RWLocker.h" #include "RWLocker.h"
#define DEBUG 1
enum {
M_PLAYLIST_OPEN = 'open',
M_PLAYLIST_SAVE = 'save',
M_PLAYLIST_EMPTY = 'emty'
};
#define SPACE 5
PlaylistWindow::PlaylistWindow(BRect frame, Playlist* playlist, PlaylistWindow::PlaylistWindow(BRect frame, Playlist* playlist,
Controller* controller) Controller* controller)
@ -28,18 +47,19 @@ PlaylistWindow::PlaylistWindow(BRect frame, Playlist* playlist,
, fCommandStack(new CommandStack(fLocker)) , fCommandStack(new CommandStack(fLocker))
, fCommandStackListener(this) , fCommandStackListener(this)
{ {
frame = Bounds(); frame = Bounds();
_CreateMenu(frame); _CreateMenu(frame);
// will adjust frame to account for menubar
frame.right -= B_V_SCROLL_BAR_WIDTH; frame.right -= B_V_SCROLL_BAR_WIDTH;
fListView = new PlaylistListView(frame, playlist, controller, fListView = new PlaylistListView(frame, playlist, controller,
fCommandStack); fCommandStack);
BScrollView* scrollView = new BScrollView("playlist scrollview", BScrollView* scrollView = new BScrollView("playlist scrollview", fListView,
fListView, B_FOLLOW_ALL, 0, false, true, B_NO_BORDER); B_FOLLOW_ALL_SIDES, 0, false, true, B_NO_BORDER);
fTopView = scrollView; fTopView = scrollView;
AddChild(fTopView); AddChild(fTopView);
// small visual tweak // small visual tweak
@ -109,7 +129,23 @@ PlaylistWindow::MessageReceived(BMessage* message)
} }
break; break;
} }
case M_PLAYLIST_SAVE:
if (!fSavePanel)
fSavePanel = new BFilePanel(B_SAVE_PANEL);
fSavePanel->Show();
break;
case B_SAVE_REQUESTED:
printf("We are saving\n");
//Use fListView and have a SaveToFile?
break;
case M_PLAYLIST_OPEN:
if (!fOpenPanel)
fOpenPanel = new BFilePanel(B_OPEN_PANEL);
fOpenPanel->Show();
break;
case M_PLAYLIST_EMPTY:
break;
default: default:
BWindow::MessageReceived(message); BWindow::MessageReceived(message);
break; break;
@ -127,15 +163,22 @@ PlaylistWindow::_CreateMenu(BRect& frame)
BMenuBar* menuBar = new BMenuBar(frame, "main menu"); BMenuBar* menuBar = new BMenuBar(frame, "main menu");
BMenu* fileMenu = new BMenu("Playlist"); BMenu* fileMenu = new BMenu("Playlist");
menuBar->AddItem(fileMenu); menuBar->AddItem(fileMenu);
// TODO add some items: "Open", "Save", "Make Empty"... // fileMenu->AddItem(new BMenuItem("Open"B_UTF8_ELLIPSIS,
// new BMessage(M_PLAYLIST_OPEN), 'O'));
// fileMenu->AddItem(new BMenuItem("Save"B_UTF8_ELLIPSIS,
// new BMessage(M_PLAYLIST_SAVE), 'S'));
// fileMenu->AddSeparatorItem();
fileMenu->AddItem(new BMenuItem("Close",
new BMessage(B_QUIT_REQUESTED), 'W'));
BMenu* editMenu = new BMenu("Edit"); BMenu* editMenu = new BMenu("Edit");
BMessage* message = new BMessage(B_UNDO); fUndoMI = new BMenuItem("Undo", new BMessage(B_UNDO), 'Z');
fUndoMI = new BMenuItem("Undo", message);
editMenu->AddItem(fUndoMI); editMenu->AddItem(fUndoMI);
message = new BMessage(B_REDO); fRedoMI = new BMenuItem("Redo", new BMessage(B_REDO), 'Z', B_SHIFT_KEY);
fRedoMI = new BMenuItem("Undo", message);
editMenu->AddItem(fRedoMI); editMenu->AddItem(fRedoMI);
editMenu->AddSeparatorItem();
editMenu->AddItem(new BMenuItem("Make Empty",
new BMessage(M_PLAYLIST_EMPTY), 'N'));
menuBar->AddItem(editMenu); menuBar->AddItem(editMenu);
AddChild(menuBar); AddChild(menuBar);

View File

@ -3,8 +3,10 @@
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
* Stephan Aßmus <superstippi@gmx.de> * Stephan Aßmus <superstippi@gmx.de>
* Fredrik Modéen <fredrik@modeen.se>
*/ */
#ifndef PLAYLIST_WINDOW_H #ifndef PLAYLIST_WINDOW_H
#define PLAYLIST_WINDOW_H #define PLAYLIST_WINDOW_H
@ -21,6 +23,7 @@ class Notifier;
class Playlist; class Playlist;
class PlaylistListView; class PlaylistListView;
class RWLocker; class RWLocker;
class BButton;
class PlaylistWindow : public BWindow { class PlaylistWindow : public BWindow {
public: public:
@ -42,6 +45,9 @@ class PlaylistWindow : public BWindow {
BView* fTopView; BView* fTopView;
BMenuItem* fUndoMI; BMenuItem* fUndoMI;
BMenuItem* fRedoMI; BMenuItem* fRedoMI;
BFilePanel* fOpenPanel;
BFilePanel* fSavePanel;
RWLocker* fLocker; RWLocker* fLocker;
CommandStack* fCommandStack; CommandStack* fCommandStack;