[gimp] app: GimpDrawTool: implement GimpTool::modifier_key()...



commit 01235690cfce58bff5f699c020fd72f15b1f7559
Author: Michael Natterer <mitch gimp org>
Date:   Mon Jun 26 21:03:09 2017 +0200

    app: GimpDrawTool: implement GimpTool::modifier_key()...
    
    ...and ::sctive_modifier_key()
    
    and remove their implementations from most widget-ported subclasses.

 app/tools/gimpcroptool.c    |   36 ++++-------------------
 app/tools/gimpdrawtool.c    |   65 +++++++++++++++++++++++++++++++++++++-----
 app/tools/gimpmeasuretool.c |   40 ++++++--------------------
 3 files changed, 73 insertions(+), 68 deletions(-)
---
diff --git a/app/tools/gimpcroptool.c b/app/tools/gimpcroptool.c
index d1dc647..1650ecb 100644
--- a/app/tools/gimpcroptool.c
+++ b/app/tools/gimpcroptool.c
@@ -66,11 +66,6 @@ static void     gimp_crop_tool_motion                     (GimpTool
                                                            guint32               time,
                                                            GdkModifierType       state,
                                                            GimpDisplay          *display);
-static void      gimp_crop_tool_active_modifier_key       (GimpTool             *tool,
-                                                           GdkModifierType       key,
-                                                           gboolean              press,
-                                                           GdkModifierType       state,
-                                                           GimpDisplay          *display);
 static void      gimp_crop_tool_cursor_update             (GimpTool             *tool,
                                                            const GimpCoords     *coords,
                                                            GdkModifierType       state,
@@ -133,15 +128,14 @@ gimp_crop_tool_class_init (GimpCropToolClass *klass)
   GObjectClass  *object_class = G_OBJECT_CLASS (klass);
   GimpToolClass *tool_class   = GIMP_TOOL_CLASS (klass);
 
-  object_class->constructed       = gimp_crop_tool_constructed;
+  object_class->constructed  = gimp_crop_tool_constructed;
 
-  tool_class->control             = gimp_crop_tool_control;
-  tool_class->button_press        = gimp_crop_tool_button_press;
-  tool_class->button_release      = gimp_crop_tool_button_release;
-  tool_class->motion              = gimp_crop_tool_motion;
-  tool_class->active_modifier_key = gimp_crop_tool_active_modifier_key;
-  tool_class->cursor_update       = gimp_crop_tool_cursor_update;
-  tool_class->options_notify      = gimp_crop_tool_options_notify;
+  tool_class->control        = gimp_crop_tool_control;
+  tool_class->button_press   = gimp_crop_tool_button_press;
+  tool_class->button_release = gimp_crop_tool_button_release;
+  tool_class->motion         = gimp_crop_tool_motion;
+  tool_class->cursor_update  = gimp_crop_tool_cursor_update;
+  tool_class->options_notify = gimp_crop_tool_options_notify;
 }
 
 static void
@@ -336,22 +330,6 @@ gimp_crop_tool_motion (GimpTool         *tool,
 }
 
 static void
