Rev 7628 | Rev 7765 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
6920 | leency | 1 | #define MEMSIZE 4096 * 50 |
2 | |||
3 | //===================================================// |
||
4 | // // |
||
5 | // LIB // |
||
6 | // // |
||
7 | //===================================================// |
||
8 | |||
7219 | leency | 9 | #include "../lib/fs.h" |
6920 | leency | 10 | #include "../lib/list_box.h" |
11 | #include "../lib/gui.h" |
||
7183 | leency | 12 | #include "../lib/random.h" |
7182 | leency | 13 | #include "../lib/kfont.h" |
6920 | leency | 14 | |
7049 | leency | 15 | #include "../lib/obj/libio.h" |
16 | #include "../lib/obj/libimg.h" |
||
6920 | leency | 17 | #include "../lib/obj/libini.h" |
7182 | leency | 18 | #include "../lib/obj/proc_lib.h" |
19 | #include "../lib/obj/box_lib.h" |
||
6920 | leency | 20 | |
21 | #include "../lib/patterns/simple_open_dialog.h" |
||
22 | |||
23 | //===================================================// |
||
24 | // // |
||
25 | // DATA // |
||
26 | // // |
||
27 | //===================================================// |
||
28 | |||
29 | //simple open dialog data |
||
30 | char default_dir[] = "/rd/1"; |
||
7189 | leency | 31 | od_filter filter2 = { 15, "MP3\0WAV\0XM\0\0" }; |
6920 | leency | 32 | |
7628 | leency | 33 | #define ABOUT_MESSAGE " v2.94 Final |
7189 | leency | 34 | |
7628 | leency | 35 | A tiny music folder player. |
36 | Supports MP3, WAV, XM audio file formats. |
||
6920 | leency | 37 | |
7229 | leency | 38 | Hot keys: |
7628 | leency | 39 | Open file: O key |
40 | Play/Stop: Space or P key |
||
41 | Start playing selected file: Enter |
||
42 | Goto next/previous track: Ctrl + Left/Right |
||
43 | Change sound volume: Left/Right key |
||
44 | Remove from the list: Delete |
||
45 | Permanently delete file: Shift + Delete |
||
46 | Show file info: I |
||
47 | Repeat: R |
||
48 | Shuffle: S |
||
49 | Mute: M |
||
6920 | leency | 50 | |
7189 | leency | 51 | kolibri-n.org & aspero.pro" |
6920 | leency | 52 | |
7189 | leency | 53 | scroll_bar scroll1 = { 5,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee, |
54 | 0,0,0,0,0,0,0,0,0,0,0,0,0,1,1}; |
||
55 | |||
6920 | leency | 56 | proc_info Form; |
57 | llist list; |
||
58 | |||
59 | char pixie_ini_path[4096]; |
||
60 | char work_folder[4096]; |
||
61 | char current_filename[256]; |
||
62 | |||
63 | enum { |
||
64 | BUTTON_WINDOW_CLOSE = 1, |
||
65 | BUTTON_WINDOW_MINIMIZE, |
||
66 | BUTTON_WINDOW_REDUCE, |
||
67 | BUTTON_PLAYBACK_PLAY_PAUSE = 10, |
||
68 | BUTTON_PLAYBACK_PREV, |
||
69 | BUTTON_PLAYBACK_NEXT, |
||
7183 | leency | 70 | BUTTON_REPEAT, |
71 | BUTTON_SHUFFLE, |
||
6920 | leency | 72 | BUTTON_OPEN_DIALOG, |
73 | BUTTON_SHOW_VOLUME |
||
74 | }; |
||
75 | |||
76 | int player_run_id; |
||
77 | int notify_run_id; |
||
78 | |||
7742 | leency | 79 | bool repeat=false; |
80 | bool shuffle=false; |
||
7183 | leency | 81 | |
6920 | leency | 82 | int current_playing_file_n=0; |
83 | |||
84 | word win_x_normal, win_y_normal; |
||
85 | word win_x_small, win_y_small; |
||
86 | |||
87 | byte window_mode; |
||
88 | enum { |
||
89 | WINDOW_MODE_NORMAL, |
||
90 | WINDOW_MODE_SMALL |
||
91 | }; |
||
92 | |||
93 | byte playback_mode; |
||
94 | enum { |
||
95 | PLAYBACK_MODE_STOPED, |
||
96 | PLAYBACK_MODE_PLAYING |
||
97 | }; |
||
98 | |||
7192 | leency | 99 | #define LAST_FOLDER_EXISTS 1 |
100 | |||
6920 | leency | 101 | //===================================================// |
102 | // // |
||
103 | // CODE // |
||
104 | // // |
||
105 | //===================================================// |
||
106 | |||
107 | #include "get_files_list.h" |
||
108 | #include "settings.h" |
||
109 | |||
110 | void LoadLibraries() |
||
111 | { |
||
112 | load_dll(boxlib, #box_lib_init,0); |
||
113 | load_dll(libio, #libio_init,1); |
||
114 | load_dll(libimg, #libimg_init,1); |
||
115 | load_dll(libini, #lib_init,1); |
||
116 | load_dll(Proc_lib, #OpenDialog_init,0); |
||
7182 | leency | 117 | OpenDialog_init stdcall (#o_dialog); |
6920 | leency | 118 | } |
119 | |||
120 | void main() |
||
121 | { |
||
7183 | leency | 122 | list.SetFont(8, 16, 13); |
6920 | leency | 123 | LoadLibraries(); |
124 | LoadIniConfig(); |
||
7348 | leency | 125 | if (!param) { |
126 | notify("'Pixie Player\nPress O key to open MP3/WAV/XM file' -St"); |
||
127 | if (work_folder) param=LAST_FOLDER_EXISTS; |
||
128 | } |
||
7182 | leency | 129 | kfont.init(DEFAULT_FONT); |
130 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); |
||
6920 | leency | 131 | loop() |
132 | { |
||
133 | WaitEventTimeout(10); |
||
134 | switch(EAX & 0xFF) { |
||
135 | case evMouse: |
||
136 | mouse.get(); |
||
137 | scrollbar_v_mouse (#scroll1); |
||
138 | if (list.first != scroll1.position) |
||
139 | { |
||
140 | list.first = scroll1.position; |
||
141 | DrawPlayList(); |
||
142 | break; |
||
143 | } |
||
144 | if (list.MouseOver(mouse.x, mouse.y)) |
||
145 | { |
||
146 | if (mouse.vert) && (list.MouseScroll(mouse.vert)) DrawPlayList(); |
||
147 | if (mouse.dblclick) EventStartPlayingSelectedItem(); |
||
7189 | leency | 148 | if (mouse.down) && (mouse.key&MOUSE_LEFT) |
149 | && (list.ProcessMouse(mouse.x, mouse.y)) DrawPlayList(); |
||
6920 | leency | 150 | } |
7189 | leency | 151 | if(mouse.key&MOUSE_LEFT) && (mouse.x<14) |
152 | && (window_mode == WINDOW_MODE_SMALL) EventDragWindow(); |
||
7628 | leency | 153 | if (mouse.down) && (mouse.y>skin_height) && (mouse.key&MOUSE_RIGHT) EventShowAbout(); |
6920 | leency | 154 | break; |
155 | case evButton: |
||
156 | switch(GetButtonID()) { |
||
157 | case BUTTON_WINDOW_CLOSE: EventExitApp(); break; |
||
158 | case BUTTON_WINDOW_MINIMIZE: MinimizeWindow(); break; |
||
159 | case BUTTON_WINDOW_REDUCE: EventChangeWindowMode(); break; |
||
160 | case BUTTON_PLAYBACK_PREV: EventPlaybackPrevious(); break; |
||
161 | case BUTTON_PLAYBACK_NEXT: EventPlaybackNext(); break; |
||
162 | case BUTTON_PLAYBACK_PLAY_PAUSE: EventPlayAndPause(); break; |
||
7183 | leency | 163 | case BUTTON_REPEAT: EventRepeatClick(); break; |
7192 | leency | 164 | case BUTTON_SHUFFLE: EventShuffleClick(); break; |
6920 | leency | 165 | case BUTTON_OPEN_DIALOG: EventFileDialogOpen(); break; |
166 | case BUTTON_SHOW_VOLUME: RunProgram("/sys/@VOLUME", NULL); break; |
||
167 | } |
||
168 | break; |
||
169 | case evKey: |
||
170 | GetKeys(); |
||
171 | if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) { |
||
172 | if (key_scancode==SCAN_CODE_LEFT) EventPlaybackPrevious(); |
||
173 | if (key_scancode==SCAN_CODE_RIGHT) EventPlaybackNext(); |
||
174 | break; |
||
7347 | leency | 175 | } |
176 | if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) { |
||
177 | if (key_scancode==SCAN_CODE_DEL) EventPermanentlyDeleteFile(); |
||
178 | break; |
||
179 | } |
||
6920 | leency | 180 | if (key_scancode==SCAN_CODE_KEY_O) EventFileDialogOpen(); |
181 | if (key_scancode==SCAN_CODE_KEY_M) RunProgram("/sys/@VOLUME", "m"); |
||
7192 | leency | 182 | if (key_scancode==SCAN_CODE_KEY_R) EventRepeatClick(); |
183 | if (key_scancode==SCAN_CODE_KEY_S) EventShuffleClick(); |
||
7429 | leency | 184 | if (key_scancode==SCAN_CODE_KEY_I) EventShowTagInfo(); |
6920 | leency | 185 | if (key_scancode==SCAN_CODE_RIGHT) RunProgram("/sys/@VOLUME", "+"); |
186 | if (key_scancode==SCAN_CODE_LEFT) RunProgram("/sys/@VOLUME", "-"); |
||
187 | if (key_scancode==SCAN_CODE_ENTER) EventStartPlayingSelectedItem(); |
||
7347 | leency | 188 | if (key_scancode==SCAN_CODE_DEL) EventRemoveItemFromList(); |
7189 | leency | 189 | if (key_scancode==SCAN_CODE_KEY_P)||(key_scancode==SCAN_CODE_SPACE) EventPlayAndPause(); |
7229 | leency | 190 | if (key_scancode==SCAN_CODE_F1) EventShowAbout(); |
6920 | leency | 191 | if (list.ProcessKey(key_scancode)) DrawPlayList(); |
192 | break; |
||
193 | case evReDraw: |
||
7189 | leency | 194 | if (window_mode == WINDOW_MODE_NORMAL) |
195 | DefineDragableWindow(win_x_normal, win_y_normal, skin.w - 1, skin.h + list.h-1); |
||
196 | if (window_mode == WINDOW_MODE_SMALL) |
||
197 | DefineDragableWindow(win_x_small, win_y_small, WIN_W_SMALL, WIN_H_SMALL); |
||
6920 | leency | 198 | draw_window(); |
199 | if (param[0]) { |
||
7192 | leency | 200 | if (param==LAST_FOLDER_EXISTS) EventOpenFolder(NULL); |
201 | else EventOpenFolder(#param); |
||
6920 | leency | 202 | param[0] = NULL; |
7348 | leency | 203 | } |
6920 | leency | 204 | break; |
205 | default: |
||
206 | EventCheckSongFinished(); |
||
207 | } |
||
208 | } |
||
209 | } |
||
210 | |||
211 | |||
212 | void DrawPlayList() |
||
213 | { |
||
214 | int i; |
||
215 | int yyy; |
||
7196 | leency | 216 | int kfont_width; |
6920 | leency | 217 | char temp_filename[4096]; |
7182 | leency | 218 | dword text_color, bg_color; |
6920 | leency | 219 | for (i=0; i |
220 | { |
||
221 | strcpy(#temp_filename, files_mas[i + list.first] * 304 + buf + 72); |
||
7189 | leency | 222 | temp_filename[strrchr(#temp_filename, '.')-1] = '\0'; |
6920 | leency | 223 | |
224 | yyy = i*list.item_h+list.y; |
||
225 | |||
226 | //this is selected file |
||
227 | if (list.cur_y - list.first == i) |
||
228 | { |
||
229 | if (i>=list.count) continue; |
||
7182 | leency | 230 | bg_color = theme.color_list_active_bg; |
231 | text_color = theme.color_list_text; |
||
6920 | leency | 232 | } |
233 | //this is not selected file |
||
234 | else |
||
235 | { |
||
236 | if (i>=list.count) continue; |
||
7182 | leency | 237 | bg_color = theme.color_list_bg; |
238 | text_color = theme.color_list_text; |
||
6920 | leency | 239 | } |
240 | //this is cur_y playing file |
||
7189 | leency | 241 | if (i + list.first == current_playing_file_n) |
242 | && (playback_mode == PLAYBACK_MODE_PLAYING) |
||
6920 | leency | 243 | { |
7182 | leency | 244 | text_color = theme.color_list_active_text; |
6920 | leency | 245 | } |
7182 | leency | 246 | DrawBar(list.x, yyy, list.w, list.item_h, bg_color); |
7196 | leency | 247 | kfont_width = kfont.WriteIntoWindow(6, yyy+list.text_y, bg_color, |
7189 | leency | 248 | text_color, list.font_type, #temp_filename); |
7196 | leency | 249 | if (kfont_width>skin.w-15) DrawBar(skin.w-1, yyy, 1, list.item_h, theme.color_list_border); |
6920 | leency | 250 | } |
7189 | leency | 251 | DrawBar(list.x,list.visible * list.item_h + list.y, list.w, |
252 | -list.visible * list.item_h + list.h, theme.color_list_bg); |
||
6920 | leency | 253 | DrawScroller(); |
254 | } |
||
255 | |||
256 | |||
257 | void draw_window() { |
||
258 | GetProcessInfo(#Form, SelfInfo); |
||
259 | DrawTopPanel(); |
||
260 | IF (Form.status_window>=2) return; |
||
261 | if (window_mode == WINDOW_MODE_NORMAL) |
||
262 | { |
||
263 | DrawPlayList(); |
||
264 | DrawRectangle(0, skin.h-1, skin.w-1, list.h+1, theme.color_list_border); |
||
265 | } |
||
266 | } |
||
267 | |||
268 | void DrawTopPanel() |
||
269 | { |
||
7196 | leency | 270 | int kfont_width; |
6920 | leency | 271 | int button_y; |
272 | //Mode depended |
||
273 | if (window_mode == WINDOW_MODE_NORMAL) |
||
274 | { |
||
7182 | leency | 275 | button_y = 46; |
6920 | leency | 276 | img_draw stdcall(skin.image, 0, 0, skin.w, skin.h, 0, 0); |
7189 | leency | 277 | if (playback_mode != PLAYBACK_MODE_STOPED) |
7200 | leency | 278 | img_draw stdcall(skin.image, 47, button_y, 41, 21, skin.w+1, WIN_H_SMALL+1); |
7189 | leency | 279 | if (repeat) |
7200 | leency | 280 | img_draw stdcall(skin.image, 217, button_y+2, 17,17,skin.w+43, WIN_H_SMALL+1); |
7189 | leency | 281 | if (shuffle) |
7200 | leency | 282 | img_draw stdcall(skin.image, 236, button_y+2, 17,17, skin.w+62, WIN_H_SMALL+1); |
7183 | leency | 283 | |
7189 | leency | 284 | if (!work_folder) DrawPixieTitle("Pixie"); |
7166 | leency | 285 | else DrawPixieTitle(#work_folder + strrchr(#work_folder, '/')); |
7196 | leency | 286 | kfont_width = kfont.WriteIntoWindow(8, 24, theme.color_top_panel_bg, |
287 | theme.color_top_panel_song_name, list.font_type, #current_filename); |
||
288 | if (kfont_width>skin.w-15) DrawBar(skin.w-1, 24, 1, list.item_h, theme.color_list_border); |
||
7166 | leency | 289 | //Playing control buttons |
7183 | leency | 290 | DefineHiddenButton(7, button_y, 38, 20, BUTTON_PLAYBACK_PREV); |
7200 | leency | 291 | DefineHiddenButton(48, button_y, 38, 20, BUTTON_PLAYBACK_PLAY_PAUSE); |
7183 | leency | 292 | DefineHiddenButton(87, button_y, 38, 20, BUTTON_PLAYBACK_NEXT); |
7166 | leency | 293 | //Window control buttons |
7183 | leency | 294 | DefineHiddenButton(Form.width - 27, 1, 26, 15, BUTTON_WINDOW_CLOSE); |
295 | DefineHiddenButton(Form.width - 55, 1, 26, 15, BUTTON_WINDOW_MINIMIZE); |
||
296 | DefineHiddenButton(Form.width - 83, 1, 26, 15, BUTTON_WINDOW_REDUCE); |
||
297 | //Other buttons |
||
7200 | leency | 298 | DefineHiddenButton(218, button_y+3, 17, 16, BUTTON_REPEAT); |
299 | DefineHiddenButton(237, button_y+3, 17, 16, BUTTON_SHUFFLE); |
||
300 | DefineHiddenButton(270, button_y+3, 17, 16, BUTTON_OPEN_DIALOG); |
||
301 | DefineHiddenButton(289, button_y+3, 17, 16, BUTTON_SHOW_VOLUME); |
||
6920 | leency | 302 | } |
303 | else if (window_mode == WINDOW_MODE_SMALL) |
||
304 | { |
||
7166 | leency | 305 | button_y = 7; |
6920 | leency | 306 | img_draw stdcall(skin.image, 0, 0, WIN_W_SMALL, WIN_H_SMALL, skin.w-1, 0); |
7196 | leency | 307 | if (playback_mode != PLAYBACK_MODE_STOPED) |
308 | img_draw stdcall(skin.image, 46, button_y-1, 27, 19, skin.w+83, WIN_H_SMALL+1); |
||
6920 | leency | 309 | DefineHiddenButton(0, 0, WIN_W_SMALL, WIN_H_SMALL, 99 + BT_NOFRAME); |
7166 | leency | 310 | //Playing control buttons |
7189 | leency | 311 | DefineHiddenButton(20, button_y, 24, 16, BUTTON_PLAYBACK_PREV); |
312 | DefineHiddenButton(46, button_y, 24, 16, BUTTON_PLAYBACK_PLAY_PAUSE); |
||
313 | DefineHiddenButton(72, button_y, 24, 16, BUTTON_PLAYBACK_NEXT); |
||
7166 | leency | 314 | //Window control buttons |
315 | DefineHiddenButton(Form.width - 20, 1, 19, 13, BUTTON_WINDOW_CLOSE); |
||
316 | DefineHiddenButton(Form.width - 20, 16, 19, 13, BUTTON_WINDOW_REDUCE); |
||
6920 | leency | 317 | } |
318 | } |
||
319 | |||
320 | |||
321 | void DrawScroller() |
||
322 | { |
||
323 | scroll1.max_area = list.count; |
||
324 | scroll1.cur_area = list.visible; |
||
325 | scroll1.position = list.first; |
||
326 | scroll1.all_redraw = 0; |
||
327 | scroll1.start_x = skin.w - scroll1.size_x-1; |
||
328 | scroll1.start_y = list.y-1; |
||
329 | scroll1.size_y = list.h+2; |
||
330 | if (list.count > list.visible) scrollbar_v_draw(#scroll1); |
||
331 | } |
||
332 | |||
7613 | leency | 333 | void DrawPixieTitle(dword _t) |
6920 | leency | 334 | { |
7613 | leency | 335 | char title[35]; |
336 | strlcpy(#title, _t, sizeof(title)); |
||
337 | if (strlen(#title)>30) strcpy(#title+30, "..."); |
||
7189 | leency | 338 | kfont.WriteIntoWindow(8, 5, theme.color_top_panel_bg, |
7613 | leency | 339 | theme.color_top_panel_folder_name, list.font_type, #title); |
6920 | leency | 340 | } |
341 | |||
342 | //===================================================// |
||
343 | // // |
||
344 | // EVENTS // |
||
345 | // // |
||
346 | //===================================================// |
||
347 | |||
348 | |||
349 | void EventOpenFolder(dword _open_path) |
||
350 | { |
||
7192 | leency | 351 | if (!_open_path) |
6920 | leency | 352 | { |
7192 | leency | 353 | OpenDirectory(#work_folder); |
354 | } |
||
355 | else |
||
356 | { |
||
6920 | leency | 357 | strcpy(#work_folder, _open_path); |
358 | work_folder[strrchr(#work_folder, '/')-1]='\0'; |
||
359 | OpenDirectory(#work_folder); |
||
360 | SetOpenedFileFirst(_open_path); |
||
361 | } |
||
362 | list.SetSizes(1, skin.h, skin.w-1, 22*15, 22); |
||
363 | if (list.count <= list.visible) |
||
364 | { |
||
365 | list.h = list.count * list.item_h; |
||
366 | list.visible = list.count; |
||
367 | list.w -= 1; |
||
368 | } |
||
369 | else |
||
370 | { |
||
371 | list.w -= scroll1.size_x; |
||
372 | } |
||
7196 | leency | 373 | if (window_mode==WINDOW_MODE_NORMAL) MoveSize(OLD, OLD, OLD, skin.h + list.h); |
6920 | leency | 374 | list.KeyHome(); |
375 | current_playing_file_n=0; |
||
7196 | leency | 376 | EventStopPlaying(); |
377 | if (_open_path) EventStartPlaying(); |
||
6920 | leency | 378 | } |
379 | |||
380 | |||
7196 | leency | 381 | void EventStopPlaying() |
6920 | leency | 382 | { |
383 | if (player_run_id) player_run_id = KillProcess(player_run_id); |
||
384 | if (notify_run_id) notify_run_id = KillProcess(notify_run_id); |
||
385 | playback_mode = PLAYBACK_MODE_STOPED; |
||
386 | DrawTopPanel(); |
||
387 | DrawPlayList(); |
||
388 | } |
||
389 | |||
390 | |||
7196 | leency | 391 | void EventStartPlaying() |
6920 | leency | 392 | { |
393 | word i; |
||
394 | char item_path[4096]; |
||
395 | char notify_message[512]; |
||
7196 | leency | 396 | EventStopPlaying(); |
7182 | leency | 397 | if (current_playing_file_n >= list.count) { |
398 | current_playing_file_n = list.count-1; |
||
6920 | leency | 399 | return; |
400 | } |
||
401 | if (current_playing_file_n < 0) { |
||
402 | current_playing_file_n = 0; |
||
403 | return; |
||
404 | } |
||
405 | playback_mode = PLAYBACK_MODE_PLAYING; |
||
7347 | leency | 406 | strlcpy(#current_filename, GetPlayingItemName(), sizeof(current_filename)); |
7177 | leency | 407 | sprintf(#item_path,"-h %s/%s",#work_folder,#current_filename); |
7196 | leency | 408 | current_filename[strrchr(#current_filename, '.')-1] = '\0'; |
6920 | leency | 409 | DrawPlayList(); |
410 | DrawTopPanel(); |
||
7182 | leency | 411 | player_run_id = RunProgram("/sys/media/ac97snd", #item_path); |
6920 | leency | 412 | sprintf(#notify_message,"'Now playing:\n%s' -St",#current_filename); |
7196 | leency | 413 | if (!repeat) && (window_mode==WINDOW_MODE_SMALL) |
7183 | leency | 414 | { |
415 | for (i=2; i |
||
7189 | leency | 416 | { |
417 | //replace ' char to avoid @notify misunderstood |
||
418 | if (notify_message[i]=='\'') notify_message[i]=96; |
||
419 | } |
||
7183 | leency | 420 | notify_run_id = notify(#notify_message); |
421 | } |
||
6920 | leency | 422 | } |
423 | |||
424 | |||
425 | void EventPlayAndPause() |
||
426 | { |
||
427 | if (playback_mode == PLAYBACK_MODE_PLAYING) |
||
428 | { |
||
429 | playback_mode = PLAYBACK_MODE_STOPED; |
||
7196 | leency | 430 | EventStopPlaying(); |
6920 | leency | 431 | } |
432 | else |
||
433 | { |
||
434 | playback_mode = PLAYBACK_MODE_PLAYING; |
||
7196 | leency | 435 | EventStartPlaying(); |
6920 | leency | 436 | } |
437 | } |
||
438 | |||
439 | |||
440 | void EventChangeWindowMode() |
||
441 | { |
||
442 | if (window_mode == WINDOW_MODE_NORMAL) |
||
443 | { |
||
444 | window_mode = WINDOW_MODE_SMALL; |
||
445 | win_x_normal = Form.left; |
||
446 | win_y_normal = Form.top; |
||
447 | MoveSize(OLD, OLD, WIN_W_SMALL-1, WIN_H_SMALL-1); |
||
448 | MoveSize(OLD, win_y_small, OLD, OLD); |
||
449 | MoveSize(win_x_small, OLD, OLD, OLD); |
||
450 | } |
||
451 | else |
||
452 | { |
||
453 | window_mode = WINDOW_MODE_NORMAL; |
||
454 | win_x_small = Form.left; |
||
455 | win_y_small = Form.top; |
||
456 | MoveSize(win_x_normal, win_y_normal, skin.w -1 ,skin.h + list.h); |
||
457 | } |
||
458 | } |
||
459 | |||
460 | void EventExitApp() |
||
461 | { |
||
7196 | leency | 462 | EventStopPlaying(); |
6920 | leency | 463 | SaveIniConfig(); |
464 | ExitProcess(); |
||
465 | } |
||
466 | |||
467 | void EventPlaybackPrevious() |
||
468 | { |
||
7183 | leency | 469 | if (shuffle) current_playing_file_n = random(list.count); |
470 | else current_playing_file_n--; |
||
7196 | leency | 471 | EventStartPlaying(); |
6920 | leency | 472 | } |
473 | |||
474 | void EventPlaybackNext() |
||
475 | { |
||
7183 | leency | 476 | if (shuffle) current_playing_file_n = random(list.count); |
477 | else current_playing_file_n++; |
||
7196 | leency | 478 | EventStartPlaying(); |
6920 | leency | 479 | } |
480 | |||
481 | void EventStartPlayingSelectedItem() |
||
482 | { |
||
483 | current_playing_file_n=list.cur_y; |
||
7196 | leency | 484 | EventStartPlaying(); |
6920 | leency | 485 | } |
486 | |||
487 | void EventFileDialogOpen() |
||
488 | { |
||
489 | OpenDialog_start stdcall (#o_dialog); |
||
490 | if (o_dialog.status==1) EventOpenFolder(#openfile_path); |
||
491 | } |
||
492 | |||
493 | void EventCheckSongFinished() |
||
494 | { |
||
7189 | leency | 495 | if (playback_mode == PLAYBACK_MODE_PLAYING) |
496 | && (!GetProcessSlot(player_run_id)) { |
||
7196 | leency | 497 | if (repeat) EventStartPlaying(); |
7183 | leency | 498 | else EventPlaybackNext(); |
6920 | leency | 499 | } |
500 | } |
||
501 | |||
7183 | leency | 502 | void EventRepeatClick() |
503 | { |
||
504 | repeat ^= 1; |
||
505 | DrawTopPanel(); |
||
506 | } |
||
6920 | leency | 507 | |
7192 | leency | 508 | void EventShuffleClick() |
7183 | leency | 509 | { |
510 | shuffle ^= 1; |
||
511 | DrawTopPanel(); |
||
512 | } |
||
513 | |||
7347 | leency | 514 | void EventRemoveItemFromList() |
7196 | leency | 515 | { |
516 | int i; |
||
517 | if (list.cur_y == current_playing_file_n) EventStopPlaying(); |
||
518 | for (i=list.cur_y; i |
||
519 | list.count--; |
||
7202 | leency | 520 | if (list.cur_y <= current_playing_file_n) current_playing_file_n--; |
7196 | leency | 521 | list.CheckDoesValuesOkey(); |
522 | if (list.count <= list.visible) |
||
523 | { |
||
524 | list.h = list.count * list.item_h; |
||
525 | list.visible = list.count; |
||
526 | if (window_mode==WINDOW_MODE_NORMAL) MoveSize(OLD, OLD, OLD, skin.h + list.h); |
||
527 | } |
||
528 | else DrawPlayList(); |
||
529 | } |
||
530 | |||
7347 | leency | 531 | void EventPermanentlyDeleteFile() |
532 | { |
||
533 | char item_path[4096]; |
||
534 | sprintf(#item_path,"%s/%s",#work_folder,GetSelectedItemName()); |
||
535 | DeleteFile(#item_path); |
||
536 | EventRemoveItemFromList(); |
||
537 | } |
||
538 | |||
7189 | leency | 539 | void EventShowAbout() |
540 | { |
||
7229 | leency | 541 | CreateThread(#ShowAboutThread,#menu_stak+4092); |
542 | } |
||
543 | |||
544 | void ShowAboutThread() |
||
545 | { |
||
7189 | leency | 546 | proc_info pop_up; |
547 | loop() switch(WaitEvent()) |
||
548 | { |
||
549 | case evButton: |
||
550 | ExitProcess(); |
||
551 | break; |
||
552 | case evKey: |
||
553 | GetKeys(); |
||
554 | if (key_scancode == SCAN_CODE_ESC) ExitProcess(); |
||
555 | break; |
||
556 | case evReDraw: |
||
7628 | leency | 557 | DefineDragableWindow(150, 200, 400, 400); |
7189 | leency | 558 | GetProcessInfo(#pop_up, SelfInfo); |
7229 | leency | 559 | |
7189 | leency | 560 | DrawBar(0, 0, pop_up.width, pop_up.height, theme.color_top_panel_bg); |
561 | DrawRectangle(0, 0, pop_up.width, pop_up.height, theme.color_list_border); |
||
562 | |||
563 | DefineHiddenButton(pop_up.width - 27, 1, 26, 15, BUTTON_WINDOW_CLOSE); |
||
7628 | leency | 564 | //img_draw stdcall(skin.image, pop_up.width-28, 0, 28, 18, skin.w - 29, 0); |
7192 | leency | 565 | DrawCaptButton(pop_up.width-10-80, pop_up.height - 34, 80, 24, 2, |
7628 | leency | 566 | 0x171717, 0xF5EFB3, "Cool"); |
7229 | leency | 567 | |
7628 | leency | 568 | WriteText(131,16, 0x81, 0x8E7C61, "Pixie Player"); |
569 | WriteText(130,15, 0x81, 0xF5EFB3, "Pixie Player"); |
||
7229 | leency | 570 | |
7628 | leency | 571 | WriteTextLines(10, 40, 0x90, theme.color_top_panel_song_name, ABOUT_MESSAGE, 19); |
572 | DrawIcon32(45, 15, theme.color_top_panel_bg, 65); |
||
573 | DrawIcon32(pop_up.width-32-45, 15, theme.color_top_panel_bg, 65); |
||
574 | |||
7189 | leency | 575 | } |
576 | } |
||
577 | |||
7429 | leency | 578 | /* |
579 | struct { |
||
580 | char tag[4]; |
||
581 | char title[60]; |
||
582 | char artist[60]; |
||
583 | char album[60]; |
||
584 | char speed; |
||
585 | char genre[30]; |
||
586 | char start_time[6]; |
||
587 | char end_time[6]; |
||
588 | } tag11; |
||
7189 | leency | 589 | |
7429 | leency | 590 | struct { |
591 | char tag[3]; |
||
592 | char title[30]; |
||
593 | char artist[30]; |
||
594 | char album[30]; |
||
595 | char year[4]; |
||
596 | char comment[30]; |
||
597 | unsigned char genre; //https://www.w3.org/People/Bos/MP3tag/mp3tag.c |
||
598 | } tag10; |
||
599 | */ |
||
600 | |||
601 | void EventShowTagInfo() |
||
602 | { |
||
603 | char item_path[4096]; |
||
604 | sprintf(#item_path,"%s/%s",#work_folder,GetSelectedItemName()); |
||
605 | RunProgram("/sys/media/mp3info", #item_path); |
||
606 | } |
||
607 | |||
608 | |||
6920 | leency | 609 | stop: |
610 | |||
611 | char menu_stak[4096];=>=>>=>14)> |