2004-04-20 20:21:17 +08:00
|
|
|
/* align_layers.c
|
1997-11-25 06:05:25 +08:00
|
|
|
* Author: Shuji Narazaki <narazaki@InetQ.or.jp>
|
1998-01-25 17:29:29 +08:00
|
|
|
* Version: 0.26
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
1998-01-25 17:29:29 +08:00
|
|
|
* Copyright (C) 1997-1998 Shuji Narazaki <narazaki@InetQ.or.jp>
|
1997-11-25 06:05:25 +08:00
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
1997-11-25 06:05:25 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
1997-11-25 06:05:25 +08:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
1997-11-25 06:05:25 +08:00
|
|
|
*/
|
|
|
|
|
1999-12-18 05:24:24 +08:00
|
|
|
#include "config.h"
|
2000-01-07 00:40:17 +08:00
|
|
|
|
2000-01-13 23:39:26 +08:00
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
|
|
|
|
2000-01-07 00:40:17 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
|
|
|
|
2005-08-14 02:29:14 +08:00
|
|
|
#define PLUG_IN_PROC "plug-in-align-layers"
|
2008-03-24 23:29:55 +08:00
|
|
|
#define PLUG_IN_BINARY "align-layers"
|
2011-04-09 02:31:34 +08:00
|
|
|
#define PLUG_IN_ROLE "gimp-align-layers"
|
2005-08-14 02:29:14 +08:00
|
|
|
#define SCALE_WIDTH 150
|
2000-01-28 03:26:00 +08:00
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
H_NONE,
|
|
|
|
H_COLLECT,
|
|
|
|
LEFT2RIGHT,
|
|
|
|
RIGHT2LEFT,
|
|
|
|
SNAP2HGRID
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
H_BASE_LEFT,
|
|
|
|
H_BASE_CENTER,
|
|
|
|
H_BASE_RIGHT
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-01-28 03:26:00 +08:00
|
|
|
V_NONE,
|
|
|
|
V_COLLECT,
|
|
|
|
TOP2BOTTOM,
|
|
|
|
BOTTOM2TOP,
|
|
|
|
SNAP2VGRID
|
|
|
|
};
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
V_BASE_TOP,
|
|
|
|
V_BASE_CENTER,
|
|
|
|
V_BASE_BOTTOM
|
|
|
|
};
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-12-24 06:07:06 +08:00
|
|
|
static void query (void);
|
|
|
|
static void run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals);
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
static GimpPDBStatusType align_layers (gint32 image_id);
|
2001-12-04 01:59:48 +08:00
|
|
|
static void align_layers_get_align_offsets (gint32 drawable_id,
|
2003-12-24 06:07:06 +08:00
|
|
|
gint *x,
|
|
|
|
gint *y);
|
2000-01-28 03:26:00 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
static gint align_layers_dialog (void);
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2006-05-16 20:26:20 +08:00
|
|
|
const GimpPlugInInfo PLUG_IN_INFO =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-01-13 23:39:26 +08:00
|
|
|
NULL, /* init_proc */
|
2000-01-26 07:06:12 +08:00
|
|
|
NULL, /* quit_proc */
|
2000-01-13 23:39:26 +08:00
|
|
|
query, /* query_proc */
|
2000-01-26 07:06:12 +08:00
|
|
|
run, /* run_proc */
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2000-01-28 03:26:00 +08:00
|
|
|
/* dialog variables */
|
1997-11-25 06:05:25 +08:00
|
|
|
typedef struct
|
|
|
|
{
|
2003-12-24 06:07:06 +08:00
|
|
|
gint h_style;
|
|
|
|
gint h_base;
|
|
|
|
gint v_style;
|
|
|
|
gint v_base;
|
|
|
|
gboolean ignore_bottom;
|
|
|
|
gboolean base_is_bottom_layer;
|
|
|
|
gint grid_size;
|
1997-11-25 06:05:25 +08:00
|
|
|
} ValueType;
|
|
|
|
|
2003-10-21 07:32:20 +08:00
|
|
|
static ValueType VALS =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2000-01-28 03:26:00 +08:00
|
|
|
H_NONE,
|
|
|
|
H_BASE_LEFT,
|
|
|
|
V_NONE,
|
|
|
|
V_BASE_TOP,
|
|
|
|
TRUE,
|
|
|
|
FALSE,
|
|
|
|
10
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
1998-03-19 10:11:53 +08:00
|
|
|
MAIN ()
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
static void
|
2000-01-13 23:39:26 +08:00
|
|
|
query (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2006-05-16 20:26:20 +08:00
|
|
|
static const GimpParamDef args [] =
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2009-01-20 04:11:36 +08:00
|
|
|
{ GIMP_PDB_INT32, "run-mode", "The run mode { RUN-INTERACTIVE (0), RUN-NONINTERACTIVE (1) }"},
|
2005-08-14 02:29:14 +08:00
|
|
|
{ GIMP_PDB_IMAGE, "image", "Input image"},
|
|
|
|
{ GIMP_PDB_DRAWABLE, "drawable", "Input drawable (not used)"},
|
2009-04-12 00:57:42 +08:00
|
|
|
{ GIMP_PDB_INT32, "link-after-alignment", "Link the visible layers after alignment { TRUE, FALSE }"},
|
|
|
|
{ GIMP_PDB_INT32, "use-bottom", "use the bottom layer as the base of alignment { TRUE, FALSE }"}
|
1997-11-25 06:05:25 +08:00
|
|
|
};
|
1999-12-18 05:24:24 +08:00
|
|
|
|
2005-08-14 02:29:14 +08:00
|
|
|
gimp_install_procedure (PLUG_IN_PROC,
|
2006-03-17 17:29:48 +08:00
|
|
|
N_("Align all visible layers of the image"),
|
2003-12-24 06:07:06 +08:00
|
|
|
"Align visible layers",
|
|
|
|
"Shuji Narazaki <narazaki@InetQ.or.jp>",
|
|
|
|
"Shuji Narazaki",
|
|
|
|
"1997",
|
2007-06-10 01:17:30 +08:00
|
|
|
N_("Align Visi_ble Layers..."),
|
2004-07-02 04:22:43 +08:00
|
|
|
"RGB*,GRAY*,INDEXED*",
|
2003-12-24 06:07:06 +08:00
|
|
|
GIMP_PLUGIN,
|
|
|
|
G_N_ELEMENTS (args), 0,
|
|
|
|
args, NULL);
|
2004-05-07 08:30:24 +08:00
|
|
|
|
2005-12-29 05:08:26 +08:00
|
|
|
gimp_plugin_menu_register (PLUG_IN_PROC, "<Image>/Image/Arrange");
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-07-02 02:54:28 +08:00
|
|
|
run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2008-08-20 22:19:35 +08:00
|
|
|
static GimpParam values[2];
|
2001-12-04 01:59:48 +08:00
|
|
|
GimpPDBStatusType status = GIMP_PDB_EXECUTION_ERROR;
|
2001-12-29 21:26:29 +08:00
|
|
|
GimpRunMode run_mode;
|
2001-12-04 01:59:48 +08:00
|
|
|
gint image_id, layer_num;
|
2001-12-29 21:26:29 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
run_mode = param[0].data.d_int32;
|
|
|
|
image_id = param[1].data.d_int32;
|
|
|
|
|
2003-03-26 00:38:19 +08:00
|
|
|
INIT_I18N ();
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
*nreturn_vals = 1;
|
2001-12-29 21:26:29 +08:00
|
|
|
*return_vals = values;
|
2003-10-21 07:32:20 +08:00
|
|
|
|
2001-12-29 21:26:29 +08:00
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
1997-11-25 06:05:25 +08:00
|
|
|
values[0].data.d_status = status;
|
|
|
|
|
|
|
|
switch ( run_mode )
|
|
|
|
{
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_INTERACTIVE:
|
1997-11-25 06:05:25 +08:00
|
|
|
gimp_image_get_layers (image_id, &layer_num);
|
|
|
|
if (layer_num < 2)
|
2003-12-24 06:07:06 +08:00
|
|
|
{
|
2008-08-20 22:19:35 +08:00
|
|
|
*nreturn_vals = 2;
|
|
|
|
values[1].type = GIMP_PDB_STRING;
|
|
|
|
values[1].data.d_string = _("There are not enough layers to align.");
|
2003-12-24 06:07:06 +08:00
|
|
|
return;
|
|
|
|
}
|
2005-08-14 02:29:14 +08:00
|
|
|
gimp_get_data (PLUG_IN_PROC, &VALS);
|
2007-06-22 21:35:06 +08:00
|
|
|
VALS.grid_size = MAX (VALS.grid_size, 1);
|
2000-01-28 03:26:00 +08:00
|
|
|
if (! align_layers_dialog ())
|
2003-12-24 06:07:06 +08:00
|
|
|
return;
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2003-03-26 00:38:19 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_NONINTERACTIVE:
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
2003-03-26 00:38:19 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
case GIMP_RUN_WITH_LAST_VALS:
|
2005-08-14 02:29:14 +08:00
|
|
|
gimp_get_data (PLUG_IN_PROC, &VALS);
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
}
|
2000-01-28 03:26:00 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
status = align_layers (image_id);
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
if (run_mode != GIMP_RUN_NONINTERACTIVE)
|
2000-01-28 03:26:00 +08:00
|
|
|
gimp_displays_flush ();
|
2000-08-22 09:26:57 +08:00
|
|
|
if (run_mode == GIMP_RUN_INTERACTIVE && status == GIMP_PDB_SUCCESS)
|
2005-08-14 02:29:14 +08:00
|
|
|
gimp_set_data (PLUG_IN_PROC, &VALS, sizeof (ValueType));
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
1997-11-25 06:05:25 +08:00
|
|
|
values[0].data.d_status = status;
|
|
|
|
}
|
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
static GimpPDBStatusType
|
1997-11-25 06:05:25 +08:00
|
|
|
align_layers (gint32 image_id)
|
|
|
|
{
|
2003-12-24 06:07:06 +08:00
|
|
|
gint layer_num = 0;
|
|
|
|
gint visible_layer_num = 0;
|
2000-04-21 03:37:39 +08:00
|
|
|
gint *layers = NULL;
|
2003-12-24 06:07:06 +08:00
|
|
|
gint index;
|
2000-04-21 03:37:39 +08:00
|
|
|
gint vindex;
|
2003-12-24 06:07:06 +08:00
|
|
|
gint step_x = 0;
|
|
|
|
gint step_y = 0;
|
|
|
|
gint x = 0;
|
|
|
|
gint y = 0;
|
|
|
|
gint orig_x = 0;
|
|
|
|
gint orig_y = 0;
|
|
|
|
gint offset_x = 0;
|
|
|
|
gint offset_y = 0;
|
|
|
|
gint base_x = 0;
|
|
|
|
gint base_y = 0;
|
2000-04-21 03:37:39 +08:00
|
|
|
gint bg_index = 0;
|
2003-10-21 07:32:20 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
layers = gimp_image_get_layers (image_id, &layer_num);
|
2000-04-21 03:37:39 +08:00
|
|
|
bg_index = layer_num - 1;
|
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
for (index = 0; index < layer_num; index++)
|
2000-04-21 03:37:39 +08:00
|
|
|
{
|
2010-07-09 18:27:36 +08:00
|
|
|
if (gimp_item_get_visible (layers[index]))
|
2003-12-24 06:07:06 +08:00
|
|
|
visible_layer_num++;
|
2000-04-21 03:37:39 +08:00
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
if (VALS.ignore_bottom)
|
|
|
|
{
|
|
|
|
layer_num--;
|
2010-07-09 18:27:36 +08:00
|
|
|
if (gimp_item_get_visible (layers[bg_index]))
|
2003-12-24 06:07:06 +08:00
|
|
|
visible_layer_num--;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (0 < visible_layer_num)
|
|
|
|
{
|
2003-12-24 06:07:06 +08:00
|
|
|
gint min_x = G_MAXINT;
|
|
|
|
gint min_y = G_MAXINT;
|
|
|
|
gint max_x = G_MININT;
|
|
|
|
gint max_y = G_MININT;
|
2003-10-21 07:32:20 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
/* 0 is the top layer */
|
|
|
|
for (index = 0; index < layer_num; index++)
|
2003-12-24 06:07:06 +08:00
|
|
|
{
|
2010-07-09 18:27:36 +08:00
|
|
|
if (gimp_item_get_visible (layers[index]))
|
2003-12-24 06:07:06 +08:00
|
|
|
{
|
|
|
|
gimp_drawable_offsets (layers[index], &orig_x, &orig_y);
|
|
|
|
align_layers_get_align_offsets (layers[index], &offset_x,
|
|
|
|
&offset_y);
|
|
|
|
orig_x += offset_x;
|
|
|
|
orig_y += offset_y;
|
|
|
|
|
|
|
|
if ( orig_x < min_x ) min_x = orig_x;
|
|
|
|
if ( max_x < orig_x ) max_x = orig_x;
|
|
|
|
if ( orig_y < min_y ) min_y = orig_y;
|
|
|
|
if ( max_y < orig_y ) max_y = orig_y;
|
|
|
|
}
|
|
|
|
}
|
2000-04-21 03:37:39 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if (VALS.base_is_bottom_layer)
|
2003-12-24 06:07:06 +08:00
|
|
|
{
|
|
|
|
gimp_drawable_offsets (layers[bg_index], &orig_x, &orig_y);
|
|
|
|
align_layers_get_align_offsets (layers[bg_index], &offset_x,
|
|
|
|
&offset_y);
|
|
|
|
orig_x += offset_x;
|
|
|
|
orig_y += offset_y;
|
|
|
|
base_x = min_x = orig_x;
|
|
|
|
base_y = min_y = orig_y;
|
|
|
|
}
|
2000-04-21 03:37:39 +08:00
|
|
|
|
|
|
|
if (visible_layer_num > 1)
|
2003-12-24 06:07:06 +08:00
|
|
|
{
|
|
|
|
step_x = (max_x - min_x) / (visible_layer_num - 1);
|
|
|
|
step_y = (max_y - min_y) / (visible_layer_num - 1);
|
|
|
|
}
|
2000-04-21 03:37:39 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if ( (VALS.h_style == LEFT2RIGHT) || (VALS.h_style == RIGHT2LEFT))
|
2003-12-24 06:07:06 +08:00
|
|
|
base_x = min_x;
|
2000-04-21 03:37:39 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
if ( (VALS.v_style == TOP2BOTTOM) || (VALS.v_style == BOTTOM2TOP))
|
2003-12-24 06:07:06 +08:00
|
|
|
base_y = min_y;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
2003-10-21 07:32:20 +08:00
|
|
|
|
2003-12-05 22:18:47 +08:00
|
|
|
gimp_image_undo_group_start (image_id);
|
2003-10-21 07:32:20 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
for (vindex = -1, index = 0; index < layer_num; index++)
|
|
|
|
{
|
2010-07-09 18:27:36 +08:00
|
|
|
if (gimp_item_get_visible (layers[index]))
|
2003-12-24 06:07:06 +08:00
|
|
|
vindex++;
|
2003-10-21 07:32:20 +08:00
|
|
|
else
|
2003-12-24 06:07:06 +08:00
|
|
|
continue;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
|
|
|
gimp_drawable_offsets (layers[index], &orig_x, &orig_y);
|
|
|
|
align_layers_get_align_offsets (layers[index], &offset_x, &offset_y);
|
2003-10-21 07:32:20 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (VALS.h_style)
|
2003-12-24 06:07:06 +08:00
|
|
|
{
|
|
|
|
case H_NONE:
|
|
|
|
x = orig_x;
|
|
|
|
break;
|
|
|
|
case H_COLLECT:
|
|
|
|
x = base_x - offset_x;
|
|
|
|
break;
|
|
|
|
case LEFT2RIGHT:
|
|
|
|
x = (base_x + vindex * step_x) - offset_x;
|
|
|
|
break;
|
|
|
|
case RIGHT2LEFT:
|
|
|
|
x = (base_x + (visible_layer_num - vindex - 1) * step_x) - offset_x;
|
|
|
|
break;
|
|
|
|
case SNAP2HGRID:
|
|
|
|
x = VALS.grid_size
|
|
|
|
* (int) ((orig_x + offset_x + VALS.grid_size /2) / VALS.grid_size)
|
|
|
|
- offset_x;
|
|
|
|
break;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (VALS.v_style)
|
2003-12-24 06:07:06 +08:00
|
|
|
{
|
|
|
|
case V_NONE:
|
|
|
|
y = orig_y;
|
|
|
|
break;
|
|
|
|
case V_COLLECT:
|
|
|
|
y = base_y - offset_y;
|
|
|
|
break;
|
|
|
|
case TOP2BOTTOM:
|
|
|
|
y = (base_y + vindex * step_y) - offset_y;
|
|
|
|
break;
|
|
|
|
case BOTTOM2TOP:
|
|
|
|
y = (base_y + (visible_layer_num - vindex - 1) * step_y) - offset_y;
|
|
|
|
break;
|
|
|
|
case SNAP2VGRID:
|
|
|
|
y = VALS.grid_size
|
|
|
|
* (int) ((orig_y + offset_y + VALS.grid_size / 2) / VALS.grid_size)
|
|
|
|
- offset_y;
|
|
|
|
break;
|
|
|
|
}
|
1997-11-25 06:05:25 +08:00
|
|
|
gimp_layer_set_offsets (layers[index], x, y);
|
|
|
|
}
|
2003-10-21 07:32:20 +08:00
|
|
|
|
2003-12-05 22:18:47 +08:00
|
|
|
gimp_image_undo_group_end (image_id);
|
2000-01-15 05:38:47 +08:00
|
|
|
|
2000-08-22 09:26:57 +08:00
|
|
|
return GIMP_PDB_SUCCESS;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-12-24 06:07:06 +08:00
|
|
|
align_layers_get_align_offsets (gint32 drawable_id,
|
|
|
|
gint *x,
|
|
|
|
gint *y)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2004-04-20 20:21:17 +08:00
|
|
|
GimpDrawable *layer = gimp_drawable_get (drawable_id);
|
2003-10-21 07:32:20 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (VALS.h_base)
|
|
|
|
{
|
|
|
|
case H_BASE_LEFT:
|
|
|
|
*x = 0;
|
|
|
|
break;
|
|
|
|
case H_BASE_CENTER:
|
2004-04-20 20:21:17 +08:00
|
|
|
*x = layer->width / 2;
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case H_BASE_RIGHT:
|
|
|
|
*x = layer->width;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
*x = 0;
|
|
|
|
break;
|
|
|
|
}
|
2004-04-20 20:21:17 +08:00
|
|
|
|
1997-11-25 06:05:25 +08:00
|
|
|
switch (VALS.v_base)
|
|
|
|
{
|
|
|
|
case V_BASE_TOP:
|
|
|
|
*y = 0;
|
|
|
|
break;
|
|
|
|
case V_BASE_CENTER:
|
2004-04-20 20:21:17 +08:00
|
|
|
*y = layer->height / 2;
|
1997-11-25 06:05:25 +08:00
|
|
|
break;
|
|
|
|
case V_BASE_BOTTOM:
|
|
|
|
*y = layer->height;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
*y = 0;
|
|
|
|
break;
|
|
|
|
}
|
2004-04-20 20:21:17 +08:00
|
|
|
|
|
|
|
gimp_drawable_detach (layer);
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2000-01-28 03:26:00 +08:00
|
|
|
align_layers_dialog (void)
|
1997-11-25 06:05:25 +08:00
|
|
|
{
|
2005-09-10 02:07:31 +08:00
|
|
|
GtkWidget *dialog;
|
2000-01-16 23:38:38 +08:00
|
|
|
GtkWidget *table;
|
2004-04-20 20:21:17 +08:00
|
|
|
GtkWidget *combo;
|
2000-01-28 03:26:00 +08:00
|
|
|
GtkWidget *toggle;
|
2000-01-16 23:38:38 +08:00
|
|
|
GtkObject *adj;
|
2003-11-06 23:27:05 +08:00
|
|
|
gboolean run;
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-08-14 02:29:14 +08:00
|
|
|
gimp_ui_init (PLUG_IN_BINARY, FALSE);
|
2000-01-16 23:38:38 +08:00
|
|
|
|
2011-04-09 02:31:34 +08:00
|
|
|
dialog = gimp_dialog_new (_("Align Visible Layers"), PLUG_IN_ROLE,
|
2005-09-10 02:07:31 +08:00
|
|
|
NULL, 0,
|
|
|
|
gimp_standard_help_func, PLUG_IN_PROC,
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
|
|
|
|
GTK_STOCK_OK, GTK_RESPONSE_OK,
|
2001-11-29 21:23:44 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
NULL);
|
2000-01-13 23:39:26 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
gtk_dialog_set_alternative_button_order (GTK_DIALOG (dialog),
|
2005-09-06 05:40:29 +08:00
|
|
|
GTK_RESPONSE_OK,
|
|
|
|
GTK_RESPONSE_CANCEL,
|
|
|
|
-1);
|
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
gimp_window_set_transient (GTK_WINDOW (dialog));
|
2005-02-09 04:40:33 +08:00
|
|
|
|
2003-12-11 05:13:29 +08:00
|
|
|
table = gtk_table_new (7, 3, FALSE);
|
2004-05-18 20:54:26 +08:00
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 6);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (table), 12);
|
2009-07-16 00:57:12 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (gtk_dialog_get_content_area (GTK_DIALOG (dialog))),
|
|
|
|
table, FALSE, FALSE, 0);
|
2003-12-11 05:13:29 +08:00
|
|
|
gtk_widget_show (table);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2011-11-17 06:13:03 +08:00
|
|
|
combo = gimp_int_combo_box_new (C_("align-style", "None"), H_NONE,
|
2004-04-20 20:21:17 +08:00
|
|
|
_("Collect"), H_COLLECT,
|
|
|
|
_("Fill (left to right)"), LEFT2RIGHT,
|
|
|
|
_("Fill (right to left)"), RIGHT2LEFT,
|
2004-05-26 04:16:07 +08:00
|
|
|
_("Snap to grid"), SNAP2HGRID,
|
2004-04-20 20:21:17 +08:00
|
|
|
NULL);
|
|
|
|
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), VALS.h_style);
|
2003-11-15 02:05:39 +08:00
|
|
|
|
2004-04-20 20:21:17 +08:00
|
|
|
g_signal_connect (combo, "changed",
|
|
|
|
G_CALLBACK (gimp_int_combo_box_get_active),
|
|
|
|
&VALS.h_style);
|
2003-11-15 02:05:39 +08:00
|
|
|
|
2000-01-31 11:13:02 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 0,
|
2004-05-26 04:16:07 +08:00
|
|
|
_("_Horizontal style:"), 0.0, 0.5,
|
2004-05-18 20:54:26 +08:00
|
|
|
combo, 2, FALSE);
|
2004-04-20 20:21:17 +08:00
|
|
|
|
2000-01-28 03:26:00 +08:00
|
|
|
|
2004-05-26 04:16:07 +08:00
|
|
|
combo = gimp_int_combo_box_new (_("Left edge"), H_BASE_LEFT,
|
2004-04-20 20:21:17 +08:00
|
|
|
_("Center"), H_BASE_CENTER,
|
2004-05-26 04:16:07 +08:00
|
|
|
_("Right edge"), H_BASE_RIGHT,
|
2004-04-20 20:21:17 +08:00
|
|
|
NULL);
|
|
|
|
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), VALS.h_base);
|
2000-01-28 03:26:00 +08:00
|
|
|
|
2004-04-20 20:21:17 +08:00
|
|
|
g_signal_connect (combo, "changed",
|
|
|
|
G_CALLBACK (gimp_int_combo_box_get_active),
|
|
|
|
&VALS.h_base);
|
2000-01-28 03:26:00 +08:00
|
|
|
|
2000-01-31 11:13:02 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 1,
|
2004-05-26 04:16:07 +08:00
|
|
|
_("Ho_rizontal base:"), 0.0, 0.5,
|
2004-05-18 20:54:26 +08:00
|
|
|
combo, 2, FALSE);
|
2000-01-28 03:26:00 +08:00
|
|
|
|
2011-11-17 06:13:03 +08:00
|
|
|
combo = gimp_int_combo_box_new (C_("align-style", "None"), V_NONE,
|
2004-04-20 20:21:17 +08:00
|
|
|
_("Collect"), V_COLLECT,
|
|
|
|
_("Fill (top to bottom)"), TOP2BOTTOM,
|
|
|
|
_("Fill (bottom to top)"), BOTTOM2TOP,
|
2004-05-26 04:16:07 +08:00
|
|
|
_("Snap to grid"), SNAP2VGRID,
|
2004-04-20 20:21:17 +08:00
|
|
|
NULL);
|
|
|
|
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), VALS.v_style);
|
2003-11-15 02:05:39 +08:00
|
|
|
|
2004-04-20 20:21:17 +08:00
|
|
|
g_signal_connect (combo, "changed",
|
|
|
|
G_CALLBACK (gimp_int_combo_box_get_active),
|
|
|
|
&VALS.v_style);
|
2003-11-15 02:05:39 +08:00
|
|
|
|
2000-01-31 11:13:02 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 2,
|
2004-05-26 04:16:07 +08:00
|
|
|
_("_Vertical style:"), 0.0, 0.5,
|
2004-05-18 20:54:26 +08:00
|
|
|
combo, 2, FALSE);
|
2000-01-28 03:26:00 +08:00
|
|
|
|
2004-05-26 04:16:07 +08:00
|
|
|
combo = gimp_int_combo_box_new (_("Top edge"), V_BASE_TOP,
|
2004-04-20 20:21:17 +08:00
|
|
|
_("Center"), V_BASE_CENTER,
|
2004-05-26 04:16:07 +08:00
|
|
|
_("Bottom edge"), V_BASE_BOTTOM,
|
2004-04-20 20:21:17 +08:00
|
|
|
NULL);
|
|
|
|
gimp_int_combo_box_set_active (GIMP_INT_COMBO_BOX (combo), VALS.v_base);
|
2000-01-28 03:26:00 +08:00
|
|
|
|
2004-04-20 20:21:17 +08:00
|
|
|
g_signal_connect (combo, "changed",
|
|
|
|
G_CALLBACK (gimp_int_combo_box_get_active),
|
|
|
|
&VALS.v_base);
|
2000-01-28 03:26:00 +08:00
|
|
|
|
2000-01-31 11:13:02 +08:00
|
|
|
gimp_table_attach_aligned (GTK_TABLE (table), 0, 3,
|
2004-05-26 04:16:07 +08:00
|
|
|
_("Ver_tical base:"), 0.0, 0.5,
|
2004-05-18 20:54:26 +08:00
|
|
|
combo, 2, FALSE);
|
|
|
|
|
|
|
|
adj = gimp_scale_entry_new (GTK_TABLE (table), 0, 4,
|
2004-05-26 04:16:07 +08:00
|
|
|
_("_Grid size:"), SCALE_WIDTH, 0,
|
2007-06-22 21:35:06 +08:00
|
|
|
VALS.grid_size, 1, 200, 1, 10, 0,
|
2004-05-18 20:54:26 +08:00
|
|
|
TRUE, 0, 0,
|
|
|
|
NULL, NULL);
|
2005-07-01 00:03:24 +08:00
|
|
|
g_signal_connect (adj, "value-changed",
|
2004-05-18 20:54:26 +08:00
|
|
|
G_CALLBACK (gimp_int_adjustment_update),
|
|
|
|
&VALS.grid_size);
|
2000-01-28 03:26:00 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
toggle = gtk_check_button_new_with_mnemonic
|
2004-05-26 04:16:07 +08:00
|
|
|
(_("_Ignore the bottom layer even if visible"));
|
2000-01-28 03:26:00 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), VALS.ignore_bottom);
|
2004-05-18 20:54:26 +08:00
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), toggle, 0, 3, 5, 6);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (toggle);
|
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (toggle, "toggled",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&VALS.ignore_bottom);
|
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
toggle = gtk_check_button_new_with_mnemonic
|
2004-05-26 04:16:07 +08:00
|
|
|
(_("_Use the (invisible) bottom layer as the base"));
|
2000-01-28 03:26:00 +08:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle),
|
2003-12-24 06:07:06 +08:00
|
|
|
VALS.base_is_bottom_layer);
|
2004-05-18 20:54:26 +08:00
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), toggle, 0, 3, 6, 7);
|
1997-11-25 06:05:25 +08:00
|
|
|
gtk_widget_show (toggle);
|
|
|
|
|
2003-01-07 14:16:02 +08:00
|
|
|
g_signal_connect (toggle, "toggled",
|
2001-12-29 21:26:29 +08:00
|
|
|
G_CALLBACK (gimp_toggle_button_update),
|
|
|
|
&VALS.base_is_bottom_layer);
|
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
gtk_widget_show (dialog);
|
2003-10-21 07:32:20 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
run = (gimp_dialog_run (GIMP_DIALOG (dialog)) == GTK_RESPONSE_OK);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2005-09-10 02:07:31 +08:00
|
|
|
gtk_widget_destroy (dialog);
|
1997-11-25 06:05:25 +08:00
|
|
|
|
2003-11-06 23:27:05 +08:00
|
|
|
return run;
|
1997-11-25 06:05:25 +08:00
|
|
|
}
|