[patch] middle click panning and related



Contains:

patch 1. middle button panning + SHIFT and CONTROL functions for scroll wheel (SHIFT = x scroll, CONTROL = zoom) + shift click for sticky tools (in fact, it reverses tool stickyness) - I had to replace "toggled" signal (which isn't triggered on reclicking same button with different SHIFT state) with "clicked"

patch 2. some name changes for flowchart sheet, http://bugzilla.gnome.org/show_bug.cgi?id=115238 (doesn't fix the bug completely, just the naming part).

Krzysztof


Index: app/create_object.c
===================================================================
RCS file: /cvs/gnome/dia/app/create_object.c,v
retrieving revision 1.23
diff -u -r1.23 create_object.c
--- app/create_object.c 12 Jul 2003 09:40:12 -0000      1.23
+++ app/create_object.c 15 Jul 2003 19:06:09 -0000
@@ -161,7 +161,7 @@
 
   undo_set_transactionpoint(ddisp->diagram->undo);
   
-  if (prefs.reset_tools_after_create)
+  if (prefs.reset_tools_after_create != tool->invert_persistence)
       tool_reset();
   ddisplay_set_all_cursor(default_cursor);
 }
@@ -207,7 +207,7 @@
 
 
 
-Tool *create_create_object_tool(ObjectType *objtype, void *user_data)
+Tool *create_create_object_tool(ObjectType *objtype, void *user_data, int invert_persistence)
 {
   CreateObjectTool *tool;
 
@@ -221,6 +221,7 @@
   tool->objtype = objtype;
   tool->user_data = user_data;
   tool->moving = FALSE;
+  tool->invert_persistence = invert_persistence;
   
   return (Tool *) tool;
 }
Index: app/create_object.h
===================================================================
RCS file: /cvs/gnome/dia/app/create_object.h,v
retrieving revision 1.5
diff -u -r1.5 create_object.h
--- app/create_object.h 24 Jun 2000 14:46:58 -0000      1.5
+++ app/create_object.h 15 Jul 2003 19:06:10 -0000
@@ -34,10 +34,11 @@
   Handle *handle;
   Object *obj;
   Point last_to;
+  int invert_persistence;
 };
 
 
-Tool *create_create_object_tool(ObjectType *objtype, void *user_date);
+Tool *create_create_object_tool(ObjectType *objtype, void *user_date, int invert_persistence);
 void free_create_object_tool(Tool *tool);
 
 #endif /* CREATE_OBJECT_H */
