1/*
2 * Copyright 2007-2009, Haiku. All rights reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Stephan A��mus <superstippi@gmx.de>
7 */
8#ifndef PLAYLIST_LIST_VIEW_H
9#define PLAYLIST_LIST_VIEW_H
10
11#include <PopUpMenu.h>
12
13#include "ListViews.h"
14
15class CommandStack;
16class Controller;
17class ControllerObserver;
18class Playlist;
19class PlaylistItem;
20class PlaylistObserver;
21
22class PlaylistListView : public SimpleListView {
23public:
24								PlaylistListView(BRect frame,
25									Playlist* playlist,
26									Controller* controller,
27									CommandStack* stack);
28	virtual						~PlaylistListView();
29
30	// BView interface
31	virtual	void				AttachedToWindow();
32	virtual	void				MessageReceived(BMessage* message);
33
34	virtual	void				MouseDown(BPoint where);
35	virtual	void				KeyDown(const char* bytes, int32 numBytes);
36
37	// SimpleListView interface
38	virtual	void				MoveItems(const BList& indices, int32 toIndex);
39	virtual	void				CopyItems(const BList& indices, int32 toIndex);
40	virtual	void				RemoveItemList(const BList& indices);
41
42	virtual	void				DrawListItem(BView* owner, int32 index,
43									BRect frame) const;
44
45	// PlaylistListView
46			void				ItemsReceived(const BMessage* message,
47									int32 appendIndex);
48
49			void				Randomize();
50			void				RemoveSelectionToTrash();
51			void				RemoveToTrash(int32 index);
52			void				RemoveItemList(const BList& indices,
53									bool intoTrash);
54	virtual	void				SkipBackward();
55	virtual	void				SkipForward();
56
57private:
58	class Item;
59
60			void				_Wind(bigtime_t howMuch, int64 frames);
61			void				_FullSync();
62			void				_AddItem(PlaylistItem* item, int32 index);
63			void				_RemoveItem(int32 index);
64
65			void				_SetCurrentPlaylistIndex(int32 index);
66			void				_SetPlaybackState(uint32 state);
67
68			void				_AddDropContextMenu();
69			uint32				_ShowDropContextMenu(BPoint loc);
70
71			Playlist*			fPlaylist;
72			PlaylistObserver*	fPlaylistObserver;
73
74			Controller*			fController;
75			ControllerObserver*	fControllerObserver;
76
77			CommandStack*		fCommandStack;
78
79			int32				fCurrentPlaylistIndex;
80			uint32				fPlaybackState;
81
82			font_height			fFontHeight;
83			Item*				fLastClickedItem;
84
85			BPopUpMenu*			fDropContextMenu;
86};
87
88#endif // PLAYLIST_LIST_VIEW_H
89