]> git.street.me.uk Git - andy/viking.git/commitdiff
Pan tool (as default)
authorGuilhem Bonnefille <guilhem.bonnefille@gmail.com>
Sat, 15 Mar 2008 10:31:39 +0000 (10:31 +0000)
committerGuilhem Bonnefille <guilhem.bonnefille@gmail.com>
Sat, 15 Mar 2008 10:31:39 +0000 (10:31 +0000)
ChangeLog
src/icons/Makefile.am
src/icons/mover_22.png [new file with mode: 0644]
src/menu.xml.h
src/vikwindow.c

index 83c5cfd902583b0c18cabe9e3f651bd0b0d63e9c..035c0f2727f3d2269adcc8a786e26218ed893b21 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,7 @@
 2008-03-15:
 Guilhem Bonnefille <guilhem.bonnefille@gmail.com>:
        * Fix: [ 1839948 ] Maximize/Restore changes current cursor
+       * Add panning tool as default
 
 2008-02-25:
 Guilhem Bonnefille <guilhem.bonnefille@gmail.com>:
index 804e2c1d28d68b3c3a8cb64e472571b11224b634..a691c4fcc4f5ffbde859f7579ade5fc000e644d5 100644 (file)
@@ -91,6 +91,7 @@ ICONS = \
   geozoom_18.png \
   mapdl_18.png \
   demdl_18.png \
+  mover_22.png \
   ruler_18.png \
   showpic_18.png \
   zoom_18.png \
diff --git a/src/icons/mover_22.png b/src/icons/mover_22.png
new file mode 100644 (file)
index 0000000..b99d3e4
Binary files /dev/null and b/src/icons/mover_22.png differ
index 914ff692cca4866166b4ecc524e92e319f24dd27..422befc1959603341e791d7f03ab71a4cc9c0a2e 100644 (file)
@@ -86,6 +86,7 @@ static const char *menu_xml =
        "      <separator/>"
        "    </menu>"
        "    <menu action='Tools'>"
+       "      <menuitem action='Pan'/>"
        "      <menuitem action='Zoom'/>"
        "      <menuitem action='Ruler'/>"
        "    </menu>"
@@ -116,6 +117,7 @@ static const char *menu_xml =
        "      <separator/>"
        "    </placeholder>"
        "    <placeholder name='ToolItems'>"
+       "    <toolitem action='Pan'/>"
        "    <toolitem action='Zoom'/>"
        "    <toolitem action='Ruler'/>"
        "    </placeholder>"
index 720bf86baa066d5a50f8b57a9040a2bac8fb927b..563227ab99abc8dac876d8b322980f6ee710d753 100644 (file)
@@ -162,7 +162,8 @@ struct _VikWindow {
 };
 
 enum {
- TOOL_ZOOM = 0,
+ TOOL_PAN = 0,
+ TOOL_ZOOM,
  TOOL_RULER,
  TOOL_LAYER,
  NUMBER_OF_TOOLS
@@ -176,8 +177,9 @@ enum {
 
 static guint window_signals[VW_LAST_SIGNAL] = { 0 };
 
-static gchar *tool_names[NUMBER_OF_TOOLS] = { N_("Zoom"), N_("Ruler"), N_("Pan") };
+static gchar *tool_names[NUMBER_OF_TOOLS] = { N_("Pan"), N_("Zoom"), N_("Ruler") };
 
+GdkCursor *vw_cursor_pan = NULL;
 GdkCursor *vw_cursor_zoom = NULL;
 GdkCursor *vw_cursor_ruler = NULL;
 
@@ -273,7 +275,7 @@ static void window_init ( VikWindow *vw )
   window_create_ui(vw);
   window_set_filename (vw, NULL);
   
-  toolbox_activate(vw->vt, "Zoom");
+  toolbox_activate(vw->vt, "Pan");
 
   vw->filename = NULL;
   vw->item_factory = NULL;
@@ -413,7 +415,7 @@ static void window_configure_event ( VikWindow *vw )
     // This is a hack to set the cursor corresponding to the first tool
     // FIXME find the correct way to initialize both tool and its cursor
     first = 0;
-    gdk_window_set_cursor ( GTK_WIDGET(vw->viking_vvp)->window, vw_cursor_zoom );
+    gdk_window_set_cursor ( GTK_WIDGET(vw->viking_vvp)->window, vw_cursor_pan );
   }
 }
 
@@ -496,7 +498,7 @@ static void draw_mouse_motion (VikWindow *vw, GdkEventMotion *event)
   gdouble zoom;
   VikDemInterpol interpol_method;
 
-  toolbox_move(vw->vt, (GdkEventButton *)event);
+  toolbox_move(vw->vt, event);
 
   vik_viewport_screen_to_coord ( vw->viking_vvp, event->x, event->y, &coord );
   vik_coord_to_utm ( &coord, &utm );
@@ -918,6 +920,47 @@ static VikToolInterface zoom_tool =
     (VikToolMouseFunc) zoomtool_release };
 /*** end zoom code ********************************************************/
 
