38
38
public class Ella.Point : GLib.Object
44
set { x2 += value - x; x1 += value - x; x_ = value; }
49
set { y1 += value - y_; y2 += value - y_; y_ = value; }
42
56
public Point(double x, double y)
58
x1 = x2 = this.x_ = x;
59
y1 = y2 = this.y_ = y;
1136
public void button_press_event(Gdk.EventButton event)
1138
switch(event.button)
1141
select_point_at(event.x, event.y);
1144
select_point_at(event.x, event.y);
1145
points[point_selected].x1 -= 10;
1146
points[point_selected].y1 -= 10;
1147
points[point_selected].x2 += 10;
1148
points[point_selected].y2 += 10;
1153
public void motion_notify_event(Gdk.EventMotion event)
1155
move_point(event.x, event.y);
1095
1158
public void move_point(double event_x, double event_y)
1097
1160
event_x = event_x / width;
1098
1161
event_y = event_y / height;
1099
points[point_selected].x = event_x;
1100
points[point_selected].y = event_y;
1162
switch(point_select)
1165
points[point_selected].x = event_x;
1166
points[point_selected].y = event_y;
1169
points[point_selected].x1 = event_x;
1170
points[point_selected].y1 = event_y;
1173
points[point_selected].x2 = event_x;
1174
points[point_selected].y2 = event_y;
1103
1182
public void select_point_at(double event_x, double event_y)
1105
event_x = (event_x - x) / width;
1106
event_y = (event_y - y) / height;
1184
event_x = (event_x) / width;
1185
event_y = (event_y) / height;
1107
1187
foreach(Point point in points)
1109
1189
if(RectIsIn(event_x, event_y, point.rect))
1111
1191
select_point(point);
1195
else if(RectIsIn(event_x, event_y, point.rect1))
1197
select_point(point);
1201
else if(RectIsIn(event_x, event_y, point.rect2))
1203
select_point(point);
1127
1220
cr.translate(x - x_root, y - y_root);
1128
1221
cr.scale(width, height);
1129
1222
cr.set_line_width(line_width);
1223
double old_point_x = -1;
1224
double old_point_y = -1;
1130
1225
foreach(Point point in points)
1132
cr.line_to(point.x, point.y);
1227
if(old_point_x >= 0)
1229
cr.curve_to(old_point_x, old_point_y, point.x1, point.y1, point.x, point.y);
1233
cr.line_to(point.x, point.y);
1235
old_point_x = point.x2;
1236
old_point_y = point.y2;
1134
1238
cr.close_path();
1135
1239
cr.set_source_rgba(red, green, blue, alpha);
1148
1252
foreach(Point item in points)
1150
1254
var rect = item.rect;
1255
cr.set_source_rgb(0,0,0);
1151
1256
cr.rectangle(rect.x * width, rect.y * height, rect.width, rect.height);
1258
cr.set_source_rgba(0,0,0,0.5);
1259
cr.rectangle(item.x1, item.y1, rect.width, rect.height);
1261
cr.rectangle(item.x2, item.y2, rect.width, rect.height);
1154
1264
var rect = points[point_selected].rect;
1155
1265
cr.rectangle(rect.x * width, rect.y * height, rect.width, rect.height);