Commit 7427a53c authored by Sven Neumann's avatar Sven Neumann

Layer to Imagesize in C


--Sven
parent 8fd4ffea
Sat Nov 27 14:49:20 MET 1999 Sven Neuman <sven@gimp.org>
* app/commands.c
* app/commands.h
* app/layer.c
* app/layer.h
* app/layers_dialog.c
* app/layers_dialog.h
* app/menus.c: implemented "Resize Layer to Imagesize" in C
* app/apptypes.h: indentation
* app/bezier_select.c
* app/nav_window.h: get rid of compiler warnings
1999-11-27 Michael Natterer <mitch@gimp.org>
* app/main.c: bind the "gimp-perl" textdomain.
......@@ -11,10 +26,9 @@
Sat Nov 27 04:08:32 MET 1999 Sven Neuman <sven@gimp.org>
* app/fileops.c: I might break it again, but loading a single
* app/fileops.c: I might break it again, but creating a single
preview seemed to be broken after Adam fixed my last change.
IMHO it works as it should now... [and Adam sez: "I didn't
touch preview loading."]
IMHO it works as it should now...
Sat Nov 27 03:51:41 MET 1999 Sven Neuman <sven@gimp.org>
......
......@@ -1030,6 +1030,17 @@ layers_alpha_select_cmd_callback (GtkWidget *widget,
gdisplays_flush ();
}
void
layers_resize_to_image_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
GDisplay *gdisp;
return_if_no_display (gdisp);
layer_resize_to_image (gdisp->gimage->active_layer);
gdisplays_flush ();
}
/***** Tools *****/
void
......
......@@ -100,6 +100,7 @@ void layers_flatten_cmd_callback (GtkWidget *, gpointer);
void layers_mask_select_cmd_callback (GtkWidget *, gpointer);
void layers_add_alpha_channel_cmd_callback (GtkWidget *, gpointer);
void layers_alpha_select_cmd_callback (GtkWidget *, gpointer);
void layers_resize_to_image_cmd_callback (GtkWidget *, gpointer);
void tools_default_colors_cmd_callback (GtkWidget *, gpointer);
void tools_swap_colors_cmd_callback (GtkWidget *, gpointer);
......
......@@ -153,11 +153,11 @@ typedef struct _paint_core PaintCore;
typedef struct _GimpBrush GimpBrush;
typedef struct _GimpBrushClass GimpBrushClass;
typedef struct _layer_undo LayerUndo;
typedef struct _layer_undo LayerUndo;
typedef struct _layer_mask_undo LayerMaskUndo;
typedef struct _layer_mask_undo LayerMaskUndo;
typedef struct _fs_to_layer_undo FStoLayerUndo;
typedef struct _fs_to_layer_undo FStoLayerUndo;
typedef struct _PlugIn PlugIn;
typedef struct _PlugInDef PlugInDef;
......
......@@ -32,6 +32,7 @@
#include "bezier_selectP.h"
#include "paths_dialogP.h"
#include "selection_options.h"
#include "undo.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
......
......@@ -1030,6 +1030,17 @@ layers_alpha_select_cmd_callback (GtkWidget *widget,
gdisplays_flush ();
}
void
layers_resize_to_image_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
GDisplay *gdisp;
return_if_no_display (gdisp);
layer_resize_to_image (gdisp->gimage->active_layer);
gdisplays_flush ();
}
/***** Tools *****/
void
......
......@@ -100,6 +100,7 @@ void layers_flatten_cmd_callback (GtkWidget *, gpointer);
void layers_mask_select_cmd_callback (GtkWidget *, gpointer);
void layers_add_alpha_channel_cmd_callback (GtkWidget *, gpointer);
void layers_alpha_select_cmd_callback (GtkWidget *, gpointer);
void layers_resize_to_image_cmd_callback (GtkWidget *, gpointer);
void tools_default_colors_cmd_callback (GtkWidget *, gpointer);
void tools_swap_colors_cmd_callback (GtkWidget *, gpointer);
......
......@@ -902,6 +902,30 @@ layer_resize (Layer *layer,
GIMP_DRAWABLE(layer)->width, GIMP_DRAWABLE(layer)->height);
}
void
layer_resize_to_image (Layer *layer)
{
GImage *gimage;
gint offset_x;
gint offset_y;
if (!(gimage = GIMP_DRAWABLE (layer)->gimage))
return;
undo_push_group_start (gimage, LAYER_RESIZE_UNDO);
if (layer_is_floating_sel (layer))
floating_sel_relax (layer, TRUE);
gimp_drawable_offsets (GIMP_DRAWABLE (layer), &offset_x, &offset_y);
layer_resize (layer, gimage->width, gimage->height, offset_x, offset_y);
if (layer_is_floating_sel (layer))
floating_sel_rigor (layer, TRUE);
undo_push_group_end (gimage);
}
BoundSeg *
layer_boundary (Layer *layer,
gint *num_segs)
......
......@@ -94,6 +94,7 @@ void layer_translate (Layer *, gint, gint);
void layer_add_alpha (Layer *);
void layer_scale (Layer *, gint, gint, gint);
void layer_resize (Layer *, gint, gint, gint, gint);
void layer_resize_to_image (Layer *);
BoundSeg * layer_boundary (Layer *, gint *);
void layer_invalidate_boundary (Layer *);
gint layer_pick_correlate (Layer *, gint, gint);
......
......@@ -902,6 +902,30 @@ layer_resize (Layer *layer,
GIMP_DRAWABLE(layer)->width, GIMP_DRAWABLE(layer)->height);
}
void
layer_resize_to_image (Layer *layer)
{
GImage *gimage;
gint offset_x;
gint offset_y;
if (!(gimage = GIMP_DRAWABLE (layer)->gimage))
return;
undo_push_group_start (gimage, LAYER_RESIZE_UNDO);
if (layer_is_floating_sel (layer))
floating_sel_relax (layer, TRUE);
gimp_drawable_offsets (GIMP_DRAWABLE (layer), &offset_x, &offset_y);
layer_resize (layer, gimage->width, gimage->height, offset_x, offset_y);
if (layer_is_floating_sel (layer))
floating_sel_rigor (layer, TRUE);
undo_push_group_end (gimage);
}
BoundSeg *
layer_boundary (Layer *layer,
gint *num_segs)
......
......@@ -94,6 +94,7 @@ void layer_translate (Layer *, gint, gint);
void layer_add_alpha (Layer *);
void layer_scale (Layer *, gint, gint, gint);
void layer_resize (Layer *, gint, gint, gint, gint);
void layer_resize_to_image (Layer *);
BoundSeg * layer_boundary (Layer *, gint *);
void layer_invalidate_boundary (Layer *);
gint layer_pick_correlate (Layer *, gint, gint);
......
......@@ -1030,6 +1030,17 @@ layers_alpha_select_cmd_callback (GtkWidget *widget,
gdisplays_flush ();
}
void
layers_resize_to_image_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
GDisplay *gdisp;
return_if_no_display (gdisp);
layer_resize_to_image (gdisp->gimage->active_layer);
gdisplays_flush ();
}
/***** Tools *****/
void
......
......@@ -100,6 +100,7 @@ void layers_flatten_cmd_callback (GtkWidget *, gpointer);
void layers_mask_select_cmd_callback (GtkWidget *, gpointer);
void layers_add_alpha_channel_cmd_callback (GtkWidget *, gpointer);
void layers_alpha_select_cmd_callback (GtkWidget *, gpointer);
void layers_resize_to_image_cmd_callback (GtkWidget *, gpointer);
void tools_default_colors_cmd_callback (GtkWidget *, gpointer);
void tools_swap_colors_cmd_callback (GtkWidget *, gpointer);
......
......@@ -1030,6 +1030,17 @@ layers_alpha_select_cmd_callback (GtkWidget *widget,
gdisplays_flush ();
}
void
layers_resize_to_image_cmd_callback (GtkWidget *widget,
gpointer client_data)
{
GDisplay *gdisp;
return_if_no_display (gdisp);
layer_resize_to_image (gdisp->gimage->active_layer);
gdisplays_flush ();
}
/***** Tools *****/
void
......
......@@ -100,6 +100,7 @@ void layers_flatten_cmd_callback (GtkWidget *, gpointer);
void layers_mask_select_cmd_callback (GtkWidget *, gpointer);
void layers_add_alpha_channel_cmd_callback (GtkWidget *, gpointer);
void layers_alpha_select_cmd_callback (GtkWidget *, gpointer);
void layers_resize_to_image_cmd_callback (GtkWidget *, gpointer);
void tools_default_colors_cmd_callback (GtkWidget *, gpointer);
void tools_swap_colors_cmd_callback (GtkWidget *, gpointer);
......
......@@ -1043,6 +1043,7 @@ layers_dialog_set_menu_sensitivity (void)
SET_OPS_SENSITIVE (5, ac && gimage && lp);
SET_SENSITIVE ("Layer Boundary Size...", ac && gimage && lp);
SET_SENSITIVE ("Resize to Image", ac && gimage && lp);
SET_SENSITIVE ("Scale Layer...", ac && gimage && lp);
SET_SENSITIVE ("Merge Visible Layers...", fs && ac && gimage && lp);
......@@ -1625,6 +1626,20 @@ layers_dialog_resize_layer_callback (GtkWidget *widget,
layers_dialog_resize_layer_query (gimage, gimage->active_layer);
}
void
layers_dialog_resize_to_image_callback (GtkWidget *widget,
gpointer data)
{
GImage *gimage;
if (!layersD || !(gimage = layersD->gimage))
return;
layer_resize_to_image (gimage->active_layer);
gdisplays_flush ();
}
void
layers_dialog_add_layer_mask_callback (GtkWidget *widget,
gpointer data)
......
......@@ -29,6 +29,7 @@ void layers_dialog_duplicate_layer_callback (GtkWidget *, gpointer);
void layers_dialog_delete_layer_callback (GtkWidget *, gpointer);
void layers_dialog_scale_layer_callback (GtkWidget *, gpointer);
void layers_dialog_resize_layer_callback (GtkWidget *, gpointer);
void layers_dialog_resize_to_image_callback (GtkWidget *, gpointer);
void layers_dialog_add_layer_mask_callback (GtkWidget *, gpointer);
void layers_dialog_apply_layer_mask_callback (GtkWidget *, gpointer);
void layers_dialog_anchor_layer_callback (GtkWidget *, gpointer);
......
......@@ -494,6 +494,9 @@ static GimpItemFactoryEntry image_entries[] =
{ { N_("/Layers/Rotate"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Layers/Resize to Image"), NULL, layers_resize_to_image_cmd_callback, 0 },
"layers/resize_to_image.html", NULL },
{ { "/Layers/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Layers/Anchor Layer"), "<control>H", layers_anchor_cmd_callback, 0 },
......@@ -700,9 +703,11 @@ static GimpItemFactoryEntry layers_entries[] =
NULL, NULL },
{ { N_("/Layer Boundary Size..."), "<control>R", layers_dialog_resize_layer_callback, 0 },
"dialogs/resize_layer.html", NULL },
{ { N_("/Resize to Image"), NULL, layers_dialog_resize_to_image_callback, 0 },
"resize_to_image.html", NULL },
{ { N_("/Scale Layer..."), "<control>S", layers_dialog_scale_layer_callback, 0 },
"dialogs/scale_layer.html", NULL },
{ { "/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Merge Visible Layers..."), "<control>M", layers_dialog_merge_layers_callback, 0 },
......
......@@ -902,6 +902,30 @@ layer_resize (Layer *layer,
GIMP_DRAWABLE(layer)->width, GIMP_DRAWABLE(layer)->height);
}
void
layer_resize_to_image (Layer *layer)
{
GImage *gimage;
gint offset_x;
gint offset_y;
if (!(gimage = GIMP_DRAWABLE (layer)->gimage))
return;
undo_push_group_start (gimage, LAYER_RESIZE_UNDO);
if (layer_is_floating_sel (layer))
floating_sel_relax (layer, TRUE);
gimp_drawable_offsets (GIMP_DRAWABLE (layer), &offset_x, &offset_y);
layer_resize (layer, gimage->width, gimage->height, offset_x, offset_y);
if (layer_is_floating_sel (layer))
floating_sel_rigor (layer, TRUE);
undo_push_group_end (gimage);
}
BoundSeg *
layer_boundary (Layer *layer,
gint *num_segs)
......
......@@ -94,6 +94,7 @@ void layer_translate (Layer *, gint, gint);
void layer_add_alpha (Layer *);
void layer_scale (Layer *, gint, gint, gint);
void layer_resize (Layer *, gint, gint, gint, gint);
void layer_resize_to_image (Layer *);
BoundSeg * layer_boundary (Layer *, gint *);
void layer_invalidate_boundary (Layer *);
gint layer_pick_correlate (Layer *, gint, gint);
......
......@@ -1043,6 +1043,7 @@ layers_dialog_set_menu_sensitivity (void)
SET_OPS_SENSITIVE (5, ac && gimage && lp);
SET_SENSITIVE ("Layer Boundary Size...", ac && gimage && lp);
SET_SENSITIVE ("Resize to Image", ac && gimage && lp);
SET_SENSITIVE ("Scale Layer...", ac && gimage && lp);
SET_SENSITIVE ("Merge Visible Layers...", fs && ac && gimage && lp);
......@@ -1625,6 +1626,20 @@ layers_dialog_resize_layer_callback (GtkWidget *widget,
layers_dialog_resize_layer_query (gimage, gimage->active_layer);
}
void
layers_dialog_resize_to_image_callback (GtkWidget *widget,
gpointer data)
{
GImage *gimage;
if (!layersD || !(gimage = layersD->gimage))
return;
layer_resize_to_image (gimage->active_layer);
gdisplays_flush ();
}
void
layers_dialog_add_layer_mask_callback (GtkWidget *widget,
gpointer data)
......
......@@ -29,6 +29,7 @@ void layers_dialog_duplicate_layer_callback (GtkWidget *, gpointer);
void layers_dialog_delete_layer_callback (GtkWidget *, gpointer);
void layers_dialog_scale_layer_callback (GtkWidget *, gpointer);
void layers_dialog_resize_layer_callback (GtkWidget *, gpointer);
void layers_dialog_resize_to_image_callback (GtkWidget *, gpointer);
void layers_dialog_add_layer_mask_callback (GtkWidget *, gpointer);
void layers_dialog_apply_layer_mask_callback (GtkWidget *, gpointer);
void layers_dialog_anchor_layer_callback (GtkWidget *, gpointer);
......
......@@ -494,6 +494,9 @@ static GimpItemFactoryEntry image_entries[] =
{ { N_("/Layers/Rotate"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Layers/Resize to Image"), NULL, layers_resize_to_image_cmd_callback, 0 },
"layers/resize_to_image.html", NULL },
{ { "/Layers/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Layers/Anchor Layer"), "<control>H", layers_anchor_cmd_callback, 0 },
......@@ -700,9 +703,11 @@ static GimpItemFactoryEntry layers_entries[] =
NULL, NULL },
{ { N_("/Layer Boundary Size..."), "<control>R", layers_dialog_resize_layer_callback, 0 },
"dialogs/resize_layer.html", NULL },
{ { N_("/Resize to Image"), NULL, layers_dialog_resize_to_image_callback, 0 },
"resize_to_image.html", NULL },
{ { N_("/Scale Layer..."), "<control>S", layers_dialog_scale_layer_callback, 0 },
"dialogs/scale_layer.html", NULL },
{ { "/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Merge Visible Layers..."), "<control>M", layers_dialog_merge_layers_callback, 0 },
......
......@@ -494,6 +494,9 @@ static GimpItemFactoryEntry image_entries[] =
{ { N_("/Layers/Rotate"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Layers/Resize to Image"), NULL, layers_resize_to_image_cmd_callback, 0 },
"layers/resize_to_image.html", NULL },
{ { "/Layers/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Layers/Anchor Layer"), "<control>H", layers_anchor_cmd_callback, 0 },
......@@ -700,9 +703,11 @@ static GimpItemFactoryEntry layers_entries[] =
NULL, NULL },
{ { N_("/Layer Boundary Size..."), "<control>R", layers_dialog_resize_layer_callback, 0 },
"dialogs/resize_layer.html", NULL },
{ { N_("/Resize to Image"), NULL, layers_dialog_resize_to_image_callback, 0 },
"resize_to_image.html", NULL },
{ { N_("/Scale Layer..."), "<control>S", layers_dialog_scale_layer_callback, 0 },
"dialogs/scale_layer.html", NULL },
{ { "/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Merge Visible Layers..."), "<control>M", layers_dialog_merge_layers_callback, 0 },
......
......@@ -21,15 +21,16 @@
#include "info_dialog.h"
InfoDialog *nav_window_create (void *);
void nav_window_free (GDisplay *,InfoDialog *);
void nav_window_update_window_marker(InfoDialog *);
void nav_dialog_popup (InfoDialog *idialog);
void nav_window_preview_resized (InfoDialog *idialog);
InfoDialog *nav_window_create (void *);
void nav_window_free (GDisplay *,InfoDialog *);
void nav_window_update_window_marker (InfoDialog *);
void nav_dialog_popup (InfoDialog *idialog);
void nav_window_preview_resized (InfoDialog *idialog);
void nav_window_popup_preview_resized (GtkWidget **widget);
void nav_window_follow_auto (void);
/* popup functions */
void nav_popup_click_handler(GtkWidget *widget, GdkEventButton *event, gpointer data);
void nav_popup_free(GtkWidget *widget);
void nav_popup_click_handler (GtkWidget *widget, GdkEventButton *event, gpointer data);
void nav_popup_free (GtkWidget *widget);
#endif /* __NAV_WINDOW_H__ */
......@@ -32,6 +32,7 @@
#include "bezier_selectP.h"
#include "paths_dialogP.h"
#include "selection_options.h"
#include "undo.h"
#include "libgimp/gimpintl.h"
#include "libgimp/gimpmath.h"
......
......@@ -494,6 +494,9 @@ static GimpItemFactoryEntry image_entries[] =
{ { N_("/Layers/Rotate"), NULL, NULL, 0, "<Branch>" },
NULL, NULL },
{ { N_("/Layers/Resize to Image"), NULL, layers_resize_to_image_cmd_callback, 0 },
"layers/resize_to_image.html", NULL },
{ { "/Layers/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Layers/Anchor Layer"), "<control>H", layers_anchor_cmd_callback, 0 },
......@@ -700,9 +703,11 @@ static GimpItemFactoryEntry layers_entries[] =
NULL, NULL },
{ { N_("/Layer Boundary Size..."), "<control>R", layers_dialog_resize_layer_callback, 0 },
"dialogs/resize_layer.html", NULL },
{ { N_("/Resize to Image"), NULL, layers_dialog_resize_to_image_callback, 0 },
"resize_to_image.html", NULL },
{ { N_("/Scale Layer..."), "<control>S", layers_dialog_scale_layer_callback, 0 },
"dialogs/scale_layer.html", NULL },
{ { "/---", NULL, NULL, 0, "<Separator>" },
NULL, NULL },
{ { N_("/Merge Visible Layers..."), "<control>M", layers_dialog_merge_layers_callback, 0 },
......
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