Subversion Repositories Kolibri OS

Rev

Rev 7347 | Rev 7429 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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