[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gEDA-dev: [patch] keyboard panning support



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi again

This is another patch (for CVS head) that provides four new scheme
callbacks for keyboard shortcuts: "view-pan-left", "view-pan-right",
"view-pan-up" and "view-pan-down". It also adds a new integer
configuration variable "keyboardpan-gain".

By binding these callbacks to cursor keys it is now possible to move the
viewport only by using the keyboard. The "keyboardpan-gain" controls how
much the viewport moves for each keypress.

Rationale behind this patch:

I've been using XCircuit for quite a few years and I am now trying to
move to GSchem. I found the "x" keyboard shortcut (view-pan-hotkey) and
right mouse button panning to be a bit awkward compared to just pressing
the cursor keys (like in XCircuit). Also at the moment the cursor keys
do not appear to be used for anything.

I hope this patch doesn't count as a major change :)

Best regards
Tomaz Solc
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEyIo4sAlAlRhL9q8RAs0rAKCEBirCkIEnr76IJhb63fLHC+I6gwCeITsY
GZlHtrc0pVy4u9nmVKjSDao=
=pCpQ
-----END PGP SIGNATURE-----
Index: include/i_vars.h
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/include/i_vars.h,v
retrieving revision 1.35
diff -u -3 -r1.35 i_vars.h
--- include/i_vars.h	24 Jul 2006 03:29:21 -0000	1.35
+++ include/i_vars.h	26 Jul 2006 18:58:24 -0000
@@ -89,3 +89,4 @@
 extern int default_auto_save_interval;
 extern int default_drag_can_move;
 extern int default_mousepan_gain;
+extern int default_keyboardpan_gain;
Index: include/prototype.h
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/include/prototype.h,v
retrieving revision 1.132
diff -u -3 -r1.132 prototype.h
--- include/prototype.h	24 Jul 2006 03:29:21 -0000	1.132
+++ include/prototype.h	26 Jul 2006 18:58:25 -0000
@@ -115,6 +115,10 @@
 SCM g_keys_view_zoom_box(void);
 SCM g_keys_view_zoom_box_hotkey(void);
 SCM g_keys_view_pan(void);
+SCM g_keys_view_pan_left(void);
+SCM g_keys_view_pan_right(void);
+SCM g_keys_view_pan_up(void);
+SCM g_keys_view_pan_down(void);
 SCM g_keys_view_pan_hotkey(void);
 SCM g_keys_view_update_cues(void);
 SCM g_keys_page_manager(void);
@@ -270,6 +274,7 @@
 SCM g_rc_auto_save_interval(SCM seconds);
 SCM g_rc_drag_can_move(SCM mode);
 SCM g_rc_mousepan_gain(SCM mode);
+SCM g_rc_keyboardpan_gain(SCM mode);
 /* g_register.c */
 void g_register_funcs(void);
 /* globals.c */
@@ -350,6 +355,10 @@
 void i_callback_view_zoom_in_hotkey(gpointer data, guint callback_action, GtkWidget *widget);
 void i_callback_view_zoom_out_hotkey(gpointer data, guint callback_action, GtkWidget *widget);
 void i_callback_view_pan(gpointer data, guint callback_action, GtkWidget *widget);
+void i_callback_view_pan_left(gpointer data, guint callback_action, GtkWidget *widget);
+void i_callback_view_pan_right(gpointer data, guint callback_action, GtkWidget *widget);
+void i_callback_view_pan_up(gpointer data, guint callback_action, GtkWidget *widget);
+void i_callback_view_pan_down(gpointer data, guint callback_action, GtkWidget *widget);
 void i_callback_view_pan_hotkey(gpointer data, guint callback_action, GtkWidget *widget);
 void i_callback_view_update_cues(gpointer data, guint callback_action, GtkWidget *widget);
 void i_callback_page_manager(gpointer data, guint callback_action, GtkWidget *widget);
Index: lib/system-gschemrc.in
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/lib/system-gschemrc.in,v
retrieving revision 1.95
diff -u -3 -r1.95 system-gschemrc.in
--- lib/system-gschemrc.in	24 Jul 2006 03:29:21 -0000	1.95
+++ lib/system-gschemrc.in	26 Jul 2006 18:58:26 -0000
@@ -179,6 +179,11 @@
 ;(mousepan-gain 1)
 ;(mousepan-gain 10)
 
+; keyboardpan-gain integer
+;
+; Controls how much the display pans when using keyboard shortcuts. 
+(keyboardpan-gain 20)
+
 
 
 ; action-feedback-mode string
@@ -1247,6 +1252,10 @@
     ("v" . view-keymap)
     ("w" . view-zoom-box-hotkey)
     ("x" . view-pan-hotkey)
+    ("Left" . view-pan-left)
+    ("Right" . view-pan-right)
+    ("Up" . view-pan-up)
+    ("Down" . view-pan-down)
     ("y" . buffer-keymap)
     ("z" . view-zoom-in-hotkey)
     ("period" . repeat-last-command)
Index: src/g_keys.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/g_keys.c,v
retrieving revision 1.2
diff -u -3 -r1.2 g_keys.c
--- src/g_keys.c	15 Jul 2006 18:51:40 -0000	1.2
+++ src/g_keys.c	26 Jul 2006 18:58:26 -0000
@@ -220,6 +220,10 @@
 DEFINE_G_KEYS(view_zoom_box)
 DEFINE_G_KEYS(view_zoom_box_hotkey)
 DEFINE_G_KEYS(view_pan)
+DEFINE_G_KEYS(view_pan_left)
+DEFINE_G_KEYS(view_pan_right)
+DEFINE_G_KEYS(view_pan_up)
+DEFINE_G_KEYS(view_pan_down)
 DEFINE_G_KEYS(view_pan_hotkey)
 DEFINE_G_KEYS(view_update_cues)
 DEFINE_G_KEYS(page_manager)
Index: src/g_rc.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/g_rc.c,v
retrieving revision 1.38
diff -u -3 -r1.38 g_rc.c
--- src/g_rc.c	24 Jul 2006 03:29:21 -0000	1.38
+++ src/g_rc.c	26 Jul 2006 18:58:26 -0000
@@ -1687,3 +1687,26 @@
 
   return SCM_BOOL_T;
 }
