Subversion Repositories Kolibri OS

Rev

Rev 8954 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 8954 Rev 9015
Line 9... Line 9...
9
#include "../lib/obj/proc_lib.h"
9
#include "../lib/obj/proc_lib.h"
Line 10... Line 10...
10
 
10
 
Line 11... Line 11...
11
/* === TRANSLATIONS === */
11
/* === TRANSLATIONS === */
12
 
12
 
-
 
13
#ifdef LANG_RUS
-
 
14
	?define T_SCREENSHOT "‘ªà¨­è®â"
-
 
15
	?define T_READY "ƒ®â®¢."
13
#ifdef LANG_RUS
16
	?define T_RECORD "‡ ¯¨áì"
14
	?define T_TAKE_SCREENSHOT "‘¤¥« âì áªà¨­è®â"
17
	?define T_STOP "Žáâ ­®¢¨âì § ¯¨áì"
15
	?define T_SETTINGS " áâனª¨"
18
	?define T_SETTINGS " áâனª¨"
16
	?define T_EDITBOX_FRAME "ãâì á®åà ­¥­¨ï áªà¨­è®â "
19
	?define T_EDITBOX_FRAME "ãâì á®åà ­¥­¨ï áªà¨­è®â "
17
	?define T_DELAY "‡ ¤¥à¦ª  ¢ ᥪ㭤 å"
20
	?define T_DELAY "‡ ¤¥à¦ª  ¢ ᥪ㭤 å"
18
	?define T_NO_DIR "' ¯ª  ­¥ áãé¥áâ¢ã¥â!' -E"
21
	?define T_NO_DIR " ¯ª  ¤«ï á®åà ­¥­¨ï ­¥ áãé¥áâ¢ã¥â!"
-
 
22
#else
-
 
23
	?define T_SCREENSHOT "Screenshot"
-
 
24
	?define T_READY "Ready."
19
#else
25
	?define T_RECORD "Record"
20
	?define T_TAKE_SCREENSHOT "Take a screenshot"
26
	?define T_STOP "Stop recording"
21
	?define T_SETTINGS "Settings"
27
	?define T_SETTINGS "Settings"
22
	?define T_EDITBOX_FRAME "Save path"
28
	?define T_EDITBOX_FRAME "Save path"
23
	?define T_DELAY "Delay in seconds"
29
	?define T_DELAY "Delay in seconds"
Line 24... Line 30...
24
	?define T_NO_DIR "'Directory does not exists!' -E"
30
	?define T_NO_DIR "Saving directory does not exists!"
Line 25... Line 31...
25
#endif
31
#endif
Line 26... Line 32...
26
 
32
 
27
/* === DATA === */	
33
/* === DATA === */	
-
 
34
 
28
 
35
proc_info Form;
29
proc_info Form;
36
 
30
 
37
enum {
Line -... Line 38...
-
 
38
	BTN_SCREENSHOT=10,
-
 
39
	BTN_RECORD,
31
enum {
40
	BTN_SETTINGS,
32
	BTN_MAKE_SCREENSHOT=10,
41
	BTN_CHOOSE_SAVING_PATH
Line 33... Line 42...
33
	BTN_SETTINGS,
42
};
Line 34... Line 43...
34
	BTN_CHOOSE_SAVING_PATH
43
 
35
};
44
bool recording=false;
Line 77... Line 86...
77
 
86
 
