[planner: 28/32] gantt/usage-view: Restore ctrl+mousewheel zoom on chart area




commit e10b9ae8f2c41ac1506cc4047720f73702e60b62
Author: Mart Raudsepp <leio gentoo org>
Date:   Mon Jun 14 00:44:24 2021 +0300

    gantt/usage-view: Restore ctrl+mousewheel zoom on chart area
    
    There are some bugs and as noted in TODO comments, but this makes it work
    again, more or less, for the common cases for now.

 src/planner-gantt-view.c | 14 +++++++++++++-
 src/planner-usage-view.c | 22 +++++++++++++++++-----
 2 files changed, 30 insertions(+), 6 deletions(-)
---
diff --git a/src/planner-gantt-view.c b/src/planner-gantt-view.c
index 182faad6..440423fc 100644
--- a/src/planner-gantt-view.c
+++ b/src/planner-gantt-view.c
@@ -208,10 +208,12 @@ gantt_view_chart_scroll_event (GtkWidget * gki, GdkEventScroll * event, PlannerG
        gboolean dontpropagate = FALSE;
        gboolean can_in, can_out;
        PlannerGanttViewPriv *priv;
+       gdouble delta_y;
 
        if (event->state & GDK_CONTROL_MASK) {
                priv = view->priv;
                planner_gantt_chart_can_zoom (PLANNER_GANTT_CHART (priv->gantt), &can_in, &can_out);
+               /* TODO: Why is the canvas area getting GDK_SCROLL_SMOOTH but header not? */
                switch (event->direction) {
                        case GDK_SCROLL_UP: {
                                dontpropagate = TRUE;
@@ -223,7 +225,17 @@ gantt_view_chart_scroll_event (GtkWidget * gki, GdkEventScroll * event, PlannerG
                                dontpropagate = TRUE;
                                if (can_out)
                                        gantt_view_zoom_out_cb  (NULL, view);
-                               break;
+                               break;
+                       case GDK_SCROLL_SMOOTH:
+                               /* TODO: Test over with different input methods (that give values other than 
1 or -1),
+                                * possibly gather deltas together to handle the smoothness */
+                               /* TODO: First wheel event seems to carry a delta of zero and thus do nothing 
*/
+                               gdk_event_get_scroll_deltas ((GdkEvent *)event, NULL, &delta_y);
+                               if (can_in && delta_y < 0)
+                                       gantt_view_zoom_in_cb (NULL, view);
+                               else if (can_out && delta_y > 0)
+                                       gantt_view_zoom_out_cb (NULL, view);
+                               break;
                        default:
                                break;
                }
diff --git a/src/planner-usage-view.c b/src/planner-usage-view.c
index 80fde53a..c7d4a44e 100644
--- a/src/planner-usage-view.c
+++ b/src/planner-usage-view.c
@@ -128,24 +128,36 @@ usage_view_chart_scroll_event (GtkWidget * gki, GdkEventScroll * event, PlannerV
 
        gboolean can_in, can_out;
        PlannerUsageViewPriv *priv;
+       gdouble delta_y;
 
        if (event->state & GDK_CONTROL_MASK) {
                priv = PLANNER_USAGE_VIEW (view)->priv;
                planner_usage_chart_can_zoom (priv->chart, &can_in, &can_out);
+               /* TODO: Why is the canvas area getting GDK_SCROLL_SMOOTH but header not? */
                switch (event->direction) {
-                       case GDK_SCROLL_UP: {
+                       case GDK_SCROLL_UP: {
                                dontpropagate = TRUE;
                                if (can_in)
                                        usage_view_zoom_in_cb  (NULL, view);
-                               break;
+                               break;
                        }
                        case GDK_SCROLL_DOWN:
                                dontpropagate = TRUE;
                                if (can_out)
                                        usage_view_zoom_out_cb  (NULL, view);
-                               break;
-                     default:
-                       break;
+                               break;
+                       case GDK_SCROLL_SMOOTH:
+                               /* TODO: Test over with different input methods (that give values other than 
1 or -1),
+                               * possibly gather deltas together to handle the smoothness */
+                               /* TODO: First wheel event seems to carry a delta of zero and thus do nothing 
*/
+                               gdk_event_get_scroll_deltas ((GdkEvent *)event, NULL, &delta_y);
+                               if (can_in && delta_y < 0)
+                                       usage_view_zoom_in_cb (NULL, view);
+                               else if (can_out && delta_y > 0)
+                                       usage_view_zoom_out_cb (NULL, view);
+                               break;
+                       default:
+                               break;
                }
        }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]