From 8f04f4027258018e0d64a605169c5e3ba7984134 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Sun, 13 Aug 2023 18:13:53 -0300 Subject: [PATCH] views/month: Factor out row offsetting in a function And use it in the pixel-based variant. --- src/gui/views/gcal-month-view.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/gui/views/gcal-month-view.c b/src/gui/views/gcal-month-view.c index 17b5be38..c3a23cf3 100644 --- a/src/gui/views/gcal-month-view.c +++ b/src/gui/views/gcal-month-view.c @@ -461,17 +461,12 @@ get_grid_height (GcalMonthView *self) } static void -offset_and_shuffle_rows_by_pixels (GcalMonthView *self, - gdouble dy_pixels) +offset_and_shuffle_rows (GcalMonthView *self, + gdouble dy) { - gdouble row_height; - gint grid_height; - GCAL_ENTRY; - grid_height = get_grid_height (self); - row_height = grid_height / (gdouble) N_ROWS_PER_PAGE; - self->row_offset += dy_pixels / row_height; + self->row_offset += dy; if (fabs (self->row_offset) > 0.5) { @@ -504,6 +499,23 @@ offset_and_shuffle_rows_by_pixels (GcalMonthView *self, GCAL_EXIT; } +static void +offset_and_shuffle_rows_by_pixels (GcalMonthView *self, + gdouble dy_pixels) +{ + gdouble row_height; + gint grid_height; + + GCAL_ENTRY; + + grid_height = get_grid_height (self); + row_height = grid_height / (gdouble) N_ROWS_PER_PAGE; + + offset_and_shuffle_rows (self, dy_pixels / row_height); + + GCAL_EXIT; +} + static void animate_row_offset_cb (gdouble value, gpointer user_data)