[go: up one dir, main page]

Menu

#184 mouse wheel zoom

open
nobody
None
5
2021-01-24
2014-04-11
No

zooming in/out with the mouse wheel + modifier key

example:
ctrl+wheel_up : zoom in
ctrl+wheel_down: zoom out

Discussion

  • sadf

    sadf - 2018-12-06

    I could use the same feature.

    I currently use a hack for that. I do not know much about the source code, so that could break something else.
    On top of that, it just zooms to the center, it only works with XInput, i only tested it on linux and there are other limitations.

    --- a/xournal-0.4.8.2016/src/xo-callbacks.c
    +++ b/xournal-0.4.8.2016_zoom_hack/src/xo-callbacks.c
    @@ -2418,7 +2418,27 @@ on_canvas_button_press_event           (GtkWidget       *widget,
         // double-clicks may have broken axes member (free'd) due to a bug in GDK
    
       if (event->button > 3) { // scroll wheel events! don't paint...
    -    if (ui.use_xinput && !gtk_check_version(2, 17, 0) && event->button <= 7) {
    +    if (ui.use_xinput && !gtk_check_version(2, 17, 0) && event->button <= 7) 
    +      {
    +        guint state=(gtk_accelerator_get_default_mod_mask()&event->state); //get state of modifier keys (alt, ctrl, shift, ..)
    +        if(state == GDK_SHIFT_MASK) //shift is pressed  (and no other modifier keys), => change up/down to left/right
    +        { 
    +          if(event->button == 4) event->button=6;  
    +          if(event->button == 5) event->button=7;
    +        }
    +        if(state==GDK_CONTROL_MASK) //ctrl is pressed (and no other modifier keys) => zoom in and out
    +        {
    +          if(event->button == 4)
    +          {
    +            on_viewZoomIn_activate(NULL,NULL);
    +            return FALSE;
    +          }
    +          else if(event->button == 5)
    +          {
    +            on_viewZoomOut_activate(NULL,NULL);
    +            return FALSE;
    +          }
    +        }
           /* with GTK+ 2.17 and later, the entire widget hierarchy is xinput-aware,
              so the core button event gets discarded and the scroll event never 
              gets processed by the main window. This is arguably a GTK+ bug.
    
     
  • phbr

    phbr - 2021-01-24

    Thanks for your work, I use your software almost every day.

    I'm digging up this old request, but this feature would be really interesting to improve the user experience. I use v. 0.4.8.2016 on Kubuntu 20.04.

     
  • Denis Auroux

    Denis Auroux - 2021-01-24

    I've added to the GIT repository a quick hack for this -- essentially equivalent to what was proposed by "sadf" above, except with a less steep zoom factor (1.1 instead of the zoom factor used by the toolbar and shortcuts). It still has the same limitations -- it only works with XInput enabled (hence likely not in the Windows version), it zooms around the center of the view rather than the position of the cursor, and there's a lot of visual tearing if you zoom in too far. Sorry -- it's a useful feature even when slightly broken, and I just don't have time to implement it better at the moment.

    Denis

     

Log in to post a comment.