Subversion Repositories Kolibri OS

Rev

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

Rev 9602 Rev 9632
Line 19... Line 19...
19
//                                                   //
19
//                                                   //
20
//                       DATA                        //
20
//                       DATA                        //
21
//                                                   //
21
//                                                   //
22
//===================================================//
22
//===================================================//
Line -... Line 23...
-
 
23
 
23
 
24
//Sizes
24
#define PAD 13
25
#define PAD 13
25
#define TOOLBAR_ITEM_H PAD+PAD
26
#define TOOLBAR_ITEM_H PAD + PAD
26
#define TOOLBAR_W 132
27
#define TOOLBAR_W 132
-
 
28
#define STATUSBAR_H 20
-
 
29
#define HEADERH TOOLBAR_ITEM_H + 14
-
 
30
#define HEADER_TEXT_Y HEADERH - 14 / 2
27
#define STATUSBAR_H 20
31
#define CANVASX TOOLBAR_W + PAD + PAD
-
 
32
#define CANVASY HEADERH + 2
-
 
33
 
-
 
34
// Colors
-
 
35
#define COL_WORK        0x242424
-
 
36
#define COL_WORK_TEXT   0xBEBEBE
-
 
37
#define COL_LIGHT       0x424242
-
 
38
#define COL_DARK        0x1D1D1D
-
 
39
#define COL_LINE        0x010101
-
 
40
#define COL_BUTTON      0x181818
Line 28... Line 41...
28
#define ISIZE 18
41
#define COL_BUTTON_TEXT 0x18A2CC
Line 29... Line 42...
29
 
42
 
30
block canvas = { TOOLBAR_W + PAD + PAD, 0, NULL, NULL };
43
block canvas = { CANVASX, CANVASY, NULL, NULL };
Line 31... Line 44...
31
 
44
 
32
EVENTS button;
-
 
Line 33... Line 45...
33
EVENTS key;
45
EVENTS button;
34
 
46
EVENTS key;
Line 35... Line 47...
35
proc_info Form;
47
 
-
 
48
proc_info Form;
-
 
49
 
36
dword semi_white;
50
char default_dir[4096] = "/sys";
Line 37... Line -...
37
 
-
 
38
char default_dir[4096] = "/sys";
-
 
39
od_filter filter2 = { 69, "BMP\0GIF\0ICO\0CUR\0JPEG\0JPG\0PNG\0PNM\0TGA\0TIFF\0TIF\0WBMP\0XBM\0XCF\Z80\0\0" };
51
od_filter filter2 = { 69, "BMP\0GIF\0ICO\0CUR\0JPEG\0JPG\0PNG\0PNM\0TGA\0TIFF\0TIF\0WBMP\0XBM\0XCF\Z80\0\0" };
40
 
52
 
Line 41... Line 53...
41
libimg_image icons18;
53
libimg_image icons18;
42
libimg_image main_image;
54
libimg_image icons18a;
Line 43... Line 55...
43
 
55
libimg_image pixie_skin;
Line 66... Line 78...
66
//                                                   //
78
//                                                   //
67
//===================================================//
79
//===================================================//
Line 68... Line 80...
68
 
80
 
69
void init_ui()
81
void init_ui()
70
{
-
 
71
	sc.get();
-
 
72
	semi_white = MixColors(sc.work, 0xFFFfff, skin_is_dark()*90 + 96);
82
{
73
	icons18.load("/sys/icons16.png");
83
	icons18.load("/sys/icons16.png");
-
 
84
	icons18.replace_2colors(0xffFFFfff, COL_LIGHT, 0xffCACBD6, COL_LIGHT-0x080808);
74
	icons18.replace_color(0xffFFFfff, semi_white);
85
	icons18a.load("/sys/icons16.png");
-
 
86
	icons18a.replace_2colors(0xffFFFfff, COL_BUTTON, 0xffCACBD6, 0);
-
 
87
 
75
	icons18.replace_color(0xffCACBD6, MixColors(sc.work, 0, 200));
88
	pixie_skin.load("/sys/media/pixieskn.png");
Line 76... Line 89...
76
}
89
}
77
 
