mirror of https://github.com/GNOME/gimp.git
Added option to crop the active layer only
Fri Dec 4 01:43:59 EST 1998 Nick Fetchak <nuke@bayside.net> * app/crop.[ch]: Added option to crop the active layer only
This commit is contained in:
parent
b556943f2c
commit
a616697415
|
@ -1,3 +1,7 @@
|
|||
Fri Dec 4 01:43:59 EST 1998 Nick Fetchak <nuke@bayside.net>
|
||||
|
||||
* app/crop.[ch]: Added option to crop the active layer only
|
||||
|
||||
Thu Dec 3 16:51:42 CST 1998 Shawn T. Amundson <amundson@gtk.org>
|
||||
|
||||
* app/channel_ops.c
|
||||
|
|
84
app/crop.c
84
app/crop.c
|
@ -105,13 +105,64 @@ static void crop_orig_y_changed (GtkWidget *, gpointer);
|
|||
static void crop_width_changed (GtkWidget *, gpointer);
|
||||
static void crop_height_changed (GtkWidget *, gpointer);
|
||||
|
||||
static void *crop_options = NULL;
|
||||
/* Options callbacks */
|
||||
static void crop_checkbutton_update (GtkWidget *, gpointer);
|
||||
|
||||
static GtkWidget *options_widget = NULL;
|
||||
static CropToolOptions options;
|
||||
|
||||
static Argument *crop_invoker (Argument *);
|
||||
|
||||
|
||||
/* Functions */
|
||||
|
||||
static void
|
||||
init_crop_options()
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *label;
|
||||
GtkWidget *checkbutton;
|
||||
|
||||
/* the main vbox */
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
|
||||
/* the main label */
|
||||
label = gtk_label_new (_("Crop Options"));
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
/* layer toggle */
|
||||
checkbutton = gtk_check_button_new_with_label(_("Current layer only"));
|
||||
gtk_box_pack_start(GTK_BOX(vbox), checkbutton,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_signal_connect(GTK_OBJECT(checkbutton), "toggled",
|
||||
(GtkSignalFunc) crop_checkbutton_update,
|
||||
&options.layer_only);
|
||||
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(checkbutton),
|
||||
options.layer_only);
|
||||
gtk_widget_show(checkbutton);
|
||||
|
||||
/* Register this selection options widget with the main tools
|
||||
* options dialog */
|
||||
|
||||
tools_register_options (CROP, vbox);
|
||||
}
|
||||
|
||||
static void
|
||||
crop_checkbutton_update (GtkWidget *w,
|
||||
gpointer data)
|
||||
{
|
||||
int *toggle_val;
|
||||
|
||||
toggle_val = (int *) data;
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (w)->active)
|
||||
*toggle_val = TRUE;
|
||||
else
|
||||
*toggle_val = FALSE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
crop_button_press (Tool *tool,
|
||||
GdkEventButton *bevent,
|
||||
|
@ -522,8 +573,8 @@ tools_new_crop ()
|
|||
Tool * tool;
|
||||
Crop * private;
|
||||
|
||||
if (! crop_options)
|
||||
crop_options = tools_register_no_options (CROP, _("Crop Tool Options"));
|
||||
if (! options_widget)
|
||||
init_crop_options ();
|
||||
|
||||
tool = (Tool *) g_malloc (sizeof (Tool));
|
||||
private = (Crop *) g_malloc (sizeof (Crop));
|
||||
|
@ -580,17 +631,42 @@ crop_image (GImage *gimage,
|
|||
Layer *layer;
|
||||
Layer *floating_layer;
|
||||
Channel *channel;
|
||||
GimpDrawable *drawable;
|
||||
GList *guide_list_ptr;
|
||||
GSList *list;
|
||||
int width, height;
|
||||
int lx1, ly1, lx2, ly2;
|
||||
int off_x, off_y;
|
||||
int doff_x, doff_y;
|
||||
|
||||
width = x2 - x1;
|
||||
height = y2 - y1;
|
||||
|
||||
/* Make sure new width and height are non-zero */
|
||||
if (width && height)
|
||||
{
|
||||
if (options.layer_only)
|
||||
{
|
||||
undo_push_group_start (gimage, LAYER_RESIZE_UNDO);
|
||||
|
||||
layer = gimage->active_layer;
|
||||
|
||||
if (layer_is_floating_sel (layer))
|
||||
floating_sel_relax (layer, TRUE);
|
||||
|
||||
drawable_offsets (GIMP_DRAWABLE(layer), &doff_x, &doff_y);
|
||||
|
||||
off_x = (doff_x - x1);
|
||||
off_y = (doff_y - y1);
|
||||
|
||||
layer_resize (layer, width, height, off_x, off_y);
|
||||
|
||||
if (layer_is_floating_sel (layer))
|
||||
floating_sel_rigor (layer, TRUE);
|
||||
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
else
|
||||
{
|
||||
floating_layer = gimage_floating_sel (gimage);
|
||||
|
||||
|
@ -672,6 +748,8 @@ crop_image (GImage *gimage,
|
|||
gdisplays_update_full (gimage);
|
||||
gdisplays_shrink_wrap (gimage);
|
||||
}
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -26,6 +26,12 @@ void crop_draw (Tool *);
|
|||
Tool * tools_new_crop (void);
|
||||
void tools_free_crop (Tool *);
|
||||
|
||||
/* tool options */
|
||||
typedef struct {
|
||||
int layer_only;
|
||||
} CropToolOptions;
|
||||
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord crop_proc;
|
||||
|
||||
|
|
|
@ -105,13 +105,64 @@ static void crop_orig_y_changed (GtkWidget *, gpointer);
|
|||
static void crop_width_changed (GtkWidget *, gpointer);
|
||||
static void crop_height_changed (GtkWidget *, gpointer);
|
||||
|
||||
static void *crop_options = NULL;
|
||||
/* Options callbacks */
|
||||
static void crop_checkbutton_update (GtkWidget *, gpointer);
|
||||
|
||||
static GtkWidget *options_widget = NULL;
|
||||
static CropToolOptions options;
|
||||
|
||||
static Argument *crop_invoker (Argument *);
|
||||
|
||||
|
||||
/* Functions */
|
||||
|
||||
static void
|
||||
init_crop_options()
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *label;
|
||||
GtkWidget *checkbutton;
|
||||
|
||||
/* the main vbox */
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
|
||||
/* the main label */
|
||||
label = gtk_label_new (_("Crop Options"));
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
/* layer toggle */
|
||||
checkbutton = gtk_check_button_new_with_label(_("Current layer only"));
|
||||
gtk_box_pack_start(GTK_BOX(vbox), checkbutton,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_signal_connect(GTK_OBJECT(checkbutton), "toggled",
|
||||
(GtkSignalFunc) crop_checkbutton_update,
|
||||
&options.layer_only);
|
||||
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(checkbutton),
|
||||
options.layer_only);
|
||||
gtk_widget_show(checkbutton);
|
||||
|
||||
/* Register this selection options widget with the main tools
|
||||
* options dialog */
|
||||
|
||||
tools_register_options (CROP, vbox);
|
||||
}
|
||||
|
||||
static void
|
||||
crop_checkbutton_update (GtkWidget *w,
|
||||
gpointer data)
|
||||
{
|
||||
int *toggle_val;
|
||||
|
||||
toggle_val = (int *) data;
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (w)->active)
|
||||
*toggle_val = TRUE;
|
||||
else
|
||||
*toggle_val = FALSE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
crop_button_press (Tool *tool,
|
||||
GdkEventButton *bevent,
|
||||
|
@ -522,8 +573,8 @@ tools_new_crop ()
|
|||
Tool * tool;
|
||||
Crop * private;
|
||||
|
||||
if (! crop_options)
|
||||
crop_options = tools_register_no_options (CROP, _("Crop Tool Options"));
|
||||
if (! options_widget)
|
||||
init_crop_options ();
|
||||
|
||||
tool = (Tool *) g_malloc (sizeof (Tool));
|
||||
private = (Crop *) g_malloc (sizeof (Crop));
|
||||
|
@ -580,17 +631,42 @@ crop_image (GImage *gimage,
|
|||
Layer *layer;
|
||||
Layer *floating_layer;
|
||||
Channel *channel;
|
||||
GimpDrawable *drawable;
|
||||
GList *guide_list_ptr;
|
||||
GSList *list;
|
||||
int width, height;
|
||||
int lx1, ly1, lx2, ly2;
|
||||
int off_x, off_y;
|
||||
int doff_x, doff_y;
|
||||
|
||||
width = x2 - x1;
|
||||
height = y2 - y1;
|
||||
|
||||
/* Make sure new width and height are non-zero */
|
||||
if (width && height)
|
||||
{
|
||||
if (options.layer_only)
|
||||
{
|
||||
undo_push_group_start (gimage, LAYER_RESIZE_UNDO);
|
||||
|
||||
layer = gimage->active_layer;
|
||||
|
||||
if (layer_is_floating_sel (layer))
|
||||
floating_sel_relax (layer, TRUE);
|
||||
|
||||
drawable_offsets (GIMP_DRAWABLE(layer), &doff_x, &doff_y);
|
||||
|
||||
off_x = (doff_x - x1);
|
||||
off_y = (doff_y - y1);
|
||||
|
||||
layer_resize (layer, width, height, off_x, off_y);
|
||||
|
||||
if (layer_is_floating_sel (layer))
|
||||
floating_sel_rigor (layer, TRUE);
|
||||
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
else
|
||||
{
|
||||
floating_layer = gimage_floating_sel (gimage);
|
||||
|
||||
|
@ -672,6 +748,8 @@ crop_image (GImage *gimage,
|
|||
gdisplays_update_full (gimage);
|
||||
gdisplays_shrink_wrap (gimage);
|
||||
}
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -26,6 +26,12 @@ void crop_draw (Tool *);
|
|||
Tool * tools_new_crop (void);
|
||||
void tools_free_crop (Tool *);
|
||||
|
||||
/* tool options */
|
||||
typedef struct {
|
||||
int layer_only;
|
||||
} CropToolOptions;
|
||||
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord crop_proc;
|
||||
|
||||
|
|
|
@ -105,13 +105,64 @@ static void crop_orig_y_changed (GtkWidget *, gpointer);
|
|||
static void crop_width_changed (GtkWidget *, gpointer);
|
||||
static void crop_height_changed (GtkWidget *, gpointer);
|
||||
|
||||
static void *crop_options = NULL;
|
||||
/* Options callbacks */
|
||||
static void crop_checkbutton_update (GtkWidget *, gpointer);
|
||||
|
||||
static GtkWidget *options_widget = NULL;
|
||||
static CropToolOptions options;
|
||||
|
||||
static Argument *crop_invoker (Argument *);
|
||||
|
||||
|
||||
/* Functions */
|
||||
|
||||
static void
|
||||
init_crop_options()
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *label;
|
||||
GtkWidget *checkbutton;
|
||||
|
||||
/* the main vbox */
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
|
||||
/* the main label */
|
||||
label = gtk_label_new (_("Crop Options"));
|
||||
gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
/* layer toggle */
|
||||
checkbutton = gtk_check_button_new_with_label(_("Current layer only"));
|
||||
gtk_box_pack_start(GTK_BOX(vbox), checkbutton,
|
||||
FALSE, FALSE, 0);
|
||||
gtk_signal_connect(GTK_OBJECT(checkbutton), "toggled",
|
||||
(GtkSignalFunc) crop_checkbutton_update,
|
||||
&options.layer_only);
|
||||
gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(checkbutton),
|
||||
options.layer_only);
|
||||
gtk_widget_show(checkbutton);
|
||||
|
||||
/* Register this selection options widget with the main tools
|
||||
* options dialog */
|
||||
|
||||
tools_register_options (CROP, vbox);
|
||||
}
|
||||
|
||||
static void
|
||||
crop_checkbutton_update (GtkWidget *w,
|
||||
gpointer data)
|
||||
{
|
||||
int *toggle_val;
|
||||
|
||||
toggle_val = (int *) data;
|
||||
|
||||
if (GTK_TOGGLE_BUTTON (w)->active)
|
||||
*toggle_val = TRUE;
|
||||
else
|
||||
*toggle_val = FALSE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
crop_button_press (Tool *tool,
|
||||
GdkEventButton *bevent,
|
||||
|
@ -522,8 +573,8 @@ tools_new_crop ()
|
|||
Tool * tool;
|
||||
Crop * private;
|
||||
|
||||
if (! crop_options)
|
||||
crop_options = tools_register_no_options (CROP, _("Crop Tool Options"));
|
||||
if (! options_widget)
|
||||
init_crop_options ();
|
||||
|
||||
tool = (Tool *) g_malloc (sizeof (Tool));
|
||||
private = (Crop *) g_malloc (sizeof (Crop));
|
||||
|
@ -580,17 +631,42 @@ crop_image (GImage *gimage,
|
|||
Layer *layer;
|
||||
Layer *floating_layer;
|
||||
Channel *channel;
|
||||
GimpDrawable *drawable;
|
||||
GList *guide_list_ptr;
|
||||
GSList *list;
|
||||
int width, height;
|
||||
int lx1, ly1, lx2, ly2;
|
||||
int off_x, off_y;
|
||||
int doff_x, doff_y;
|
||||
|
||||
width = x2 - x1;
|
||||
height = y2 - y1;
|
||||
|
||||
/* Make sure new width and height are non-zero */
|
||||
if (width && height)
|
||||
{
|
||||
if (options.layer_only)
|
||||
{
|
||||
undo_push_group_start (gimage, LAYER_RESIZE_UNDO);
|
||||
|
||||
layer = gimage->active_layer;
|
||||
|
||||
if (layer_is_floating_sel (layer))
|
||||
floating_sel_relax (layer, TRUE);
|
||||
|
||||
drawable_offsets (GIMP_DRAWABLE(layer), &doff_x, &doff_y);
|
||||
|
||||
off_x = (doff_x - x1);
|
||||
off_y = (doff_y - y1);
|
||||
|
||||
layer_resize (layer, width, height, off_x, off_y);
|
||||
|
||||
if (layer_is_floating_sel (layer))
|
||||
floating_sel_rigor (layer, TRUE);
|
||||
|
||||
undo_push_group_end (gimage);
|
||||
}
|
||||
else
|
||||
{
|
||||
floating_layer = gimage_floating_sel (gimage);
|
||||
|
||||
|
@ -672,6 +748,8 @@ crop_image (GImage *gimage,
|
|||
gdisplays_update_full (gimage);
|
||||
gdisplays_shrink_wrap (gimage);
|
||||
}
|
||||
gdisplays_flush ();
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -26,6 +26,12 @@ void crop_draw (Tool *);
|
|||
Tool * tools_new_crop (void);
|
||||
void tools_free_crop (Tool *);
|
||||
|
||||
/* tool options */
|
||||
typedef struct {
|
||||
int layer_only;
|
||||
} CropToolOptions;
|
||||
|
||||
|
||||
/* Procedure definition and marshalling function */
|
||||
extern ProcRecord crop_proc;
|
||||
|
||||
|
|
Loading…
Reference in New Issue