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

Re: gEDA-user: Option to not display polygons



Colin D Bennett wrote:

> Only, I don't the functionality
> is quite hooked up to the Control-click yet... it still seems to toggle
> the entire group when I tried it.

For some reason I don't quite understand, only two of the three modified 
files made it into the patch. This was the change in gui-top-window.c
where my brave new function to toggle just one layer would be called. 
Don't know, how this could happen.

Anyway, I attached a new version of the patch that contains diffs of 
all three files. So it should be working now.

The source in misc.c is commented in a nice way. This made it a easy to 
comprehend and modify. I wouldn't say the same about gui-top-window.c . 

And yet another side note: My original patch took 41 hours until it passed 
moderation. See the footer of my mail for my feelings on this.

---<)kaimartin(>---
-- 
Kai-Martin Knaak
Email: kmk@xxxxxxxxxxxxxxx
http://pool.sks-keyservers.net:11371/pks/lookup?search=0x6C0B9F53
not happy with moderation of geda-user
From acf6bf31e6f728fad33be92d17631df7fb91464d Mon Sep 17 00:00:00 2001
From: Kai-Martin Knaak <kmk@xxxxxxxxxxxx>
Date: Tue, 2 Aug 2011 02:15:21 +0200
Subject: [PATCH] Only-toggle-the-visibility-of-the-current-layer-if-control
 is pressed

This adds the ability to toggle the visibility of the current group only,
rather than change the whole layer group. To access, press [control] during
the left-mouse-click on the layer button.
---
 src/hid/gtk/gui-top-window.c |   13 ++++++++++---
 src/misc.c                   |   26 +++++++++++++++++++++-----
 src/misc.h                   |    1 +
 3 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/src/hid/gtk/gui-top-window.c b/src/hid/gtk/gui-top-window.c
index e9c2669..3765f7e 100644
--- a/src/hid/gtk/gui-top-window.c
+++ b/src/hid/gtk/gui-top-window.c
@@ -1143,8 +1143,16 @@ layer_enable_button_cb (GtkWidget * widget, gpointer data)
 	      return;
 	    }
 	}
-      /* switch layer group on/off */
-      ChangeGroupVisibility (layer, active, false);
+
+      /* if control modifier is pressed, only change visibility of this layer
+       * else toggle visibility of the whole group
+       */
+      if (gui->control_is_pressed ()) {
+          ChangeLayerVisibility (layer, active, false);
+        }
+      else {
+          ChangeGroupVisibility (layer, active, false);
+        }
       redraw = TRUE;
       break;
     }
@@ -1851,7 +1859,6 @@ delete_chart_cb (GtkWidget * widget, GdkEvent * event, GHidPort * port)
 static void
 destroy_chart_cb (GtkWidget * widget, GHidPort * port)
 {
-  ghid_shutdown_renderer (port);
   gtk_main_quit ();
 }
 
diff --git a/src/misc.c b/src/misc.c
index ce2ab4a..c56f679 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -1196,6 +1196,26 @@ PushOnTopOfLayerStack (int NewTop)
 }
 
 
+/*-----------------------------------------------------------------------
+ * changes the visibility of a group
+ * returns 1
+ */
+int
+ChangeLayerVisibility (int Layer, bool On, bool ChangeStackOrder)
+{
+  int changed = 1;
+
+  PCB->Data->Layer[Layer].On = On;
+  if (On && ChangeStackOrder)
+    PushOnTopOfLayerStack (Layer);
+
+  /* update control panel */
+  hid_action ("LayersChanged");
+
+  return (changed);
+}
+
+
 /* ----------------------------------------------------------------------
  * changes the visibility of all layers in a group
  * returns the number of changed layers
@@ -1232,12 +1252,8 @@ ChangeGroupVisibility (int Layer, bool On, bool ChangeStackOrder)
       }
 
   /* change at least the passed layer */
-  PCB->Data->Layer[Layer].On = On;
-  if (On && ChangeStackOrder)
-    PushOnTopOfLayerStack (Layer);
+  ChangeLayerVisibility (Layer, On, ChangeStackOrder);
 
-  /* update control panel and exit */
-  hid_action ("LayersChanged");
   return (changed);
 }
 
diff --git a/src/misc.h b/src/misc.h
index 45d6e52..16eb7ac 100644
--- a/src/misc.h
+++ b/src/misc.h
@@ -73,6 +73,7 @@ int GetLayerNumber (DataTypePtr, LayerTypePtr);
 int GetLayerGroupNumberByPointer (LayerTypePtr);
 int GetLayerGroupNumberByNumber (Cardinal);
 int GetGroupOfLayer (int);
+int ChangeLayerVisibility (int, bool, bool);
 int ChangeGroupVisibility (int, bool, bool);
 void LayerStringToLayerStack (char *);
 
-- 
1.7.5.4



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