Rev 7177 | Rev 7183 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7177 | Rev 7182 | ||
---|---|---|---|
Line 11... | Line 11... | ||
11 | //===================================================// |
11 | //===================================================// |
Line 12... | Line 12... | ||
12 | 12 | ||
13 | #include "../lib/file_system.h" |
13 | #include "../lib/file_system.h" |
14 | #include "../lib/list_box.h" |
14 | #include "../lib/list_box.h" |
- | 15 | #include "../lib/gui.h" |
|
- | 16 | #include "../lib/kfont.h" |
|
Line 15... | Line -... | ||
15 | #include "../lib/gui.h" |
- | |
16 | 17 | #include "../lib/collection.h" |
|
17 | #include "../lib/obj/box_lib.h" |
18 | |
18 | #include "../lib/obj/libio.h" |
19 | #include "../lib/obj/libio.h" |
- | 20 | #include "../lib/obj/libimg.h" |
|
- | 21 | #include "../lib/obj/libini.h" |
|
Line 19... | Line 22... | ||
19 | #include "../lib/obj/libimg.h" |
22 | #include "../lib/obj/proc_lib.h" |
20 | #include "../lib/obj/libini.h" |
- | |
21 | - | ||
22 | #include "../lib/patterns/libimg_load_skin.h" |
23 | #include "../lib/obj/box_lib.h" |
Line 23... | Line 24... | ||
23 | 24 | ||
24 | #include "../lib/obj/proc_lib.h" |
25 | #include "../lib/patterns/libimg_load_skin.h" |
25 | #include "../lib/patterns/simple_open_dialog.h" |
26 | #include "../lib/patterns/simple_open_dialog.h" |
Line 32... | Line 33... | ||
32 | 33 | ||
33 | //simple open dialog data |
34 | //simple open dialog data |
34 | char default_dir[] = "/rd/1"; |
35 | char default_dir[] = "/rd/1"; |
Line 35... | Line 36... | ||
35 | od_filter filter2 = { 8, "MP3\0\0" }; |
36 | od_filter filter2 = { 8, "MP3\0\0" }; |
36 | 37 | ||
Line 37... | Line 38... | ||
37 | #define ABOUT_MESSAGE "'Pixies Player v2.4 |
38 | #define ABOUT_MESSAGE "'Pixies Player v2.5 |
38 | A tiny MP3 folder player. |
39 | A tiny MP3 folder player. |
39 | 40 | ||
Line 83... | Line 84... | ||
83 | enum { |
84 | enum { |
84 | PLAYBACK_MODE_STOPED, |
85 | PLAYBACK_MODE_STOPED, |
85 | PLAYBACK_MODE_PLAYING |
86 | PLAYBACK_MODE_PLAYING |
86 | }; |
87 | }; |
Line -... | Line 88... | ||
- | 88 | ||
- | 89 | collection music_col; |
|
87 | 90 | ||
88 | //===================================================// |
91 | //===================================================// |
89 | // // |
92 | // // |
90 | // CODE // |
93 | // CODE // |
91 | // // |
94 | // // |
Line 111... | Line 114... | ||
111 | strcpy(#pixie_ini_path, tempstr); |
114 | strcpy(#pixie_ini_path, tempstr); |
112 | list.SetFont(8, 14, 0x90); |
115 | list.SetFont(8, 14, 0x90); |
113 | if (!param) notify("'Pixie Player\nPress O key to open MP3 file' -St"); |
116 | if (!param) notify("'Pixie Player\nPress O key to open MP3 file' -St"); |
114 | LoadLibraries(); |
117 | LoadLibraries(); |
115 | LoadIniConfig(); |
118 | LoadIniConfig(); |
116 | SetEventMask(0100111b); |
119 | kfont.init(DEFAULT_FONT); |
- | 120 | SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER); |
|
117 | loop() |
121 | loop() |
118 | { |
122 | { |
119 | WaitEventTimeout(10); |
123 | WaitEventTimeout(10); |
120 | switch(EAX & 0xFF) { |
124 | switch(EAX & 0xFF) { |
121 | case evMouse: |
125 | case evMouse: |
Line 183... | Line 187... | ||
183 | void DrawPlayList() |
187 | void DrawPlayList() |
184 | { |
188 | { |
185 | int i; |
189 | int i; |
186 | int yyy; |
190 | int yyy; |
187 | char temp_filename[4096]; |
191 | char temp_filename[4096]; |
- | 192 | dword text_color, bg_color; |
|
188 | for (i=0; i |
193 | for (i=0; i |
189 | { |
194 | { |
190 | strcpy(#temp_filename, files_mas[i + list.first] * 304 + buf + 72); |
195 | strcpy(#temp_filename, files_mas[i + list.first] * 304 + buf + 72); |
191 | temp_filename[strlen(#temp_filename)-4] = '\0'; |
196 | //temp_filename[strlen(#temp_filename)-4] = '\0'; |
192 | if (strlen(#temp_filename)>47) strcpy(#temp_filename+44, "..."); |
197 | //if (strlen(#temp_filename)>47) strcpy(#temp_filename+44, "..."); |
Line 193... | Line 198... | ||
193 | 198 | ||
Line 194... | Line 199... | ||
194 | yyy = i*list.item_h+list.y; |
199 | yyy = i*list.item_h+list.y; |
195 | 200 | ||
196 | //this is selected file |
201 | //this is selected file |
197 | if (list.cur_y - list.first == i) |
202 | if (list.cur_y - list.first == i) |
198 | { |
203 | { |
199 | if (i>=list.count) continue; |
204 | if (i>=list.count) continue; |
200 | DrawBar(list.x, yyy, list.w, list.item_h, theme.color_list_active_bg); |
205 | bg_color = theme.color_list_active_bg; |
201 | WriteText(12,yyy+list.text_y,list.font_type, theme.color_list_active_text, #temp_filename); |
206 | text_color = theme.color_list_text; |
202 | } |
207 | } |
203 | //this is not selected file |
208 | //this is not selected file |
204 | else |
209 | else |
205 | { |
210 | { |
206 | if (i>=list.count) continue; |
211 | if (i>=list.count) continue; |
207 | DrawBar(list.x,yyy,list.w, list.item_h, theme.color_list_bg); |
212 | bg_color = theme.color_list_bg; |
208 | WriteText(12,yyy+list.text_y,list.font_type, theme.color_list_text, #temp_filename); |
213 | text_color = theme.color_list_text; |
209 | } |
214 | } |
210 | //this is cur_y playing file |
215 | //this is cur_y playing file |
211 | if (i + list.first == current_playing_file_n) && (playback_mode == PLAYBACK_MODE_PLAYING) |
216 | if (i + list.first == current_playing_file_n) && (playback_mode == PLAYBACK_MODE_PLAYING) |
212 | { |
- | |
213 | WriteText(3, yyy+list.text_y+3,0x80, theme.color_list_active_pointer, "\x10"); |
217 | { |
- | 218 | text_color = theme.color_list_active_text; |
|
- | 219 | } |
|
214 | WriteText(12,yyy+list.text_y,list.font_type, theme.color_list_active_text, #temp_filename); |
220 | DrawBar(list.x, yyy, list.w, list.item_h, bg_color); |
215 | } |
221 | kfont.WriteIntoWindow(12, yyy+list.text_y, bg_color, text_color, 11, #temp_filename); |
216 | } |
222 | } |
217 | DrawBar(list.x,list.visible * list.item_h + list.y, list.w, -list.visible * list.item_h + list.h, theme.color_list_bg); |
223 | DrawBar(list.x,list.visible * list.item_h + list.y, list.w, -list.visible * list.item_h + list.h, theme.color_list_bg); |
Line 232... | Line 238... | ||
232 | 238 | ||
233 | dword GetSongTitle() |
239 | dword GetSongTitle() |
234 | { |
240 | { |
235 | char cur_y_playing_title[245]; |
241 | char cur_y_playing_title[245]; |
236 | strcpy(#cur_y_playing_title, #current_filename); |
242 | strcpy(#cur_y_playing_title, #current_filename); |
237 | cur_y_playing_title[strlen(#cur_y_playing_title)-4] = '\0'; |
243 | //cur_y_playing_title[strlen(#cur_y_playing_title)-4] = '\0'; |
238 | if (strlen(#cur_y_playing_title) > 36) strcpy(#cur_y_playing_title + 34, "..."); |
244 | //if (strlen(#cur_y_playing_title) > 36) strcpy(#cur_y_playing_title + 34, "..."); |
239 | return #cur_y_playing_title; |
245 | return #cur_y_playing_title; |
Line 240... | Line 246... | ||
240 | } |
246 | } |
Line 245... | Line 251... | ||
245 | 251 | ||
246 | int button_y; |
252 | int button_y; |
247 | //Mode depended |
253 | //Mode depended |
248 | if (window_mode == WINDOW_MODE_NORMAL) |
254 | if (window_mode == WINDOW_MODE_NORMAL) |
249 | { |
255 | { |
250 | button_y = 47; |
256 | button_y = 46; |
251 | img_draw stdcall(skin.image, 0, 0, skin.w, skin.h, 0, 0); |
257 | img_draw stdcall(skin.image, 0, 0, skin.w, skin.h, 0, 0); |
252 | if (playback_mode != PLAYBACK_MODE_STOPED) img_draw stdcall(skin.image, 38, button_y, 33, 17, skin.w+1, WIN_H_SMALL+1); |
258 | if (playback_mode != PLAYBACK_MODE_STOPED) img_draw stdcall(skin.image, 40, button_y, 35, 19, skin.w+1, WIN_H_SMALL+1); |
253 | if /*(!list.count) && */ (!work_folder) DrawPixieTitle("Pixie"); |
259 | if /*(!list.count) && */ (!work_folder) DrawPixieTitle("Pixie"); |
254 | else DrawPixieTitle(#work_folder + strrchr(#work_folder, '/')); |
260 | else DrawPixieTitle(#work_folder + strrchr(#work_folder, '/')); |
255 | WriteText(10, 26, list.font_type, theme.color_top_panel_song_name, GetSongTitle()); |
261 | kfont.WriteIntoWindow(10, 26, theme.color_top_panel_bg, theme.color_top_panel_song_name, 11, GetSongTitle()); |
256 | //Playing control buttons |
262 | //Playing control buttons |
257 | DefineHiddenButton(7, button_y, 30, 16, BUTTON_PLAYBACK_PREV); |
263 | DefineHiddenButton(7, button_y, 32, 18, BUTTON_PLAYBACK_PREV); |
258 | DefineHiddenButton(39, button_y, 30, 16, BUTTON_PLAYBACK_PLAY_PAUSE); |
264 | DefineHiddenButton(41, button_y, 32, 18, BUTTON_PLAYBACK_PLAY_PAUSE); |
259 | DefineHiddenButton(71, button_y, 30, 16, BUTTON_PLAYBACK_NEXT); |
265 | DefineHiddenButton(75, button_y, 32, 18, BUTTON_PLAYBACK_NEXT); |
260 | //Window control buttons |
266 | //Window control buttons |
261 | DefineHiddenButton(Form.width - 21, 1, 20, 13, BUTTON_WINDOW_CLOSE); |
267 | DefineHiddenButton(Form.width - 21, 1, 20, 13, BUTTON_WINDOW_CLOSE); |
262 | DefineHiddenButton(Form.width - 43, 1, 20, 13, BUTTON_WINDOW_MINIMIZE); |
268 | DefineHiddenButton(Form.width - 43, 1, 20, 13, BUTTON_WINDOW_MINIMIZE); |
263 | DefineHiddenButton(Form.width - 65, 1, 20, 13, BUTTON_WINDOW_REDUCE); |
269 | DefineHiddenButton(Form.width - 65, 1, 20, 13, BUTTON_WINDOW_REDUCE); |
Line 293... | Line 299... | ||
293 | if (list.count > list.visible) scrollbar_v_draw(#scroll1); |
299 | if (list.count > list.visible) scrollbar_v_draw(#scroll1); |
294 | } |
300 | } |
Line 295... | Line 301... | ||
295 | 301 | ||
296 | void DrawPixieTitle(dword _title) |
302 | void DrawPixieTitle(dword _title) |
- | 303 | { |
|
297 | { |
304 | kfont.bold = true; |
- | 305 | kfont.WriteIntoWindow(10, 6, theme.color_top_panel_bg, theme.color_top_panel_folder_name, 12, _title); |
|
298 | WriteTextB(10, 6, list.font_type, theme.color_top_panel_folder_name, _title); |
306 | kfont.bold = false; |
Line 299... | Line 307... | ||
299 | } |
307 | } |
300 | 308 | ||
301 | //===================================================// |
309 | //===================================================// |
Line 347... | Line 355... | ||
347 | { |
355 | { |
348 | word i; |
356 | word i; |
349 | char item_path[4096]; |
357 | char item_path[4096]; |
350 | char notify_message[512]; |
358 | char notify_message[512]; |
351 | EventStopPlayingMp3(); |
359 | EventStopPlayingMp3(); |
352 | if (current_playing_file_n > list.count) { |
360 | if (current_playing_file_n >= list.count) { |
353 | current_playing_file_n = list.count; |
361 | current_playing_file_n = list.count-1; |
354 | return; |
362 | return; |
355 | } |
363 | } |
356 | if (current_playing_file_n < 0) { |
364 | if (current_playing_file_n < 0) { |
357 | current_playing_file_n = 0; |
365 | current_playing_file_n = 0; |
358 | return; |
366 | return; |
Line 360... | Line 368... | ||
360 | playback_mode = PLAYBACK_MODE_PLAYING; |
368 | playback_mode = PLAYBACK_MODE_PLAYING; |
361 | strlcpy(#current_filename, Getcur_yItemName(), sizeof(current_filename)); |
369 | strlcpy(#current_filename, Getcur_yItemName(), sizeof(current_filename)); |
362 | sprintf(#item_path,"-h %s/%s",#work_folder,#current_filename); |
370 | sprintf(#item_path,"-h %s/%s",#work_folder,#current_filename); |
363 | DrawPlayList(); |
371 | DrawPlayList(); |
364 | DrawTopPanel(); |
372 | DrawTopPanel(); |
365 | if (strcmpi(#item_path+strlen(#item_path)-3,".mp3")) player_run_id = RunProgram("/sys/media/ac97snd", #item_path); |
373 | player_run_id = RunProgram("/sys/media/ac97snd", #item_path); |
366 | sprintf(#notify_message,"'Now playing:\n%s' -St",#current_filename); |
374 | sprintf(#notify_message,"'Now playing:\n%s' -St",#current_filename); |
367 | for (i=2; i |
375 | for (i=2; i |
368 | notify_run_id = notify(#notify_message); |
376 | notify_run_id = notify(#notify_message); |
369 | } |
377 | } |