diff --git a/src/vikviewport.c b/src/vikviewport.c index 5622e1d5..14fe13a8 100644 --- a/src/vikviewport.c +++ b/src/vikviewport.c @@ -1127,10 +1127,10 @@ void vik_viewport_set_zoom ( VikViewport *vvp, gdouble xympp ) viewport_clear_surface_tool ( vvp ); } -/* or could do factor */ -void vik_viewport_zoom_in ( VikViewport *vvp ) +gboolean vik_viewport_zoom_in ( VikViewport *vvp ) { - g_return_if_fail ( vvp != NULL ); + g_return_val_if_fail ( vvp != NULL, FALSE ); + gboolean ans = FALSE; if ( vvp->xmpp >= (VIK_VIEWPORT_MIN_ZOOM*2) && vvp->ympp >= (VIK_VIEWPORT_MIN_ZOOM*2) ) { vvp->xmpp /= 2; @@ -1140,13 +1140,16 @@ void vik_viewport_zoom_in ( VikViewport *vvp ) vvp->ymfactor = mercator_factor ( vvp->ympp, vvp->scale ); viewport_utm_zone_check(vvp); + ans = TRUE; } viewport_clear_surface_tool ( vvp ); + return ans; } -void vik_viewport_zoom_out ( VikViewport *vvp ) +gboolean vik_viewport_zoom_out ( VikViewport *vvp ) { - g_return_if_fail ( vvp != NULL ); + g_return_val_if_fail ( vvp != NULL, FALSE ); + gboolean ans = FALSE; if ( vvp->xmpp <= (VIK_VIEWPORT_MAX_ZOOM/2) && vvp->ympp <= (VIK_VIEWPORT_MAX_ZOOM/2) ) { vvp->xmpp *= 2; @@ -1156,8 +1159,10 @@ void vik_viewport_zoom_out ( VikViewport *vvp ) vvp->ymfactor = mercator_factor ( vvp->ympp, vvp->scale ); viewport_utm_zone_check(vvp); + ans = TRUE; } viewport_clear_surface_tool ( vvp ); + return ans; } gdouble vik_viewport_get_zoom ( VikViewport *vvp ) diff --git a/src/vikviewport.h b/src/vikviewport.h index d2c297b6..a92907de 100644 --- a/src/vikviewport.h +++ b/src/vikviewport.h @@ -77,8 +77,8 @@ gdouble vik_viewport_get_ympp ( VikViewport *vvp ); gdouble vik_viewport_get_xmpp ( VikViewport *vvp ); void vik_viewport_set_zoom ( VikViewport *vvp, gdouble mpp ); gdouble vik_viewport_get_zoom ( VikViewport *vvp ); -void vik_viewport_zoom_in ( VikViewport *vvp ); -void vik_viewport_zoom_out ( VikViewport *vvp ); +gboolean vik_viewport_zoom_in ( VikViewport *vvp ); +gboolean vik_viewport_zoom_out ( VikViewport *vvp ); guint vik_viewport_get_scale ( VikViewport *vvp ); diff --git a/src/vikwindow.c b/src/vikwindow.c index 61c45cb0..3fe0c92f 100644 --- a/src/vikwindow.c +++ b/src/vikwindow.c @@ -2174,17 +2174,17 @@ static void scroll_zoom_direction ( VikWindow *vw, GdkScrollDirection direction #if !GTK_CHECK_VERSION (3,0,0) if ( a_vik_get_invert_scroll_direction() ) { if ( direction == GDK_SCROLL_DOWN ) - vik_viewport_zoom_in (vw->viking_vvp); + (void)vik_viewport_zoom_in (vw->viking_vvp); else if ( direction == GDK_SCROLL_UP ) { - vik_viewport_zoom_out (vw->viking_vvp); + (void)vik_viewport_zoom_out (vw->viking_vvp); } } else #endif { if ( direction == GDK_SCROLL_UP ) - vik_viewport_zoom_in (vw->viking_vvp); + (void)vik_viewport_zoom_in (vw->viking_vvp); else if ( direction == GDK_SCROLL_DOWN ) { - vik_viewport_zoom_out (vw->viking_vvp); + (void)vik_viewport_zoom_out (vw->viking_vvp); } } } @@ -2244,9 +2244,9 @@ static void zoom_at_xy ( VikWindow *vw, guint point_x, guint point_y, gboolean s scroll_zoom_direction ( vw, direction ); else { if ( event_button == 1 ) - vik_viewport_zoom_in ( vw->viking_vvp ); + (void)vik_viewport_zoom_in ( vw->viking_vvp ); else if ( event_button == 3 ) - vik_viewport_zoom_out ( vw->viking_vvp ); + (void)vik_viewport_zoom_out ( vw->viking_vvp ); } vik_viewport_coord_to_screen ( vw->viking_vvp, &coord, &x, &y ); vik_viewport_set_center_screen ( vw->viking_vvp, center_x + (x - point_x), center_y + (y - point_y) ); @@ -3136,17 +3136,17 @@ static VikLayerToolFuncStatus zoomtool_click (VikLayer *vl, GdkEventButton *even // This zoom is on the center position vik_viewport_set_center_screen ( te->vw->viking_vvp, center_x, center_y ); if ( event->button == 1 ) - vik_viewport_zoom_in (te->vw->viking_vvp); + (void)vik_viewport_zoom_in (te->vw->viking_vvp); else if ( event->button == 3 ) - vik_viewport_zoom_out (te->vw->viking_vvp); + (void)vik_viewport_zoom_out (te->vw->viking_vvp); } else if ( modifiers == GDK_CONTROL_MASK ) { // This zoom is to recenter on the mouse position vik_viewport_set_center_screen ( te->vw->viking_vvp, (gint) event->x, (gint) event->y ); if ( event->button == 1 ) - vik_viewport_zoom_in (te->vw->viking_vvp); + (void)vik_viewport_zoom_in (te->vw->viking_vvp); else if ( event->button == 3 ) - vik_viewport_zoom_out (te->vw->viking_vvp); + (void)vik_viewport_zoom_out (te->vw->viking_vvp); } else if ( modifiers == GDK_SHIFT_MASK ) { // Get start of new zoom bounds @@ -3252,14 +3252,14 @@ static VikLayerToolFuncStatus zoomtool_release (VikLayer *vl, GdkEventButton *ev // Zoom in/out by three if possible vik_viewport_set_center_screen ( te->vw->viking_vvp, event->x, event->y ); if ( event->button == 1 ) { - vik_viewport_zoom_in ( te->vw->viking_vvp ); - vik_viewport_zoom_in ( te->vw->viking_vvp ); - vik_viewport_zoom_in ( te->vw->viking_vvp ); + (void)vik_viewport_zoom_in ( te->vw->viking_vvp ); + (void)vik_viewport_zoom_in ( te->vw->viking_vvp ); + (void)vik_viewport_zoom_in ( te->vw->viking_vvp ); } else if ( event->button == 3 ) { - vik_viewport_zoom_out ( te->vw->viking_vvp ); - vik_viewport_zoom_out ( te->vw->viking_vvp ); - vik_viewport_zoom_out ( te->vw->viking_vvp ); + (void)vik_viewport_zoom_out ( te->vw->viking_vvp ); + (void)vik_viewport_zoom_out ( te->vw->viking_vvp ); + (void)vik_viewport_zoom_out ( te->vw->viking_vvp ); } } } @@ -3309,12 +3309,12 @@ static VikLayerToolFuncStatus pantool_click (VikLayer *vl, GdkEventButton *event if ( event->button == 1 ) { guint modifier = event->state & GDK_SHIFT_MASK; if ( modifier ) - vik_viewport_zoom_out ( vw->viking_vvp ); + (void)vik_viewport_zoom_out ( vw->viking_vvp ); else - vik_viewport_zoom_in ( vw->viking_vvp ); + (void)vik_viewport_zoom_in ( vw->viking_vvp ); } else if ( event->button == 3 ) - vik_viewport_zoom_out ( vw->viking_vvp ); + (void)vik_viewport_zoom_out ( vw->viking_vvp ); draw_update ( vw ); } @@ -3717,19 +3717,27 @@ static void draw_zoom_cb ( GtkAction *a, VikWindow *vw ) what = atoi(s+4); } + guint zresult = 0; switch (what) { case -3: case -5: - vik_viewport_zoom_in ( vw->viking_vvp ); break; + zresult = vik_viewport_zoom_in ( vw->viking_vvp ); + if ( !zresult ) + a_dialog_info_msg ( GTK_WINDOW(vw), _("Maximum zoomed in level reached") ); + break; case -4: case -6: - vik_viewport_zoom_out ( vw->viking_vvp ); break; + zresult = vik_viewport_zoom_out ( vw->viking_vvp ); + if ( !zresult ) + a_dialog_info_msg ( GTK_WINDOW(vw), _("Maximum zoomed out level reached.") ); + break; case -1: vik_viewport_set_zoom ( vw->viking_vvp, 0.5 ); break; case -2: vik_viewport_set_zoom ( vw->viking_vvp, 0.25 ); break; case 0: vik_viewport_set_zoom ( vw->viking_vvp, a_vik_get_default_zoom() ); break; - default: vik_viewport_set_zoom ( vw->viking_vvp, what ); + default: vik_viewport_set_zoom ( vw->viking_vvp, what ); break; } + draw_update ( vw ); }