+
+/*! \brief Scheme function for setting the step for keyboard pan.
+ *
+ * Default setting is 10.
+ */
+SCM g_rc_keyboardpan_gain(SCM gain)
+{
+  int val;
+
+  SCM_ASSERT (SCM_INUMP (gain), gain, SCM_ARG1, "keyboardpan-gain");
+  
+  val = SCM_INUM (gain);
+
+  if (val <= 0) {
+    fprintf(stderr, _("Invalid gain [%d] passed to keyboardpan-gain\n"),
+            val);
+    val = 10; /* absolute default */
+  }
+
+  default_keyboardpan_gain = val;
+
+  return SCM_BOOL_T;
+}
Index: src/g_register.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/g_register.c,v
retrieving revision 1.42
diff -u -3 -r1.42 g_register.c
--- src/g_register.c	24 Jul 2006 03:29:21 -0000	1.42
+++ src/g_register.c	26 Jul 2006 18:58:26 -0000
@@ -147,6 +147,7 @@
   { "output-vector-threshold",   1, 0, 0, g_rc_output_vector_threshold },
   { "add-attribute-offset",      1, 0, 0, g_rc_add_attribute_offset },
   { "mousepan-gain",             1, 0, 0, g_rc_mousepan_gain },
+  { "keyboardpan-gain",          1, 0, 0, g_rc_keyboardpan_gain },
 
   /* backup functions */
   { "auto-save-interval",        1, 0, 0, g_rc_auto_save_interval },
