[libshumate/tintou/zoom-click] map: Allow to zoom with double click
- From: Corentin Noël <corentinnoel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libshumate/tintou/zoom-click] map: Allow to zoom with double click
- Date: Mon, 1 Aug 2022 21:18:41 +0000 (UTC)
commit ce6ab8e8a43ae752f930b524c8302bcfb2b0b920
Author: Corentin Noël <tintou noel tf>
Date: Mon Aug 1 22:47:28 2022 +0200
map: Allow to zoom with double click
Handle double click on the primary button to zoom-in.
shumate/shumate-map.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
---
diff --git a/shumate/shumate-map.c b/shumate/shumate-map.c
index 983db33..6c5248f 100644
--- a/shumate/shumate-map.c
+++ b/shumate/shumate-map.c
@@ -596,6 +596,22 @@ on_rotate_gesture_update (ShumateMap *self,
move_location_to_coords (self, self->gesture_begin_lat, self->gesture_begin_lon, x, y);
}
+static void
+on_click_gesture_pressed (ShumateMap *self,
+ int n_press,
+ double x,
+ double y,
+ GtkGestureClick *click)
+{
+ if (n_press == 2)
+ {
+ double zoom_level = shumate_viewport_get_zoom_level (self->viewport);
+ self->current_x = x;
+ self->current_y = y;
+ set_zoom_level (self, zoom_level + 1);
+ }
+}
+
static void
on_motion_controller_motion (ShumateMap *self,
double x,
@@ -804,6 +820,7 @@ shumate_map_init (ShumateMap *self)
GtkGesture *swipe_gesture;
GtkGesture *zoom_gesture;
GtkGesture *rotate_gesture;
+ GtkGesture *click_gesture;
self->viewport = shumate_viewport_new ();
self->zoom_on_double_click = TRUE;
@@ -844,6 +861,11 @@ shumate_map_init (ShumateMap *self)
gtk_gesture_group (zoom_gesture, rotate_gesture);
+ click_gesture = gtk_gesture_click_new ();
+ gtk_gesture_single_set_button (GTK_GESTURE_SINGLE (click_gesture), GDK_BUTTON_PRIMARY);
+ g_signal_connect_swapped (click_gesture, "pressed", G_CALLBACK (on_click_gesture_pressed), self);
+ gtk_widget_add_controller (GTK_WIDGET (self), GTK_EVENT_CONTROLLER (click_gesture));
+
key_controller = gtk_event_controller_key_new ();
gtk_widget_add_controller (GTK_WIDGET (self), key_controller);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]