In progress...

This commit is contained in:
Kolan Sh 2018-01-16 14:17:14 +03:00
parent 7db26d2154
commit bc63b1ef99
3 changed files with 10 additions and 10 deletions

View File

@ -48,8 +48,8 @@ namespace CairoChart {
public CairoChart.Math math { get; protected set; default = new Math(); }
public Cursors cursors2 { get; protected set; default = new Cursors (); }
public List<Point128?> cursors = new List<Point128?> ();
public Point128 active_cursor = Point128(); // { get; protected set; default = Point128 (); }
public List<Point?> cursors = new List<Point?> ();
public Point active_cursor = Point(); // { get; protected set; default = Point128 (); }
public bool is_cursor_active { get; protected set; default = false; }
public Cursors.Style cursor_style = Cursors.Style();
@ -442,8 +442,8 @@ namespace CairoChart {
}
}
public virtual void set_active_cursor (double x, double y, bool remove = false) {
active_cursor = Point128 (scr2rel_x(x), scr2rel_y(y));
public virtual void set_active_cursor (Point p, bool remove = false) {
active_cursor = scr2rel_point(p);
is_cursor_active = ! remove;
}
@ -484,8 +484,8 @@ namespace CairoChart {
protected virtual Float128 scr2rel_y (Float128 y) {
return rz_y_max - (plot_y_max - y) / (plot_y_max - plot_y_min) * (rz_y_max - rz_y_min);
}
protected virtual Point128 scr2rel_point (Point128 p) {
return Point128 (scr2rel_x(p.x), scr2rel_y(p.y));
protected virtual Point scr2rel_point (Point p) {
return Point (scr2rel_x(p.x), scr2rel_y(p.y));
}
public virtual Float128 rel2scr_x(Float128 x) {

View File

@ -44,7 +44,7 @@ namespace CairoChart {
CursorCross[] crossings;
}
protected List<Point128?> get_all_cursors (Chart chart) {
protected List<Point?> get_all_cursors (Chart chart) {
var all_cursors = chart.cursors.copy_deep ((src) => { return src; });
if (chart.is_cursor_active)
all_cursors.append(chart.active_cursor);

View File

@ -454,11 +454,11 @@ int main (string[] args) {
switch (event.button) {
case 1: // start cursor position selection
if ((event.state & Gdk.ModifierType.SHIFT_MASK) != 0) { // remove cursor
chart.set_active_cursor (event.x, event.y, true);
chart.set_active_cursor (Point(event.x, event.y), true);
chart.remove_active_cursor();
mouse_state = MouseState.FREE;
} else { // add cursor
chart.set_active_cursor (event.x, event.y);
chart.set_active_cursor (Point(event.x, event.y));
mouse_state = MouseState.CURSOR_SELECTION;
}
da.queue_draw_area(0, 0, da.get_allocated_width(), da.get_allocated_height());
@ -532,7 +532,7 @@ int main (string[] args) {
break;
case MouseState.CURSOR_SELECTION:
chart.set_active_cursor (event.x, event.y);
chart.set_active_cursor (Point(event.x, event.y));
da.queue_draw_area(0, 0, da.get_allocated_width(), da.get_allocated_height());
break;
}