Subversion Repositories Kolibri OS

Rev

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

Rev 7274 Rev 7275
Line 2... Line 2...
2
 * Icon Editor for KolibriOS
2
 * Icon Editor for KolibriOS
3
 * Authors: Leency, Nicolas
3
 * Authors: Leency, Nicolas
4
 * Licence: GPL v2
4
 * Licence: GPL v2
5
*/
5
*/
Line 6... Line -...
6
 
-
 
7
/*
-
 
8
TODO:
-
 
9
window colors
-
 
10
enhance icon
-
 
11
pipet aside color view
-
 
12
*/
-
 
13
 
6
 
Line 14... Line 7...
14
#define MEMSIZE 4096*500
7
#define MEMSIZE 4096*500
15
 
8
 
16
#include "../lib/gui.h"
9
#include "../lib/gui.h"
Line 30... Line 23...
30
//                                                   //
23
//                                                   //
31
//                       DATA                        //
24
//                       DATA                        //
32
//                                                   //
25
//                                                   //
33
//===================================================//
26
//===================================================//
Line 34... Line 27...
34
 
27
 
Line 35... Line 28...
35
#define T_TITLE "Icon Editor 0.55 Alpha"
28
#define T_TITLE "Icon Editor 0.56 Alpha"
36
 
29
 
37
#define TOPBAR_H    24+8
30
#define TOPBAR_H    24+8
Line 85... Line 78...
85
	BTN_SELECT,
78
	BTN_SELECT,
86
	BTN_SCREEN_COPY,
79
	BTN_SCREEN_COPY,
87
	BTN_ZOOM_IN,
80
	BTN_ZOOM_IN,
88
	BTN_ZOOM_OUT,
81
	BTN_ZOOM_OUT,
89
	BTN_CANVAS_RESIZE,
82
	BTN_CANVAS_RESIZE,
-
 
83
	BTN_CROP,
90
	BTNS_PALETTE_COLOR_MAS = 100,
84
	BTNS_PALETTE_COLOR_MAS = 100,
91
	BTNS_LAST_USED_COLORS = 400
85
	BTNS_LAST_USED_COLORS = 400
92
};
86
};
Line 93... Line 87...
93
 
87
 
Line 298... Line 292...
298
					setCurrentTool(TOOL_SCREEN_COPY);
292
					setCurrentTool(TOOL_SCREEN_COPY);
299
					break;
293
					break;
300
				case BTN_CANVAS_RESIZE:
294
				case BTN_CANVAS_RESIZE:
301
					notify("Sorry, not implemented yet.");
295
					notify("Sorry, not implemented yet.");
302
					break;
296
					break;
-
 
297
				case BTN_CROP:
-
 
298
					EventCrop();
-
 
299
					break;
303
				case CLOSE_BTN:
300
				case CLOSE_BTN:
304
					EventExitIconEdit();
301
					EventExitIconEdit();
305
					break;
302
					break;
306
			}
303
			}
307
			break;
304
			break;
Line 332... Line 329...
332
 
329
 
Line 333... Line 330...
333
			break;
330
			break;
334
		 
331
		 
335
		case evReDraw:
332
		case evReDraw:
336
			Window_CanvasReSize.thread_exists();
333
			Window_CanvasReSize.thread_exists();
337
			draw_window();
334
			DrawWindow();
338
			break;
335
			break;
Line 339... Line 336...
339
	}
336
	}
Line 360... Line 357...
360
 
357
 
361
void DrawStatusBar()
358
void DrawStatusBar()
362
{
359
{
Line -... Line 360...
-
 
360
	zoom.draw(wrapper.x, wrapper.y + wrapper.h + 6);
363
	zoom.draw(wrapper.x, wrapper.y + wrapper.h + 6);
361
 
364
 
362
	sprintf(#param,"%i x %i", image.columns, image.rows);
365
	DrawCaptButton(
363
	DrawCaptButton(
366
		wrapper.x+wrapper.w-calc(strlen(#param)*8) +6 - 1,
364
		wrapper.x+wrapper.w-calc(strlen(#param)*8) -6 - 1,
367
		zoom.y,
365
		zoom.y,
368
		calc(strlen(#param)*8)-6,
366
		calc(strlen(#param)*8)+6,
369
		18,
367
		18,
370
		BTN_CANVAS_RESIZE,
368
		BTN_CANVAS_RESIZE,
371
		system.color.work_button,
369
		system.color.work_button,
372
		system.color.work_button_text,
370
		system.color.work_button_text,
373
		sprintf(#param,"%i x %i", image.rows, image.columns)
371
		#param
Line 374... Line 372...
374
		);
372
		);
375
}
373
}
376
 
374
 
377
void draw_window()
375
void DrawWindow()
378
{
376
{
379
	#define GAP 27
377
	#define GAP 27
Line 402... Line 400...
402
	
400
	
403
	DrawTopPanelButton(BTN_FLIP_HOR,   tx.inc(GAP+BLOCK_SPACE), 34);
401
	DrawTopPanelButton(BTN_FLIP_HOR,   tx.inc(GAP+BLOCK_SPACE), 34);
Line 404... Line 402...
404
	DrawTopPanelButton(BTN_FLIP_VER,   tx.inc(GAP),   35);
402
	DrawTopPanelButton(BTN_FLIP_VER,   tx.inc(GAP),   35);
-
 
403
 
-
 
404
	DrawTopPanelButton(BTN_TEST_ICON,  tx.inc(GAP+BLOCK_SPACE), 12);
405
 
405
 
406
	DrawTopPanelButton(BTN_TEST_ICON,  tx.inc(GAP+BLOCK_SPACE), 12);
406
	DrawTopPanelButton(BTN_CROP,  tx.inc(GAP+BLOCK_SPACE), 46);
Line 407... Line 407...
407
	// DrawTopPanelButton(BTN_ROTATE_LEFT,   tx.inc(GAP), 36); //not implemented
407
	// DrawTopPanelButton(BTN_ROTATE_LEFT,   tx.inc(GAP), 36); //not implemented
Line 687... Line 687...
687
		DrawCanvas();
687
		DrawCanvas();
688
	}
688
	}
689
	actionsHistory.saveCurrentState();
689
	actionsHistory.saveCurrentState();
690
}
690
}
Line -... Line 691...
-
 
691
 
-
 
692
void EventCrop()
-
 
693
{
-
 
694
	if (selection.state) {
-
 
695
		EventSaveIconToFile();
-
 
696
		image.create(selection.buf.rows, selection.buf.columns);
-
 
697
		selection.move_to_point(0,0);
-
 
698
		selection.apply_to_image();
-
 
699
		selection.reset();
-
 
700
		actionsHistory.init();
-
 
701
		DrawWindow();
-
 
702
	}
-
 
703
	else {
-
 
704
		notify("'You need to select something before usnig crop tool.' -W");
-
 
705
	}
-
 
706
}
691
 
707
 
Line 692... Line 708...
692
stop:
708
stop: