-
Notifications
You must be signed in to change notification settings - Fork 2
/
interface.pb
191 lines (170 loc) · 9.06 KB
/
interface.pb
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
OpenWindow(#wnd,0,0,1280,720,#myNameVer,#PB_Window_SizeGadget|#PB_Window_SizeGadget|#PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_ScreenCentered)
WindowBounds(#wnd,1280,720,#PB_Ignore,#PB_Ignore)
CreateMenu(#menu,WindowID(#wnd))
MenuTitle("File")
MenuItem(#openPlaylist,"Open Playlist...")
MenuItem(#savePlaylist,"Save Playlist...")
MenuBar()
MenuItem(#addDirectory,"Add Directory...")
MenuItem(#addFile,"Add File(s)...")
MenuTitle("Playlist")
MenuItem(#playlistFind,"Find..." + Chr(9) + "+CMD+F")
MenuItem(#playlistDontGroupByAlbums,"Don't group by albums")
MenuBar()
MenuItem(#playlistShiftUp,"Move item up" + Chr(9) + "+SHIFT+↑")
MenuItem(#playlistShiftDown,"Move item down" + Chr(9) + "+SHIFT+↓")
MenuBar()
MenuItem(#playlistQueue,"Queue" + Chr(9) + "+␣")
MenuItem(#playlistPlay,"Play" + Chr(9) + "+⏎")
MenuItem(#playlistFinder,"Reveal in Finder")
MenuItem(#playlistReloadTags,"Reload tags" + Chr(9) + "+R")
MenuItem(#playlistRemove,"Remove from playlist" + Chr(9) + "+⌫")
MenuTitle("Playback")
MenuItem(#playbackCursorFollowsPlayback,"Cursor follows playback")
MenuItem(#playbackPlaybackFollowsCursor,"Playback follows cursor")
OpenSubMenu("Order")
MenuItem(#playbackOrderDefault,"Default")
MenuItem(#playbackOrderShuffleTracks,"Shuffle (tracks)")
MenuItem(#playbackOrderShuffleAlbums,"Shuffle (albums)")
CloseSubMenu()
MenuBar()
MenuItem(#playbackStopAtQueueEnd,"Stop at queue end")
MenuTitle("Last.fm")
MenuItem(#lastfmState,"")
MenuBar()
MenuItem(#lastfmUser,"")
DisableMenuItem(#menu,#lastfmUser,#True)
CreatePopupMenu(#playlistMenu)
MenuItem(#playlistQueue,"Queue" + Chr(9) + "␣")
MenuItem(#playlistPlay,"Play" + Chr(9) + "⏎")
MenuItem(#playlistFinder,"Reveal in Finder")
MenuItem(#playlistReloadTags,"Reload tags" + Chr(9) + "R")
MenuItem(#playlistRemove,"Remove from playlist" + Chr(9) + "⌫")
ListIconGadget(#playlist,0,0,WindowWidth(#wnd)-500,WindowHeight(#wnd),"",35)
AddGadgetColumn(#playlist,#file,"File",200)
AddGadgetColumn(#playlist,#track,"#",25)
AddGadgetColumn(#playlist,#artist,"Artist",200)
AddGadgetColumn(#playlist,#title,"Title",200)
AddGadgetColumn(#playlist,#duration,"Duration",65)
AddGadgetColumn(#playlist,#album,"Album",150)
AddGadgetColumn(#playlist,#details,"Details",80)
;CocoaMessage(0,GadgetID(#playlist),"setFloatsGroupRows:",#NO)
ListIconGadgetHideColumn(#playlist,#file,#True)
SetListIconColumnHeaderJustification(#playlist,#status,#justifyCenter)
SetListIconColumnHeaderJustification(#playlist,#track,#justifyRight)
SetListIconColumnHeaderJustification(#playlist,#duration,#justifyCenter)
SetListIconColumnHeaderJustification(#playlist,#details,#justifyRight)
;CocoaMessage(0,GadgetID(#playlist),"setGridStyleMask:",1)
;CocoaMessage(0, GadgetID(#playlist), "setUsesAlternatingRowBackgroundColors:", #YES)
;CocoaMessage(0, GadgetID(#playlist), "setUsesAutomaticRowHeights:", #YES)
;CocoaMessage(0,GadgetID(#playlist),"setAllowsTypeSelect:",#NO)
;CocoaMessage(0,GadgetID(#playlist),"setFloatsGroupRows:",#YES)
;CocoaMessage(0,GadgetID(#playlist),"setStyle:",4)
LoadFont(1,"Menlo",24,#PB_Font_Bold)
CreateImage(#defaultAlbumArt,500,500)
StartDrawing(ImageOutput(#defaultAlbumArt))
DrawingFont(FontID(1))
Box(0,0,500,500,0)
DrawText(500/2-TextWidth("[no album art]")/2,500/2-TextHeight("[no album art]")/2,"[no album art]",$CCCCCC,0)
StopDrawing()
FreeFont(1)
ImageGadget(#albumArt,WindowWidth(#wnd)-500,0,500,500,ImageID(#defaultAlbumArt))
CopyImage(#defaultAlbumArt,#tmpImage)
ResizeImage(#tmpImage,300,300,#PB_Image_Smooth)
SaveImage(#tmpImage,dataDir + "/tmp/album-art.jpg",#PB_ImagePlugin_JPEG,7)
FreeImage(#tmpImage)
TextGadget(#nowPlaying,WindowWidth(#wnd)-500,500,500,59,"",#PB_Text_Center)
TextGadget(#nowPlayingDuration,WindowWidth(#wnd)-500,559,500,16,"[standby]",#PB_Text_Center)
ProgressBarGadget(#nowPlayingProgress,WindowWidth(#wnd)-495,575,490,20,0,100)
SetGadgetState(#nowPlayingProgress,-2)
ButtonGadget(#toolbarPreviousAlbum,WindowWidth(#wnd)-495,595,50,25,#previousAlbumSymbol)
ButtonGadget(#toolbarPrevious,WindowWidth(#wnd)-445,595,50,25,#previousSymbol)
ButtonGadget(#toolbarPlayPause,WindowWidth(#wnd)-395,595,50,25,#playSymbol)
ButtonGadget(#toolbarNext,WindowWidth(#wnd)-345,595,50,25,#nextSymbol)
ButtonGadget(#toolbarNextAlbum,WindowWidth(#wnd)-295,595,50,25,#nextAlbumSymbol)
ButtonGadget(#toolbarStop,WindowWidth(#wnd)-245,595,50,25,#stopSymbol)
ButtonGadget(#toolbarLyricsReloadWeb,WindowWidth(#wnd)-55,595,50,25,#refreshSymbol)
GadgetToolTip(#toolbarPreviousAlbum,"Previous Album")
GadgetToolTip(#toolbarPrevious,"Previous Track")
GadgetToolTip(#toolbarPlayPause,"Play/Pause")
GadgetToolTip(#toolbarNext,"Next Track")
GadgetToolTip(#toolbarNextAlbum,"Next Album")
GadgetToolTip(#toolbarStop,"Stop")
GadgetToolTip(#toolbarLyricsReloadWeb,"Reload lyrics from Genius")
EditorGadget(#lyrics,WindowWidth(#wnd)-500,620,500,WindowHeight(#wnd)-620,#PB_Editor_ReadOnly|#PB_Editor_WordWrap)
HideGadget(#toolbarLyricsReloadWeb,#True)
Macro prefs()
OpenWindow(#wndPrefs,0,0,400,300,#myName + " Preferences",#PB_Window_WindowCentered|#PB_Window_SystemMenu|#PB_Window_Tool|#PB_Window_Invisible,WindowID(#wnd))
;StickyWindow(#wndPrefs,#True)
PanelGadget(#prefsPanel,0,0,400,300)
AddGadgetItem(#prefsPanel,-1,"Shortcuts")
ButtonGadget(#prefsShortcutEdit,5,10,100,25,"Edit")
TextGadget(#prefsShortcutToggleLabel,10,45,250,20,"Play/Pause:")
ShortcutGadget(#prefsShortcutToggle,10,65,100,20,0)
CocoaMessage(0,GadgetID(#prefsShortcutToggle),"setFocusRingType:",1)
TextGadget(#prefsShortcutNextLabel,10,95,250,20,"Next track:")
ShortcutGadget(#prefsShortcutNext,10,115,100,20,0)
CocoaMessage(0,GadgetID(#prefsShortcutNext),"setFocusRingType:",1)
TextGadget(#prefsShortcutPreviousLabel,10,145,250,20,"Previous track:")
ShortcutGadget(#prefsShortcutPrevious,10,165,100,20,0)
CocoaMessage(0,GadgetID(#prefsShortcutPrevious),"setFocusRingType:",1)
TextGadget(#prefsShortcutFindLabel,10,195,250,20,"Find:")
ShortcutGadget(#prefsShortcutFind,10,215,100,20,0)
CocoaMessage(0,GadgetID(#prefsShortcutFind),"setFocusRingType:",1)
SetGadgetText(#prefsShortcutToggle,settings\shortcuts\toggle_shortcut)
SetGadgetText(#prefsShortcutNext,settings\shortcuts\next_shortcut)
SetGadgetText(#prefsShortcutPrevious,settings\shortcuts\previous_shortcut)
SetGadgetText(#prefsShortcutFind,settings\shortcuts\find_shortcut)
For i = #prefsShortcutToggle To #prefsShortcutFind Step 2
DisableGadget(i,#True)
Next
AddGadgetItem(#prefsPanel,-1,"Web")
CheckBoxGadget(#prefsWebEnable,10,5,240,20,"Enable web server")
HyperLinkGadget(#prefsWebLink,250,9,160,20,"",$00aa00,#PB_HyperLink_Underline)
TextGadget(#prefsWebPortLabel,10,35,250,20,"Web server port (1025-65534):")
SpinGadget(#prefsWebPort,10,55,80,20,1025,65534,#PB_Spin_Numeric)
CocoaMessage(0,GadgetID(#prefsWebPort),"setFocusRingType:",1)
TextGadget(#prefsWebApiKeyLabel,10,85,350,20,"API key (used for authorization, leave blank to generate):")
StringGadget(#prefsWebApiKey,10,105,350,20,"")
CocoaMessage(0,GadgetID(#prefsWebApiKey),"setFocusRingType:",1)
SetGadgetColor(#prefsWebLink,#PB_Gadget_FrontColor,$458c1e)
SetGadgetText(#prefsWebPort,Str(settings\web\web_server_port))
SetGadgetState(#prefsWebPort,settings\web\web_server_port)
SetGadgetText(#prefsWebApiKey,settings\web\api_key)
If settings\web\use_web_server
SetGadgetState(#prefsWebEnable,#PB_Checkbox_Checked)
DisableGadget(#prefsWebPort,#True)
EndIf
If IsThread(webThread)
HideGadget(#prefsWebLink,#False)
SetGadgetText(#prefsWebLink,"running on port " + Str(settings\web\web_server_port))
Else
HideGadget(#prefsWebLink,#True)
EndIf
AddGadgetItem(#prefsPanel,-1,"Features")
CheckBoxGadget(#prefsUseTerminalNotifier,10,5,360,20,"Use terminal-notifier if available")
TextGadget(#prefsUseTerminalNotifierNote,10,25,360,60,"Used for playback notifications. It must be accessible as " + #terminalNotifier + ~". Install it with brew:\n`brew install terminal-notifier`")
CheckBoxGadget(#prefsUseGenius,10,100,360,20,"Use LyricsGenius if available")
TextGadget(#prefsUseGeniusNote,10,120,360,80,~"Used for downloading lyrics. Install it with brew and pip:\n`brew install python@3`\n`pip3 install lyricsgenius`\nTest by calling:\n`/usr/local/bin/python3 -m lyricsgenius -h`")
If settings\use_terminal_notifier
SetGadgetState(#prefsUseTerminalNotifier,#PB_Checkbox_Checked)
EndIf
If settings\use_genius
SetGadgetState(#prefsUseGenius,#PB_Checkbox_Checked)
EndIf
HideWindow(#wndPrefs,#False)
EndMacro
Macro action()
OpenWindow(#wndFind,0,0,400,300,"Find",#PB_Window_WindowCentered|#PB_Window_SystemMenu|#PB_Window_Tool|#PB_Window_Invisible,WindowID(#wnd))
StringGadget(#actionSearch,5,5,390,20,"",#PB_String_BorderLess)
ListViewGadget(#actionResults,0,25,400,275)
CocoaMessage(0,GadgetID(#actionSearch),"setFocusRingType:",1)
CocoaMessage(0,GadgetID(#actionResults),"setFocusRingType:",1)
AddKeyboardShortcut(#wndFind,#PB_Shortcut_Up,#actionUp)
AddKeyboardShortcut(#wndFind,#PB_Shortcut_Down,#actionDown)
AddKeyboardShortcut(#wndFind,#PB_Shortcut_Escape,#actionCancel)
AddKeyboardShortcut(#wndFind,#PB_Shortcut_Return,#actionConfirm)
HideWindow(#wndFind,#False)
SetActiveWindow(#wndFind)
SetActiveGadget(#actionSearch)
EndMacro