[gimp/gimp-2-10] app: don't resize layer when applying filter if its position/size are locked



commit 58e486ad936a4b41bdbc195ba3943f0922a99ce6
Author: Ell <ell_se yahoo com>
Date:   Wed Oct 2 17:59:00 2019 +0300

    app: don't resize layer when applying filter if its position/size are locked
    
    When applying a filter to a layer whose position and size are
    locked, avoid resizing the layer to the result size in ADJUST mode.
    We do this by always returning GIMP_TRANSFORM_RESIZE_CLIP in
    gimp_item_get_clip() when the position is locked, and properly
    updating the drawable-filter's clip mode, and the filter-tool's UI,
    when the position lock changes.
    
    (cherry picked from commit 6ed6cd78d8ac968f0e7c384277c5e10de7f85bea)

 app/core/gimpdrawablefilter.c | 98 +++++++++++++++++++++++++------------------
 app/core/gimpitem.c           |  5 ++-
 app/tools/gimpfiltertool.c    | 18 ++++++++
 3 files changed, 79 insertions(+), 42 deletions(-)
---
diff --git a/app/core/gimpdrawablefilter.c b/app/core/gimpdrawablefilter.c
index d09ee4912f..e4fb0fa8ce 100644
--- a/app/core/gimpdrawablefilter.c
+++ b/app/core/gimpdrawablefilter.c
@@ -94,47 +94,49 @@ struct _GimpDrawableFilter
 };
 
 