78
void main()
87
void main()
79
{	
88
{	
Line -... Line 89...
-
 
89
	int id;
80
	int id;
90
 
Line 81... Line 91...
81
 
91
	I_Param = T_READY;
Line 82... Line 92...
82
	init_libraries();
92
	init_libraries();
83
 
93
 
84
	edit_box_set_text stdcall (#edit_save, "/tmp0/1");	
94
	edit_box_set_text stdcall (#edit_save, "/tmp0/1");	
85
 
95
 
86
	@SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
96
	@SetEventMask(EVM_REDRAW+EVM_KEY+EVM_BUTTON+EVM_MOUSE+EVM_MOUSE_FILTER);
87
	loop() switch(@WaitEvent())
97
	loop() switch(@WaitEventTimeout(delay.value*100))
Line 88... Line 98...
88
	{
98
	{
89
	case evMouse:
99
	case evMouse:
90
		edit_box_mouse stdcall (#edit_save);
100
		edit_box_mouse stdcall (#edit_save);
91
		break;
101
		break;
92
 
102
 
-
 
103
	case evButton:
93
	case evButton:
104
		id = @GetButtonID();
94
		id = @GetButtonID();
105
		switch(id){
95
		switch(id){
106
			case CLOSE_BTN: @ExitProcess();
96
			case CLOSE_BTN: @ExitProcess();
107
			case BTN_SCREENSHOT: EventScreenshotClick(); break;
97
			case BTN_MAKE_SCREENSHOT: EventTakeScreenshot(); break;
108
			case BTN_RECORD: EventRecordingClick(); break;
Line 98... Line 109...
98
			case BTN_SETTINGS: EventClickSettings(); break;
109
			case BTN_SETTINGS: EventSettingsClick(); break;
99
			case BTN_CHOOSE_SAVING_PATH: EventChooseSavePath(); break;
110
			case BTN_CHOOSE_SAVING_PATH: EventChooseSavePathClick(); break;
100
			default: delay.click(id);
111
			default: delay.click(id);
101
		}
112
		}
102
		break;
113
		break;
103
 
114
 
104
	case evKey:
115
	case evKey:
Line 105... Line 116...
105
		@GetKey();
116
		@GetKey();
106
		edit_box_key stdcall (#edit_save);
117
		edit_box_key stdcall (#edit_save);
-
 
118
		EAX >>= 16;
-
 
119
		if (SCAN_CODE_ENTER == AL) EventScreenshotClick();
-
 
120
		else if (SCAN_CODE_ESC == AL) ExitProcess();
107
		EAX >>= 16;
121
		break;
108
		if (SCAN_CODE_ENTER == AL) EventTakeScreenshot();
122
     
Line 109... Line 123...
109
		if (SCAN_CODE_ESC == AL) ExitProcess();
123
	case evReDraw:
110
		break;
124
		DrawWindow();
111
     
125
 
Line 112... Line 126...
112
	case evReDraw:
126
	default:
113
		DrawWindow();
127
		if (recording) MakeScreenshot();
114
	}
128
	}
115
}
129
}
Line -... Line 130...
-
 
130
 
116
 
131
 
-
 
132
void DrawWindow()
-
 
133
{
-
 
134
	unsigned i;
-
 
135
 
-
 
136
	sc.get();
-
 
137
	DefineAndDrawWindow(screen.width-400, screen.height/3, 280, 
-
 
138
		skin_height + 50+PD+PD, 0x34, sc.work, "EasyShot",0);
117
 
139
	GetProcessInfo(#Form, SelfInfo);
118
void DrawWindow()
140
 
-
 
141
	if (!recording) {
-
 
142
		DrawCaptButton(PD, PD, 101, 28, BTN_SCREENSHOT, 
119
{
143
			0x0090B8, 0xFFFfff, T_SCREENSHOT);
120
	int i;
144
		DrawCaptButton(PD+105, PD, 75, 28, BTN_RECORD, 
121
 
-
 
Line -... Line 145...
-
 
145
			0x0090B8, 0xFFFfff, T_RECORD);
Line 122... Line 146...
122
	sc.get();
146
	} else {
123
	DefineAndDrawWindow(screen.width-400, screen.height/3, 270, 
147
		DrawCaptButton(PD, PD, 96+80+4, 28, BTN_RECORD, 
124
		skin_height + 30+PD+PD, 0x34, sc.work, "EasyShot",0);
-
 
125
	GetProcessInfo(#Form, SelfInfo);
148
			0xC75C54, 0xFFFfff, T_STOP);
126
 
149
	}
127
	DrawCaptButton(PD, PD, 170, 28, BTN_MAKE_SCREENSHOT, 0x0090B8, 0xFFFfff, T_TAKE_SCREENSHOT);
150
	DefineButton(PD+200, PD, 35, 28, BTN_SETTINGS, sc.button);
128
	DefineButton(PD+170+20, PD, 35, 28, BTN_SETTINGS, sc.button);
-
 
129
	for (i=0; i<=2; i++) DrawBar(PD+170+30, i*5+PD+9, 15, 2, sc.button_text);
-
 
Line 130... Line 151...
130
	delay.draw(PD, SETTINGS_Y);
151
	for (i=0; i<=2; i++) DrawBar(PD+210, i*5+PD+9, 15, 2, sc.button_text);
131
	DrawFileBox(#edit_save, T_EDITBOX_FRAME, BTN_CHOOSE_SAVING_PATH);	
152
	DrawStatusBar(I_Param);	
132
}
153
 
133
 
154
	delay.draw(PD, SETTINGS_Y);
134
 
155
	DrawFileBox(#edit_save, T_EDITBOX_FRAME, BTN_CHOOSE_SAVING_PATH);
135
void EventChooseSavePath()
156
 
Line 136... Line -...
136
{
-
 
137
	OpenDialog_start stdcall (#open_folder_dialog);
157
}
138
	if (open_folder_dialog.status) {
158
 
139
		edit_box_set_text stdcall (#edit_save, #save_path);	
159
void DrawStatusBar(char *s)
140
	}
160
{
141
}
-
 
142
 
-
 
143
 
-
 
144
void EventClickSettings()
-
 
145
{
161
	I_Param = s; 
146
	show_settings ^= 1;
162
	WriteTextWithBg(PD, 35+PD, 0xD0, sc.work_text, I_Param, sc.work_light);
147
	@MoveSize(OLD, OLD, show_settings*75 + 270, 
163
}
148
		show_settings*110 + skin_height + PD+PD+30);
164
 
149
}
165
dword ScreenshotBuf()
150
 
166
{
151
 
167
	static dword screenshot;
152
void EventTakeScreenshot() 
168
	if (!screenshot) screenshot = malloc(screen.width * screen.height * 3);	
153
{
169
	return screenshot;
Line 154... Line 170...
154
	int i=0;
170
}
155
	char save_file_name[4096];
171
 
156
	static dword screenshot;
172
bool GetSavingPath()
-
 
173
{
-
 
174
	int i=0;
-
 
175
	char save_file_name[4096];
-
 
176
	do {
-
 
177
		i++;
-
 
178
		//sprintf(, "%s/screen_%i.png", #save_path, i);
-
 
179
		strcpy(#save_file_name, #save_path);
-
 
180
		if (save_file_name[strlen(#save_file_name)-1]!='/') chrcat(#save_file_name, '/');
-
 
181
		strcat(#save_file_name, "scr_");
-
 
182
		strcat(#save_file_name, itoa(i));
-
 
183
		strcat(#save_file_name, ".png");
-
 
184
	} while (file_exists(#save_file_name));
-
 
185
 
-
 
186
	if (!dir_exists(#save_path)) {
157
 
187
		DrawStatusBar(T_NO_DIR);
-
 
188
		return NULL;
-
 
189
	}
-
 
190
	return #save_file_name;
-
 
191
}
-
 
192
 
-
 
193
void MakeScreenshot() 
-
 
194
{
Line -... Line 195...
-
 
195
	if (I_Path = GetSavingPath()) {
-
 
196
		CopyScreen(ScreenshotBuf(), 0, 0, screen.width, screen.height);
158
	if (!screenshot) screenshot = malloc(screen.width * screen.height * 3);
197
		I_Param = save_image(ScreenshotBuf(), screen.width, screen.height, I_Path);
159
 
198
		if (!I_Param) I_Param = I_Path;
160
	do {
199
		DrawStatusBar(I_Param);
161
		i++;
-
 
162
		//sprintf(, "%s/screen_%i.png", #save_path, i);
200
	} else {
163
		strcpy(#save_file_name, #save_path);
201
		recording = false;
Line -... Line 202...
-
 
202
		DrawWindow();
-
 
203
	}
-
 
204
}
-
 
205
 
-
 
206
//===================================================//
-
 
207
//                                                   //
-
 
208
//                      EVENTS                       //
-
 
209
//                                                   //
-
 
210
//===================================================//
-
 
211
 
-
 
212
void EventScreenshotClick()
-
 
213
{
-
 
214
	MinimizeWindow();
-
 
215
	pause(delay.value*100);
-
 
216
	MakeScreenshot();
-
 
217
	ActivateWindow(GetProcessSlot(Form.ID));
-
 
218
}
-
 
219
 
-
 
220
void EventRecordingClick()
-
 
221
{
164
		if (save_file_name[strlen(#save_file_name)-1]!='/') chrcat(#save_file_name, '/');
222
	recording ^= 1;