1 /* 2 * Copyright 2007-2010, Haiku. All rights reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus <superstippi@gmx.de> 7 * Fredrik Modéen <fredrik@modeen.se> 8 */ 9 #ifndef PLAYLIST_WINDOW_H 10 #define PLAYLIST_WINDOW_H 11 12 13 #include <Entry.h> 14 #include <ObjectList.h> 15 #include <Window.h> 16 17 #include "PlaylistObserver.h" 18 #include "ListenerAdapter.h" 19 20 21 class BMenuBar; 22 class BMenuItem; 23 class CommandStack; 24 class Controller; 25 class Notifier; 26 class PlaylistListView; 27 class RWLocker; 28 class BButton; 29 class BFilePanel; 30 class BStringView; 31 32 33 enum { 34 // file 35 M_PLAYLIST_OPEN = 'open', 36 M_PLAYLIST_SAVE = 'save', 37 M_PLAYLIST_SAVE_AS = 'svas', 38 M_PLAYLIST_SAVE_RESULT = 'psrs', 39 40 // edit 41 M_PLAYLIST_RANDOMIZE = 'rand', 42 M_PLAYLIST_REMOVE = 'rmov', 43 M_PLAYLIST_MOVE_TO_TRASH = 'trsh' 44 }; 45 46 47 class PlaylistWindow : public BWindow { 48 public: 49 PlaylistWindow(BRect frame, 50 Playlist* playlist, 51 Controller* controller); 52 virtual ~PlaylistWindow(); 53 54 virtual bool QuitRequested(); 55 virtual void MessageReceived(BMessage* message); 56 57 private: 58 59 class DurationListener : public PlaylistObserver, public BLooper { 60 public: 61 62 DurationListener(PlaylistWindow& parent); 63 ~DurationListener(); 64 65 void MessageReceived(BMessage* message); 66 67 bigtime_t TotalDuration(); 68 69 private: 70 void _HandleItemAdded(PlaylistItem* item, 71 int32 index); 72 void _HandleItemRemoved(int32 index); 73 74 BObjectList<bigtime_t> 75 fKnown; 76 bigtime_t fTotalDuration; 77 PlaylistWindow& fParent; 78 }; 79 80 friend class DurationListener; 81 82 void _CreateMenu(BRect& frame); 83 void _ObjectChanged(const Notifier* object); 84 void _SavePlaylist(const BMessage* filePanelMessage); 85 void _SavePlaylist(const entry_ref& ref); 86 void _SavePlaylist(BEntry& origEntry, 87 BEntry& tempEntry, const char* finalName); 88 void _QueryInitialDurations(); 89 void _UpdateTotalDuration(bigtime_t duration); 90 91 Playlist* fPlaylist; 92 PlaylistListView* fListView; 93 94 BView* fTopView; 95 BMenuItem* fUndoMI; 96 BMenuItem* fRedoMI; 97 98 RWLocker* fLocker; 99 CommandStack* fCommandStack; 100 ListenerAdapter fCommandStackListener; 101 102 entry_ref fSavedPlaylistRef; 103 104 DurationListener* fDurationListener; 105 BStringView* fTotalDuration; 106 }; 107 108 109 #endif // PLAYLIST_WINDOW_H 110