Index: app/disp_callbacks.c
===================================================================
RCS file: /cvs/gnome/dia/app/disp_callbacks.c,v
retrieving revision 1.68
diff -u -r1.68 disp_callbacks.c
--- app/disp_callbacks.c        12 Jul 2003 09:40:12 -0000      1.68
+++ app/disp_callbacks.c        15 Jul 2003 19:06:12 -0000
@@ -427,10 +427,24 @@
         switch (sevent->direction)
         {
             case GDK_SCROLL_UP:
-              ddisplay_scroll_up(ddisp);
+              if (sevent->state & GDK_SHIFT_MASK)
+                  ddisplay_scroll_left(ddisp);
+              else if (sevent->state & GDK_CONTROL_MASK) {
+                  ddisplay_untransform_coords(ddisp, sevent->x, sevent->y, &middle.x, &middle.y);
+                  ddisplay_zoom(ddisp, &middle, 2);
+              }
+              else 
+                  ddisplay_scroll_up(ddisp);
               break;
             case GDK_SCROLL_DOWN:
-              ddisplay_scroll_down(ddisp);
+              if (sevent->state & GDK_SHIFT_MASK)
+                  ddisplay_scroll_right(ddisp);
+              else if (sevent->state & GDK_CONTROL_MASK) { 
+                    ddisplay_untransform_coords(ddisp, sevent->x, sevent->y, &middle.x, &middle.y);
+                    ddisplay_zoom(ddisp, &middle, 0.5);
+              }
+              else
+                  ddisplay_scroll_down(ddisp);
               break;
             case GDK_SCROLL_LEFT:
               ddisplay_scroll_left(ddisp);
@@ -478,6 +492,8 @@
         switch (bevent->button)
         {
             case 1:
+              if (transient_tool)
+                break;
               if (*active_tool->double_click_func)
                 (*active_tool->double_click_func) (active_tool, bevent, ddisp);
               break;
@@ -506,6 +522,8 @@
         switch (bevent->button)
         {
             case 1:
+              if (transient_tool)
+                break;
                   /* get the focus again, may be lost by zoom combo */
               gtk_widget_grab_focus(canvas);
               if (*active_tool->button_press_func)
@@ -516,9 +534,16 @@
               if (ddisp->menu_bar == NULL) {
                 popup_object_menu(ddisp, bevent);
               }
+             else if (!transient_tool) {
+               gtk_widget_grab_focus(canvas);
+               transient_tool = create_scroll_tool();
+               (*transient_tool->button_press_func) (transient_tool, bevent, ddisp);
+             }
               break;
 
             case 3:
+              if (transient_tool)
+                break;
               if (ddisp->menu_bar == NULL) {
                 if (bevent->state & GDK_CONTROL_MASK) {
                       /* for two button mouse users ... */
@@ -551,6 +576,13 @@
               break;
 
             case 2:
+             if (transient_tool) {
+               (*transient_tool->button_release_func) (transient_tool,
+                                                    bevent, ddisp);
+                                                               
+               tool_free(transient_tool);
+               transient_tool = NULL;
+             }
               break;
 
             case 3:
@@ -574,7 +606,9 @@
           mevent->state = tmask;
           mevent->is_hint = FALSE;
         }
-        if (*active_tool->motion_func)
+        if (transient_tool && (*transient_tool->motion_func)) 
+          (*transient_tool->motion_func) (transient_tool, mevent, ddisp);
+        else if (*active_tool->motion_func)
           (*active_tool->motion_func) (active_tool, mevent, ddisp);
         break;
 
Index: app/interface.c
===================================================================
RCS file: /cvs/gnome/dia/app/interface.c,v
retrieving revision 1.92
diff -u -r1.92 interface.c
--- app/interface.c     12 Jul 2003 09:40:12 -0000      1.92
+++ app/interface.c     15 Jul 2003 19:06:15 -0000
@@ -548,8 +548,12 @@
   }
 
   if (tooldata->type != -1) {
+    gint x, y;
+    GdkModifierType mask;
+    /*  get the modifiers  */
+    gdk_window_get_pointer (gtk_widget_get_parent_window(w), &x, &y, &mask);
     tool_select (tooldata->type, tooldata->extra_data, tooldata->user_data,
-                 w);
+                 w, mask&1);
   }
 }
 
@@ -563,7 +567,7 @@
   if ((event->type == GDK_2BUTTON_PRESS) &&
       (event->button == 1)) {
     tool_options_dialog_show (tooldata->type, tooldata->extra_data, 
-                              tooldata->user_data, w);
+                              tooldata->user_data, w, event->state&1);
     return TRUE;
   }
 
@@ -597,6 +601,7 @@
                             pixmap, mask);
 }
 
+/*
 void 
 tool_select_callback(GtkWidget *widget, gpointer data) {
   ToolButtonData *tooldata = (ToolButtonData *)data;
@@ -611,6 +616,7 @@
                  tooldata->user_data,widget);    
   }
 }
+*/
 
 static void
 create_tools(GtkWidget *parent)
@@ -660,7 +666,7 @@
     
     gtk_container_add (GTK_CONTAINER (button), pixmapwidget);
     
