Complete.Org: Mailing Lists: Archives: freeciv-dev: October 2003:
[Freeciv-Dev] Re: (PR#6381) hovering on the overview minimap
Home

[Freeciv-Dev] Re: (PR#6381) hovering on the overview minimap

[Top] [All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index] [Thread Index]
To: undisclosed-recipients: ;
Subject: [Freeciv-Dev] Re: (PR#6381) hovering on the overview minimap
From: "Jason Short" <jdorje@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 2 Oct 2003 20:29:14 -0700
Reply-to: rt@xxxxxxxxxxxxxx

Jason Short wrote:
> When in HOVER_GOTO state, the goto destination should be updated when 
> you hover over the overview minimap.
> 
> This patch implements this for gui-gtk.  Similar code should work for 
> other GUIs.

Patch attached.

As a side note, how come nobody ever thought of this before?  The 
functionality of the hovering goto has always bothered me.

jason

Index: client/mapctrl_common.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapctrl_common.c,v
retrieving revision 1.17
diff -u -r1.17 mapctrl_common.c
--- client/mapctrl_common.c     2003/10/02 17:45:00     1.17
+++ client/mapctrl_common.c     2003/10/03 03:23:14
@@ -226,6 +226,24 @@
   }
 }
 
+/****************************************************************************
+  Update the goto/patrol line to the given overview canvas location.
+****************************************************************************/
+void overview_update_line(int overview_x, int overview_y)
+{
+  if ((hover_state == HOVER_GOTO || hover_state == HOVER_PATROL)
+      && draw_goto_line) {
+    int x, y, old_x, old_y;
+
+    overview_to_map_pos(&x, &y, overview_x, overview_y);
+
+    get_line_dest(&old_x, &old_y);
+    if (!same_pos(old_x, old_y, x, y)) {
+      draw_line(x, y);
+    }
+  }
+}
+
 /**************************************************************************
   Find the focus unit's chance of success at attacking/defending the
   given tile.  Return FALSE if the values cannot be determined (e.g., no
Index: client/mapctrl_common.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/mapctrl_common.h,v
retrieving revision 1.10
diff -u -r1.10 mapctrl_common.h
--- client/mapctrl_common.h     2003/09/19 12:39:37     1.10
+++ client/mapctrl_common.h     2003/10/03 03:23:14
@@ -25,6 +25,7 @@
 void recenter_button_pressed(int canvas_x, int canvas_y);
 void update_turn_done_button_state(void);
 void update_line(int canvas_x, int canvas_y);
+void overview_update_line(int overview_x, int overview_y);
 char* popup_info_text(int xtile, int ytile);
 
 bool get_chance_to_win(int *att_chance, int *def_chance,
Index: client/gui-gtk/gui_main.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/gui_main.c,v
retrieving revision 1.138
diff -u -r1.138 gui_main.c
--- client/gui-gtk/gui_main.c   2003/07/23 13:46:01     1.138
+++ client/gui-gtk/gui_main.c   2003/10/03 03:23:14
@@ -554,8 +554,9 @@
 
   overview_canvas = gtk_drawing_area_new();
 
-  gtk_widget_set_events(overview_canvas, GDK_EXPOSURE_MASK
-                                      | GDK_BUTTON_PRESS_MASK );
+  gtk_widget_set_events(overview_canvas, (GDK_EXPOSURE_MASK
+                                         | GDK_BUTTON_PRESS_MASK
+                                         | GDK_POINTER_MOTION_MASK));
 
   gtk_drawing_area_size(GTK_DRAWING_AREA(overview_canvas), 160, 100);
   gtk_box_pack_start(GTK_BOX(avbox), overview_canvas, FALSE, FALSE, 0);
@@ -565,6 +566,9 @@
 
   gtk_signal_connect(GTK_OBJECT(overview_canvas), "button_press_event",
                      (GtkSignalFunc) butt_down_overviewcanvas, NULL);
+
+  gtk_signal_connect(GTK_OBJECT(overview_canvas), "motion_notify_event",
+                    GTK_SIGNAL_FUNC(move_overviewcanvas), NULL);
 
   /* The Rest */
 
Index: client/gui-gtk/mapctrl.c
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapctrl.c,v
retrieving revision 1.89
diff -u -r1.89 mapctrl.c
--- client/gui-gtk/mapctrl.c    2003/09/19 12:39:37     1.89
+++ client/gui-gtk/mapctrl.c    2003/10/03 03:23:14
@@ -234,8 +234,17 @@
   int x, y;
 
   gdk_window_get_pointer(map_canvas->window, &x, &y, 0);
-
-  update_line(x, y);
+  if (x >= 0 && y >= 0
+      && x < mapview_canvas.width && y < mapview_canvas.width) {
+    update_line(x, y);
+  } else {
+    gdk_window_get_pointer(overview_canvas->window, &x, &y, 0);
+    if (x >= 0 && y >= 0
+       && x < OVERVIEW_TILE_WIDTH * map.xsize
+       && y < OVERVIEW_TILE_WIDTH * map.ysize) {
+      overview_update_line(x, y);
+    }
+  }
 }
 
 /**************************************************************************
@@ -244,6 +253,15 @@
 gint move_mapcanvas(GtkWidget *widget, GdkEventButton *event)
 {
   update_line(event->x, event->y);
+  return TRUE;
+}
+
+/**************************************************************************
+  Draw a goto line when the mouse moves over the overview canvas.
+**************************************************************************/
+gint move_overviewcanvas(GtkWidget *widget, GdkEventButton *event)
+{
+  overview_update_line(event->x, event->y);
   return TRUE;
 }
 
Index: client/gui-gtk/mapctrl.h
===================================================================
RCS file: /home/freeciv/CVS/freeciv/client/gui-gtk/mapctrl.h,v
retrieving revision 1.13
diff -u -r1.13 mapctrl.h
--- client/gui-gtk/mapctrl.h    2003/07/02 16:40:18     1.13
+++ client/gui-gtk/mapctrl.h    2003/10/03 03:23:14
@@ -26,6 +26,7 @@
 gint butt_down_wakeup(GtkWidget *w, GdkEventButton *ev);
 gint butt_down_overviewcanvas(GtkWidget *w, GdkEventButton *ev);
 gint move_mapcanvas(GtkWidget *widget, GdkEventButton *event);
+gint move_overviewcanvas(GtkWidget *widget, GdkEventButton *event);
 
 void center_on_unit(void);
 void popupinfo_popdown_callback(GtkWidget *w, gpointer data);

[Prev in Thread] Current Thread [Next in Thread]