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

Re: gEDA-user: Default to dot grid instead of mesh grid



On Wed, 2009-04-29 at 16:16 -0700, Yamazaki R2 wrote:
> Thanks peter, for now ill just change that variable and recompile.
> 
> What file is responsible for reading the gschemrc file and getting the
> settings from there? I can also just edit that file and add a variable
> for the grid style.

Quite a few files unfortunately. From vague memory, these are involved:

src/g_register.c
src/g_rc.c
src/i_vars.c
include/i_vars.h
include/prototype.h

I've attached an example change which added a similar parameter for
controling the style of mouse binding being used.

-- 
Peter Clifton

Electrical Engineering Division,
Engineering Department,
University of Cambridge,
9, JJ Thomson Avenue,
Cambridge
CB3 0FA

Tel: +44 (0)7729 980173 - (No signal in the lab!)
diff --git a/gschem/include/gschem_struct.h b/gschem/include/gschem_struct.h
index 6ba4d94..c99c29f 100644
--- a/gschem/include/gschem_struct.h
+++ b/gschem/include/gschem_struct.h
@@ -155,6 +155,7 @@ struct st_gschem_toplevel {
   int log_window_type;    /* controls if the log window is decorated or not */
   int third_button;       /* controls what the third mouse button does */
   int middle_button;      /* controls what the third mouse button does */
+  int scroll_wheel;       /* controls what the mouse scroll wheel does */
   int file_preview;       /* controls if the preview area is enabled or not */
   int enforce_hierarchy;  /* controls how much freedom user has when traversing the hierarchy */
   int text_origin_marker; /* controls if text origin marker is displayed or not */
diff --git a/gschem/include/i_vars.h b/gschem/include/i_vars.h
index f20926d..0ebf72a 100644
--- a/gschem/include/i_vars.h
+++ b/gschem/include/i_vars.h
@@ -59,6 +59,7 @@ extern int default_log_window;
 extern int default_log_window_type;
 extern int default_third_button;
 extern int default_middle_button;
+extern int default_scroll_wheel;
 extern int default_net_consolidate;
 extern int default_file_preview;
 extern int default_enforce_hierarchy;
diff --git a/gschem/include/prototype.h b/gschem/include/prototype.h
index c08c0b5..0089a26 100644
--- a/gschem/include/prototype.h
+++ b/gschem/include/prototype.h
@@ -241,6 +241,7 @@ SCM g_rc_log_window(SCM mode);
 SCM g_rc_log_window_type(SCM mode);
 SCM g_rc_third_button(SCM mode);
 SCM g_rc_middle_button(SCM mode);
+SCM g_rc_scroll_wheel(SCM mode);
 SCM g_rc_net_consolidate(SCM mode);
 SCM g_rc_file_preview(SCM mode);
 SCM g_rc_enforce_hierarchy(SCM mode);
diff --git a/gschem/lib/system-gschemrc.in b/gschem/lib/system-gschemrc.in
index cac762f..4f9838b 100644
--- a/gschem/lib/system-gschemrc.in
+++ b/gschem/lib/system-gschemrc.in
@@ -667,6 +667,16 @@
 (third-button "popup")
 ;(third-button "mousepan")
 
+; scroll-wheel string
+;
+; Controls the binding of the mouse scroll wheel.
+; "classic" style is the gschem default, where scrolling with no modifier
+; key is mapped to zoom, + CTRL -> x-axis pan, + SHIFT -> y-axis pan.
+; "gtk" style changes the behaviour to be more like other GTK appliactions,
+; no modifier -> y-axis pan, + CTRL -> zoom, + SHIFT -> x-axis pan.
+(scroll-wheel "classic")
+;(scroll-wheel "gtk")
+
 ; warp-cursor string
 ;
 ; Controls if the cursor is warped (or moved) when you zoom in and out.
diff --git a/gschem/src/g_rc.c b/gschem/src/g_rc.c
index 114e3ec..ec426cd 100644
--- a/gschem/src/g_rc.c
+++ b/gschem/src/g_rc.c
@@ -918,6 +918,23 @@ SCM g_rc_middle_button(SCM mode)
  *  \par Function Description
  *
  */
+SCM g_rc_scroll_wheel(SCM mode)
+{
+  static const vstbl_entry mode_table[] = {
+    {SCROLL_WHEEL_CLASSIC, "classic"},
+    {SCROLL_WHEEL_GTK,     "gtk"},
+  };
+
+  RETURN_G_RC_MODE("scroll-wheel",
+                   default_scroll_wheel,
+                   2);
+}
+
+/*! \todo Finish function documentation!!!
+ *  \brief
+ *  \par Function Description
+ *
+ */
 SCM g_rc_net_consolidate(SCM mode)
 {
   static const vstbl_entry mode_table[] = {
diff --git a/gschem/src/g_register.c b/gschem/src/g_register.c
index 1e7a89f..da021f1 100644
--- a/gschem/src/g_register.c
+++ b/gschem/src/g_register.c
@@ -117,6 +117,7 @@ static struct gsubr_t gschem_funcs[] = {
   { "log-window-type",           1, 0, 0, g_rc_log_window_type },
   { "third-button",              1, 0, 0, g_rc_third_button },
   { "middle-button",             1, 0, 0, g_rc_middle_button },
+  { "scroll-wheel",              1, 0, 0, g_rc_scroll_wheel },
   { "net-consolidate",           1, 0, 0, g_rc_net_consolidate },
   { "file-preview",              1, 0, 0, g_rc_file_preview },
   { "enforce-hierarchy",         1, 0, 0, g_rc_enforce_hierarchy },
diff --git a/gschem/src/i_vars.c b/gschem/src/i_vars.c
index ecd5fd4..2f8f17a 100644
--- a/gschem/src/i_vars.c
+++ b/gschem/src/i_vars.c
@@ -88,6 +88,7 @@ int   default_middle_button = STROKE;
 #else
 int   default_middle_button = REPEAT;
 #endif
+int   default_scroll_wheel = SCROLL_WHEEL_CLASSIC;
 int   default_net_consolidate = TRUE;
 int   default_file_preview = FALSE;
 int   default_enforce_hierarchy = TRUE;
@@ -214,6 +215,7 @@ void i_vars_set(GSCHEM_TOPLEVEL *w_current)
   w_current->image_height       = default_image_height;
   w_current->third_button       = default_third_button;
   w_current->middle_button      = default_middle_button;
+  w_current->scroll_wheel       = default_scroll_wheel;
   toplevel->net_consolidate    = default_net_consolidate;
   w_current->file_preview       = default_file_preview;
   w_current->enforce_hierarchy  = default_enforce_hierarchy;
diff --git a/gschem/src/x_event.c b/gschem/src/x_event.c
index d2680ee..716fe24 100644
--- a/gschem/src/x_event.c
+++ b/gschem/src/x_event.c
@@ -1436,6 +1436,11 @@ gint x_event_scroll (GtkWidget *widget, GdkEventScroll *event,
 		     GSCHEM_TOPLEVEL *w_current)
 {
   GtkAdjustment *adj;
+  gboolean pan_xaxis = FALSE;
+  gboolean pan_yaxis = FALSE;
+  gboolean zoom = FALSE;
+  int pan_direction = 1;
+  int zoom_direction = ZOOM_IN;
 
   exit_if_null(w_current);
   global_window_current = w_current;
@@ -1445,83 +1450,59 @@ gint x_event_scroll (GtkWidget *widget, GdkEventScroll *event,
   w_current->CONTROLKEY = (event->state & GDK_CONTROL_MASK) ? 1 : 0;
   w_current->ALTKEY     = (event->state & GDK_MOD1_MASK) ? 1 : 0;
 
-  switch (event->direction) {
-  case(GDK_SCROLL_UP):
-    if (!w_current->CONTROLKEY && !w_current->SHIFTKEY)
-    {
-      /* turn the up/down scroll wheel into a zoom in / out */
-      /*! \todo Change "HOTKEY" TO new "MOUSE" specifier?
-       */
-      a_zoom(w_current, ZOOM_IN, HOTKEY, 0);
- 
-      if (w_current->undo_panzoom) {
-        o_undo_savestate(w_current, UNDO_VIEWPORT_ONLY); 
-      }
+  if (w_current->scroll_wheel == SCROLL_WHEEL_CLASSIC) {
+    /* Classic gschem behaviour */
+    zoom =      !w_current->CONTROLKEY && !w_current->SHIFTKEY;
+    pan_yaxis = !w_current->CONTROLKEY &&  w_current->SHIFTKEY;
+    pan_xaxis =  w_current->CONTROLKEY && !w_current->SHIFTKEY;
+  } else {
+    /* GTK style behaviour */
+    zoom =       w_current->CONTROLKEY && !w_current->SHIFTKEY;
+    pan_yaxis = !w_current->CONTROLKEY && !w_current->SHIFTKEY;
+    pan_xaxis = !w_current->CONTROLKEY &&  w_current->SHIFTKEY;
+  }
 
-    } else if ( !w_current->CONTROLKEY ) {
-      /* if the control key is not held down, scroll up / down */
-      /* You must have scrollbars enabled if you want to use the scroll wheel to pan */
-      if (w_current->scrollbars_flag == FALSE )
-        return 0;
-      adj = gtk_range_get_adjustment(GTK_RANGE(w_current->v_scrollbar));
-      gtk_adjustment_set_value(adj, adj->value - (adj->page_increment / 4));
-    } else {
-      /* if the control key is held down, then scroll left as well */
-      /* You must have scrollbars enabled if you want to use the scroll wheel to pan */
-      if (w_current->scrollbars_flag == FALSE )
-        return 0;
-      adj = gtk_range_get_adjustment(GTK_RANGE(w_current->h_scrollbar));
-      gtk_adjustment_set_value(adj, adj->value - (adj->page_increment / 4));
-    }
-    break;
+  /* You must have scrollbars enabled if you want to use the scroll wheel to pan */
+  if (!w_current->scrollbars_flag) {
+    pan_xaxis = FALSE;
+    pan_yaxis = FALSE;
+  }
 
-  case(GDK_SCROLL_DOWN):
-    if (!w_current->CONTROLKEY && !w_current->SHIFTKEY)
-    {
-      /* turn the up/down scroll wheel into a zoom in / out */
-      /*! \todo Change "HOTKEY" TO new "MOUSE" specifier?
-       */
-      a_zoom(w_current, ZOOM_OUT, HOTKEY, 0);
-      if (w_current->undo_panzoom) {
-        o_undo_savestate(w_current, UNDO_VIEWPORT_ONLY); 
-      }
-    } else if ( !w_current->CONTROLKEY ) {
-      /* if the control key is not held down, scroll up / down */
-      /* You must have scrollbars enabled if you want to use the scroll wheel to pan */
-      if (w_current->scrollbars_flag == FALSE )
-        return 0;
-      adj = gtk_range_get_adjustment(GTK_RANGE(w_current->v_scrollbar));
-      gtk_adjustment_set_value(adj, min(adj->value + (adj->page_increment / 4),
-                                        adj->upper - adj->page_size));
-    } else {
-      /* if the control key is held down, then scroll right as well */
-      /* You must have scrollbars enabled if you want to use the scroll wheel to pan */
-      if (w_current->scrollbars_flag == FALSE )
-        return 0;
-      adj = gtk_range_get_adjustment(GTK_RANGE(w_current->h_scrollbar));
-      gtk_adjustment_set_value(adj, min(adj->value + (adj->page_increment / 4),
-                                        adj->upper - adj->page_size));
-    }
-    break;
+  switch (event->direction) {
+    case GDK_SCROLL_UP:
+    case GDK_SCROLL_LEFT:
+      pan_direction = -1;
+      zoom_direction = ZOOM_IN;
+      break;
+    case GDK_SCROLL_DOWN:
+    case GDK_SCROLL_RIGHT:
+      pan_direction =  1;
+      zoom_direction = ZOOM_OUT;
+      break;
+  }
 
-  case(GDK_SCROLL_LEFT):
-    /* You must have scrollbars enabled if you want to use the scroll wheel to pan */
-    if (w_current->scrollbars_flag == FALSE)
-      return 0;
-    adj = gtk_range_get_adjustment(GTK_RANGE(w_current->h_scrollbar));
-    gtk_adjustment_set_value(adj, adj->value - (adj->page_increment / 4));
-    break;
+  if (zoom) {
+    /*! \todo Change "HOTKEY" TO new "MOUSE" specifier? */
+    a_zoom(w_current, zoom_direction, HOTKEY, 0);
+  }
 
-  case(GDK_SCROLL_RIGHT):
-    /* You must have scrollbars enabled if you want to use the scroll wheel to pan */
-    if (w_current->scrollbars_flag == FALSE)
-      return 0;
+  if (pan_xaxis) {
     adj = gtk_range_get_adjustment(GTK_RANGE(w_current->h_scrollbar));
-    gtk_adjustment_set_value(adj, min(adj->value + (adj->page_increment / 4),
+    gtk_adjustment_set_value(adj, min(adj->value + pan_direction *
+                                        (adj->page_increment / 4),
                                       adj->upper - adj->page_size));
-    break;
+  }
 
+  if (pan_yaxis) {
+    adj = gtk_range_get_adjustment(GTK_RANGE(w_current->v_scrollbar));
+    gtk_adjustment_set_value(adj, min(adj->value + pan_direction *
+                                        (adj->page_increment / 4),
+                                      adj->upper - adj->page_size));
   }
 
-  return(0);
+  if (w_current->undo_panzoom && (zoom || pan_xaxis || pan_yaxis)) {
+    o_undo_savestate(w_current, UNDO_VIEWPORT_ONLY);
+  }
+
+  return 0;
 }
diff --git a/libgeda/include/defines.h b/libgeda/include/defines.h
index 873346d..624b016 100644
--- a/libgeda/include/defines.h
+++ b/libgeda/include/defines.h
@@ -293,6 +293,10 @@
 #define ACTION			2
 #define MID_MOUSEPAN_ENABLED	3
 
+/* for scroll-wheel */
+#define SCROLL_WHEEL_CLASSIC 0
+#define SCROLL_WHEEL_GTK     1
+
 /* for selected_from */
 #define DONTCARE		0
 #define MENU			1

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