-    gtk_signal_connect (GTK_OBJECT (button), "toggled",
+    gtk_signal_connect (GTK_OBJECT (button), "clicked",
                        GTK_SIGNAL_FUNC (tool_select_update),
                        &tool_data[i].callback_data);
     
@@ -766,7 +772,7 @@
     data->extra_data = sheet_obj->object_type;
     data->user_data = sheet_obj->user_data;
     
-    gtk_signal_connect (GTK_OBJECT (button), "toggled",
+    gtk_signal_connect (GTK_OBJECT (button), "clicked",
                        GTK_SIGNAL_FUNC (tool_select_update),
                        data);
     
@@ -871,7 +877,7 @@
                             data, (GdkDestroyNotify)g_free);
     if (first_button == NULL) first_button = button;
     
-    gtk_signal_connect (GTK_OBJECT (button), "toggled",
+    gtk_signal_connect (GTK_OBJECT (button), "clicked",
                        GTK_SIGNAL_FUNC (tool_select_update), data);
     gtk_signal_connect (GTK_OBJECT (button), "button_press_event",
                        GTK_SIGNAL_FUNC (tool_button_press), data);
@@ -935,7 +941,7 @@
   gtk_widget_show(separator);
 
   sheet_option_menu = gtk_option_menu_new();
-  gtk_widget_set_usize(sheet_option_menu, 20, -1);
+  gtk_widget_set_size_request(sheet_option_menu, 20, -1);
   sheet_menu = gtk_menu_new();
   gtk_option_menu_set_menu(GTK_OPTION_MENU(sheet_option_menu), sheet_menu);
   gtk_wrap_box_pack_wrapped(GTK_WRAP_BOX(parent), sheet_option_menu,
@@ -1263,4 +1269,3 @@
 {
   return toolbox_shell;
 }
-
Index: app/scroll_tool.c
===================================================================
RCS file: /cvs/gnome/dia/app/scroll_tool.c,v
retrieving revision 1.7
diff -u -r1.7 scroll_tool.c
--- app/scroll_tool.c   23 Mar 2001 14:29:48 -0000      1.7
+++ app/scroll_tool.c   15 Jul 2003 19:06:18 -0000
@@ -53,7 +53,6 @@
   return (Tool *)tool;
 }
 
-
 void
 free_scroll_tool(Tool *tool)
 {
Index: app/tool.c
===================================================================
RCS file: /cvs/gnome/dia/app/tool.c,v
retrieving revision 1.8
diff -u -r1.8 tool.c
--- app/tool.c  16 Aug 2001 12:18:19 -0000      1.8
+++ app/tool.c  15 Jul 2003 19:06:19 -0000
@@ -26,6 +26,7 @@
 #include "defaults.h"
 
 Tool *active_tool = NULL;
+Tool *transient_tool = NULL;
 static GtkWidget *active_button = NULL;
 static GtkWidget *former_button = NULL;
 
@@ -45,26 +46,61 @@
                          GTK_BUTTON(modify_tool_button), NULL);
 }
 
-void 
-tool_select(ToolType type, gpointer extra_data, 
-            gpointer user_data, GtkWidget *button)
+void
+tool_get(ToolState *state)
+{
+  state->type = active_tool->type;
+  state->button = active_button;
+  if (state->type == CREATE_OBJECT_TOOL) {
+    state->user_data = ((CreateObjectTool *)active_tool)->user_data;
+    state->extra_data = ((CreateObjectTool *)active_tool)->objtype->name;
+    state->invert_persistence = ((CreateObjectTool *)active_tool)->invert_persistence;
+  }
+  else
+  {
+    state->user_data = NULL;
+    state->extra_data = NULL;
+    state->invert_persistence = 0;
+  }
+}
+
+void
+tool_restore(const ToolState *state)
 {
-  former_button = active_button;
+  tool_select(state->type, state->extra_data, state->user_data, state->button,
+              state->invert_persistence);
+}
 
-  switch(active_tool->type) {
+void
+tool_free(Tool *tool)
+{
+  switch(tool->type) {
   case MODIFY_TOOL:
-    free_modify_tool(active_tool);
+    free_modify_tool(tool);
     break;
   case CREATE_OBJECT_TOOL:
-    free_create_object_tool(active_tool);
+    free_create_object_tool(tool);
     break;
   case MAGNIFY_TOOL:
-    free_magnify_tool(active_tool);
+    free_magnify_tool(tool);
     break;
   case SCROLL_TOOL:
-    free_scroll_tool(active_tool);
+    free_scroll_tool(tool);
     break;
+  default:
+    g_assert(0);    
   }
+}
+
+void 
+tool_select(ToolType type, gpointer extra_data, 
+            gpointer user_data, GtkWidget *button,
+            int invert_persistence)
+{
+  if (button)
+    former_button = active_button;
+
+  tool_free(active_tool);
   switch(type) {
   case MODIFY_TOOL:
     active_tool = create_modify_tool();
@@ -72,7 +108,7 @@
   case CREATE_OBJECT_TOOL:
     active_tool =
       create_create_object_tool(object_get_type((char *)extra_data),
-                               (void *) user_data);
+                               (void *) user_data, invert_persistence);
     break;
   case MAGNIFY_TOOL:
     active_tool = create_magnify_tool();
@@ -80,18 +116,22 @@
   case SCROLL_TOOL:
     active_tool = create_scroll_tool();
     break;
+  default:
+    g_assert(0);    
   }
-  active_button = button;
+  if (button)
+    active_button = button;
 }
 
 void
 tool_options_dialog_show(ToolType type, gpointer extra_data, 
-                        gpointer user_data, GtkWidget *button) 
+                        gpointer user_data, GtkWidget *button,
+                         int invert_persistence) 
 {
   ObjectType *objtype;
- 
+
   if (active_tool->type != type) 
-    tool_select(type,extra_data,user_data,button);
+    tool_select(type,extra_data,user_data,button,invert_persistence);
 
   switch(type) {
   case MODIFY_TOOL:
Index: app/tool.h
===================================================================
RCS file: /cvs/gnome/dia/app/tool.h,v
retrieving revision 1.7
diff -u -r1.7 tool.h
--- app/tool.h  16 Aug 2001 12:18:19 -0000      1.7
+++ app/tool.h  15 Jul 2003 19:06:20 -0000
@@ -22,6 +22,7 @@
 
 typedef struct _Tool Tool;
 typedef struct _ToolInfo ToolInfo;
+typedef struct _ToolState ToolState;
 
 typedef enum _ToolType ToolType;
 
@@ -54,15 +55,25 @@
   char *tooltip;
 };
 
-extern Tool *active_tool;
+struct _ToolState {
+  ToolType type;
+  gpointer extra_data;
+  gpointer user_data;
+  GtkWidget *button;
+  int invert_persistence;
+};
+
+extern Tool *active_tool, *transient_tool;
 
+void tool_get(ToolState *state);
+void tool_restore(const ToolState *state);
+void tool_free(Tool *tool);
 void tool_select(ToolType type, gpointer extra_data, gpointer user_date,
-                 GtkWidget *button);
+                 GtkWidget *button, int invert_persistence);
 void tool_select_former(void);
 void tool_reset(void);
 void tool_options_dialog_show(ToolType type, gpointer extra_data, 
-                             gpointer user_data,GtkWidget *button);
+                             gpointer user_data,GtkWidget *button,
+                              int invert_persistence);
 
 #endif /* TOOL_H */
