[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-cvs: pcb.git: branch: master updated (93577465317687486e0ba7b0f08d2277e3548779)



The branch, master has been updated
       via  93577465317687486e0ba7b0f08d2277e3548779 (commit)
      from  b28b17eea3d964b3a206e00d0ef676e033efca8e (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


=========
 Summary
=========

 src/gpcb-menu.res               |   13 +++++++++
 src/hid/gtk/gtkhid-main.c       |   55 +++++++++++++++++++++++++++++++++++++++
 src/hid/gtk/gui-output-events.c |   33 +++++++++--------------
 3 files changed, 81 insertions(+), 20 deletions(-)


=================
 Commit Messages
=================

commit 93577465317687486e0ba7b0f08d2277e3548779
Author: Jared Casper <jaredcasper@xxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxx>

    Adding ability to customize mouse scroll action in GTK.
    
    Changed the mouse_scroll gtk event handler to use do_mouse_action
    instead of manually handling the event.  gtk treats scrolling
    differently as a mouse button event, and doesn't give a mouse button
    number, so this patch just hard codes up/down/left/right to buttons 4
    through 7.  This corresponds to the default names used in the resource
    file, and, for X11, gtk hardcodes mouse buttons 4 - 7 to the scrolling
    events anyway.  This may cause problems in quartz or windows if some
    mouse has a bunch of buttons and quartz/windows maps those buttons to
    numbers 4 - 7, but I don't have a system to test that (and in that
    case the names in the resource file would be wrong as well).
    
    Added a Scroll action to the gtk hid to be able to mimic the existing
    scroll wheel behavior with an action script.

:100644 100644 50ac639... b844f56... M	src/gpcb-menu.res
:100644 100644 0156559... bac3e0e... M	src/hid/gtk/gtkhid-main.c
:100644 100644 adbdbea... 9ea3207... M	src/hid/gtk/gui-output-events.c

=========
 Changes
=========

commit 93577465317687486e0ba7b0f08d2277e3548779
Author: Jared Casper <jaredcasper@xxxxxxxxx>
Commit: DJ Delorie <dj@xxxxxxxxxxx>

    Adding ability to customize mouse scroll action in GTK.
    
    Changed the mouse_scroll gtk event handler to use do_mouse_action
    instead of manually handling the event.  gtk treats scrolling
    differently as a mouse button event, and doesn't give a mouse button
    number, so this patch just hard codes up/down/left/right to buttons 4
    through 7.  This corresponds to the default names used in the resource
    file, and, for X11, gtk hardcodes mouse buttons 4 - 7 to the scrolling
    events anyway.  This may cause problems in quartz or windows if some
    mouse has a bunch of buttons and quartz/windows maps those buttons to
    numbers 4 - 7, but I don't have a system to test that (and in that
    case the names in the resource file would be wrong as well).
    
    Added a Scroll action to the gtk hid to be able to mimic the existing
    scroll wheel behavior with an action script.

diff --git a/src/gpcb-menu.res b/src/gpcb-menu.res
index 50ac639..b844f56 100644
--- a/src/gpcb-menu.res
+++ b/src/gpcb-menu.res
@@ -30,6 +30,19 @@ Mouse =
     shift-ctrl = { Display(ToggleRubberbandMode) Mode(Save) Mode(Move) Mode(Notify) }
     up-shift-ctrl = { Mode(Notify) Mode(Restore) Display(ToggleRubberbandMode) }
   }
+  Up = {
+    Zoom(0.8)
+    shift = Scroll(up)
+    ctrl = Scroll(left)
+  }
+  Down = {
+    Zoom(1.25)
+    shift = Scroll(down)
+    ctrl = Scroll(right)
+  }
+# If you want zoom to center, do this instead.
+  #Up = { {Zoom(0.8) Center()} }
+  #Down = { {Zoom(1.25) Center()} }
 }
 
 MainMenu =
diff --git a/src/hid/gtk/gtkhid-main.c b/src/hid/gtk/gtkhid-main.c
index 0156559..bac3e0e 100644
--- a/src/hid/gtk/gtkhid-main.c
+++ b/src/hid/gtk/gtkhid-main.c
@@ -2474,6 +2474,60 @@ SetUnits (int argc, char **argv, int x, int y)
 }
 
 /* ------------------------------------------------------------ */
