[gimp] Set BAD cursors if the active drawable is locked



commit 9040afc0fc49b8cbeb296b66c8efc4e497a944ef
Author: Michael Natterer <mitch gimp org>
Date:   Fri Aug 21 19:34:59 2009 +0200

    Set BAD cursors if the active drawable is locked

 app/tools/gimpblendtool.c      |   20 ++++++++--------
 app/tools/gimpbucketfilltool.c |   29 +++++++++++++---------
 app/tools/gimppainttool.c      |   50 ++++++++++++++++++++++++++++++++++++++++
 app/tools/gimptransformtool.c  |    7 +++++
 4 files changed, 84 insertions(+), 22 deletions(-)
---
diff --git a/app/tools/gimpblendtool.c b/app/tools/gimpblendtool.c
index 9201166..81268dd 100644
--- a/app/tools/gimpblendtool.c
+++ b/app/tools/gimpblendtool.c
@@ -350,19 +350,19 @@ gimp_blend_tool_cursor_update (GimpTool         *tool,
                                GdkModifierType   state,
                                GimpDisplay      *display)
 {
-  switch (gimp_drawable_type (gimp_image_get_active_drawable (display->image)))
+  GimpDrawable       *drawable;
+  GimpCursorModifier  modifier = GIMP_CURSOR_MODIFIER_NONE;
+
+  drawable = gimp_image_get_active_drawable (display->image);
+
+  if (gimp_drawable_is_indexed (drawable) ||
+      gimp_item_get_lock_content (GIMP_ITEM (drawable)))
     {
-    case GIMP_INDEXED_IMAGE:
-    case GIMP_INDEXEDA_IMAGE:
-      gimp_tool_control_set_cursor_modifier (tool->control,
-                                             GIMP_CURSOR_MODIFIER_BAD);
-      break;
-    default:
-      gimp_tool_control_set_cursor_modifier (tool->control,
-                                             GIMP_CURSOR_MODIFIER_NONE);
-      break;
+      modifier = GIMP_CURSOR_MODIFIER_BAD;
     }
 
+  gimp_tool_control_set_cursor_modifier (tool->control, modifier);
+
   GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, display);
 }
 
