[gimp] app: DodgeBurn/Convolve: Fix error in behavior of modifier keys



commit d4316902a2d1ab3f83f8be9faae31938f1b27598
Author: Enrico Schröder <enni schroeder gmail com>
Date:   Thu Mar 31 22:41:10 2011 +0200

    app: DodgeBurn/Convolve: Fix error in behavior of modifier keys
    
    Fix for bug #632816: When holding shift key to go to LineDraw mode,
    then pressing ctrl and releasing shift before ctrl, the release of
    ctrl switches the function of DodgeBurn and Convolute tool. This patch
    adds a variable to GimpDodgeBurnTool/GimpConvolveTool to only switch
    said function on releasing ctrl when it has been toggled previously.

 app/tools/gimpconvolvetool.c  |   17 ++++++++++++++---
 app/tools/gimpconvolvetool.h  |    2 ++
 app/tools/gimpdodgeburntool.c |   17 ++++++++++++++---
 app/tools/gimpdodgeburntool.h |    2 ++
 4 files changed, 32 insertions(+), 6 deletions(-)
---
diff --git a/app/tools/gimpconvolvetool.c b/app/tools/gimpconvolvetool.c
index df81bf3..76cc7e7 100644
--- a/app/tools/gimpconvolvetool.c
+++ b/app/tools/gimpconvolvetool.c
@@ -108,11 +108,22 @@ gimp_convolve_tool_modifier_key (GimpTool        *tool,
                                  GdkModifierType  state,
                                  GimpDisplay     *display)
 {
-  GimpConvolveOptions *options = GIMP_CONVOLVE_TOOL_GET_OPTIONS (tool);
+  GimpConvolveTool    *convolve = GIMP_CONVOLVE_TOOL (tool);
+  GimpConvolveOptions *options  = GIMP_CONVOLVE_TOOL_GET_OPTIONS (tool);
+
+  if (((key == GDK_CONTROL_MASK)  &&
+       ! (state & GDK_SHIFT_MASK) && /* leave stuff untouched in line draw mode */
+       press != convolve->toggled)
 
-  if ((key == GDK_CONTROL_MASK) &&
-      ! (state & GDK_SHIFT_MASK)) /* leave stuff untouched in line draw mode */
+      ||
+
+      (key == GDK_SHIFT_MASK && /* toggle back after keypresses CTRL(hold)->  */
+       ! press               && /* SHIFT(hold)->CTRL(release)->SHIFT(release) */
+       convolve->toggled     &&
+       ! (state & GDK_CONTROL_MASK)))
     {
+      convolve->toggled = press;
+
       switch (options->type)
         {
         case GIMP_BLUR_CONVOLVE:
diff --git a/app/tools/gimpconvolvetool.h b/app/tools/gimpconvolvetool.h
index 5cea1fa..d3e6f22 100644
--- a/app/tools/gimpconvolvetool.h
+++ b/app/tools/gimpconvolvetool.h
@@ -38,6 +38,8 @@ typedef struct _GimpConvolveToolClass GimpConvolveToolClass;
 struct _GimpConvolveTool
 {
   GimpBrushTool parent_instance;
+
+  gboolean      toggled;
 };
 
 struct _GimpConvolveToolClass
diff --git a/app/tools/gimpdodgeburntool.c b/app/tools/gimpdodgeburntool.c
index b720dc5..f0f8c2f 100644
--- a/app/tools/gimpdodgeburntool.c
+++ b/app/tools/gimpdodgeburntool.c
@@ -108,11 +108,22 @@ gimp_dodge_burn_tool_modifier_key (GimpTool        *tool,
                                    GdkModifierType  state,
                                    GimpDisplay     *display)
 {
-  GimpDodgeBurnOptions *options = GIMP_DODGE_BURN_TOOL_GET_OPTIONS (tool);
+  GimpDodgeBurnTool    *dodgeburn = GIMP_DODGE_BURN_TOOL (tool);
+  GimpDodgeBurnOptions *options   = GIMP_DODGE_BURN_TOOL_GET_OPTIONS (tool);
+
+  if ((key == GDK_CONTROL_MASK   &&
+      ! (state & GDK_SHIFT_MASK) && /* leave stuff untouched in line draw mode */
+       press != dodgeburn->toggled)
 
-  if (key == GDK_CONTROL_MASK &&
-      ! (state & GDK_SHIFT_MASK)) /* leave stuff untouched in line draw mode */
+      ||
+
+      (key == GDK_SHIFT_MASK && /* toggle back after keypresses CTRL(hold)->  */
+       ! press               && /* SHIFT(hold)->CTRL(release)->SHIFT(release) */
+       dodgeburn->toggled    &&
+       ! (state & GDK_CONTROL_MASK)))
     {
+      dodgeburn->toggled = press;
+
       switch (options->type)
         {
         case GIMP_DODGE:
diff --git a/app/tools/gimpdodgeburntool.h b/app/tools/gimpdodgeburntool.h
index 0619b4d..5e0291d 100644
--- a/app/tools/gimpdodgeburntool.h
+++ b/app/tools/gimpdodgeburntool.h
@@ -37,6 +37,8 @@ typedef struct _GimpDodgeBurnToolClass GimpDodgeBurnToolClass;
 struct _GimpDodgeBurnTool
 {
   GimpBrushTool parent_instance;
+
+  gboolean      toggled;
 };
 
 struct _GimpDodgeBurnToolClass



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