90
 
78
void main()
91
void main()
79
{
92
{
80
	int pressed_button_id;
93
	int pressed_button_id;
81
	load_dll(libimg, #libimg_init, 1);
94
	load_dll(libimg, #libimg_init, 1);
82
	load_dll(boxlib, #box_lib_init,0);
95
	load_dll(boxlib, #box_lib_init,0);
Line 83... Line -...
83
	load_dll(Proc_lib, #OpenDialog_init,0);
-
 
84
	OpenDialog_init stdcall (#o_dialog);
96
	load_dll(Proc_lib, #OpenDialog_init,0);
Line 85... Line 97...
85
 
97
	OpenDialog_init stdcall (#o_dialog);
86
	init_ui();
98
 
87
	open_image("/sys/home.png");
99
	open_image("/sys/home.png");
Line 96... Line 108...
96
			if (scroll_v.delta) || (scroll_h.delta) draw_canvas();
108
			if (scroll_v.delta) || (scroll_h.delta) draw_canvas();
97
			if (EAX = mouse.vert) {
109
			if (EAX = mouse.vert) {
98
				if (EAX<10) event_scroll_canvas(SCAN_CODE_DOWN); 
110
				if (EAX<10) event_scroll_canvas(SCAN_CODE_DOWN); 
99
				else event_scroll_canvas(SCAN_CODE_UP);
111
				else event_scroll_canvas(SCAN_CODE_UP);
100
			} if (EAX = mouse.hor) {
112
			} if (EAX = mouse.hor) {
101
				debugval("mouse.hor", mouse.hor);
-
 
102
				if (EAX<10) event_scroll_canvas(SCAN_CODE_RIGHT); 
113
				if (EAX<10) event_scroll_canvas(SCAN_CODE_RIGHT); 
103
				else event_scroll_canvas(SCAN_CODE_LEFT);
114
				else event_scroll_canvas(SCAN_CODE_LEFT);
104
			}
115
			}
105
			break;
116
			break;
Line 125... Line 136...
125
	}
136
	}
126
}
137
}
Line 127... Line 138...
127
 
138
 
128
void draw_window()
139
void draw_window()
129
{
-
 
130
	incn tx;
-
 
131
	char save_as_type[32];
-
 
132
	sc.get();
140
{
133
	Form.width = screen.w/6*5;
141
	Form.width = screen.w/6*5;
134
	Form.height = screen.h/6*5;
142
	Form.height = screen.h/6*5;
135
	DefineAndDrawWindow(screen.w-Form.width/2, screen.h-Form.height/2, Form.width, Form.height, 0x73, NULL, #win_title, 0);
143
	DefineAndDrawWindow(screen.w-Form.width/2, screen.h-Form.height/2, Form.width, Form.height, 0x42, NULL, NULL, 0);
136
	GetProcessInfo(#Form, SelfInfo);
144
	GetProcessInfo(#Form, SelfInfo);
137
	if (Form.status_window&ROLLED_UP) return;
145
	if (Form.status_window&ROLLED_UP) return;
138
	if (Form.width  < 560) { MoveSize(OLD,OLD,560,OLD); return; }
146
	if (Form.width  < 560) { MoveSize(OLD,OLD,560,OLD); return; }
-
 
147
	if (Form.height < 430) { MoveSize(OLD,OLD,OLD,430); return; }
-
 
148
	scroll_v.all_redraw = scroll_h.all_redraw = 1;
-
 
149
	draw_content();
-
 
150
}
-
 
151
 
-
 
152
void draw_content()
-
 
153
{
139
	if (Form.height < 430) { MoveSize(OLD,OLD,OLD,430); return; }
154
	incn tx;
140
	button.init(40);
155
	button.init(40);
Line 141... Line 156...
141
	key.init(40);
156
	key.init(40);
142
 
-
 
143
	DrawBar(0, 0, canvas.x, Form.cheight, sc.work);
157
 
144
 
158
	init_ui();
145
	canvas.w = Form.cwidth - canvas.x;
159
	canvas.w = Form.cwidth - CANVASX - 1;
146
	canvas.h = Form.cheight - STATUSBAR_H;
160
	canvas.h = Form.cheight - STATUSBAR_H - CANVASY - 1;
Line -... Line 161...
-
 
161
	if (main_image.h > canvas.h) canvas.w -= scroll_v.size_x + 1;
-
 
162
	if (main_image.w > canvas.w) canvas.h -= scroll_h.size_y + 1;
-
 
163
 
147
	if (main_image.h > canvas.h) canvas.w -= scroll_v.size_x + 1;
164
	//window border and panel border
-
 
165
	DrawRectangle(0,0,Form.width,Form.height,COL_LINE);
-
 
166
	DrawRectangle(1,1,Form.width-2,Form.height-2,COL_LIGHT);
148
	if (main_image.w > canvas.w) canvas.h -= scroll_h.size_y + 1;
167
	DrawBar(CANVASX, 0, 1, Form.cheight, COL_LINE);
149
 
168
 
150
	DrawBar(canvas.x, 0, 1, canvas.h, sc.work_text);
169
	//draw title
-
 
170
	DrawBar(2, 2, CANVASX-2, HEADERH-1, COL_DARK);
-
 
171
	WriteText(PAD+5, HEADER_TEXT_Y, 0x90, COL_WORK_TEXT, "ImageEditor Pro");
-
 
172
 
-
 
173
	//draw header
-
 
174
	DrawBar(CANVASX+1, 2, Form.width-CANVASX-2, HEADERH-1, COL_WORK);
-
 
175
	DrawBar(CANVASX+1, CANVASY-1, Form.width-CANVASX-2, 1, COL_LINE);
-
 
176
	img_draw stdcall(pixie_skin.image, Form.width-63, 7, 57, 18, 265, 0);
Line 151... Line -...
151
	if (main_image.h > canvas.h) && (main_image.w > canvas.w) {
-
 
152
		DrawBar(canvas.x+canvas.w, canvas.y+canvas.h, scroll_v.size_x+1, scroll_h.size_y+1, sc.work);
177
	DefineHiddenButton(Form.width-63, 7, 28, 17, button.add(#MinimizeWindow));
-
 
178
	DefineHiddenButton(Form.width-35, 7, 28, 17, 1);
153
	}
179
	draw_acive_panel();
154
 
180
 
155
	scroll_v.all_redraw = scroll_h.all_redraw = 1;
-
 
156
	if (skin_is_dark()) 
181
	//left panel bg
157
	{
182
	DrawBar(2, 1+HEADERH, CANVASX-2, Form.cheight-2-HEADERH, COL_WORK);
158
		scroll_v.bckg_col = scroll_h.bckg_col = sc.light;
-
 
Line 159... Line 183...
159
		scroll_v.frnt_col = scroll_h.frnt_col = sc.button;
183
 
160
		scroll_v.line_col = scroll_h.line_col = sc.button_text;
184
	if (main_image.h > canvas.h) && (main_image.w > canvas.w) {
161
	}
185
		DrawBar(CANVASX+canvas.w, CANVASY+canvas.h, scroll_v.size_x+1, scroll_h.size_y+1, COL_WORK);
162
	scroll_v.line_col = scroll_h.line_col = sc.work_text;		
186
	}
163
 
187
 
164
	#define GAP_S TOOLBAR_ITEM_H+8
188
	#define GAP_S TOOLBAR_ITEM_H+8
165
	#define GAP_B TOOLBAR_ITEM_H+23
189
	#define GAP_B TOOLBAR_ITEM_H+23
166
	tx.set(PAD-GAP_S);
190
	tx.set(PAD-GAP_S+HEADERH);
167
	//draw_tool_btn(10, ECTRL + SCAN_CODE_KEY_N, PAD, tx.inc(GAP_S), 02, "Create image", false);
191
	//draw_tool_btn(10, ECTRL + SCAN_CODE_KEY_N, PAD, tx.inc(GAP_S), 02, "Create image", false);
Line 168... Line 192...
168
	draw_tool_btn(#event_open, ECTRL + SCAN_CODE_KEY_O, PAD, tx.inc(GAP_S), 00, "Open image", false);
192
	draw_tool_btn(#event_open, ECTRL + SCAN_CODE_KEY_O, PAD, tx.inc(GAP_S), 00, "Open image", false);
169
	//draw_tool_btn(13, ECTRL + SCAN_CODE_LEFT,  PAD, tx.inc(GAP_B), 30, false);
193
	//draw_tool_btn(13, ECTRL + SCAN_CODE_LEFT,  PAD, tx.inc(GAP_B), 30, false);
170
	//draw_tool_btn(14, ECTRL + SCAN_CODE_RIGHT, PAD, tx.inc(GAP_S), 31, false);
194
	//draw_tool_btn(14, ECTRL + SCAN_CODE_RIGHT, PAD, tx.inc(GAP_S), 31, false);
171
	//draw_tool_btn(15, ECTRL + SCAN_CODE_UP,    PAD, tx.inc(GAP_S), 32, false);
195
	//draw_tool_btn(15, ECTRL + SCAN_CODE_UP,    PAD, tx.inc(GAP_S), 32, false);
Line 172... Line 196...
172
	//draw_tool_btn(16, ECTRL + SCAN_CODE_DOWN,  PAD, tx.inc(GAP_S), 33, false);
196
	//draw_tool_btn(16, ECTRL + SCAN_CODE_DOWN,  PAD, tx.inc(GAP_S), 33, false);
173
 
197
 
174
 	draw_tool_btn(#event_save, ECTRL + SCAN_CODE_KEY_S, PAD, tx.inc(GAP_B), 05, "Save file", false);
198
 	draw_tool_btn(#event_save, ECTRL + SCAN_CODE_KEY_S, PAD, tx.inc(GAP_B), 05, "Save as", false);
175
 	draw_tool_btn(#event_save_png, 0, PAD, tx.inc(GAP_S), -1, "PNG", saving_type & SAVE_AS_PNG);
199
 	draw_tool_btn(#event_save_png, 0, PAD, tx.inc(GAP_S), -1, "PNG", saving_type & SAVE_AS_PNG);
176
	draw_tool_btn(#event_save_bmp, 0, PAD*2+34, tx.n,     -1, "BMP", saving_type & SAVE_AS_BMP);
-
 
177
	draw_tool_btn(#event_save_raw, 0, PAD*3+68, tx.n,     -1, "RAW", saving_type & SAVE_AS_RAW);
-
 
178
 
-
 
Line 179... Line 200...
179
 	draw_tool_btn(#event_activate_crop,  0, PAD, tx.inc(GAP_B), 46, "Crop", active_tool & TOOL_CROP);
200
	draw_tool_btn(#event_save_bmp, 0, PAD*2+34, tx.n,     -1, "BMP", saving_type & SAVE_AS_BMP);
180
	draw_tool_btn(#event_activate_resize,0, PAD, tx.inc(GAP_S), 06, "Resize", active_tool & TOOL_RESIZE);
201
	draw_tool_btn(#event_save_raw, 0, PAD*3+68, tx.n,     -1, "RAW", saving_type & SAVE_AS_RAW);
181
	draw_tool_btn(#event_activate_depth, 0, PAD, tx.inc(GAP_S), 52, "Color depth", active_tool & TOOL_COLOR_DEPTH);
202
 
Line 182... Line 203...
182
	draw_tool_btn(#event_activate_flprot,0, PAD, tx.inc(GAP_S), 36, "Flip/Rotate", active_tool & TOOL_FLIP_ROTATE);
203
 	draw_tool_btn(#event_activate_crop,  0, PAD, tx.inc(GAP_B), 46, "Crop", active_tool & TOOL_CROP);
183
	//draw_tool_btn(#event_flip_hor, ECTRL + SCAN_CODE_KEY_H, PAD,      tx.inc(GAP_S), 34, NULL, false);
204
	draw_tool_btn(#event_activate_resize,0, PAD, tx.inc(GAP_S), 06, "Resize", active_tool & TOOL_RESIZE);
184
	//draw_tool_btn(#event_flip_ver, ECTRL + SCAN_CODE_KEY_V, PAD*2+34, tx.n,          35, NULL, false);
205
	draw_tool_btn(#event_activate_depth, 0, PAD, tx.inc(GAP_S), 52, "Color depth", active_tool & TOOL_COLOR_DEPTH);
185
	//draw_tool_btn(#event_rotate,   ECTRL + SCAN_CODE_KEY_R, PAD*3+68, tx.n,          36, NULL, false);
-
 
186
 
206
	draw_tool_btn(#event_activate_flprot,0, PAD, tx.inc(GAP_S), 36, "Flip/Rotate", active_tool & TOOL_FLIP_ROTATE);
187
	draw_status_bar();
207
 
188
	draw_canvas();
208
	draw_status_bar();
-
 
209
	draw_canvas();
-
 
210
}
-
 
211
 
-
 
212
void draw_status_bar()
-
 
213
{
-
 
214
	char img_info[24];
-
 
215
	sprintf(#img_info, "%i\01%i\02%s", main_image.w, main_image.h, libimg_bpp[main_image.type-1]);
189
}
216
	DrawBar(CANVASX+1, Form.cheight - STATUSBAR_H - 1, Form.cwidth - CANVASX -2, STATUSBAR_H, COL_WORK);
Line 190... Line 217...
190
 
217
	WriteText(CANVASX+4, Form.cheight - STATUSBAR_H + 2, 0x90, COL_WORK_TEXT, #img_info);
191
void draw_status_bar()
218
	for (ESI=0; img_info[ESI]!=0; ESI++) {
192
{
219
		if (img_info[ESI] == '\01') img_info[ESI]='x';
-
 
220
		else if (img_info[ESI] == '\02') img_info[ESI]='@';
193
	char img_info[24];
221
		else img_info[ESI]=' ';
194
	//draw_image_info
222
	}
-
 
223
	ECX = 0x90 << 24 + COL_BUTTON_TEXT;
195
	sprintf(#img_info, "%ix%i@%s", main_image.w, main_image.h, libimg_bpp[main_image.type-1]);
224
	$int 64
-
 
225
}
-
 
226
 
-
 
227
void draw_tool_btn(dword _event, _hotkey, _x, _y, _icon_n, _text, _active)
-
 
228
{
-
 
229
	int w = TOOLBAR_W;
196
	DrawBar(canvas.x, Form.cheight - STATUSBAR_H, Form.cwidth - canvas.x, STATUSBAR_H, sc.work);
230
	dword img_ptr;
197
	WriteText(canvas.x, Form.cheight - STATUSBAR_H + 2, 0x90, sc.work_text, #img_info);
231
	if (!_text) w = PAD + PAD + 6;
198
}
232
	if (_icon_n==-1) w = strlen(_text) * 8 + 14;
199
 
233
	if (_active) {
200
void draw_tool_btn(dword _event, _hotkey, _x, _y, _icon_n, _text, _active)
234
		img_ptr = icons18a.image;
201
{
235
		EDX = COL_BUTTON;
202
	int w = TOOLBAR_W;
236
	} else {
203
	if (!_text) w = PAD + PAD + 12;
237
		img_ptr = icons18.image; 
-
 
238
		EDX = COL_LIGHT;
204
	if (_icon_n==-1) w = strlen(_text) * 8 + 14;
239
	} 
205
	if (_active) EDX = sc.button; else EDX = semi_white;
240
	DrawBar(_x, _y, w, TOOLBAR_ITEM_H+1, EDX);
206
	DrawBar(_x, _y, w, TOOLBAR_ITEM_H+1, EDX);
241
	PutPixel(_x,_y,COL_WORK);
207
	PutPixel(_x,_y,sc.work);
242
	PutPixel(_x,_y+TOOLBAR_ITEM_H,COL_WORK);
208
	PutPixel(_x,_y+TOOLBAR_ITEM_H,sc.work);
243
	PutPixel(_x+w-1,_y,COL_WORK);
209
	PutPixel(_x+w-1,_y,sc.work);
244
	PutPixel(_x+w-1,_y+TOOLBAR_ITEM_H,COL_WORK);
210
	PutPixel(_x+w-1,_y+TOOLBAR_ITEM_H,sc.work);
245
	if (_event) DefineHiddenButton(_x, _y, w, TOOLBAR_ITEM_H, button.add(_event));
211
	if (_event) DefineHiddenButton(_x, _y, w, TOOLBAR_ITEM_H, button.add(_event));
246
	if (_hotkey) key.add_n(_hotkey, _event);
212
	if (_hotkey) key.add_n(_hotkey, _event);
247
	if (_icon_n!=-1) {
213
	if (_icon_n!=-1) {
248
		#define ISIZE 18
Line 214... Line 249...
214
		img_draw stdcall(icons18.image, _x+7, _y+4, ISIZE, ISIZE, 0, _icon_n*ISIZE);
249
		img_draw stdcall(img_ptr, _x+7, _y+4, ISIZE, ISIZE, 0, _icon_n*ISIZE);
215
		_x += PAD+ISIZE+2;
250
		_x += PAD+ISIZE+2;
-
 
251
	} else {
-
 
252
		_x += 7;
-
 
253
	}
-
 
254
	if (_text) {
-
 
255
		if (_active) EDX = COL_BUTTON_TEXT; else EDX = COL_WORK_TEXT;
-
 
256
		WriteText(_x, _y+6, 0x90, EDX, _text);
-
 
257
	}
-
 
258
}
-
 
259
 
216
	} else {
260
void draw_canvas()
217
		_x += 7;
261
{
218
	}
262
	int content_w = math.min(main_image.w, canvas.w-1);
219
	if (_text) {
-
 
220
		if (_active) EDX = sc.button_text; else EDX = sc.work_text;
263
	int content_h = math.min(main_image.h, canvas.h);
221
		WriteText(_x, _y+6, 0x90, EDX, _text);
-
 
222
	}
-
 
223
}
264
	if (main_image.image) {
224
 
-
 
225
void draw_scroll_v()
265
		img_draw stdcall(main_image.image, CANVASX+1, CANVASY,
226
{
266
		content_w, content_h, scroll_h.position, scroll_v.position);
227
	scroll_v.max_area = main_image.h;
-
 
228
	scroll_v.cur_area = scroll_v.size_y = canvas.h;
267
 	}
229
	scroll_v.start_x = canvas.x + canvas.w;
268
	DrawBar(CANVASX+1+content_w, CANVASY, canvas.w - content_w - 1, content_h, COL_DARK);
230
	scroll_v.start_y = 0;
-
 
Line 231... Line -...
231
	if (main_image.h > canvas.h) scrollbar_v_draw stdcall (#scroll_v);
-
 
232
}
-
 
233
 
-
 
234
void draw_scroll_h()
-
 
235
{
-
 
236
	scroll_h.max_area = main_image.w;
-
 
237
	scroll_h.cur_area = scroll_h.size_x = canvas.w;
-
 
238
	scroll_h.start_x = canvas.x;
-
 
239
	scroll_h.start_y = canvas.y + canvas.h;
-
 
240
	if (main_image.w > canvas.w) scrollbar_h_draw stdcall (#scroll_h);
-
 
241
}
-
 
242
 
-
 
243
void draw_canvas()
-
 
244
{
-
 
245
	int content_w, content_h;
-
 
246
	content_w = math.min(main_image.w, canvas.w-1);
-
 
247
	content_h = math.min(main_image.h, canvas.h);
269
	DrawBar(CANVASX+1, CANVASY+content_h, canvas.w - 1, canvas.h - content_h, COL_DARK);
Line 248... Line 270...
248
 
270
	//Draw scroll V
249
	if (main_image.image) {
271
	scroll_v.max_area = main_image.h;
250
		img_draw stdcall(main_image.image, canvas.x+1, canvas.y,
272
	scroll_v.cur_area = scroll_v.size_y = canvas.h + 1;
251
		content_w, content_h, scroll_h.position, scroll_v.position);
-
 
252
 	}
273
	scroll_v.start_x = CANVASX + canvas.w;
253
 
274
	if (main_image.h > canvas.h) scrollbar_v_draw stdcall (#scroll_v);
Line 254... Line 275...
254
	DrawBar(canvas.x+1+content_w, canvas.y, canvas.w - content_w - 1, content_h, 0xBFCAD2);
275
	//Draw scroll H
255
	DrawBar(canvas.x+1, canvas.y+content_h, canvas.w - 1, canvas.h - content_h, 0xBFCAD2);
276
	scroll_h.max_area = main_image.w;
256
 
277
	scroll_h.cur_area = scroll_h.size_x = canvas.w;
257
	draw_scroll_v();
278
	scroll_h.start_y = CANVASY + canvas.h;
258
	draw_scroll_h();
279
	if (main_image.w > canvas.w) scrollbar_h_draw stdcall (#scroll_h);
259
}
280
 
260
 
281
}
Line -... Line 282...
-
 
282
 
-
 
283
void set_file_path(char* _new_title)
-
 
284
{
-
 
285
	strcpy(#param, _new_title);
-
 
286
	draw_status_bar();
-
 
287
}
-
 
288
 
-
 
289
void open_image(char* _path)
-
 
290
{
-
 
291
	main_image.load(_path);
-
 
292
	set_file_path(_path);
-
 
293
	scroll_v.position = 0;
-
 
294
	scroll_h.position = 0;
-
 
295
}
-
 
296
 
-
 
297
void draw_acive_panel()
-
 
298
{
-
 
299
	switch(active_tool) {
-
 
300
		case TOOL_CROP:
-
 
301
			WriteText(CANVASX+PAD, HEADER_TEXT_Y, 0x90, COL_WORK_TEXT, "Crop tool");
-
 
302
			break;
-
 
303
		case TOOL_RESIZE:
-
 
304
			WriteText(CANVASX+PAD, HEADER_TEXT_Y, 0x90, COL_WORK_TEXT, "New width");
-
 
305
			WriteText(CANVASX+PAD+150, HEADER_TEXT_Y, 0x90, COL_WORK_TEXT, "New height");
-
 
306
			draw_tool_btn(#event_rotate_left, SCAN_CODE_ENTER, CANVASX + PAD + 300, 7, -1, "Apply", false);
-
 
307
			break;
-
 
308
		case TOOL_COLOR_DEPTH:
-
 
309
			WriteText(CANVASX+PAD, HEADER_TEXT_Y, 0x90, COL_WORK_TEXT, "Color depth tool");
-
 
310
			break;
-
 
311
		case TOOL_FLIP_ROTATE:
-
 
312
			WriteText(CANVASX+PAD, HEADER_TEXT_Y, 0x90, COL_WORK_TEXT, "Flip");
-
 
313
			draw_tool_btn(#event_flip_hor, ECTRL + SCAN_CODE_KEY_H, CANVASX + PAD + 040, 7, 34, NULL, false);
261
void update_title(char* _new_title)
314
			draw_tool_btn(#event_flip_ver, ECTRL + SCAN_CODE_KEY_V, CANVASX + PAD + 080, 7, 35, NULL, false);
262
{
315
			WriteText(CANVASX+PAD + 142, HEADER_TEXT_Y, 0x90, COL_WORK_TEXT, "Rotate");
263
	strcpy(#win_title+9, " - ");
316
			draw_tool_btn(#event_rotate_left,   ECTRL + SCAN_CODE_KEY_L, CANVASX + PAD + 200, 7, 37, NULL, false);
264
	strlcpy(#win_title+12, _new_title, sizeof(win_title));
317
			draw_tool_btn(#event_rotate_right,   ECTRL + SCAN_CODE_KEY_R, CANVASX + PAD + 240, 7, 36, NULL, false);
265
	DrawTitle(#win_title);
318
			// WriteText(CANVASX+PAD + 142, HEADER_TEXT_Y, 0x90, COL_WORK_TEXT, "Move");
Line 299... Line 352...
299
{
352
{
300
	img_flip stdcall (main_image.image, FLIP_VERTICAL);
353
	img_flip stdcall (main_image.image, FLIP_VERTICAL);
301
	draw_canvas();
354
	draw_canvas();
302
}
355
}
Line 303... Line 356...
303
 
356
 
-
 
357
void event_rotate_left()
-
 
358
{
-
 
359
	img_rotate stdcall (main_image.image, ROTATE_270_CW);
-
 
360
	main_image.w >< main_image.h;
-
 
361
	draw_content();
-
 
362
}
-
 
363
 
304
void event_rotate()
364
void event_rotate_right()
305
{
365
{
306
	img_rotate stdcall (main_image.image, ROTATE_90_CW);
366
	img_rotate stdcall (main_image.image, ROTATE_90_CW);
307
	main_image.w >< main_image.h;
367
	main_image.w >< main_image.h;
308
	draw_window();
368
	draw_content();
Line 309... Line 369...
309
}
369
}
310
 
370
 
311
void event_save_png() { saving_type = SAVE_AS_PNG; draw_window(); }
371
void event_save_png() { saving_type = SAVE_AS_PNG; draw_content(); }
312
void event_save_bmp() { saving_type = SAVE_AS_BMP; draw_window(); }
372
void event_save_bmp() { saving_type = SAVE_AS_BMP; draw_content(); }
313
void event_save_raw() { saving_type = SAVE_AS_RAW; draw_window(); }
373
void event_save_raw() { saving_type = SAVE_AS_RAW; draw_content(); }
314
 
374
 
315
void event_activate_crop() { active_tool = TOOL_CROP; draw_window(); }
375
void event_activate_crop() { active_tool = TOOL_CROP; draw_content(); }
316
void event_activate_resize() { active_tool = TOOL_RESIZE; draw_window(); }
376
void event_activate_resize() { active_tool = TOOL_RESIZE; draw_content(); }
Line 317... Line 377...
317
void event_activate_depth() { active_tool = TOOL_COLOR_DEPTH; draw_window(); }
377
void event_activate_depth() { active_tool = TOOL_COLOR_DEPTH; draw_content(); }
318
void event_activate_flprot() { active_tool = TOOL_FLIP_ROTATE; draw_window(); }
378
void event_activate_flprot() { active_tool = TOOL_FLIP_ROTATE; draw_content(); }
319
 
379
 
320
void event_save()
380
void event_save()
321
{
381
{
322
	o_dialog.type = 1; //save file
382
	o_dialog.type = 1; //save file
323
	switch (saving_type) {
383
	switch (saving_type) {
324
		case SAVE_AS_PNG:
384
		case SAVE_AS_PNG:
325
				strcpy(#filename_area, "image.png");
385
				strcpy(#filename_area, "image.png");
326
				OpenDialog_start stdcall (#o_dialog);
386
				OpenDialog_start stdcall (#o_dialog);
327
				if (o_dialog.status) {
387
				if (o_dialog.status) {
328
					update_title(#openfile_path);
388
					set_file_path(#openfile_path);
329
					img_to_rgb stdcall (main_image.image);
389
					img_to_rgb stdcall (main_image.image);
330
					save_image(main_image.imgsrc, main_image.w, main_image.h, #openfile_path);
390
					save_image(main_image.imgsrc, main_image.w, main_image.h, #openfile_path);