diff --git a/src/callback.c b/src/callback.c index 5935cf06..809df75e 100644 --- a/src/callback.c +++ b/src/callback.c @@ -2196,6 +2196,7 @@ static int handle_mouse_wheel(int event, int mx, int my, KeySym key, int button, waves_callback(event, mx, my, key, button, aux, state); return 1; } + /* zoom out */ view_unzoom(CADZOOMSTEP); return 0; } @@ -2204,6 +2205,7 @@ static int handle_mouse_wheel(int event, int mx, int my, KeySym key, int button, waves_callback(event, mx, my, key, button, aux, state); return 1; } + /* zoom in */ view_zoom(CADZOOMSTEP); return 0; } @@ -2213,6 +2215,7 @@ static int handle_mouse_wheel(int event, int mx, int my, KeySym key, int button, waves_callback(event, mx, my, key, button, aux, state); return 1; } + /* pan to the right; move schematic to left */ xctx->xorigin+=-CADMOVESTEP*xctx->zoom/2.; draw(); redraw_w_a_l_r_p_z_rubbers(1); @@ -2222,16 +2225,20 @@ static int handle_mouse_wheel(int event, int mx, int my, KeySym key, int button, waves_callback(event, mx, my, key, button, aux, state); return 1; } + + /* pan to the left; move schematic to right */ xctx->xorigin-=-CADMOVESTEP*xctx->zoom/2.; draw(); redraw_w_a_l_r_p_z_rubbers(1); } else if(button==Button4 && (state & ControlMask) && !(state & Button2Mask)) { + /* pan down; move schematic up */ xctx->yorigin+=-CADMOVESTEP*xctx->zoom/2.; draw(); redraw_w_a_l_r_p_z_rubbers(1); } else if(button==Button5 && (state & ControlMask) && !(state & Button2Mask)) { + /* pan up; move schematic down */ xctx->yorigin-=-CADMOVESTEP*xctx->zoom/2.; draw(); redraw_w_a_l_r_p_z_rubbers(1); diff --git a/src/xschem.tcl b/src/xschem.tcl index 1bdef451..1cbf6e1c 100644 --- a/src/xschem.tcl +++ b/src/xschem.tcl @@ -9950,7 +9950,7 @@ proc show_bindkeys {} { } proc set_bindings {topwin} { -global env has_x OS autofocus_mainwindow +global env has_x OS autofocus_mainwindow replace_key ### ### Tk event handling ### @@ -9978,14 +9978,74 @@ global env has_x OS autofocus_mainwindow bind $topwin "if {{%W} eq {$topwin}} {xschem callback %W %T %x %y 0 %w %h %s}" # transform mousewheel events into button4/5 events - if {[info tclversion] > 8.7} { - bind $topwin { - if {%D > 0} { - xschem callback %W 4 %x %y 0 4 0 %s + if {[info tclversion] >= 8.7} { + set zoom_state 0 + set vert_pan_state 4 + set horiz_pan_state 1 + # transform mouse wheel modifier key remapping into MouseWheel equivalents + if {[info exist replace_key(Button-4)]} { + if {[regexp {Control} $replace_key(Button-4)]} { + set zoom_state 4 + } elseif {[regexp {Shift} $replace_key(Button-4)]} { + set zoom_state 1 } else { - xschem callback %W 4 %x %y 0 5 0 %s + set zoom_state 0 } } + + if {[info exist replace_key(Shift-Button-4)]} { + if {[regexp {Control} $replace_key(Shift-Button-4)]} { + set horiz_pan_state 4 + } elseif {[regexp {Shift} $replace_key(Shift-Button-4)]} { + set horiz_pan_state 1 + } else { + set horiz_pan_state 0 + } + } + + if {[info exist replace_key(Control-Button-4)]} { + if {[regexp {Control} $replace_key(Control-Button-4)]} { + set vert_pan_state 4 + } elseif {[regexp {Shift} $replace_key(Control-Button-4)]} { + set vert_pan_state 1 + } else { + set vert_pan_state 0 + } + } + + bind $topwin " + # puts \"MouseWheel: %D\" + if {%D > 0} { + # zoom in + xschem callback %W 4 %x %y 0 4 0 $zoom_state + } else { + # zoom out + xschem callback %W 4 %x %y 0 5 0 $zoom_state + } + " + + bind $topwin " + # puts \"Shift-MouseWheel: %D\" + if {%D > 0} { + # pan to the right; move schematic to left + xschem callback %W 4 %x %y 0 4 0 $horiz_pan_state + } else { + # pan to the left; move schematic to right + xschem callback %W 4 %x %y 0 5 0 $horiz_pan_state + } + " + + bind $topwin " + # puts \"Ctrl-MouseWheel: %D\" + if {%D > 0} { + # pan down; move schematic up + xschem callback %W 4 %x %y 0 4 0 $vert_pan_state + } else { + # pan up; move schematic down + xschem callback %W 4 %x %y 0 5 0 $vert_pan_state + } + " + } bind $topwin "xschem callback %W -3 %x %y 0 %b 0 %s"