-static void       gimp_drawable_filter_dispose            (GObject             *object);
-static void       gimp_drawable_filter_finalize           (GObject             *object);
-
-static void       gimp_drawable_filter_sync_clip          (GimpDrawableFilter  *filter,
-                                                           gboolean             sync_region);
-static void       gimp_drawable_filter_sync_region        (GimpDrawableFilter  *filter);
-static void       gimp_drawable_filter_sync_crop          (GimpDrawableFilter  *filter,
-                                                           gboolean             old_crop_enabled,
-                                                           const GeglRectangle *old_crop_rect,
-                                                           gboolean             old_preview_enabled,
-                                                           GimpAlignmentType    old_preview_alignment,
-                                                           gdouble              old_preview_position,
-                                                           gboolean             update);
-static void       gimp_drawable_filter_sync_opacity       (GimpDrawableFilter  *filter);
-static void       gimp_drawable_filter_sync_mode          (GimpDrawableFilter  *filter);
-static void       gimp_drawable_filter_sync_affect        (GimpDrawableFilter  *filter);
-static void       gimp_drawable_filter_sync_format        (GimpDrawableFilter  *filter);
-static void       gimp_drawable_filter_sync_mask          (GimpDrawableFilter  *filter);
-static void       gimp_drawable_filter_sync_transform     (GimpDrawableFilter  *filter);
-static void       gimp_drawable_filter_sync_gamma_hack    (GimpDrawableFilter  *filter);
-
-static gboolean   gimp_drawable_filter_is_filtering       (GimpDrawableFilter  *filter);
-static gboolean   gimp_drawable_filter_add_filter         (GimpDrawableFilter  *filter);
-static gboolean   gimp_drawable_filter_remove_filter      (GimpDrawableFilter  *filter);
-
-static void       gimp_drawable_filter_update_drawable    (GimpDrawableFilter  *filter,
-                                                           const GeglRectangle *area);
-
-static void       gimp_drawable_filter_affect_changed     (GimpImage           *image,
-                                                           GimpChannelType      channel,
-                                                           GimpDrawableFilter  *filter);
-static void       gimp_drawable_filter_mask_changed       (GimpImage           *image,
-                                                           GimpDrawableFilter  *filter);
-static void       gimp_drawable_filter_profile_changed    (GimpColorManaged    *managed,
-                                                           GimpDrawableFilter  *filter);
-static void       gimp_drawable_filter_format_changed     (GimpDrawable        *drawable,
-                                                           GimpDrawableFilter  *filter);
-static void       gimp_drawable_filter_drawable_removed   (GimpDrawable        *drawable,
-                                                           GimpDrawableFilter  *filter);
-static void       gimp_drawable_filter_lock_alpha_changed (GimpLayer           *layer,
-                                                           GimpDrawableFilter  *filter);
+static void       gimp_drawable_filter_dispose               (GObject             *object);
+static void       gimp_drawable_filter_finalize              (GObject             *object);
+
+static void       gimp_drawable_filter_sync_clip             (GimpDrawableFilter  *filter,
+                                                              gboolean             sync_region);
+static void       gimp_drawable_filter_sync_region           (GimpDrawableFilter  *filter);
+static void       gimp_drawable_filter_sync_crop             (GimpDrawableFilter  *filter,
+                                                              gboolean             old_crop_enabled,
+                                                              const GeglRectangle *old_crop_rect,
+                                                              gboolean             old_preview_enabled,
+                                                              GimpAlignmentType    old_preview_alignment,
+                                                              gdouble              old_preview_position,
+                                                              gboolean             update);
+static void       gimp_drawable_filter_sync_opacity          (GimpDrawableFilter  *filter);
+static void       gimp_drawable_filter_sync_mode             (GimpDrawableFilter  *filter);
+static void       gimp_drawable_filter_sync_affect           (GimpDrawableFilter  *filter);
+static void       gimp_drawable_filter_sync_format           (GimpDrawableFilter  *filter);
+static void       gimp_drawable_filter_sync_mask             (GimpDrawableFilter  *filter);
+static void       gimp_drawable_filter_sync_transform        (GimpDrawableFilter  *filter);
+static void       gimp_drawable_filter_sync_gamma_hack       (GimpDrawableFilter  *filter);
+
+static gboolean   gimp_drawable_filter_is_filtering          (GimpDrawableFilter  *filter);
+static gboolean   gimp_drawable_filter_add_filter            (GimpDrawableFilter  *filter);
+static gboolean   gimp_drawable_filter_remove_filter         (GimpDrawableFilter  *filter);
+
+static void       gimp_drawable_filter_update_drawable       (GimpDrawableFilter  *filter,
+                                                              const GeglRectangle *area);
+
+static void       gimp_drawable_filter_affect_changed        (GimpImage           *image,
+                                                              GimpChannelType      channel,
+                                                              GimpDrawableFilter  *filter);
+static void       gimp_drawable_filter_mask_changed          (GimpImage           *image,
+                                                              GimpDrawableFilter  *filter);
+static void       gimp_drawable_filter_profile_changed       (GimpColorManaged    *managed,
+                                                              GimpDrawableFilter  *filter);
+static void       gimp_drawable_filter_lock_position_changed (GimpDrawable        *drawable,
+                                                              GimpDrawableFilter  *filter);
+static void       gimp_drawable_filter_format_changed        (GimpDrawable        *drawable,
+                                                              GimpDrawableFilter  *filter);
+static void       gimp_drawable_filter_drawable_removed      (GimpDrawable        *drawable,
+                                                              GimpDrawableFilter  *filter);
+static void       gimp_drawable_filter_lock_alpha_changed    (GimpLayer           *layer,
+                                                              GimpDrawableFilter  *filter);
 
 
 G_DEFINE_TYPE (GimpDrawableFilter, gimp_drawable_filter, GIMP_TYPE_FILTER)
@@ -1031,6 +1033,9 @@ gimp_drawable_filter_add_filter (GimpDrawableFilter *filter)
       g_signal_connect (image, "profile-changed",
                         G_CALLBACK (gimp_drawable_filter_profile_changed),
                         filter);
+      g_signal_connect (filter->drawable, "lock-position-changed",
+                        G_CALLBACK (gimp_drawable_filter_lock_position_changed),
+                        filter);
       g_signal_connect (filter->drawable, "format-changed",
                         G_CALLBACK (gimp_drawable_filter_format_changed),
                         filter);
