improve cursor display and move with multiple graphs with different sweep variables

This commit is contained in:
Stefan Schippers 2024-03-29 19:58:54 +01:00
parent fdeca4646a
commit ba76f42277
2 changed files with 6 additions and 6 deletions

View File

@ -429,11 +429,11 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
int idx;
double cursorx;
idx = get_raw_index(find_nth(get_tok_value(r->prop_ptr, "sweep", 0), ", ", "\"", 0, 1), NULL);
if(idx < 0) idx = 0;
cursorx = xctx->graph_cursor1_x;
if(idx) {
if(idx >= 0 ) {
cursorx = xctx->raw->cursor_a_val[idx];
}
if(idx < 0) idx = 0;
/* dragging cursors when mouse is very close */
if( fabs(xctx->mousex - W_X(cursorx)) < 10) {
xctx->graph_flags |= 16; /* Start move cursor1 */
@ -443,11 +443,11 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int
int idx;
double cursorx;
idx = get_raw_index(find_nth(get_tok_value(r->prop_ptr, "sweep", 0), ", ", "\"", 0, 1), NULL);
if(idx < 0) idx = 0;
cursorx = xctx->graph_cursor2_x;
if(idx) {
if(idx >= 0) {
cursorx = xctx->raw->cursor_b_val[idx];
}
if(idx < 0) idx = 0;
/* dragging cursors when mouse is very close */
if(fabs(xctx->mousex - W_X(cursorx)) < 10) {
xctx->graph_flags |= 32; /* Start move cursor2 */

View File

@ -2920,8 +2920,7 @@ static void draw_cursor(int active_cursor, int cursor_color, int i, Graph_ctx *g
other_cursorx = xctx->graph_cursor1_x;
}
idx = get_raw_index(find_nth(get_tok_value(r->prop_ptr, "sweep", 0), ", ", "\"", 0, 1), NULL);
if(idx < 0) idx = 0;
if(idx) {
if(idx >= 0) {
dbg(1, "draw_cursor(): idx=%d, cursor=%g\n", idx, xctx->raw->cursor_a_val[idx]);
if(active_cursor == 1) {
active_cursorx = xctx->raw->cursor_a_val[idx];
@ -2931,6 +2930,7 @@ static void draw_cursor(int active_cursor, int cursor_color, int i, Graph_ctx *g
other_cursorx = xctx->raw->cursor_a_val[idx];
}
}
if(idx < 0) idx = 0;
xx = W_X(active_cursorx);
flip = (other_cursorx > active_cursorx) ? 0 : 1;
xoffs = flip ? 3 : -3;