Commit 6ed6cd78 authored by Ell's avatar Ell

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.
parent aa02f1f3
......@@ -92,44 +92,46 @@ 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_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_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_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_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)
......@@ -903,6 +905,9 @@ gimp_drawable_filter_add_filter (GimpDrawableFilter *filter)
g_signal_connect (image, "mask-changed",
G_CALLBACK (gimp_drawable_filter_mask_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);
......@@ -943,6 +948,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_mask_changed,
filter);
......@@ -1032,6 +1040,14 @@ gimp_drawable_filter_mask_changed (GimpImage *image,
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)
......
......@@ -689,7 +689,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;
}
......
......@@ -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);
......@@ -453,6 +456,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);
......@@ -972,6 +979,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);
......@@ -1208,6 +1219,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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment