-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathPlaylistListView.h
More file actions
91 lines (72 loc) · 2.31 KB
/
PlaylistListView.h
File metadata and controls
91 lines (72 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef PLAYLIST_LIST_VIEW_H
#define PLAYLIST_LIST_VIEW_H
#include "SimpleColumnView.h"
#include <Bitmap.h>
#include <Entry.h>
#include <Messenger.h>
#include <PopUpMenu.h>
#include <String.h>
#include <vector>
enum class PlaylistItemKind { Library, Playlist };
struct PlaylistRow {
/** @name Data */
///@{
BString label;
bool writable;
PlaylistItemKind kind;
///@}
};
class PlaylistListView : public SimpleColumnView {
public:
PlaylistListView(const char *name, BMessenger target);
virtual ~PlaylistListView();
void SelectionChanged(int32 index) override;
void MessageReceived(BMessage *msg) override;
void MouseDown(BPoint where) override;
void MouseMoved(BPoint point, uint32 transit,
const BMessage *dragMsg) override;
void Draw(BRect updateRect) override;
/** @name Modification Logic */
///@{
int32 CreateNewPlaylist(const char *title);
void AddFileToPlaylist(int32 index, const entry_ref &ref);
void RemoveSelectedPlaylist();
void RenameItem(const BString &oldName, const BString &newName);
bool IsWritableAt(int32 index) const;
void SetIsUnwritableAt(int32 index, bool v);
void SetIsUnwritableByName(const BString &name, bool v);
bool RemovePlaylistAt(int32 index);
int32 AddItem(const char *title, bool writable);
int32 AddItem(const char *title, bool writable, PlaylistItemKind kind);
std::vector<BString> GetPlaylistOrder() const;
void SetPlaylistOrder(const std::vector<BString> &order);
///@}
/** @name Internal Helpers */
///@{
int32 FindIndexByName(const BString &name) const;
private:
int32 HitIndex(BPoint p) const;
void SetHoverIndex(int32 idx);
void _EnsureIconsLoaded() const;
BBitmap *_IconFor(PlaylistItemKind kind) const;
void _ReorderItem(int32 from, int32 to);
///@}
/** @name Data & State */
///@{
BMessenger fTarget;
BPopUpMenu *fContextMenu;
BPoint fLastDropPoint;
std::vector<PlaylistRow> fRows;
int32 fHoverIndex{-1};
int32 fDragIndex{-1};
int32 fDropLineIndex{-1};
BPoint fDragStartPoint;
bool fIsDragging{false};
mutable BBitmap *fIconLibrary = nullptr;
mutable BBitmap *fIconPlaylist = nullptr;
mutable float fIconSize = 16.0f;
float fIconPadX = 6.0f;
float fIconPadY = 2.0f;
///@}
};
#endif