@@ -245,6 +246,10 @@
   { "view-zoom-box-hotkey",      0, 0, 0, g_keys_view_zoom_box_hotkey },
   { "view-pan",                  0, 0, 0, g_keys_view_pan },
   { "view-pan-hotkey",           0, 0, 0, g_keys_view_pan_hotkey },
+  { "view-pan-left",		 0, 0, 0, g_keys_view_pan_left },
+  { "view-pan-right",		 0, 0, 0, g_keys_view_pan_right },
+  { "view-pan-up",		 0, 0, 0, g_keys_view_pan_up },
+  { "view-pan-down",		 0, 0, 0, g_keys_view_pan_down },
   { "view-update-cues",          0, 0, 0, g_keys_view_update_cues },
   { "page-manager",              0, 0, 0, g_keys_page_manager },
   { "page-next",                 0, 0, 0, g_keys_page_next },
Index: src/i_callbacks.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/i_callbacks.c,v
retrieving revision 1.58
diff -u -3 -r1.58 i_callbacks.c
--- src/i_callbacks.c	15 Jul 2006 18:51:41 -0000	1.58
+++ src/i_callbacks.c	26 Jul 2006 18:58:27 -0000
@@ -30,6 +30,7 @@
 
 #include "../include/globals.h"
 #include "../include/prototype.h"
+#include "../include/i_vars.h"
 
 #ifdef HAVE_LIBDMALLOC
 #include <dmalloc.h>
@@ -1546,6 +1547,58 @@
   i_update_middle_button(w_current, i_callback_view_pan, _("Pan"));
 }
 
+/*! \brief Scheme callback function that moves the viewport to the left.
+ *
+ * The distance can be set with "keyboardpan-gain" scheme callback.
+ */
+DEFINE_I_CALLBACK(view_pan_left)
+{
+  TOPLEVEL *w_current = (TOPLEVEL *) data;
+
+  exit_if_null(w_current);
+
+  a_pan_mouse(w_current, default_keyboardpan_gain, 0);
+}
+
+/*! \brief Scheme callback function that moves the viewport to the right.
+ *
+ * The distance can be set with "keyboardpan-gain" scheme callback.
+ */
+DEFINE_I_CALLBACK(view_pan_right)
+{
+  TOPLEVEL *w_current = (TOPLEVEL *) data;
+
+  exit_if_null(w_current);
+
+  a_pan_mouse(w_current, -default_keyboardpan_gain, 0);
+}
+
+/*! \brief Scheme callback function that moves the viewport up.
+ *
+ * The distance can be set with "keyboardpan-gain" scheme callback.
+ */
+DEFINE_I_CALLBACK(view_pan_up)
+{
+  TOPLEVEL *w_current = (TOPLEVEL *) data;
+
+  exit_if_null(w_current);
+
+  a_pan_mouse(w_current, 0, default_keyboardpan_gain);
+}
+
+/*! \brief Scheme callback function that moves the viewport down.
+ *
+ * The distance can be set with "keyboardpan-gain" scheme callback.
+ */
+DEFINE_I_CALLBACK(view_pan_down)
+{
+  TOPLEVEL *w_current = (TOPLEVEL *) data;
+
+  exit_if_null(w_current);
+
+  a_pan_mouse(w_current, 0, -default_keyboardpan_gain);
+}
+
 /*! \todo Finish function documentation!!!
  *  \brief
  *  \par Function Description
Index: src/i_vars.c
===================================================================
RCS file: /home/cvspsrv/cvsroot/eda/geda/gaf/gschem/src/i_vars.c,v
retrieving revision 1.32
diff -u -3 -r1.32 i_vars.c
--- src/i_vars.c	24 Jul 2006 03:29:21 -0000	1.32
+++ src/i_vars.c	26 Jul 2006 18:58:27 -0000
@@ -126,6 +126,7 @@
 
 int default_text_feedback = ONLY_WHEN_READABLE;
 int default_mousepan_gain = 5;
+int default_keyboardpan_gain = 10;
 
 /*! \todo Finish function documentation!!!
  *  \brief


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