2017-06-09 20:34:19 +02:00
|
|
|
#define MEMSIZE 4096 * 50
|
|
|
|
|
|
|
|
//===================================================//
|
|
|
|
// //
|
|
|
|
// LIB //
|
|
|
|
// //
|
|
|
|
//===================================================//
|
|
|
|
|
2018-04-03 15:57:56 +02:00
|
|
|
#include "../lib/fs.h"
|
2017-06-09 20:34:19 +02:00
|
|
|
#include "../lib/list_box.h"
|
|
|
|
#include "../lib/gui.h"
|
2018-03-12 17:12:14 +01:00
|
|
|
#include "../lib/random.h"
|
2018-03-11 21:16:50 +01:00
|
|
|
#include "../lib/kfont.h"
|
2017-06-09 20:34:19 +02:00
|
|
|
|
2017-10-05 00:59:57 +02:00
|
|
|
#include "../lib/obj/libimg.h"
|
2017-06-09 20:34:19 +02:00
|
|
|
#include "../lib/obj/libini.h"
|
2018-03-11 21:16:50 +01:00
|
|
|
#include "../lib/obj/proc_lib.h"
|
|
|
|
#include "../lib/obj/box_lib.h"
|
2017-06-09 20:34:19 +02:00
|
|
|
|
|
|
|
#include "../lib/patterns/simple_open_dialog.h"
|
|
|
|
|
|
|
|
//===================================================//
|
|
|
|
// //
|
|
|
|
// DATA //
|
|
|
|
// //
|
|
|
|
//===================================================//
|
|
|
|
|
|
|
|
//simple open dialog data
|
|
|
|
char default_dir[] = "/rd/1";
|
2018-03-16 21:06:42 +01:00
|
|
|
od_filter filter2 = { 15, "MP3\0WAV\0XM\0\0" };
|
|
|
|
|
2019-04-16 23:21:19 +02:00
|
|
|
#define ABOUT_MESSAGE " v2.94 Final
|
2017-06-09 20:34:19 +02:00
|
|
|
|
2019-04-16 23:21:19 +02:00
|
|
|
A tiny music folder player.
|
|
|
|
Supports MP3, WAV, XM audio file formats.
|
2017-06-09 20:34:19 +02:00
|
|
|
|
2018-04-16 11:30:24 +02:00
|
|
|
Hot keys:
|
2019-04-16 23:21:19 +02:00
|
|
|
Open file: O key
|
|
|
|
Play/Stop: Space or P key
|
|
|
|
Start playing selected file: Enter
|
|
|
|
Goto next/previous track: Ctrl + Left/Right
|
|
|
|
Change sound volume: Left/Right key
|
|
|
|
Remove from the list: Delete
|
|
|
|
Permanently delete file: Shift + Delete
|
|
|
|
Show file info: I
|
|
|
|
Repeat: R
|
|
|
|
Shuffle: S
|
|
|
|
Mute: M
|
2018-03-16 21:06:42 +01:00
|
|
|
|
|
|
|
kolibri-n.org & aspero.pro"
|
2017-06-09 20:34:19 +02:00
|
|
|
|
2018-03-16 21:06:42 +01:00
|
|
|
scroll_bar scroll1 = { 5,200,398,44,0,2,115,15,0,0xeeeeee,0xBBBbbb,0xeeeeee,
|
|
|
|
0,0,0,0,0,0,0,0,0,0,0,0,0,1,1};
|
2017-06-09 20:34:19 +02:00
|
|
|
|
|
|
|
proc_info Form;
|
|
|
|
llist list;
|
|
|
|
|
|
|
|
char pixie_ini_path[4096];
|
|
|
|
char work_folder[4096];
|
|
|
|
char current_filename[256];
|
|
|
|
|
|
|
|
enum {
|
|
|
|
BUTTON_WINDOW_CLOSE = 1,
|
|
|
|
BUTTON_WINDOW_MINIMIZE,
|
|
|
|
BUTTON_WINDOW_REDUCE,
|
|
|
|
BUTTON_PLAYBACK_PLAY_PAUSE = 10,
|
|
|
|
BUTTON_PLAYBACK_PREV,
|
|
|
|
BUTTON_PLAYBACK_NEXT,
|
2018-03-12 17:12:14 +01:00
|
|
|
BUTTON_REPEAT,
|
|
|
|
BUTTON_SHUFFLE,
|
2017-06-09 20:34:19 +02:00
|
|
|
BUTTON_OPEN_DIALOG,
|
|
|
|
BUTTON_SHOW_VOLUME
|
|
|
|
};
|
|
|
|
|
|
|
|
int player_run_id;
|
|
|
|
int notify_run_id;
|
|
|
|
|
2020-03-21 15:33:54 +01:00
|
|
|
bool repeat=false;
|
|
|
|
bool shuffle=false;
|
2018-03-12 17:12:14 +01:00
|
|
|
|
2017-06-09 20:34:19 +02:00
|
|
|
int current_playing_file_n=0;
|
|
|
|
|
|
|
|
word win_x_normal, win_y_normal;
|
|
|
|
word win_x_small, win_y_small;
|
|
|
|
|
|
|
|
byte window_mode;
|
|
|
|
enum {
|
|
|
|
WINDOW_MODE_NORMAL,
|
|
|
|
WINDOW_MODE_SMALL
|
|
|
|
};
|
|
|
|
|
|
|
|
byte playback_mode;
|
|
|
|
enum {
|
|
|
|
PLAYBACK_MODE_STOPED,
|
|
|
|
PLAYBACK_MODE_PLAYING
|
|
|
|
};
|
|
|
|
|
2020-05-28 02:55:16 +02:00
|
|
|
libimg_image skin;
|
|
|
|
|
2018-03-17 11:23:03 +01:00
|
|
|
#define LAST_FOLDER_EXISTS 1
|
|
|
|
|
2017-06-09 20:34:19 +02:00
|
|
|
//===================================================//
|
|
|
|
// //
|
|
|
|
// CODE //
|
|
|
|
// //
|
|
|
|
//===================================================//
|
|
|
|
|
|
|
|
#include "get_files_list.h"
|
|
|
|
#include "settings.h"
|
|
|
|
|
|
|
|
void LoadLibraries()
|
|
|
|
{
|
|
|
|
load_dll(boxlib, #box_lib_init,0);
|
|
|
|
load_dll(libimg, #libimg_init,1);
|
|
|
|
load_dll(libini, #lib_init,1);
|
|
|
|
load_dll(Proc_lib, #OpenDialog_init,0);
|
2018-03-11 21:16:50 +01:00
|
|
|
OpenDialog_init stdcall (#o_dialog);
|
2017-06-09 20:34:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void main()
|
|
|
|
{
|
2018-03-12 17:12:14 +01:00
|
|
|
list.SetFont(8, 16, 13);
|
2017-06-09 20:34:19 +02:00
|
|
|
LoadLibraries();
|
|
|
|
LoadIniConfig();
|
2018-09-10 21:01:23 +02:00
|
|
|
if (!param) {
|
|
|
|
notify("'Pixie Player\nPress O key to open MP3/WAV/XM file' -St");
|
|
|
|
if (work_folder) param=LAST_FOLDER_EXISTS;
|
|
|
|
}
|
2018-03-11 21:16:50 +01:00
|
|
|
kfont.init(DEFAULT_FONT);
|
2020-05-28 02:55:16 +02:00
|
|
|
@SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
|
|
|
|
loop() switch(@WaitEventTimeout(10))
|
2017-06-09 20:34:19 +02:00
|
|
|
{
|
|
|
|
case evMouse:
|
|
|
|
mouse.get();
|
|
|
|
scrollbar_v_mouse (#scroll1);
|
|
|
|
if (list.first != scroll1.position)
|
|
|
|
{
|
|
|
|
list.first = scroll1.position;
|
|
|
|
DrawPlayList();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (list.MouseOver(mouse.x, mouse.y))
|
|
|
|
{
|
|
|
|
if (mouse.vert) && (list.MouseScroll(mouse.vert)) DrawPlayList();
|
|
|
|
if (mouse.dblclick) EventStartPlayingSelectedItem();
|
2018-03-16 21:06:42 +01:00
|
|
|
if (mouse.down) && (mouse.key&MOUSE_LEFT)
|
|
|
|
&& (list.ProcessMouse(mouse.x, mouse.y)) DrawPlayList();
|
2017-06-09 20:34:19 +02:00
|
|
|
}
|
2018-03-16 21:06:42 +01:00
|
|
|
if(mouse.key&MOUSE_LEFT) && (mouse.x<14)
|
|
|
|
&& (window_mode == WINDOW_MODE_SMALL) EventDragWindow();
|
2019-04-16 23:21:19 +02:00
|
|
|
if (mouse.down) && (mouse.y>skin_height) && (mouse.key&MOUSE_RIGHT) EventShowAbout();
|
2017-06-09 20:34:19 +02:00
|
|
|
break;
|
|
|
|
case evButton:
|
2020-05-28 02:55:16 +02:00
|
|
|
switch(@GetButtonID()) {
|
2017-06-09 20:34:19 +02:00
|
|
|
case BUTTON_WINDOW_CLOSE: EventExitApp(); break;
|
|
|
|
case BUTTON_WINDOW_MINIMIZE: MinimizeWindow(); break;
|
|
|
|
case BUTTON_WINDOW_REDUCE: EventChangeWindowMode(); break;
|
|
|
|
case BUTTON_PLAYBACK_PREV: EventPlaybackPrevious(); break;
|
|
|
|
case BUTTON_PLAYBACK_NEXT: EventPlaybackNext(); break;
|
|
|
|
case BUTTON_PLAYBACK_PLAY_PAUSE: EventPlayAndPause(); break;
|
2018-03-12 17:12:14 +01:00
|
|
|
case BUTTON_REPEAT: EventRepeatClick(); break;
|
2018-03-17 11:23:03 +01:00
|
|
|
case BUTTON_SHUFFLE: EventShuffleClick(); break;
|
2017-06-09 20:34:19 +02:00
|
|
|
case BUTTON_OPEN_DIALOG: EventFileDialogOpen(); break;
|
|
|
|
case BUTTON_SHOW_VOLUME: RunProgram("/sys/@VOLUME", NULL); break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case evKey:
|
|
|
|
GetKeys();
|
|
|
|
if (key_modifier&KEY_LCTRL) || (key_modifier&KEY_RCTRL) {
|
|
|
|
if (key_scancode==SCAN_CODE_LEFT) EventPlaybackPrevious();
|
|
|
|
if (key_scancode==SCAN_CODE_RIGHT) EventPlaybackNext();
|
|
|
|
break;
|
2018-09-10 20:52:48 +02:00
|
|
|
}
|
|
|
|
if (key_modifier&KEY_LSHIFT) || (key_modifier&KEY_RSHIFT) {
|
|
|
|
if (key_scancode==SCAN_CODE_DEL) EventPermanentlyDeleteFile();
|
|
|
|
break;
|
|
|
|
}
|
2017-06-09 20:34:19 +02:00
|
|
|
if (key_scancode==SCAN_CODE_KEY_O) EventFileDialogOpen();
|
|
|
|
if (key_scancode==SCAN_CODE_KEY_M) RunProgram("/sys/@VOLUME", "m");
|
2018-03-17 11:23:03 +01:00
|
|
|
if (key_scancode==SCAN_CODE_KEY_R) EventRepeatClick();
|
|
|
|
if (key_scancode==SCAN_CODE_KEY_S) EventShuffleClick();
|
2018-10-03 01:32:56 +02:00
|
|
|
if (key_scancode==SCAN_CODE_KEY_I) EventShowTagInfo();
|
2017-06-09 20:34:19 +02:00
|
|
|
if (key_scancode==SCAN_CODE_RIGHT) RunProgram("/sys/@VOLUME", "+");
|
|
|
|
if (key_scancode==SCAN_CODE_LEFT) RunProgram("/sys/@VOLUME", "-");
|
|
|
|
if (key_scancode==SCAN_CODE_ENTER) EventStartPlayingSelectedItem();
|
2018-09-10 20:52:48 +02:00
|
|
|
if (key_scancode==SCAN_CODE_DEL) EventRemoveItemFromList();
|
2018-03-16 21:06:42 +01:00
|
|
|
if (key_scancode==SCAN_CODE_KEY_P)||(key_scancode==SCAN_CODE_SPACE) EventPlayAndPause();
|
2018-04-16 11:30:24 +02:00
|
|
|
if (key_scancode==SCAN_CODE_F1) EventShowAbout();
|
2017-06-09 20:34:19 +02:00
|
|
|
if (list.ProcessKey(key_scancode)) DrawPlayList();
|
|
|
|
break;
|
|
|
|
case evReDraw:
|
2018-03-16 21:06:42 +01:00
|
|
|
if (window_mode == WINDOW_MODE_NORMAL)
|
|
|
|
DefineDragableWindow(win_x_normal, win_y_normal, skin.w - 1, skin.h + list.h-1);
|
|
|
|
if (window_mode == WINDOW_MODE_SMALL)
|
|
|
|
DefineDragableWindow(win_x_small, win_y_small, WIN_W_SMALL, WIN_H_SMALL);
|
2017-06-09 20:34:19 +02:00
|
|
|
draw_window();
|
|
|
|
if (param[0]) {
|
2018-03-17 11:23:03 +01:00
|
|
|
if (param==LAST_FOLDER_EXISTS) EventOpenFolder(NULL);
|
|
|
|
else EventOpenFolder(#param);
|
2017-06-09 20:34:19 +02:00
|
|
|
param[0] = NULL;
|
2018-09-10 21:01:23 +02:00
|
|
|
}
|
2017-06-09 20:34:19 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
EventCheckSongFinished();
|
2020-05-28 02:55:16 +02:00
|
|
|
}
|
2017-06-09 20:34:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DrawPlayList()
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int yyy;
|
2018-03-20 09:24:20 +01:00
|
|
|
int kfont_width;
|
2017-06-09 20:34:19 +02:00
|
|
|
char temp_filename[4096];
|
2018-03-11 21:16:50 +01:00
|
|
|
dword text_color, bg_color;
|
2017-06-09 20:34:19 +02:00
|
|
|
for (i=0; i<list.visible; i++;)
|
|
|
|
{
|
|
|
|
strcpy(#temp_filename, files_mas[i + list.first] * 304 + buf + 72);
|
2018-03-16 21:06:42 +01:00
|
|
|
temp_filename[strrchr(#temp_filename, '.')-1] = '\0';
|
2017-06-09 20:34:19 +02:00
|
|
|
|
|
|
|
yyy = i*list.item_h+list.y;
|
|
|
|
|
|
|
|
//this is selected file
|
|
|
|
if (list.cur_y - list.first == i)
|
|
|
|
{
|
|
|
|
if (i>=list.count) continue;
|
2018-03-11 21:16:50 +01:00
|
|
|
bg_color = theme.color_list_active_bg;
|
|
|
|
text_color = theme.color_list_text;
|
2017-06-09 20:34:19 +02:00
|
|
|
}
|
|
|
|
//this is not selected file
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (i>=list.count) continue;
|
2018-03-11 21:16:50 +01:00
|
|
|
bg_color = theme.color_list_bg;
|
|
|
|
text_color = theme.color_list_text;
|
2017-06-09 20:34:19 +02:00
|
|
|
}
|
|
|
|
//this is cur_y playing file
|
2018-03-16 21:06:42 +01:00
|
|
|
if (i + list.first == current_playing_file_n)
|
|
|
|
&& (playback_mode == PLAYBACK_MODE_PLAYING)
|
2017-06-09 20:34:19 +02:00
|
|
|
{
|
2018-03-11 21:16:50 +01:00
|
|
|
text_color = theme.color_list_active_text;
|
2017-06-09 20:34:19 +02:00
|
|
|
}
|
2018-03-11 21:16:50 +01:00
|
|
|
DrawBar(list.x, yyy, list.w, list.item_h, bg_color);
|
2018-03-20 09:24:20 +01:00
|
|
|
kfont_width = kfont.WriteIntoWindow(6, yyy+list.text_y, bg_color,
|
2018-03-16 21:06:42 +01:00
|
|
|
text_color, list.font_type, #temp_filename);
|
2018-03-20 09:24:20 +01:00
|
|
|
if (kfont_width>skin.w-15) DrawBar(skin.w-1, yyy, 1, list.item_h, theme.color_list_border);
|
2017-06-09 20:34:19 +02:00
|
|
|
}
|
2018-03-16 21:06:42 +01:00
|
|
|
DrawBar(list.x,list.visible * list.item_h + list.y, list.w,
|
|
|
|
-list.visible * list.item_h + list.h, theme.color_list_bg);
|
2017-06-09 20:34:19 +02:00
|
|
|
DrawScroller();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void draw_window() {
|
|
|
|
GetProcessInfo(#Form, SelfInfo);
|
|
|
|
DrawTopPanel();
|
2021-06-26 09:59:13 +02:00
|
|
|
IF (Form.status_window&ROLLED_UP) return;
|
2017-06-09 20:34:19 +02:00
|
|
|
if (window_mode == WINDOW_MODE_NORMAL)
|
|
|
|
{
|
|
|
|
DrawPlayList();
|
|
|
|
DrawRectangle(0, skin.h-1, skin.w-1, list.h+1, theme.color_list_border);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DrawTopPanel()
|
|
|
|
{
|
2018-03-20 09:24:20 +01:00
|
|
|
int kfont_width;
|
2017-06-09 20:34:19 +02:00
|
|
|
//Mode depended
|
|
|
|
if (window_mode == WINDOW_MODE_NORMAL)
|
|
|
|
{
|
2021-12-17 11:41:38 +01:00
|
|
|
#define BIGBUTTON_Y 46
|
2017-06-09 20:34:19 +02:00
|
|
|
img_draw stdcall(skin.image, 0, 0, skin.w, skin.h, 0, 0);
|
2018-03-16 21:06:42 +01:00
|
|
|
if (playback_mode != PLAYBACK_MODE_STOPED)
|
2021-12-17 11:41:38 +01:00
|
|
|
img_draw stdcall(skin.image, 47, BIGBUTTON_Y, 41, 21, skin.w+1, WIN_H_SMALL+1);
|
2018-03-16 21:06:42 +01:00
|
|
|
if (repeat)
|
2021-12-17 11:41:38 +01:00
|
|
|
img_draw stdcall(skin.image, 189, BIGBUTTON_Y+5, 14,14,skin.w+44, WIN_H_SMALL+3);
|
2018-03-16 21:06:42 +01:00
|
|
|
if (shuffle)
|
2021-12-17 11:41:38 +01:00
|
|
|
img_draw stdcall(skin.image, 212, BIGBUTTON_Y+5, 14,14, skin.w+59, WIN_H_SMALL+3);
|
2018-03-16 21:06:42 +01:00
|
|
|
|
|
|
|
if (!work_folder) DrawPixieTitle("Pixie");
|
2018-02-21 00:23:57 +01:00
|
|
|
else DrawPixieTitle(#work_folder + strrchr(#work_folder, '/'));
|
2018-03-20 09:24:20 +01:00
|
|
|
kfont_width = kfont.WriteIntoWindow(8, 24, theme.color_top_panel_bg,
|
|
|
|
theme.color_top_panel_song_name, list.font_type, #current_filename);
|
|
|
|
if (kfont_width>skin.w-15) DrawBar(skin.w-1, 24, 1, list.item_h, theme.color_list_border);
|
2018-02-21 00:23:57 +01:00
|
|
|
//Playing control buttons
|
2021-12-17 11:41:38 +01:00
|
|
|
DefineHiddenButton(7, BIGBUTTON_Y, 38, 20, BUTTON_PLAYBACK_PREV);
|
|
|
|
DefineHiddenButton(48, BIGBUTTON_Y, 38, 20, BUTTON_PLAYBACK_PLAY_PAUSE);
|
|
|
|
DefineHiddenButton(87, BIGBUTTON_Y, 38, 20, BUTTON_PLAYBACK_NEXT);
|
2018-02-21 00:23:57 +01:00
|
|
|
//Window control buttons
|
2018-03-12 17:12:14 +01:00
|
|
|
DefineHiddenButton(Form.width - 27, 1, 26, 15, BUTTON_WINDOW_CLOSE);
|
|
|
|
DefineHiddenButton(Form.width - 55, 1, 26, 15, BUTTON_WINDOW_MINIMIZE);
|
|
|
|
DefineHiddenButton(Form.width - 83, 1, 26, 15, BUTTON_WINDOW_REDUCE);
|
|
|
|
//Other buttons
|
2021-12-17 11:41:38 +01:00
|
|
|
DefineHiddenButton(185, BIGBUTTON_Y+3, 22, 16, BUTTON_REPEAT);
|
|
|
|
DefineHiddenButton(208, BIGBUTTON_Y+3, 22, 16, BUTTON_SHUFFLE);
|
|
|
|
DefineHiddenButton(259, BIGBUTTON_Y+3, 18, 16, BUTTON_OPEN_DIALOG);
|
|
|
|
DefineHiddenButton(289, BIGBUTTON_Y+3, 18, 16, BUTTON_SHOW_VOLUME);
|
2017-06-09 20:34:19 +02:00
|
|
|
}
|
|
|
|
else if (window_mode == WINDOW_MODE_SMALL)
|
|
|
|
{
|
2021-12-17 11:41:38 +01:00
|
|
|
#define SMBUTTON_Y 7
|
2017-06-09 20:34:19 +02:00
|
|
|
img_draw stdcall(skin.image, 0, 0, WIN_W_SMALL, WIN_H_SMALL, skin.w-1, 0);
|
2018-03-20 09:24:20 +01:00
|
|
|
if (playback_mode != PLAYBACK_MODE_STOPED)
|
2021-12-17 11:41:38 +01:00
|
|
|
img_draw stdcall(skin.image, 46, SMBUTTON_Y-1, 27, 19, skin.w+83, WIN_H_SMALL+1);
|
2017-06-09 20:34:19 +02:00
|
|
|
DefineHiddenButton(0, 0, WIN_W_SMALL, WIN_H_SMALL, 99 + BT_NOFRAME);
|
2018-02-21 00:23:57 +01:00
|
|
|
//Playing control buttons
|
2021-12-17 11:41:38 +01:00
|
|
|
DefineHiddenButton(20, SMBUTTON_Y, 24, 16, BUTTON_PLAYBACK_PREV);
|
|
|
|
DefineHiddenButton(46, SMBUTTON_Y, 24, 16, BUTTON_PLAYBACK_PLAY_PAUSE);
|
|
|
|
DefineHiddenButton(72, SMBUTTON_Y, 24, 16, BUTTON_PLAYBACK_NEXT);
|
2018-02-21 00:23:57 +01:00
|
|
|
//Window control buttons
|
|
|
|
DefineHiddenButton(Form.width - 20, 1, 19, 13, BUTTON_WINDOW_CLOSE);
|
|
|
|
DefineHiddenButton(Form.width - 20, 16, 19, 13, BUTTON_WINDOW_REDUCE);
|
2017-06-09 20:34:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void DrawScroller()
|
|
|
|
{
|
|
|
|
scroll1.max_area = list.count;
|
|
|
|
scroll1.cur_area = list.visible;
|
|
|
|
scroll1.position = list.first;
|
|
|
|
scroll1.all_redraw = 0;
|
|
|
|
scroll1.start_x = skin.w - scroll1.size_x-1;
|
|
|
|
scroll1.start_y = list.y-1;
|
|
|
|
scroll1.size_y = list.h+2;
|
|
|
|
if (list.count > list.visible) scrollbar_v_draw(#scroll1);
|
|
|
|
}
|
|
|
|
|
2019-03-16 22:06:09 +01:00
|
|
|
void DrawPixieTitle(dword _t)
|
2017-06-09 20:34:19 +02:00
|
|
|
{
|
2019-03-16 22:06:09 +01:00
|
|
|
char title[35];
|
|
|
|
strlcpy(#title, _t, sizeof(title));
|
|
|
|
if (strlen(#title)>30) strcpy(#title+30, "...");
|
2018-03-16 21:06:42 +01:00
|
|
|
kfont.WriteIntoWindow(8, 5, theme.color_top_panel_bg,
|
2019-03-16 22:06:09 +01:00
|
|
|
theme.color_top_panel_folder_name, list.font_type, #title);
|
2017-06-09 20:34:19 +02:00
|
|
|
}
|
|
|
|
|
2020-04-05 20:28:02 +02:00
|
|
|
void DrawAboutWindow()
|
|
|
|
{
|
2020-05-28 02:55:16 +02:00
|
|
|
#define ABOUT_W 400
|
|
|
|
#define ABOUT_H 410
|
|
|
|
loop() switch(@WaitEvent())
|
2020-04-05 20:28:02 +02:00
|
|
|
{
|
2020-05-28 02:55:16 +02:00
|
|
|
case evButton: ExitProcess(); break;
|
|
|
|
case evKey: if (GetKeyScancode() == SCAN_CODE_ESC) ExitProcess(); break;
|
2020-04-05 20:28:02 +02:00
|
|
|
case evReDraw:
|
2020-05-28 02:55:16 +02:00
|
|
|
DefineDragableWindow(150, 200, ABOUT_W, ABOUT_H);
|
2020-04-05 20:28:02 +02:00
|
|
|
|
2020-05-28 02:55:16 +02:00
|
|
|
DrawBar(0, 0, ABOUT_W, ABOUT_H, theme.color_top_panel_bg);
|
|
|
|
DrawRectangle(0, 0, ABOUT_W, ABOUT_H, theme.color_list_border);
|
2020-04-05 20:28:02 +02:00
|
|
|
|
2020-05-28 02:55:16 +02:00
|
|
|
//DefineHiddenButton(ABOUT_W - 27, 1, 26, 15, BUTTON_WINDOW_CLOSE);
|
|
|
|
//skin.draw(ABOUT_W-28, 0, 28, 18, skin.w - 29, 0);
|
|
|
|
DrawCaptButton(ABOUT_W-10-80, ABOUT_H - 34, 80, 24, 2,
|
|
|
|
theme.color_top_panel_bg, 0xF5EFB3, "Cool");
|
2020-04-05 20:28:02 +02:00
|
|
|
|
|
|
|
WriteText(131,16, 0x81, 0x8E7C61, "Pixie Player");
|
|
|
|
WriteText(130,15, 0x81, 0xF5EFB3, "Pixie Player");
|
|
|
|
|
|
|
|
WriteTextLines(10, 40, 0x90, theme.color_top_panel_song_name, ABOUT_MESSAGE, 19);
|
|
|
|
DrawIcon32(45, 15, theme.color_top_panel_bg, 65);
|
2020-05-28 02:55:16 +02:00
|
|
|
DrawIcon32(ABOUT_W-32-45, 15, theme.color_top_panel_bg, 65);
|
2020-04-05 20:28:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-09 20:34:19 +02:00
|
|
|
//===================================================//
|
|
|
|
// //
|
|
|
|
// EVENTS //
|
|
|
|
// //
|
|
|
|
//===================================================//
|
|
|
|
|
|
|
|
|
|
|
|
void EventOpenFolder(dword _open_path)
|
|
|
|
{
|
2018-03-17 11:23:03 +01:00
|
|
|
if (!_open_path)
|
|
|
|
{
|
|
|
|
OpenDirectory(#work_folder);
|
|
|
|
}
|
|
|
|
else
|
2017-06-09 20:34:19 +02:00
|
|
|
{
|
|
|
|
strcpy(#work_folder, _open_path);
|
|
|
|
work_folder[strrchr(#work_folder, '/')-1]='\0';
|
|
|
|
OpenDirectory(#work_folder);
|
|
|
|
SetOpenedFileFirst(_open_path);
|
|
|
|
}
|
|
|
|
list.SetSizes(1, skin.h, skin.w-1, 22*15, 22);
|
|
|
|
if (list.count <= list.visible)
|
|
|
|
{
|
|
|
|
list.h = list.count * list.item_h;
|
|
|
|
list.visible = list.count;
|
|
|
|
list.w -= 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
list.w -= scroll1.size_x;
|
|
|
|
}
|
2018-03-20 09:24:20 +01:00
|
|
|
if (window_mode==WINDOW_MODE_NORMAL) MoveSize(OLD, OLD, OLD, skin.h + list.h);
|
2017-06-09 20:34:19 +02:00
|
|
|
list.KeyHome();
|
|
|
|
current_playing_file_n=0;
|
2018-03-20 09:24:20 +01:00
|
|
|
EventStopPlaying();
|
|
|
|
if (_open_path) EventStartPlaying();
|
2017-06-09 20:34:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-20 09:24:20 +01:00
|
|
|
void EventStopPlaying()
|
2017-06-09 20:34:19 +02:00
|
|
|
{
|
|
|
|
if (player_run_id) player_run_id = KillProcess(player_run_id);
|
|
|
|
if (notify_run_id) notify_run_id = KillProcess(notify_run_id);
|
|
|
|
playback_mode = PLAYBACK_MODE_STOPED;
|
|
|
|
DrawTopPanel();
|
|
|
|
DrawPlayList();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-03-20 09:24:20 +01:00
|
|
|
void EventStartPlaying()
|
2017-06-09 20:34:19 +02:00
|
|
|
{
|
|
|
|
word i;
|
|
|
|
char item_path[4096];
|
|
|
|
char notify_message[512];
|
2018-03-20 09:24:20 +01:00
|
|
|
EventStopPlaying();
|
2018-03-11 21:16:50 +01:00
|
|
|
if (current_playing_file_n >= list.count) {
|
|
|
|
current_playing_file_n = list.count-1;
|
2017-06-09 20:34:19 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (current_playing_file_n < 0) {
|
|
|
|
current_playing_file_n = 0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
playback_mode = PLAYBACK_MODE_PLAYING;
|
2018-09-10 20:52:48 +02:00
|
|
|
strlcpy(#current_filename, GetPlayingItemName(), sizeof(current_filename));
|
2018-03-07 12:18:19 +01:00
|
|
|
sprintf(#item_path,"-h %s/%s",#work_folder,#current_filename);
|
2018-03-20 09:24:20 +01:00
|
|
|
current_filename[strrchr(#current_filename, '.')-1] = '\0';
|
2017-06-09 20:34:19 +02:00
|
|
|
DrawPlayList();
|
|
|
|
DrawTopPanel();
|
2020-04-05 20:28:02 +02:00
|
|
|
//start_playing_time =
|
2018-03-11 21:16:50 +01:00
|
|
|
player_run_id = RunProgram("/sys/media/ac97snd", #item_path);
|
2020-04-05 20:28:02 +02:00
|
|
|
//player_run_id = RunProgram("/kolibrios/media/minimp3", #item_path);
|
2017-06-09 20:34:19 +02:00
|
|
|
sprintf(#notify_message,"'Now playing:\n%s' -St",#current_filename);
|
2018-03-20 09:24:20 +01:00
|
|
|
if (!repeat) && (window_mode==WINDOW_MODE_SMALL)
|
2018-03-12 17:12:14 +01:00
|
|
|
{
|
|
|
|
for (i=2; i<strlen(#notify_message)-6; i++)
|
2018-03-16 21:06:42 +01:00
|
|
|
{
|
|
|
|
//replace ' char to avoid @notify misunderstood
|
|
|
|
if (notify_message[i]=='\'') notify_message[i]=96;
|
|
|
|
}
|
2018-03-12 17:12:14 +01:00
|
|
|
notify_run_id = notify(#notify_message);
|
|
|
|
}
|
2017-06-09 20:34:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EventPlayAndPause()
|
|
|
|
{
|
|
|
|
if (playback_mode == PLAYBACK_MODE_PLAYING)
|
|
|
|
{
|
|
|
|
playback_mode = PLAYBACK_MODE_STOPED;
|
2018-03-20 09:24:20 +01:00
|
|
|
EventStopPlaying();
|
2017-06-09 20:34:19 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
playback_mode = PLAYBACK_MODE_PLAYING;
|
2018-03-20 09:24:20 +01:00
|
|
|
EventStartPlaying();
|
2017-06-09 20:34:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void EventChangeWindowMode()
|
|
|
|
{
|
|
|
|
if (window_mode == WINDOW_MODE_NORMAL)
|
|
|
|
{
|
|
|
|
window_mode = WINDOW_MODE_SMALL;
|
|
|
|
win_x_normal = Form.left;
|
|
|
|
win_y_normal = Form.top;
|
|
|
|
MoveSize(OLD, OLD, WIN_W_SMALL-1, WIN_H_SMALL-1);
|
|
|
|
MoveSize(OLD, win_y_small, OLD, OLD);
|
|
|
|
MoveSize(win_x_small, OLD, OLD, OLD);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
window_mode = WINDOW_MODE_NORMAL;
|
|
|
|
win_x_small = Form.left;
|
|
|
|
win_y_small = Form.top;
|
|
|
|
MoveSize(win_x_normal, win_y_normal, skin.w -1 ,skin.h + list.h);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventExitApp()
|
|
|
|
{
|
2018-03-20 09:24:20 +01:00
|
|
|
EventStopPlaying();
|
2017-06-09 20:34:19 +02:00
|
|
|
SaveIniConfig();
|
|
|
|
ExitProcess();
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventPlaybackPrevious()
|
|
|
|
{
|
2018-03-12 17:12:14 +01:00
|
|
|
if (shuffle) current_playing_file_n = random(list.count);
|
|
|
|
else current_playing_file_n--;
|
2018-03-20 09:24:20 +01:00
|
|
|
EventStartPlaying();
|
2017-06-09 20:34:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventPlaybackNext()
|
|
|
|
{
|
2018-03-12 17:12:14 +01:00
|
|
|
if (shuffle) current_playing_file_n = random(list.count);
|
|
|
|
else current_playing_file_n++;
|
2018-03-20 09:24:20 +01:00
|
|
|
EventStartPlaying();
|
2017-06-09 20:34:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventStartPlayingSelectedItem()
|
|
|
|
{
|
|
|
|
current_playing_file_n=list.cur_y;
|
2018-03-20 09:24:20 +01:00
|
|
|
EventStartPlaying();
|
2017-06-09 20:34:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventFileDialogOpen()
|
|
|
|
{
|
|
|
|
OpenDialog_start stdcall (#o_dialog);
|
|
|
|
if (o_dialog.status==1) EventOpenFolder(#openfile_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
void EventCheckSongFinished()
|
|
|
|
{
|
2018-03-16 21:06:42 +01:00
|
|
|
if (playback_mode == PLAYBACK_MODE_PLAYING)
|
|
|
|
&& (!GetProcessSlot(player_run_id)) {
|
2018-03-20 09:24:20 +01:00
|
|
|
if (repeat) EventStartPlaying();
|
2018-03-12 17:12:14 +01:00
|
|
|
else EventPlaybackNext();
|
2017-06-09 20:34:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-12 17:12:14 +01:00
|
|
|
void EventRepeatClick()
|
|
|
|
{
|
|
|
|
repeat ^= 1;
|
|
|
|
DrawTopPanel();
|
|
|
|
}
|
|
|
|
|
2018-03-17 11:23:03 +01:00
|
|
|
void EventShuffleClick()
|
2018-03-12 17:12:14 +01:00
|
|
|
{
|
|
|
|
shuffle ^= 1;
|
|
|
|
DrawTopPanel();
|
|
|
|
}
|
2017-06-09 20:34:19 +02:00
|
|
|
|
2018-09-10 20:52:48 +02:00
|
|
|
void EventRemoveItemFromList()
|
2018-03-20 09:24:20 +01:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
if (list.cur_y == current_playing_file_n) EventStopPlaying();
|
|
|
|
for (i=list.cur_y; i<list.count; i++) files_mas[i] = files_mas[i+1];
|
|
|
|
list.count--;
|
2018-03-22 00:26:31 +01:00
|
|
|
if (list.cur_y <= current_playing_file_n) current_playing_file_n--;
|
2018-03-20 09:24:20 +01:00
|
|
|
list.CheckDoesValuesOkey();
|
|
|
|
if (list.count <= list.visible)
|
|
|
|
{
|
|
|
|
list.h = list.count * list.item_h;
|
|
|
|
list.visible = list.count;
|
|
|
|
if (window_mode==WINDOW_MODE_NORMAL) MoveSize(OLD, OLD, OLD, skin.h + list.h);
|
|
|
|
}
|
|
|
|
else DrawPlayList();
|
|
|
|
}
|
|
|
|
|
2018-09-10 20:52:48 +02:00
|
|
|
void EventPermanentlyDeleteFile()
|
|
|
|
{
|
|
|
|
char item_path[4096];
|
|
|
|
sprintf(#item_path,"%s/%s",#work_folder,GetSelectedItemName());
|
|
|
|
DeleteFile(#item_path);
|
|
|
|
EventRemoveItemFromList();
|
|
|
|
}
|
|
|
|
|
2018-03-16 21:06:42 +01:00
|
|
|
void EventShowAbout()
|
2018-04-16 11:30:24 +02:00
|
|
|
{
|
2020-04-05 20:28:02 +02:00
|
|
|
CreateThread(#DrawAboutWindow,#menu_stak+4092);
|
2018-03-16 21:06:42 +01:00
|
|
|
}
|
|
|
|
|
2018-10-03 01:32:56 +02:00
|
|
|
/*
|
|
|
|
struct {
|
|
|
|
char tag[4];
|
|
|
|
char title[60];
|
|
|
|
char artist[60];
|
|
|
|
char album[60];
|
|
|
|
char speed;
|
|
|
|
char genre[30];
|
|
|
|
char start_time[6];
|
|
|
|
char end_time[6];
|
|
|
|
} tag11;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
char tag[3];
|
|
|
|
char title[30];
|
|
|
|
char artist[30];
|
|
|
|
char album[30];
|
|
|
|
char year[4];
|
|
|
|
char comment[30];
|
|
|
|
unsigned char genre; //https://www.w3.org/People/Bos/MP3tag/mp3tag.c
|
|
|
|
} tag10;
|
|
|
|
*/
|
|
|
|
|
|
|
|
void EventShowTagInfo()
|
|
|
|
{
|
|
|
|
char item_path[4096];
|
|
|
|
sprintf(#item_path,"%s/%s",#work_folder,GetSelectedItemName());
|
|
|
|
RunProgram("/sys/media/mp3info", #item_path);
|
|
|
|
}
|
|
|
|
|
2018-03-16 21:06:42 +01:00
|
|
|
|
2017-06-09 20:34:19 +02:00
|
|
|
stop:
|
|
|
|
|
|
|
|
char menu_stak[4096];
|