[gnome-calendar] week-view: Split zooming into dedicating functions
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-calendar] week-view: Split zooming into dedicating functions
- Date: Thu, 23 Jun 2022 17:39:42 +0000 (UTC)
commit 7b19a0fca79abae35dbd4596aa38974e6f595284
Author: Adrien Plazas <kekun plazas laposte net>
Date: Thu Jun 23 17:07:50 2022 +0200
week-view: Split zooming into dedicating functions
This will help zooming with in other ways like Ctrl+Scroll.
src/gui/views/gcal-week-view.c | 45 ++++++++++++++++++++++++++++++------------
1 file changed, 32 insertions(+), 13 deletions(-)
---
diff --git a/src/gui/views/gcal-week-view.c b/src/gui/views/gcal-week-view.c
index f1be65fb..9958ed08 100644
--- a/src/gui/views/gcal-week-view.c
+++ b/src/gui/views/gcal-week-view.c
@@ -93,15 +93,29 @@ on_event_activated (GcalWeekView *self,
}
static void
-on_zoom_gesture_scale_changed_cb (GcalWeekView *self,
- gdouble scale,
- GtkGestureZoom *gesture)
+begin_zoom (GcalWeekView *self,
+ gdouble view_center_y)
+{
+ GtkAdjustment *vadjustment;
+ gdouble center, height;
+
+ vadjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (self->scrolled_window));
+
+ center = gtk_adjustment_get_value (vadjustment) + view_center_y - gtk_adjustment_get_lower (vadjustment);
+ height = gtk_adjustment_get_upper (vadjustment) - gtk_adjustment_get_lower (vadjustment);
+
+ self->gesture_zoom_center = center / height;
+ self->gesture_zoom_initial_height = gtk_widget_get_allocated_height (self->content);
+}
+
+static void
+apply_zoom (GcalWeekView *self,
+ gdouble view_center_y,
+ gdouble scale)
{
GtkAdjustment *vadjustment;
- gdouble view_center_x, view_center_y;
gdouble height;
- gtk_gesture_get_bounding_box_center (GTK_GESTURE (gesture), &view_center_x, &view_center_y);
vadjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (self->scrolled_window));
height = self->gesture_zoom_initial_height * scale;
@@ -113,23 +127,28 @@ on_zoom_gesture_scale_changed_cb (GcalWeekView *self,
gtk_adjustment_set_value (vadjustment, (self->gesture_zoom_center * height) - view_center_y);
}
+static void
+on_zoom_gesture_scale_changed_cb (GcalWeekView *self,
+ gdouble scale,
+ GtkGestureZoom *gesture)
+{
+ gdouble view_center_x, view_center_y;
+
+ gtk_gesture_get_bounding_box_center (GTK_GESTURE (gesture), &view_center_x, &view_center_y);
+
+ apply_zoom (self, view_center_y, scale);
+}
+
static void
on_zoom_gesture_begin_cb (GcalWeekView *self,
GdkEventSequence *sequence,
GtkGesture *gesture)
{
- GtkAdjustment *vadjustment;
gdouble view_center_x, view_center_y;
- gdouble center, height;
gtk_gesture_get_bounding_box_center (gesture, &view_center_x, &view_center_y);
- vadjustment = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (self->scrolled_window));
- center = gtk_adjustment_get_value (vadjustment) + view_center_y - gtk_adjustment_get_lower (vadjustment);
- height = gtk_adjustment_get_upper (vadjustment) - gtk_adjustment_get_lower (vadjustment);
-
- self->gesture_zoom_center = center / height;
- self->gesture_zoom_initial_height = gtk_widget_get_allocated_height (self->content);
+ begin_zoom (self, view_center_y);
}
static void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]