1415ef601SStephan Aßmus /* 2bafcab92SAxel Dörfler * Copyright 2007-2010, Haiku. All rights reserved. 3415ef601SStephan Aßmus * Distributed under the terms of the MIT License. 4415ef601SStephan Aßmus * 5415ef601SStephan Aßmus * Authors: 6415ef601SStephan Aßmus * Stephan Aßmus <superstippi@gmx.de> 71b7f76bcSStephan Aßmus * Fredrik Modéen <fredrik@modeen.se> 8415ef601SStephan Aßmus */ 9415ef601SStephan Aßmus #ifndef PLAYLIST_WINDOW_H 10415ef601SStephan Aßmus #define PLAYLIST_WINDOW_H 11415ef601SStephan Aßmus 12415ef601SStephan Aßmus 13d6aa728aSStephan Aßmus #include <Entry.h> 14*1c68b67aSMarkus Himmel #include <ObjectList.h> 15415ef601SStephan Aßmus #include <Window.h> 16415ef601SStephan Aßmus 17*1c68b67aSMarkus Himmel #include "PlaylistObserver.h" 18415ef601SStephan Aßmus #include "ListenerAdapter.h" 19415ef601SStephan Aßmus 20bafcab92SAxel Dörfler 21415ef601SStephan Aßmus class BMenuBar; 22415ef601SStephan Aßmus class BMenuItem; 23415ef601SStephan Aßmus class CommandStack; 24415ef601SStephan Aßmus class Controller; 25415ef601SStephan Aßmus class Notifier; 26415ef601SStephan Aßmus class PlaylistListView; 27415ef601SStephan Aßmus class RWLocker; 281b7f76bcSStephan Aßmus class BButton; 29b9044f36SFrançois Revol class BFilePanel; 30*1c68b67aSMarkus Himmel class BStringView; 31415ef601SStephan Aßmus 32bafcab92SAxel Dörfler 33dd091096SStephan Aßmus enum { 34e28afdf1SJonas Sundström // file 35e28afdf1SJonas Sundström M_PLAYLIST_OPEN = 'open', 36e28afdf1SJonas Sundström M_PLAYLIST_SAVE = 'save', 37e28afdf1SJonas Sundström M_PLAYLIST_SAVE_AS = 'svas', 38e28afdf1SJonas Sundström M_PLAYLIST_SAVE_RESULT = 'psrs', 39e28afdf1SJonas Sundström 40e28afdf1SJonas Sundström // edit 41e28afdf1SJonas Sundström M_PLAYLIST_RANDOMIZE = 'rand', 42e28afdf1SJonas Sundström M_PLAYLIST_REMOVE = 'rmov', 43e28afdf1SJonas Sundström M_PLAYLIST_MOVE_TO_TRASH = 'trsh' 44dd091096SStephan Aßmus }; 45dd091096SStephan Aßmus 46bafcab92SAxel Dörfler 47415ef601SStephan Aßmus class PlaylistWindow : public BWindow { 48415ef601SStephan Aßmus public: 49415ef601SStephan Aßmus PlaylistWindow(BRect frame, 50415ef601SStephan Aßmus Playlist* playlist, 51415ef601SStephan Aßmus Controller* controller); 52415ef601SStephan Aßmus virtual ~PlaylistWindow(); 53415ef601SStephan Aßmus 54415ef601SStephan Aßmus virtual bool QuitRequested(); 55415ef601SStephan Aßmus virtual void MessageReceived(BMessage* message); 56415ef601SStephan Aßmus 57415ef601SStephan Aßmus private: 58*1c68b67aSMarkus Himmel 59*1c68b67aSMarkus Himmel class DurationListener : public PlaylistObserver, public BLooper { 60*1c68b67aSMarkus Himmel public: 61*1c68b67aSMarkus Himmel 62*1c68b67aSMarkus Himmel DurationListener(PlaylistWindow& parent); 63*1c68b67aSMarkus Himmel ~DurationListener(); 64*1c68b67aSMarkus Himmel 65*1c68b67aSMarkus Himmel void MessageReceived(BMessage* message); 66*1c68b67aSMarkus Himmel 67*1c68b67aSMarkus Himmel bigtime_t TotalDuration(); 68*1c68b67aSMarkus Himmel 69*1c68b67aSMarkus Himmel private: 70*1c68b67aSMarkus Himmel void _HandleItemAdded(PlaylistItem* item, 71*1c68b67aSMarkus Himmel int32 index); 72*1c68b67aSMarkus Himmel void _HandleItemRemoved(int32 index); 73*1c68b67aSMarkus Himmel 74*1c68b67aSMarkus Himmel BObjectList<bigtime_t> 75*1c68b67aSMarkus Himmel fKnown; 76*1c68b67aSMarkus Himmel bigtime_t fTotalDuration; 77*1c68b67aSMarkus Himmel PlaylistWindow& fParent; 78*1c68b67aSMarkus Himmel }; 79*1c68b67aSMarkus Himmel 80*1c68b67aSMarkus Himmel friend class DurationListener; 81*1c68b67aSMarkus Himmel 82415ef601SStephan Aßmus void _CreateMenu(BRect& frame); 83415ef601SStephan Aßmus void _ObjectChanged(const Notifier* object); 84d6aa728aSStephan Aßmus void _SavePlaylist(const BMessage* filePanelMessage); 85d6aa728aSStephan Aßmus void _SavePlaylist(const entry_ref& ref); 86d6aa728aSStephan Aßmus void _SavePlaylist(BEntry& origEntry, 87d6aa728aSStephan Aßmus BEntry& tempEntry, const char* finalName); 88*1c68b67aSMarkus Himmel void _QueryInitialDurations(); 89*1c68b67aSMarkus Himmel void _UpdateTotalDuration(bigtime_t duration); 90415ef601SStephan Aßmus 91415ef601SStephan Aßmus Playlist* fPlaylist; 92415ef601SStephan Aßmus PlaylistListView* fListView; 93415ef601SStephan Aßmus 94415ef601SStephan Aßmus BView* fTopView; 95415ef601SStephan Aßmus BMenuItem* fUndoMI; 96415ef601SStephan Aßmus BMenuItem* fRedoMI; 97415ef601SStephan Aßmus 98415ef601SStephan Aßmus RWLocker* fLocker; 99415ef601SStephan Aßmus CommandStack* fCommandStack; 100415ef601SStephan Aßmus ListenerAdapter fCommandStackListener; 101d6aa728aSStephan Aßmus 102d6aa728aSStephan Aßmus entry_ref fSavedPlaylistRef; 103*1c68b67aSMarkus Himmel 104*1c68b67aSMarkus Himmel DurationListener* fDurationListener; 105*1c68b67aSMarkus Himmel BStringView* fTotalDuration; 106415ef601SStephan Aßmus }; 107415ef601SStephan Aßmus 108bafcab92SAxel Dörfler 109415ef601SStephan Aßmus #endif // PLAYLIST_WINDOW_H 110