Subversion Repositories Kolibri OS

Rev

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

Rev 7257 Rev 7259
Line 21... Line 21...
21
int mouseX_last;
21
int mouseX_last;
22
int mouseY_last;
22
int mouseY_last;
23
bool first_click_in_canvas = false;
23
bool first_click_in_canvas = false;
Line 24... Line 24...
24
 
24
 
-
 
25
void SimpleFigureTool_onMouseEvent(int mouseX, int mouseY, int lkm, int pkm) {
-
 
26
	int x1, y1, x2, y2;
25
void SimpleFigureTool_onMouseEvent(int mouseX, int mouseY, int lkm, int pkm) {
27
 
26
	if (mouse.down) && (canvas.hovered()) first_click_in_canvas = true;
28
	if (mouse.down) && (canvas.hovered()) first_click_in_canvas = true;
27
	if (first_click_in_canvas)
29
	if (first_click_in_canvas)
28
	{
30
	{
29
		if (mouseX>canvas.x+canvas.w-zoom.value) mouseX = canvas.x+canvas.w-zoom.value;
31
		if (mouseX>canvas.x+canvas.w-zoom.value) mouseX = canvas.x+canvas.w-zoom.value;
Line 48... Line 50...
48
			mouseY_last = mouseY;
50
			mouseY_last = mouseY;
49
		}
51
		}
50
		if (mouse.up) {
52
		if (mouse.up) {
51
			if ((figTool.startX >= 0) 
53
			if ((figTool.startX >= 0) 
52
			&& (figTool.startY >= 0)) {
54
			&& (figTool.startY >= 0)) {
-
 
55
 
-
 
56
				x1 = figTool.startX - canvas.x/zoom.value;
-
 
57
				y1 = figTool.startY - canvas.y/zoom.value;
-
 
58
				x2 = mouseX - canvas.x/zoom.value;
-
 
59
				y2 = mouseY - canvas.y/zoom.value;
-
 
60
 
53
				// Draw line from start position to current position
61
				// Draw line from start position to current position
54
				if (currentTool == TOOL_LINE) {
62
				if (currentTool == TOOL_LINE) {
55
					DrawLineIcon(figTool.startX - canvas.x/zoom.value, 
63
					DrawLineIcon(x1, y1, x2, y2, tool_color, TOIMAGE);
56
						figTool.startY - canvas.y/zoom.value, 
-
 
57
						mouseX - canvas.x/zoom.value, 
-
 
58
						mouseY - canvas.y/zoom.value, 
-
 
59
						tool_color, 
-
 
60
						TOIMAGE);
-
 
61
				}
64
				}
62
				else if (currentTool == TOOL_RECT) {
65
				else if (currentTool == TOOL_RECT) {
63
					DrawRectangleIcon(figTool.startX - canvas.x/zoom.value, 
66
					DrawRectangleIcon(x1, y1, x2, y2, tool_color, TOIMAGE);
64
						figTool.startY - canvas.y/zoom.value, 
67
				}
65
						mouseX - canvas.x/zoom.value, 
68
				else if (currentTool == TOOL_BAR) {
66
						mouseY - canvas.y/zoom.value, tool_color, 
69
					DrawBarIcon(x1, y1, x2, y2, tool_color, TOIMAGE);
67
						TOIMAGE);
-
 
68
				}
70
				}
Line 69... Line 71...
69
 
71
 
Line 70... Line 72...
70
				DrawCanvas();
72
				DrawCanvas();
Line 80... Line 82...
80
		}
82
		}
81
	}
83
	}
82
}
84
}
Line 83... Line 85...
83
 
85
 
-
 
86
void SimpleFigureTool_onCanvasDraw() {
84
void SimpleFigureTool_onCanvasDraw() {
87
	int x1, y1, x2, y2;
85
	if ((figTool.startX >= 0) 
88
 	if ((figTool.startX >= 0) 
86
	&& (figTool.startY >= 0) && (mouse.key)) {
-
 
-
 
89
	&& (figTool.startY >= 0) && (mouse.key)) {
87
		if (currentTool == TOOL_LINE) {
90
 
88
			DrawLineIcon(figTool.startX - canvas.x/zoom.value, 
91
		x1 = figTool.startX - canvas.x/zoom.value;
89
				figTool.startY - canvas.y/zoom.value, 
92
		y1 = figTool.startY - canvas.y/zoom.value;
90
				mouseX_last - canvas.x/zoom.value, 
93
		x2 = mouseX_last - canvas.x/zoom.value;
91
				mouseY_last - canvas.y/zoom.value, 
-
 
92
				tool_color, 
-
 
93
				TOCANVAS);
94
		y2 = mouseY_last - canvas.y/zoom.value;
94
		}
95
 
95
		else if (currentTool == TOOL_RECT) {
96
		if (currentTool == TOOL_LINE)
96
			DrawRectangleIcon(figTool.startX - canvas.x/zoom.value, 
97
			DrawLineIcon(x1, y1, x2, y2, tool_color, TOCANVAS);
97
				figTool.startY - canvas.y/zoom.value, 
98
		else if (currentTool == TOOL_RECT)
98
				mouseX_last - canvas.x/zoom.value, 
99
			DrawRectangleIcon(x1, y1, x2, y2, tool_color, TOCANVAS);
99
				mouseY_last - canvas.y/zoom.value, 
100
		else if (currentTool == TOOL_BAR)
100
				tool_color, 
-
 
101
				TOCANVAS);
-
 
Line 102... Line 101...
102
		}
101
			DrawBarIcon(x1, y1, x2, y2, tool_color, TOCANVAS);
103
 
102
 
104
		figTool.lastTempPosX = mouseX_last - canvas.x/zoom.value;
103
		figTool.lastTempPosX = mouseX_last - canvas.x/zoom.value;
105
		figTool.lastTempPosY = mouseY_last - canvas.y/zoom.value;
104
		figTool.lastTempPosY = mouseY_last - canvas.y/zoom.value;
Line 176... Line 175...
176
	DrawLineIcon(x2, y1, x2, y2, color, target);
175
	DrawLineIcon(x2, y1, x2, y2, color, target);
177
	DrawLineIcon(x2, y2, x1, y2, color, target);
176
	DrawLineIcon(x2, y2, x1, y2, color, target);
178
	DrawLineIcon(x1, y2, x1, y1, color, target);
177
	DrawLineIcon(x1, y2, x1, y1, color, target);
179
}
178
}
Line -... Line 179...
-
 
179
 
-
 
180
void DrawBarIcon(int x1, int y1, int x2, int y2, dword color, int target) {
-
 
181
	signed signY;
-
 
182
	if (y1 < y2)
-
 
183
		signY = 1;
-
 
184
	else
-
 
185
		signY = -1;
-
 
186
 
-
 
187
	while (y1 != y2+signY) {
-
 
188
		DrawLineIcon(x1, y1, x2, y1, color, target);
-
 
189
		y1 += signY;
-
 
190
	}
180
191
}