Commit 1a259d68 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

reordered some lines, no logic changed.

2002-04-12  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpimage-crop.c: reordered some lines, no logic
	changed.

	* app/core/gimplayer.[ch]: made gimp_layer_pick_correlate()
	return a gboolean, not gint.

	* app/display/gimpdisplayshell.c
	* app/gui/layers-commands.[ch]
	* app/gui/menus.c: added "<Image>/Layers/Crop Layer" which resizes
	the active layer to the current selection's bounds, just as
	"<Image>/Image/Crop Image"
parent ebae1cae
2002-04-12 Michael Natterer <mitch@gimp.org>
* app/core/gimpimage-crop.c: reordered some lines, no logic
changed.
* app/core/gimplayer.[ch]: made gimp_layer_pick_correlate()
return a gboolean, not gint.
* app/display/gimpdisplayshell.c
* app/gui/layers-commands.[ch]
* app/gui/menus.c: added "<Image>/Layers/Crop Layer" which resizes
the active layer to the current selection's bounds, just as
"<Image>/Image/Crop Image"
2002-04-12 Zbigniew Chyla <cyba@gnome.pl>
* app/gui/dialogs-constructors.c: Marked some strings for translation.
......
......@@ -241,36 +241,72 @@ layers_delete_cmd_callback (GtkWidget *widget,
}
void
layers_scale_cmd_callback (GtkWidget *widget,
layers_resize_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GimpLayer *active_layer;
return_if_no_layer (gimage, active_layer);
layers_scale_layer_query (gimage, active_layer);
layers_resize_layer_query (gimage, active_layer);
}
void
layers_resize_cmd_callback (GtkWidget *widget,
layers_resize_to_image_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GimpLayer *active_layer;
return_if_no_layer (gimage, active_layer);
layers_resize_layer_query (gimage, active_layer);
gimp_layer_resize_to_image (active_layer);
gdisplays_flush ();
}
void
layers_resize_to_image_cmd_callback (GtkWidget *widget,
layers_scale_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GimpLayer *active_layer;
return_if_no_layer (gimage, active_layer);
gimp_layer_resize_to_image (active_layer);
layers_scale_layer_query (gimage, active_layer);
}
void
layers_crop_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GimpLayer *active_layer;
gint x1, y1, x2, y2;
gint off_x, off_y;
return_if_no_layer (gimage, active_layer);
if (! gimp_image_mask_bounds (gimage, &x1, &y1, &x2, &y2))
{
g_message (_("Cannot crop because the current selection is empty."));
return;
}
gimp_drawable_offsets (GIMP_DRAWABLE (active_layer), &off_x, &off_y);
off_x -= x1;
off_y -= y1;
undo_push_group_start (gimage, LAYER_RESIZE_UNDO_GROUP);
if (gimp_layer_is_floating_sel (active_layer))
floating_sel_relax (active_layer, TRUE);
gimp_layer_resize (active_layer, x2 - x1, y2 - y1, off_x, off_y);
if (gimp_layer_is_floating_sel (active_layer))
floating_sel_rigor (active_layer, TRUE);
undo_push_group_end (gimage);
gdisplays_flush ();
}
......
......@@ -44,12 +44,14 @@ void layers_merge_down_cmd_callback (GtkWidget *widet,
void layers_delete_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_scale_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_resize_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_resize_to_image_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_scale_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_crop_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_add_layer_mask_cmd_callback (GtkWidget *widet,
gpointer data);
......
......@@ -101,7 +101,6 @@ gimp_image_crop (GimpImage *gimage,
gint width, height;
gint lx1, ly1, lx2, ly2;
gint off_x, off_y;
gint doff_x, doff_y;
g_return_if_fail (gimage != NULL);
g_return_if_fail (GIMP_IS_IMAGE (gimage));
......@@ -116,18 +115,20 @@ gimp_image_crop (GimpImage *gimage,
if (active_layer_only)
{
undo_push_group_start (gimage, LAYER_RESIZE_UNDO_GROUP);
gint doff_x, doff_y;
layer = gimp_image_get_active_layer (gimage);
if (gimp_layer_is_floating_sel (layer))
floating_sel_relax (layer, TRUE);
gimp_drawable_offsets (GIMP_DRAWABLE (layer), &doff_x, &doff_y);
off_x = (doff_x - x1);
off_y = (doff_y - y1);
undo_push_group_start (gimage, LAYER_RESIZE_UNDO_GROUP);
if (gimp_layer_is_floating_sel (layer))
floating_sel_relax (layer, TRUE);
gimp_layer_resize (layer, width, height, off_x, off_y);
if (gimp_layer_is_floating_sel (layer))
......
......@@ -1391,7 +1391,7 @@ gimp_layer_invalidate_boundary (GimpLayer *layer)
floating_sel_invalidate (layer);
}
gint
gboolean
gimp_layer_pick_correlate (GimpLayer *layer,
gint x,
gint y)
......
......@@ -126,7 +126,7 @@ void gimp_layer_resize_to_image (GimpLayer *layer);
BoundSeg * gimp_layer_boundary (GimpLayer *layer,
gint *num_segs);
void gimp_layer_invalidate_boundary (GimpLayer *layer);
gint gimp_layer_pick_correlate (GimpLayer *layer,
gboolean gimp_layer_pick_correlate (GimpLayer *layer,
gint x,
gint y);
......
......@@ -1048,6 +1048,7 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell,
SET_SENSITIVE ("/Layer/Layer Boundary Size...", lp && !aux);
SET_SENSITIVE ("/Layer/Layer to Imagesize", lp && !aux);
SET_SENSITIVE ("/Layer/Scale Layer...", lp && !aux);
SET_SENSITIVE ("/Layer/Crop Layer", lp && !aux && sel);
SET_SENSITIVE ("/Layer/Transform/Offset...", lp);
......
......@@ -1048,6 +1048,7 @@ gimp_display_shell_set_menu_sensitivity (GimpDisplayShell *shell,
SET_SENSITIVE ("/Layer/Layer Boundary Size...", lp && !aux);
SET_SENSITIVE ("/Layer/Layer to Imagesize", lp && !aux);
SET_SENSITIVE ("/Layer/Scale Layer...", lp && !aux);
SET_SENSITIVE ("/Layer/Crop Layer", lp && !aux && sel);
SET_SENSITIVE ("/Layer/Transform/Offset...", lp);
......
......@@ -241,36 +241,72 @@ layers_delete_cmd_callback (GtkWidget *widget,
}
void
layers_scale_cmd_callback (GtkWidget *widget,
layers_resize_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GimpLayer *active_layer;
return_if_no_layer (gimage, active_layer);
layers_scale_layer_query (gimage, active_layer);
layers_resize_layer_query (gimage, active_layer);
}
void
layers_resize_cmd_callback (GtkWidget *widget,
layers_resize_to_image_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GimpLayer *active_layer;
return_if_no_layer (gimage, active_layer);
layers_resize_layer_query (gimage, active_layer);
gimp_layer_resize_to_image (active_layer);
gdisplays_flush ();
}
void
layers_resize_to_image_cmd_callback (GtkWidget *widget,
layers_scale_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GimpLayer *active_layer;
return_if_no_layer (gimage, active_layer);
gimp_layer_resize_to_image (active_layer);
layers_scale_layer_query (gimage, active_layer);
}
void
layers_crop_cmd_callback (GtkWidget *widget,
gpointer data)
{
GimpImage *gimage;
GimpLayer *active_layer;
gint x1, y1, x2, y2;
gint off_x, off_y;
return_if_no_layer (gimage, active_layer);
if (! gimp_image_mask_bounds (gimage, &x1, &y1, &x2, &y2))
{
g_message (_("Cannot crop because the current selection is empty."));
return;
}
gimp_drawable_offsets (GIMP_DRAWABLE (active_layer), &off_x, &off_y);
off_x -= x1;
off_y -= y1;
undo_push_group_start (gimage, LAYER_RESIZE_UNDO_GROUP);
if (gimp_layer_is_floating_sel (active_layer))
floating_sel_relax (active_layer, TRUE);
gimp_layer_resize (active_layer, x2 - x1, y2 - y1, off_x, off_y);
if (gimp_layer_is_floating_sel (active_layer))
floating_sel_rigor (active_layer, TRUE);
undo_push_group_end (gimage);
gdisplays_flush ();
}
......
......@@ -44,12 +44,14 @@ void layers_merge_down_cmd_callback (GtkWidget *widet,
void layers_delete_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_scale_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_resize_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_resize_to_image_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_scale_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_crop_cmd_callback (GtkWidget *widet,
gpointer data);
void layers_add_layer_mask_cmd_callback (GtkWidget *widet,
gpointer data);
......
......@@ -738,6 +738,11 @@ static GimpItemFactoryEntry image_entries[] =
"<StockItem>", GIMP_STOCK_SCALE },
NULL,
"layers/dialogs/scale_layer.html", NULL },
{ { N_("/Layer/Crop Layer"), NULL,
layers_crop_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_TOOL_CROP },
NULL,
"layers/dialogs/scale_layer.html", NULL },
/* <Image>/Layer/Transform */
......
......@@ -738,6 +738,11 @@ static GimpItemFactoryEntry image_entries[] =
"<StockItem>", GIMP_STOCK_SCALE },
NULL,
"layers/dialogs/scale_layer.html", NULL },
{ { N_("/Layer/Crop Layer"), NULL,
layers_crop_cmd_callback, 0,
"<StockItem>", GIMP_STOCK_TOOL_CROP },
NULL,
"layers/dialogs/scale_layer.html", NULL },
/* <Image>/Layer/Transform */
......
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