-gimp_crop_tool_active_modifier_key (GimpTool        *tool,
-                                    GdkModifierType  key,
-                                    gboolean         press,
-                                    GdkModifierType  state,
-                                    GimpDisplay     *display)
-{
-  GimpCropTool *crop_tool = GIMP_CROP_TOOL (tool);
-
-  if (crop_tool->rectangle)
-    {
-      gimp_tool_widget_motion_modifier (crop_tool->rectangle,
-                                        key, press, state);
-    }
-}
-
-static void
 gimp_crop_tool_cursor_update (GimpTool         *tool,
                               const GimpCoords *coords,
                               GdkModifierType   state,
diff --git a/app/tools/gimpdrawtool.c b/app/tools/gimpdrawtool.c
index 5b28db4..c334c50 100644
--- a/app/tools/gimpdrawtool.c
+++ b/app/tools/gimpdrawtool.c
@@ -75,6 +75,17 @@ static gboolean      gimp_draw_tool_key_press     (GimpTool         *tool,
 static gboolean      gimp_draw_tool_key_release   (GimpTool         *tool,
                                                    GdkEventKey      *kevent,
                                                    GimpDisplay      *display);
+static void          gimp_draw_tool_modifier_key  (GimpTool         *tool,
+                                                   GdkModifierType   key,
+                                                   gboolean          press,
+                                                   GdkModifierType   state,
+                                                   GimpDisplay      *display);
+static void          gimp_draw_tool_active_modifier_key
+                                                  (GimpTool         *tool,
+                                                   GdkModifierType   key,
+                                                   gboolean          press,
+                                                   GdkModifierType   state,
+                                                   GimpDisplay      *display);
 static void          gimp_draw_tool_oper_update   (GimpTool         *tool,
                                                    const GimpCoords *coords,
                                                    GdkModifierType   state,
@@ -116,16 +127,18 @@ gimp_draw_tool_class_init (GimpDrawToolClass *klass)
   GObjectClass  *object_class = G_OBJECT_CLASS (klass);
   GimpToolClass *tool_class   = GIMP_TOOL_CLASS (klass);
 
-  object_class->dispose   = gimp_draw_tool_dispose;
+  object_class->dispose           = gimp_draw_tool_dispose;
 
-  tool_class->has_display = gimp_draw_tool_has_display;
-  tool_class->has_image   = gimp_draw_tool_has_image;
-  tool_class->control     = gimp_draw_tool_control;
-  tool_class->key_press   = gimp_draw_tool_key_press;
-  tool_class->key_release = gimp_draw_tool_key_release;
-  tool_class->oper_update = gimp_draw_tool_oper_update;
+  tool_class->has_display         = gimp_draw_tool_has_display;
+  tool_class->has_image           = gimp_draw_tool_has_image;
+  tool_class->control             = gimp_draw_tool_control;
+  tool_class->key_press           = gimp_draw_tool_key_press;
+  tool_class->key_release         = gimp_draw_tool_key_release;
+  tool_class->modifier_key        = gimp_draw_tool_modifier_key;
+  tool_class->active_modifier_key = gimp_draw_tool_active_modifier_key;
+  tool_class->oper_update         = gimp_draw_tool_oper_update;
 
-  klass->draw             = gimp_draw_tool_real_draw;
+  klass->draw                     = gimp_draw_tool_real_draw;
 }
 
 static void
@@ -240,6 +253,42 @@ gimp_draw_tool_key_release (GimpTool    *tool,
 }
 
 static void
+gimp_draw_tool_modifier_key (GimpTool        *tool,
+                             GdkModifierType  key,
+                             gboolean         press,
+                             GdkModifierType  state,
+                             GimpDisplay     *display)
+{
+  GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
+
+  if (draw_tool->widget && display == draw_tool->display)
+    {
+      gimp_tool_widget_hover_modifier (draw_tool->widget, key, press, state);
+    }
+
+  GIMP_TOOL_CLASS (parent_class)->modifier_key (tool, key, press, state,
+                                                display);
+}
+
+static void
+gimp_draw_tool_active_modifier_key (GimpTool        *tool,
+                                    GdkModifierType  key,
+                                    gboolean         press,
+                                    GdkModifierType  state,
+                                    GimpDisplay     *display)
+{
+  GimpDrawTool *draw_tool = GIMP_DRAW_TOOL (tool);
+
+  if (draw_tool->widget && display == draw_tool->display)
+    {
+      gimp_tool_widget_motion_modifier (draw_tool->widget, key, press, state);
+    }
+
+  GIMP_TOOL_CLASS (parent_class)->active_modifier_key (tool, key, press, state,
+                                                       display);
+}
+
+static void
 gimp_draw_tool_oper_update (GimpTool         *tool,
                             const GimpCoords *coords,
                             GdkModifierType   state,
diff --git a/app/tools/gimpmeasuretool.c b/app/tools/gimpmeasuretool.c
index f311e59..aab5dda 100644
--- a/app/tools/gimpmeasuretool.c
+++ b/app/tools/gimpmeasuretool.c
@@ -75,11 +75,6 @@ static void     gimp_measure_tool_motion          (GimpTool              *tool,
 static gboolean gimp_measure_tool_key_press       (GimpTool              *tool,
                                                    GdkEventKey           *kevent,
                                                    GimpDisplay           *display);
-static void gimp_measure_tool_active_modifier_key (GimpTool              *tool,
-                                                   GdkModifierType        key,
-                                                   gboolean               press,
-                                                   GdkModifierType        state,
-                                                   GimpDisplay           *display);
 static void     gimp_measure_tool_oper_update     (GimpTool              *tool,
                                                    const GimpCoords      *coords,
                                                    GdkModifierType        state,
@@ -140,14 +135,13 @@ gimp_measure_tool_class_init (GimpMeasureToolClass *klass)
 {
   GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
 
-  tool_class->control             = gimp_measure_tool_control;
-  tool_class->button_press        = gimp_measure_tool_button_press;
-  tool_class->button_release      = gimp_measure_tool_button_release;
-  tool_class->motion              = gimp_measure_tool_motion;
-  tool_class->key_press           = gimp_measure_tool_key_press;
-  tool_class->active_modifier_key = gimp_measure_tool_active_modifier_key;
-  tool_class->oper_update         = gimp_measure_tool_oper_update;
-  tool_class->cursor_update       = gimp_measure_tool_cursor_update;
+  tool_class->control        = gimp_measure_tool_control;
+  tool_class->button_press   = gimp_measure_tool_button_press;
+  tool_class->button_release = gimp_measure_tool_button_release;
+  tool_class->motion         = gimp_measure_tool_motion;
+  tool_class->key_press      = gimp_measure_tool_key_press;
+  tool_class->oper_update    = gimp_measure_tool_oper_update;
+  tool_class->cursor_update  = gimp_measure_tool_cursor_update;
 }
 
 static void
@@ -235,8 +229,6 @@ gimp_measure_tool_button_press (GimpTool            *tool,
 
       gimp_draw_tool_set_widget (GIMP_DRAW_TOOL (tool), measure->compass);
 
-      gimp_tool_widget_hover (measure->compass, coords, state, TRUE);
-
       g_signal_connect (measure->compass, "changed",
                         G_CALLBACK (gimp_measure_tool_compass_changed),
                         measure);
@@ -250,6 +242,8 @@ gimp_measure_tool_button_press (GimpTool            *tool,
       tool->display = display;
 
       gimp_draw_tool_start (GIMP_DRAW_TOOL (measure), display);
+
+      gimp_tool_widget_hover (measure->compass, coords, state, TRUE);
     }
 
   if (gimp_tool_widget_button_press (measure->compass, coords, time, state,
@@ -338,22 +332,6 @@ gimp_measure_tool_key_press (GimpTool    *tool,
 }
 
 static void
-gimp_measure_tool_active_modifier_key (GimpTool        *tool,
-                                       GdkModifierType  key,
-                                       gboolean         press,
-                                       GdkModifierType  state,
-                                       GimpDisplay     *display)
-{
-  GimpMeasureTool *measure = GIMP_MEASURE_TOOL (tool);
-
-  if (measure->grab_widget)
-    {
-      gimp_tool_widget_motion_modifier (measure->grab_widget,
-                                        key, press, state);
-    }
-}
-
-static void
 gimp_measure_tool_oper_update (GimpTool         *tool,
                                const GimpCoords *coords,
                                GdkModifierType   state,


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