+static const char scroll_syntax[] =
+"Scroll(up|down|left|right, [div])";
+
+static const char scroll_help[] =
+"Scroll the viewport.";
+
+/* % start-doc actions Scroll
+
+@item up|down|left|right
+Specifies the direction to scroll
+
+@item div
+Optional.  Specifies how much to scroll by.  The viewport is scrolled
+by 1/div of what is visible, so div = 1 scrolls a whole page. If not
+default is given, div=40.
+
+%end-doc */
+
+static int
+ScrollAction (int argc, char **argv, int x, int y)
+{
+  gdouble dx = 0.0, dy = 0.0;
+  int div = 40;
+
+  if (!ghidgui)
+    return 0;
+
+  if (argc != 1 && argc != 2)
+    AFAIL (scroll);
+
+  if (argc == 2)
+    div = atoi(argv[1]);
+
+  if (strcasecmp (argv[0], "up") == 0)
+    dy = -(ghid_port.height * gport->zoom / div);
+  else if (strcasecmp (argv[0], "down") == 0)
+    dy = ghid_port.height * gport->zoom / div;
+  else if (strcasecmp (argv[0], "right") == 0)
+    dx = ghid_port.width * gport->zoom / div;
+  else if (strcasecmp (argv[0], "left") == 0)
+    dx = -(ghid_port.width * gport->zoom / div);
+  else
+    AFAIL (scroll);
+
+  HideCrosshair (FALSE);
+  ghid_port_ranges_pan (dx, dy, TRUE);
+  MoveCrosshairRelative (dx, dy);
+  AdjustAttachedObjects ();
+  RestoreCrosshair (FALSE);
+
+  return 0;
+}
+
+/* ------------------------------------------------------------ */
 static const char pan_syntax[] =
 "Pan([thumb], Mode)";
 
@@ -2618,6 +2672,7 @@ HID_Action ghid_main_action_list[] = {
    printcalibrate_help, printcalibrate_syntax},
   {"RouteStylesChanged", 0, RouteStylesChanged},
   {"Save", 0, Save, save_help, save_syntax},
+  {"Scroll", 0, ScrollAction, scroll_help, scroll_syntax},
   {"SetUnits", 0, SetUnits, setunits_help, setunits_syntax},
   {"SwapSides", 0, SwapSides, swapsides_help, swapsides_syntax},
   {"Zoom", "Click on zoom focus", Zoom, zoom_help, zoom_syntax}
diff --git a/src/hid/gtk/gui-output-events.c b/src/hid/gtk/gui-output-events.c
index adbdbea..9ea3207 100644
--- a/src/hid/gtk/gui-output-events.c
+++ b/src/hid/gtk/gui-output-events.c
@@ -935,34 +935,27 @@ ghid_port_window_mouse_scroll_cb (GtkWidget * widget,
 				  GdkEventScroll * ev, GHidPort * out)
 {
   ModifierKeysState mk;
-  gdouble dx = 0.0, dy = 0.0, zoom_factor;
   GdkModifierType state;
+  int button;
 
   state = (GdkModifierType) (ev->state);
   mk = ghid_modifier_keys_state (&state);
-  if (mk == NONE_PRESSED)
-    {
-      zoom_factor = (ev->direction == GDK_SCROLL_UP) ? 0.8 : 1.25;
-      ghid_port_ranges_zoom (gport->zoom * zoom_factor);
-      return TRUE;
-    }
-
-  if (mk == SHIFT_PRESSED)
-    dy = ghid_port.height * gport->zoom / 40;
-  else
-    dx = ghid_port.width * gport->zoom / 40;
 
-  if (ev->direction == GDK_SCROLL_UP)
+  /* X11 gtk hard codes buttons 4, 5, 6, 7 as below in
+   * gtk+/gdk/x11/gdkevents-x11.c:1121, but quartz and windows have
+   * special mouse scroll events, so this may conflict with a mouse
+   * who has buttons 4 - 7 that aren't the scroll wheel?
+   */
+  switch(ev->direction)
     {
-      dx = -dx;
-      dy = -dy;
+    case GDK_SCROLL_UP: button = 4; break;
+    case GDK_SCROLL_DOWN: button = 5; break;
+    case GDK_SCROLL_LEFT: button = 6; break;
+    case GDK_SCROLL_RIGHT: button = 7; break;
+    default: button = -1;
     }
 
-  HideCrosshair (FALSE);
-  ghid_port_ranges_pan (dx, dy, TRUE);
-  MoveCrosshairRelative (dx, dy);
-  AdjustAttachedObjects ();
-  RestoreCrosshair (FALSE);
+  do_mouse_action(button, mk);
 
   return TRUE;
 }




_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs