Subversion Repositories Kolibri OS

Rev

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

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