[Pioneers-commits] r31 - in trunk: client/gtk common/gtk

kemm at garage.maemo.org kemm at garage.maemo.org
Sun Mar 23 00:49:24 EET 2008


Author: kemm
Date: 2008-03-23 00:49:24 +0200 (Sun, 23 Mar 2008)
New Revision: 31

Modified:
   trunk/client/gtk/gui.c
   trunk/common/gtk/guimap.c
   trunk/common/gtk/guimap.h
Log:
Zoom In/Out/Default



Modified: trunk/client/gtk/gui.c
===================================================================
--- trunk/client/gtk/gui.c	2008-03-22 22:01:53 UTC (rev 30)
+++ trunk/client/gtk/gui.c	2008-03-22 22:49:24 UTC (rev 31)
@@ -206,6 +206,10 @@
 static void toggle_fullscreen_cb(void);
 static void preferences_cb(void);
 
+static void zoom_in_cb(void);
+static void zoom_out_cb(void);
+static void zoom_default_cb(void);
+
 static void help_about_cb(void);
 static void game_legend_cb(void);
 static void game_histogram_cb(void);
@@ -264,6 +268,14 @@
 	{"Preferences", GTK_STOCK_PREFERENCES, N_("Prefere_nces"), NULL,
 	 N_("Configure the application"), preferences_cb},
 
+    {"View", NULL, N_("_View"), NULL, NULL, NULL},
+    {"ZoomIn", GTK_STOCK_ZOOM_IN, N_("Zoom In"), "F7",
+     N_("Zoom Map In"), zoom_in_cb},
+    {"ZoomOut", GTK_STOCK_ZOOM_OUT, N_("Zoom Out"), "F8",
+     N_("Zoom Map Out"), zoom_out_cb},
+    {"ZoomDefault", GTK_STOCK_ZOOM_100, N_("Default Zoom"), NULL,
+     N_("Default Zoom"), zoom_default_cb},
+
 	{"HelpMenu", NULL, N_("_Help"), NULL, NULL, NULL},
 	{"HelpAbout", NULL, N_("_About Pioneers"), NULL,
 	 N_("Information about Pioneers"), help_about_cb},
@@ -315,6 +327,11 @@
 "      <menuitem action='BuyDevelopment'/>"
 "      <menuitem action='BuildCityWall'/>"
 "    </menu>"
+"    <menu action='View'>"
+"      <menuitem action='ZoomIn'/>"
+"      <menuitem action='ZoomOut'/>"
+"      <menuitem action='ZoomDefault'/>"
+"    </menu>"
 "    <menu action='SettingsMenu'>"
 "      <menuitem action='ShowHideToolbar'/>"
 "      <menuitem action='Fullscreen'/>"
@@ -340,6 +357,9 @@
 "    <toolitem action='BuildCity'/>"
 "    <toolitem action='BuyDevelopment'/>"
 "    <toolitem action='BuildCityWall'/>"
+"    <toolitem action='ZoomIn'/>"
+"    <toolitem action='ZoomOut'/>"
+"    <toolitem action='ZoomDefault'/>"
 "  </toolbar>"
 "</ui>";
 /* *INDENT-ON* */
@@ -864,6 +884,21 @@
 	gui_toolbar_show_accelerators(!toolbar_show_accelerators);
 }
 
+static void zoom_in_cb(void)
+{
+    guimap_user_scale(gmap, 1);
+}
+
+static void zoom_out_cb(void)
+{
+    guimap_user_scale(gmap, -1);
+}
+
+static void zoom_default_cb(void)
+{
+    guimap_user_scale_default(gmap);
+}
+
 static void preferences_cb(void)
 {
 	GtkWidget *widget;

Modified: trunk/common/gtk/guimap.c
===================================================================
--- trunk/common/gtk/guimap.c	2008-03-22 22:01:53 UTC (rev 30)
+++ trunk/common/gtk/guimap.c	2008-03-22 22:49:24 UTC (rev 31)
@@ -960,6 +960,10 @@
 	const gint reserved_height = 0;
 	gint width_radius;
 	gint height_radius;
+
+    if (gmap->user_radius)
+        return;
+    
     width_radius = (width - reserved_width)
         / ((gmap->map->x_size * 2 + 1
             - gmap->map->shrink_left
@@ -1023,6 +1027,24 @@
 	return sqrt(size_for_text_sqr) / 2;
 }
 
+void guimap_user_scale(GuiMap * gmap, gint inc)
+{
+    g_return_if_fail(gmap->area != NULL);
+
+    gmap->user_radius = TRUE;
+    gmap->hex_radius += inc;
+    guimap_display(gmap);
+}
+
+void guimap_user_scale_default(GuiMap * gmap)
+{
+    gmap->user_radius = FALSE;
+    guimap_scale_to_size(gmap,
+                         gmap->area->allocation.width,
+                         gmap->area->allocation.height);
+    guimap_display(gmap);
+}
+
 void guimap_display(GuiMap * gmap)
 {
 	gint maximum_size;

Modified: trunk/common/gtk/guimap.h
===================================================================
--- trunk/common/gtk/guimap.h	2008-03-22 22:01:53 UTC (rev 30)
+++ trunk/common/gtk/guimap.h	2008-03-22 22:49:24 UTC (rev 31)
@@ -80,6 +80,7 @@
 	gint highlight_chit;	   /**< chit number to highlight */
 	gint chit_radius;	   /**< radius of the chit */
 
+    gboolean user_radius;  /**< user defined hex radius? */
 	gint hex_radius;	   /**< size of hex on display */
 	gint x_point;		   /**< x offset of node 0 from centre */
 	gint y_point;		   /**< y offset of node 0 from centre */
@@ -116,6 +117,8 @@
 		    gint x_offset, gint y_offset, gint radius,
 		    gint n, gint terrain, gboolean highlight);
 
+void guimap_user_scale_default(GuiMap * gmap);
+void guimap_user_scale(GuiMap * gmap, gint inc);
 void guimap_scale_with_radius(GuiMap * gmap, gint radius);
 void guimap_scale_to_size(GuiMap * gmap, gint width, gint height);
 void guimap_display(GuiMap * gmap);



More information about the Pioneers-commits mailing list