+/********************************************************************************
+ ** Pan tool code
+ ********************************************************************************/
+static gpointer pantool_create (VikWindow *vw, VikViewport *vvp)
+{
+  return vw;
+}
+
+static VikLayerToolFuncStatus pantool_click (VikLayer *vl, GdkEventButton *event, VikWindow *vw)
+{
+  vw->modified = TRUE;
+  if ( event->button == 1 )
+    vik_window_pan_click ( vw, event );
+  draw_update ( vw );
+  return VIK_LAYER_TOOL_ACK;
+}
+
+static VikLayerToolFuncStatus pantool_move (VikLayer *vl, GdkEventButton *event, VikWindow *vw)
+{
+  vik_window_pan_move ( vw, event );
+  return VIK_LAYER_TOOL_ACK;
+}
+
+static VikLayerToolFuncStatus pantool_release (VikLayer *vl, GdkEventButton *event, VikWindow *vw)
+{
+  if ( event->button == 1 )
+    vik_window_pan_release ( vw, event );
+  return VIK_LAYER_TOOL_ACK;
+}
+
+static VikToolInterface pan_tool = 
+  { "Pan", 
+    (VikToolConstructorFunc) pantool_create,
+    (VikToolDestructorFunc) NULL,
+    (VikToolActivationFunc) NULL,
+    (VikToolActivationFunc) NULL,
+    (VikToolMouseFunc) pantool_click, 
+    (VikToolMouseFunc) pantool_move,
+    (VikToolMouseFunc) pantool_release };
+/*** end pan code ********************************************************/
+
 static void draw_pan_cb ( GtkAction *a, VikWindow *vw )
 {
   if (!strcmp(gtk_action_get_name(a), "PanNorth")) {
@@ -1174,7 +1217,11 @@ static void menu_tool_cb ( GtkAction *old, GtkAction *a, VikWindow *vw )
 
   toolbox_activate(vw->vt, gtk_action_get_name(a));
 
-  if (!strcmp(gtk_action_get_name(a), "Zoom")) {
+  if (!strcmp(gtk_action_get_name(a), "Pan")) {
+    vw->current_tool = TOOL_PAN;
+    gdk_window_set_cursor ( GTK_WIDGET(vw->viking_vvp)->window, vw_cursor_pan );
+  } 
+  else if (!strcmp(gtk_action_get_name(a), "Zoom")) {
     vw->current_tool = TOOL_ZOOM;
     gdk_window_set_cursor ( GTK_WIDGET(vw->viking_vvp)->window, vw_cursor_zoom );
   } 
@@ -1880,8 +1927,9 @@ static GtkRadioActionEntry mode_entries[] = {
 };
 
 static GtkRadioActionEntry tool_entries[] = {
-  { "Zoom",      "vik-icon-zoom",        N_("_Zoom"),                         "<control><shift>Z", N_("Zoom Tool"),  0 },
-  { "Ruler",     "vik-icon-ruler",       N_("_Ruler"),                        "<control><shift>R", N_("Ruler Tool"), 1 }
+  { "Pan",      "vik-icon-pan",        N_("_Pan"),                         "<control><shift>P", N_("Pan Tool"),  0 },
+  { "Zoom",      "vik-icon-zoom",        N_("_Zoom"),                         "<control><shift>Z", N_("Zoom Tool"),  1 },
+  { "Ruler",     "vik-icon-ruler",       N_("_Ruler"),                        "<control><shift>R", N_("Ruler Tool"), 2 }
 };
 
 static GtkToggleActionEntry toggle_entries[] = {
@@ -1908,6 +1956,7 @@ static void window_create_ui( VikWindow *window )
 
   toolbox_add_tool(window->vt, &ruler_tool, TOOL_LAYER_TYPE_NONE);
   toolbox_add_tool(window->vt, &zoom_tool, TOOL_LAYER_TYPE_NONE);
+  toolbox_add_tool(window->vt, &pan_tool, TOOL_LAYER_TYPE_NONE);
 
   error = NULL;
   if (!(mid = gtk_ui_manager_add_ui_from_string (uim, menu_xml, -1, &error))) {
@@ -2017,6 +2066,7 @@ static struct {
   { &addwp_18,         "Create Waypoint"   },
   { &edwp_18,          "Edit Waypoint"     },
   { &iscissors_18,     "Magic Scissors"   },
+  { &mover_22,         "vik-icon-pan"     },
   { &zoom_18,          "vik-icon-zoom"     },
   { &ruler_18,         "vik-icon-ruler"    },
   { &geozoom_18,       "Georef Zoom Tool"  },
@@ -2047,6 +2097,8 @@ void vik_window_cursors_init()
   GdkPixbuf *cursor_pixbuf;
   GError *cursor_load_err;
 
+  vw_cursor_pan = gdk_cursor_new(GDK_FLEUR);
+
   cursor_pixbuf = gdk_pixbuf_from_pixdata (&cursor_zoom, FALSE, &cursor_load_err);
   vw_cursor_zoom = gdk_cursor_new_from_pixbuf ( gdk_display_get_default(), cursor_pixbuf, 6, 6 );
 
@@ -2060,6 +2112,7 @@ void vik_window_cursors_init()
 
 void vik_window_cursors_uninit()
 {
+  gdk_cursor_unref ( vw_cursor_pan );
   gdk_cursor_unref ( vw_cursor_zoom );
   gdk_cursor_unref ( vw_cursor_ruler );
 }