diff --git a/app/tools/gimpbucketfilltool.c b/app/tools/gimpbucketfilltool.c
index ac52085..2028632 100644
--- a/app/tools/gimpbucketfilltool.c
+++ b/app/tools/gimpbucketfilltool.c
@@ -243,19 +243,24 @@ gimp_bucket_fill_tool_cursor_update (GimpTool         *tool,
   if (gimp_image_coords_in_active_pickable (display->image, coords,
                                             options->sample_merged, TRUE))
     {
-      switch (options->fill_mode)
-        {
-        case GIMP_FG_BUCKET_FILL:
-          modifier = GIMP_CURSOR_MODIFIER_FOREGROUND;
-          break;
-
-        case GIMP_BG_BUCKET_FILL:
-          modifier = GIMP_CURSOR_MODIFIER_BACKGROUND;
-          break;
+      GimpDrawable *drawable = gimp_image_get_active_drawable (display->image);
 
-        case GIMP_PATTERN_BUCKET_FILL:
-          modifier = GIMP_CURSOR_MODIFIER_PATTERN;
-          break;
+      if (! gimp_item_get_lock_content (GIMP_ITEM (drawable)))
+        {
+          switch (options->fill_mode)
+            {
+            case GIMP_FG_BUCKET_FILL:
+              modifier = GIMP_CURSOR_MODIFIER_FOREGROUND;
+              break;
+
+            case GIMP_BG_BUCKET_FILL:
+              modifier = GIMP_CURSOR_MODIFIER_BACKGROUND;
+              break;
+
+            case GIMP_PATTERN_BUCKET_FILL:
+              modifier = GIMP_CURSOR_MODIFIER_PATTERN;
+              break;
+            }
         }
     }
 
diff --git a/app/tools/gimppainttool.c b/app/tools/gimppainttool.c
index 137be79..21c7d2d 100644
--- a/app/tools/gimppainttool.c
+++ b/app/tools/gimppainttool.c
@@ -84,6 +84,10 @@ static void   gimp_paint_tool_modifier_key   (GimpTool              *tool,
                                               gboolean               press,
                                               GdkModifierType        state,
                                               GimpDisplay           *display);
+static void   gimp_paint_tool_cursor_update  (GimpTool              *tool,
+                                              const GimpCoords      *coords,
+                                              GdkModifierType        state,
+                                              GimpDisplay           *display);
 static void   gimp_paint_tool_oper_update    (GimpTool              *tool,
                                               const GimpCoords      *coords,
                                               GdkModifierType        state,
@@ -117,6 +121,7 @@ gimp_paint_tool_class_init (GimpPaintToolClass *klass)
   tool_class->button_release = gimp_paint_tool_button_release;
   tool_class->motion         = gimp_paint_tool_motion;
   tool_class->modifier_key   = gimp_paint_tool_modifier_key;
+  tool_class->cursor_update  = gimp_paint_tool_cursor_update;
   tool_class->oper_update    = gimp_paint_tool_oper_update;
 
   draw_tool_class->draw      = gimp_paint_tool_draw;
@@ -508,6 +513,51 @@ gimp_paint_tool_modifier_key (GimpTool        *tool,
 }
 
 static void
+gimp_paint_tool_cursor_update (GimpTool         *tool,
+                               const GimpCoords *coords,
+                               GdkModifierType   state,
+                               GimpDisplay      *display)
+{
+  GimpCursorModifier  modifier;
+  GimpCursorModifier  toggle_modifier;
+  GimpCursorModifier  old_modifier;
+  GimpCursorModifier  old_toggle_modifier;
+
+  modifier        = tool->control->cursor_modifier;
+  toggle_modifier = tool->control->toggle_cursor_modifier;
+
+  old_modifier        = modifier;
+  old_toggle_modifier = toggle_modifier;
+
+  if (! gimp_color_tool_is_enabled (GIMP_COLOR_TOOL (tool)))
+    {
+      GimpDrawable *drawable = gimp_image_get_active_drawable (display->image);
+
+      if (gimp_item_get_lock_content (GIMP_ITEM (drawable)))
+        {
+          modifier        = GIMP_CURSOR_MODIFIER_BAD;
+          toggle_modifier = GIMP_CURSOR_MODIFIER_BAD;
+        }
+
+      gimp_tool_control_set_cursor_modifier        (tool->control,
+                                                    modifier);
+      gimp_tool_control_set_toggle_cursor_modifier (tool->control,
+                                                    toggle_modifier);
+    }
+
+  GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state,
+                                                 display);
+
+  /*  reset old stuff here so we are not interferring with the modifiers
+   *  set by our subclasses
+   */
+  gimp_tool_control_set_cursor_modifier        (tool->control,
+                                                old_modifier);
+  gimp_tool_control_set_toggle_cursor_modifier (tool->control,
+                                                old_toggle_modifier);
+}
+
+static void
 gimp_paint_tool_oper_update (GimpTool         *tool,
                              const GimpCoords *coords,
                              GdkModifierType   state,
diff --git a/app/tools/gimptransformtool.c b/app/tools/gimptransformtool.c
index 46e7030..6fbe30f 100644
--- a/app/tools/gimptransformtool.c
+++ b/app/tools/gimptransformtool.c
@@ -755,7 +755,14 @@ gimp_transform_tool_cursor_update (GimpTool         *tool,
 
   switch (options->type)
     {
+      GimpDrawable *drawable;
+
     case GIMP_TRANSFORM_TYPE_LAYER:
+      drawable = gimp_image_get_active_drawable (display->image);
+      if (gimp_item_get_lock_content (GIMP_ITEM (drawable)))
+        modifier = GIMP_CURSOR_MODIFIER_BAD;
+      break;
+
     case GIMP_TRANSFORM_TYPE_SELECTION:
       break;
 



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