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 bigtime_t _DetermineItemDuration(PlaylistItem* item); 74*1c68b67aSMarkus Himmel 75*1c68b67aSMarkus Himmel BObjectList<bigtime_t> 76*1c68b67aSMarkus Himmel fKnown; 77*1c68b67aSMarkus Himmel bigtime_t fTotalDuration; 78*1c68b67aSMarkus Himmel PlaylistWindow& fParent; 79*1c68b67aSMarkus Himmel }; 80*1c68b67aSMarkus Himmel 81*1c68b67aSMarkus Himmel friend class DurationListener; 82*1c68b67aSMarkus Himmel 83415ef601SStephan Aßmus void _CreateMenu(BRect& frame); 84415ef601SStephan Aßmus void _ObjectChanged(const Notifier* object); 85d6aa728aSStephan Aßmus void _SavePlaylist(const BMessage* filePanelMessage); 86d6aa728aSStephan Aßmus void _SavePlaylist(const entry_ref& ref); 87d6aa728aSStephan Aßmus void _SavePlaylist(BEntry& origEntry, 88d6aa728aSStephan Aßmus BEntry& tempEntry, const char* finalName); 89*1c68b67aSMarkus Himmel void _QueryInitialDurations(); 90*1c68b67aSMarkus Himmel void _UpdateTotalDuration(bigtime_t duration); 91415ef601SStephan Aßmus 92415ef601SStephan Aßmus Playlist* fPlaylist; 93415ef601SStephan Aßmus PlaylistListView* fListView; 94415ef601SStephan Aßmus 95415ef601SStephan Aßmus BView* fTopView; 96415ef601SStephan Aßmus BMenuItem* fUndoMI; 97415ef601SStephan Aßmus BMenuItem* fRedoMI; 98415ef601SStephan Aßmus 99415ef601SStephan Aßmus RWLocker* fLocker; 100415ef601SStephan Aßmus CommandStack* fCommandStack; 101415ef601SStephan Aßmus ListenerAdapter fCommandStackListener; 102d6aa728aSStephan Aßmus 103d6aa728aSStephan Aßmus entry_ref fSavedPlaylistRef; 104*1c68b67aSMarkus Himmel 105*1c68b67aSMarkus Himmel DurationListener* fDurationListener; 106*1c68b67aSMarkus Himmel BStringView* fTotalDuration; 107415ef601SStephan Aßmus }; 108415ef601SStephan Aßmus 109bafcab92SAxel Dörfler 110415ef601SStephan Aßmus #endif // PLAYLIST_WINDOW_H 111