-
-
Index: sheets/Flowchart.sheet.in
===================================================================
RCS file: /cvs/gnome/dia/sheets/Flowchart.sheet.in,v
retrieving revision 1.2
diff -u -r1.2 Flowchart.sheet.in
--- sheets/Flowchart.sheet.in   30 Apr 2003 21:03:38 -0000      1.2
+++ sheets/Flowchart.sheet.in   15 Jul 2003 19:06:46 -0000
@@ -4,16 +4,16 @@
   <_description>Objects to draw flowcharts</_description>
   <contents>
     <object name="Flowchart - Box">
-      <_description>Box with text inside</_description>
+      <_description>Process/Auxiliary Operation</_description>
     </object>
     <object name="Flowchart - Parallelogram">
-      <_description>Parallelogram with text inside</_description>
+      <_description>Input/Output</_description>
     </object>
     <object name="Flowchart - Diamond">
-      <_description>Diamond with text inside</_description>
+      <_description>Decision</_description>
     </object>
     <object name="Flowchart - Ellipse">
-      <_description>Ellipse with text inside</_description>
+      <_description>Connector</_description>
     </object>
     <object name="Flowchart - Display">
       <_description>Display</_description>
@@ -41,7 +41,7 @@
       <_description>Predefined process</_description>
     </object>
     <object name="Flowchart - Terminal">
-      <_description>Terminal</_description>
+      <_description>Terminal Interrupt</_description>
     </object>
     <object name="Flowchart - Magnetic Disk">
       <_description>Magnetic disk</_description>


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