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

gEDA-user: [PATCH] Drag without selection in gschem



Could someone give this a test and come up with any counter-reasons why
this attached patch is NOT a good idea?  I vaguely recall a similar (or
identical?) idea was discussed on the list recently?

I was watching some students using gschem the other week, and noticed
them struggling to move objects due to the fact they had to select them
first. I wrote a patch which lets a drag action operate on whatever is
under the mouse (selected or not).

The user can override the mechanism and get a "normal" drag-selection
box by holding shift when dragging. This also happens if the user drags
on a blank area of the schematic.

This seems to work here (in conjunction with some other cleanup I pushed
to git HEAD).

I'd appreciate a second pair of eyes on it though, as I just knocked it
together quickly.

Fwiw.. dragging of selected locked objects _does not_ work.. (never did
as far as my brief skim of the code suggests.). I think we ought to fix
that.

-- 
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!)
Tel: +44 (0)1223 748328 - (Shared lab phone, ask for me)
From 7f88749446b61493e881ad6aeb0a82f909a8c0d7 Mon Sep 17 00:00:00 2001
From: Peter Clifton <pcjc2@xxxxxxxxx>
Date: Mon, 21 Mar 2011 22:51:23 +0000
Subject: [PATCH] gschem: Don't require select to drag objects

This comes from watching users interacting with gschem and their
clear expectations that objects can be dragged around the canvas
without an explicit selection step first.

When a mouse drag starts on non-selected object, starting dragging
that object rather than forming a box selection.
---
 gschem/src/x_event.c |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/gschem/src/x_event.c b/gschem/src/x_event.c
index 67989a1..a6a66eb 100644
--- a/gschem/src/x_event.c
+++ b/gschem/src/x_event.c
@@ -718,6 +718,7 @@ gint x_event_motion(GtkWidget *widget, GdkEventMotion *event,
   int w_x, w_y;
   int unsnapped_wx, unsnapped_wy;
   int skip_event=0;
+  int do_move;
   GdkEvent *test_event;
 
   exit_if_null(w_current);
@@ -791,20 +792,37 @@ gint x_event_motion(GtkWidget *widget, GdkEventMotion *event,
     break;
 
     case(STARTSELECT):
-    if (!o_find_selected_object (w_current,
-                                 w_current->first_wx, w_current->first_wy)) {
+    /* Don't move anything if the shift key is pressed, that means
+     * the user definately wants to drag out a selection box.
+     */
+    do_move = 0;
+    if (!w_current->SHIFTKEY) {
+      /* If there is a selected object under the cursor, start moving it.
+       * If we don't find anything selected, look for an object we could
+       * select to start moving it.
+       */
+      if (o_find_selected_object (w_current, w_current->first_wx, w_current->first_wy) ||
+          (o_find_object (w_current,
+                          w_current->first_wx, w_current->first_wy, TRUE) &&
+           o_select_selected (w_current)))
+        do_move = 1;
+    }
+
+    if (!do_move) {
+      /* Drag out a selection box */
       if (o_select_box_start(w_current, unsnapped_wx, unsnapped_wy)) {
         w_current->event_state = SBOX;
         w_current->inside_action = 1;
       }
       break;
     } else {
-      /* Start the object movement */
+      /* Start moving the selected object(s) */
       o_move_start(w_current, w_x, w_y);
       w_current->event_state = ENDMOVE;
       w_current->inside_action = 1;
+      /* Fall through bottom of case to finish the move */
     }
-    /* Fall through */
+    /* Fall through to handle move */
     case(ENDMOVE):
     case(MOVE):
     if (w_current->inside_action)
-- 
1.7.4.1

Attachment: signature.asc
Description: This is a digitally signed message part


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