@@ -1071,6 +1076,9 @@ gimp_drawable_filter_remove_filter (GimpDrawableFilter *filter)
       g_signal_handlers_disconnect_by_func (filter->drawable,
                                             gimp_drawable_filter_format_changed,
                                             filter);
+      g_signal_handlers_disconnect_by_func (filter->drawable,
+                                            gimp_drawable_filter_lock_position_changed,
+                                            filter);
       g_signal_handlers_disconnect_by_func (image,
                                             gimp_drawable_filter_profile_changed,
                                             filter);
@@ -1171,6 +1179,14 @@ gimp_drawable_filter_profile_changed (GimpColorManaged   *managed,
   gimp_drawable_filter_update_drawable (filter, NULL);
 }
 
+static void
+gimp_drawable_filter_lock_position_changed (GimpDrawable       *drawable,
+                                            GimpDrawableFilter *filter)
+{
+  gimp_drawable_filter_sync_clip (filter, TRUE);
+  gimp_drawable_filter_update_drawable (filter, NULL);
+}
+
 static void
 gimp_drawable_filter_format_changed (GimpDrawable       *drawable,
                                      GimpDrawableFilter *filter)
diff --git a/app/core/gimpitem.c b/app/core/gimpitem.c
index 61df00c161..2870a9edd9 100644
--- a/app/core/gimpitem.c
+++ b/app/core/gimpitem.c
@@ -695,7 +695,10 @@ static GimpTransformResize
 gimp_item_real_get_clip (GimpItem            *item,
                          GimpTransformResize  clip_result)
 {
-  return clip_result;
+  if (gimp_item_get_lock_position (item))
+    return GIMP_TRANSFORM_RESIZE_CLIP;
+  else
+    return clip_result;
 }
 
 
diff --git a/app/tools/gimpfiltertool.c b/app/tools/gimpfiltertool.c
index cac86f733d..a5ea14c138 100644
--- a/app/tools/gimpfiltertool.c
+++ b/app/tools/gimpfiltertool.c
@@ -169,6 +169,9 @@ static void      gimp_filter_tool_config_notify  (GObject             *object,
 static void      gimp_filter_tool_unset_setting  (GObject             *object,
                                                   const GParamSpec    *pspec,
                                                   GimpFilterTool      *filter_tool);
+static void      gimp_filter_tool_lock_position_changed
+                                                 (GimpDrawable        *drawable,
+                                                  GimpFilterTool      *filter_tool);
 static void      gimp_filter_tool_mask_changed   (GimpImage           *image,
                                                   GimpFilterTool      *filter_tool);
 
@@ -464,6 +467,10 @@ gimp_filter_tool_initialize (GimpTool     *tool,
 
   gimp_tool_gui_show (filter_tool->gui);
 
+  g_signal_connect_object (drawable, "lock-position-changed",
+                           G_CALLBACK (gimp_filter_tool_lock_position_changed),
+                           filter_tool, 0);
+
   g_signal_connect_object (image, "mask-changed",
                            G_CALLBACK (gimp_filter_tool_mask_changed),
                            filter_tool, 0);
@@ -989,6 +996,10 @@ gimp_filter_tool_halt (GimpFilterTool *filter_tool)
     {
       GimpImage *image = gimp_display_get_image (tool->display);
 
+      g_signal_handlers_disconnect_by_func (tool->drawable,
+                                            gimp_filter_tool_lock_position_changed,
+                                            filter_tool);
+
       g_signal_handlers_disconnect_by_func (image,
                                             gimp_filter_tool_mask_changed,
                                             filter_tool);
@@ -1227,6 +1238,13 @@ gimp_filter_tool_unset_setting (GObject          *object,
   gimp_settings_box_unset (GIMP_SETTINGS_BOX (filter_tool->settings_box));
 }
 
+static void
+gimp_filter_tool_lock_position_changed (GimpDrawable   *drawable,
+                                        GimpFilterTool *filter_tool)
+{
+  gimp_filter_tool_update_dialog (filter_tool);
+}
+
 static void
 gimp_filter_tool_mask_changed (GimpImage      *image,
                                GimpFilterTool *filter_tool)


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