From 2c1e1c1fe77999ee0f096bca37173b89abc05eb8 Mon Sep 17 00:00:00 2001 From: stefan schippers Date: Fri, 10 Jan 2025 02:35:50 +0100 Subject: [PATCH] refactoring and cleanup of wave_callback() -8- --- src/callback.c | 66 ++++++++++++++++++++++++-------------------------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/src/callback.c b/src/callback.c index b1ca8560..1e6b835f 100644 --- a/src/callback.c +++ b/src/callback.c @@ -622,9 +622,9 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int } event = 0; button = 0; /* avoid further processing ButtonPress that might set GRAPHPAN */ } - need_fullredraw = 1; + need_all_redraw = 1; } - /* Numerically set cursor position */ + /* Numerically set cursor position *** DO NOT PUT AN `else if` BELOW *** */ if(xctx->graph_flags & 4) { double logcursor, cursor; if(r->flags & 4) { /* private_cursor */ @@ -653,6 +653,36 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int } need_fullredraw = 1; } + /* Numerically set hcursor position *** DO NOT PUT AN `else if` BELOW *** */ + if(xctx->graph_flags & 128) { + double logcursor, cursor; + logcursor = cursor = gr->hcursor1_y; + if(gr->logy ) { + logcursor = mylog10(cursor); + } + if(fabs(xctx->mousey - W_Y(logcursor)) < 10) { + tclvareval("input_line {Pos:} {} ", dtoa_eng(cursor), NULL); + cursor = atof_eng(tclresult()); + my_strdup(_ALLOC_ID_, &r->prop_ptr, subst_token(r->prop_ptr, "hcursor1_y", dtoa(cursor))); + event = 0; button = 0; /* avoid further processing ButtonPress that might set GRAPHPAN */ + } + need_redraw_master = 1; + } + /* Numerically set hcursor position *** DO NOT PUT AN `else if` BELOW *** */ + if(xctx->graph_flags & 256) { + double logcursor, cursor; + logcursor = cursor = gr->hcursor2_y; + if(gr->logy ) { + logcursor = mylog10(cursor); + } + if(fabs(xctx->mousey - W_Y(logcursor)) < 10) { + tclvareval("input_line {Pos:} {} ", dtoa_eng(cursor), NULL); + cursor = atof_eng(tclresult()); + my_strdup(_ALLOC_ID_, &r->prop_ptr, subst_token(r->prop_ptr, "hcursor2_y", dtoa(cursor))); + event = 0; button = 0; /* avoid further processing ButtonPress that might set GRAPHPAN */ + } + need_redraw_master = 1; + } } else if(event == -3 && button == Button1) { if(!edit_wave_attributes(1, i, gr)) { @@ -900,38 +930,6 @@ static int waves_callback(int event, int mx, int my, KeySym key, int button, int } } } - else if(event == ButtonPress && button == Button3) { - /* Numerically set hcursor position */ - if(xctx->graph_flags & 128) { - double logcursor, cursor; - logcursor = cursor = gr->hcursor1_y; - if(gr->logy ) { - logcursor = mylog10(cursor); - } - if(fabs(xctx->mousey - W_Y(logcursor)) < 10) { - xctx->ui_state &= ~GRAPHPAN; /* we are setting a cursor so clear GRAPHPAN set before */ - tclvareval("input_line {Pos:} {} ", dtoa_eng(cursor), NULL); - cursor = atof_eng(tclresult()); - my_strdup(_ALLOC_ID_, &r->prop_ptr, subst_token(r->prop_ptr, "hcursor1_y", dtoa(cursor))); - } - need_redraw = 1; - } - /* Numerically set hcursor position */ - if(xctx->graph_flags & 256) { - double logcursor, cursor; - logcursor = cursor = gr->hcursor2_y; - if(gr->logy ) { - logcursor = mylog10(cursor); - } - if(fabs(xctx->mousey - W_Y(logcursor)) < 10) { - xctx->ui_state &= ~GRAPHPAN; /* we are setting a cursor so clear GRAPHPAN set before */ - tclvareval("input_line {Pos:} {} ", dtoa_eng(cursor), NULL); - cursor = atof_eng(tclresult()); - my_strdup(_ALLOC_ID_, &r->prop_ptr, subst_token(r->prop_ptr, "hcursor2_y", dtoa(cursor))); - } - need_redraw = 1; - } - } else if(event == ButtonPress && button == Button5 && !(state & ShiftMask)) { double delta; /* vertical move of waveforms with mouse wheel */