Bill Skaggs <weskaggs@primate.ucdavis.edu>
* gimp/app/tools/Makefile.am * gimp/app/tools/gimp-tools.c * gimp/app/tools/gimpalignoptions.c * gimp/app/tools/gimpalignoptions.h * gimp/app/tools/gimpaligntool.c * gimp/app/tools/gimpaligntool.h: Add new tool for aligning layers etc, as described in bug #147437. * gimp/app/core/gimpitem.c * gimp/app/core/gimpitem.h (gimp_item_align): add function required by new tool. * gimp/app/core/core-enums.c * gimp/app/core/core-enums.h: add enum for alignment types. * gimp/themes/Default/images/stock-hcenter-24.png * gimp/themes/Default/images/stock-vcenter-24.png * gimp/libgimpwidgets/gimpstock.c * gimp/libgimpwidgets/gimpstock.h * gimp/themes/Default/images/Makefile.am * gimp/themes/Default/images/makefile.msc: add two stock symbols, modeled on the gravity symbols.
This commit is contained in:
26
ChangeLog
26
ChangeLog
@ -1,3 +1,29 @@
|
||||
2005-06-03 Bill Skaggs <weskaggs@primate.ucdavis.edu>
|
||||
|
||||
* gimp/app/tools/Makefile.am
|
||||
* gimp/app/tools/gimp-tools.c
|
||||
* gimp/app/tools/gimpalignoptions.c
|
||||
* gimp/app/tools/gimpalignoptions.h
|
||||
* gimp/app/tools/gimpaligntool.c
|
||||
* gimp/app/tools/gimpaligntool.h: Add new tool for
|
||||
aligning layers etc, as described in bug #147437.
|
||||
|
||||
* gimp/app/core/gimpitem.c
|
||||
* gimp/app/core/gimpitem.h (gimp_item_align): add
|
||||
function required by new tool.
|
||||
|
||||
* gimp/app/core/core-enums.c
|
||||
* gimp/app/core/core-enums.h: add enum for alignment
|
||||
types.
|
||||
|
||||
* gimp/themes/Default/images/stock-hcenter-24.png
|
||||
* gimp/themes/Default/images/stock-vcenter-24.png
|
||||
* gimp/libgimpwidgets/gimpstock.c
|
||||
* gimp/libgimpwidgets/gimpstock.h
|
||||
* gimp/themes/Default/images/Makefile.am
|
||||
* gimp/themes/Default/images/makefile.msc: add two
|
||||
stock symbols, modeled on the gravity symbols.
|
||||
|
||||
2005-06-02 Bill Skaggs <weskaggs@primate.ucdavis.edu>
|
||||
|
||||
* app/tools/gimprectangletool.c (gimp_rectangle_tool_motion):
|
||||
|
@ -144,6 +144,42 @@ gimp_gravity_type_get_type (void)
|
||||
return type;
|
||||
}
|
||||
|
||||
GType
|
||||
gimp_alignment_type_get_type (void)
|
||||
{
|
||||
static const GEnumValue values[] =
|
||||
{
|
||||
{ GIMP_ALIGN_LEFT, "GIMP_ALIGN_LEFT", "left" },
|
||||
{ GIMP_ALIGN_CENTER, "GIMP_ALIGN_CENTER", "center" },
|
||||
{ GIMP_ALIGN_RIGHT, "GIMP_ALIGN_RIGHT", "right" },
|
||||
{ GIMP_ALIGN_TOP, "GIMP_ALIGN_TOP", "top" },
|
||||
{ GIMP_ALIGN_MIDDLE, "GIMP_ALIGN_MIDDLE", "middle" },
|
||||
{ GIMP_ALIGN_BOTTOM, "GIMP_ALIGN_BOTTOM", "bottom" },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static const GimpEnumDesc descs[] =
|
||||
{
|
||||
{ GIMP_ALIGN_LEFT, "GIMP_ALIGN_LEFT", NULL },
|
||||
{ GIMP_ALIGN_CENTER, "GIMP_ALIGN_CENTER", NULL },
|
||||
{ GIMP_ALIGN_RIGHT, "GIMP_ALIGN_RIGHT", NULL },
|
||||
{ GIMP_ALIGN_TOP, "GIMP_ALIGN_TOP", NULL },
|
||||
{ GIMP_ALIGN_MIDDLE, "GIMP_ALIGN_MIDDLE", NULL },
|
||||
{ GIMP_ALIGN_BOTTOM, "GIMP_ALIGN_BOTTOM", NULL },
|
||||
{ 0, NULL, NULL }
|
||||
};
|
||||
|
||||
static GType type = 0;
|
||||
|
||||
if (! type)
|
||||
{
|
||||
type = g_enum_register_static ("GimpAlignmentType", values);
|
||||
gimp_enum_set_value_descriptions (type, descs);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
GType
|
||||
gimp_fill_type_get_type (void)
|
||||
{
|
||||
|
@ -95,6 +95,21 @@ typedef enum /*< pdb-skip >*/
|
||||
} GimpGravityType;
|
||||
|
||||
|
||||
#define GIMP_TYPE_ALIGNMENT (gimp_alignment_type_get_type ())
|
||||
|
||||
GType gimp_alignment_type_get_type (void) G_GNUC_CONST;
|
||||
|
||||
typedef enum /*< pdb-skip >*/
|
||||
{
|
||||
GIMP_ALIGN_LEFT,
|
||||
GIMP_ALIGN_CENTER,
|
||||
GIMP_ALIGN_RIGHT,
|
||||
GIMP_ALIGN_TOP,
|
||||
GIMP_ALIGN_MIDDLE,
|
||||
GIMP_ALIGN_BOTTOM
|
||||
} GimpAlignmentType;
|
||||
|
||||
|
||||
#define GIMP_TYPE_FILL_TYPE (gimp_fill_type_get_type ())
|
||||
|
||||
GType gimp_fill_type_get_type (void) G_GNUC_CONST;
|
||||
|
@ -1249,3 +1249,132 @@ gimp_item_get_linked (const GimpItem *item)
|
||||
|
||||
return item->linked;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_item_align:
|
||||
* @target: The #GimpItem to move.
|
||||
* @target_alignment: The part of the target to align..
|
||||
* @reference: The #GimpItem to align the target with.
|
||||
* @reference_alignment: The part of the reference item to align the target item with..
|
||||
* @offset: How much to shift the target from perfect alignment..
|
||||
* @push_undo: If #TRUE, create an entry in the image's undo stack
|
||||
* for this action.
|
||||
*
|
||||
* Aligns the target item with the reference item in the specified way. If
|
||||
* the reference item is #NULL, then the target item is aligned with the
|
||||
* image it belongs to.
|
||||
*/
|
||||
void
|
||||
gimp_item_align (GimpItem *target,
|
||||
GimpAlignmentType target_alignment,
|
||||
GimpItem *reference,
|
||||
GimpAlignmentType reference_alignment,
|
||||
gint offset,
|
||||
gboolean push_undo)
|
||||
{
|
||||
gboolean do_x = FALSE;
|
||||
gboolean do_y = FALSE;
|
||||
gint xtranslate = 0;
|
||||
gint ytranslate = 0;
|
||||
gint reference_offset_x;
|
||||
gint reference_offset_y;
|
||||
gint reference_height;
|
||||
gint reference_width;
|
||||
gint x0 = 0;
|
||||
gint y0 = 0;
|
||||
gint x1 = 0;
|
||||
gint y1 = 0;
|
||||
|
||||
if (!target)
|
||||
return;
|
||||
|
||||
if (! (reference || target->gimage))
|
||||
return;
|
||||
|
||||
if (reference)
|
||||
{
|
||||
reference_offset_x = reference->offset_x;
|
||||
reference_offset_y = reference->offset_y;
|
||||
reference_height = reference->height;
|
||||
reference_width = reference->width;
|
||||
}
|
||||
else
|
||||
{
|
||||
reference_offset_x = 0;
|
||||
reference_offset_y = 0;
|
||||
reference_height = gimp_image_get_height (target->gimage);
|
||||
reference_width = gimp_image_get_width (target->gimage);
|
||||
}
|
||||
|
||||
switch (reference_alignment)
|
||||
{
|
||||
case GIMP_ALIGN_LEFT:
|
||||
do_x = TRUE;
|
||||
x0 = reference_offset_x;
|
||||
break;
|
||||
case GIMP_ALIGN_CENTER:
|
||||
do_x = TRUE;
|
||||
x0 = reference_offset_x + reference_width/2;
|
||||
break;
|
||||
case GIMP_ALIGN_RIGHT:
|
||||
do_x = TRUE;
|
||||
x0 = reference_offset_x + reference_width;
|
||||
break;
|
||||
case GIMP_ALIGN_TOP:
|
||||
do_y = TRUE;
|
||||
y0 = reference_offset_y;
|
||||
break;
|
||||
case GIMP_ALIGN_MIDDLE:
|
||||
do_y = TRUE;
|
||||
y0 = reference_offset_y + reference_height/2;
|
||||
break;
|
||||
case GIMP_ALIGN_BOTTOM:
|
||||
do_y = TRUE;
|
||||
y0 = reference_offset_y + reference_height;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
if (do_x)
|
||||
{
|
||||
switch (target_alignment)
|
||||
{
|
||||
case GIMP_ALIGN_LEFT:
|
||||
x1 = target->offset_x;
|
||||
break;
|
||||
case GIMP_ALIGN_CENTER:
|
||||
x1 = target->offset_x + target->width/2;
|
||||
break;
|
||||
case GIMP_ALIGN_RIGHT:
|
||||
x1 = target->offset_x + target->width;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
xtranslate = x0 - x1 + offset;
|
||||
}
|
||||
|
||||
if (do_y)
|
||||
{
|
||||
switch (target_alignment)
|
||||
{
|
||||
case GIMP_ALIGN_TOP:
|
||||
y1 = target->offset_y;
|
||||
break;
|
||||
case GIMP_ALIGN_MIDDLE:
|
||||
y1 = target->offset_y + target->height/2;
|
||||
break;
|
||||
case GIMP_ALIGN_BOTTOM:
|
||||
y1 = target->offset_y + target->height;
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
ytranslate = y0 - y1 + offset;
|
||||
}
|
||||
|
||||
gimp_item_translate (target, xtranslate, ytranslate, push_undo);
|
||||
}
|
||||
|
@ -253,5 +253,12 @@ void gimp_item_set_linked (GimpItem *item,
|
||||
gboolean push_undo);
|
||||
gboolean gimp_item_get_linked (const GimpItem *item);
|
||||
|
||||
void gimp_item_align (GimpItem *target,
|
||||
GimpAlignmentType target_alignment,
|
||||
GimpItem *refeence,
|
||||
GimpAlignmentType reference_alignment,
|
||||
gint offset,
|
||||
gboolean push_undo);
|
||||
|
||||
|
||||
#endif /* __GIMP_ITEM_H__ */
|
||||
|
@ -14,6 +14,10 @@ libapptools_a_sources = \
|
||||
\
|
||||
gimpairbrushtool.c \
|
||||
gimpairbrushtool.h \
|
||||
gimpalignoptions.c \
|
||||
gimpalignoptions.h \
|
||||
gimpaligntool.c \
|
||||
gimpaligntool.h \
|
||||
gimpblendoptions.c \
|
||||
gimpblendoptions.h \
|
||||
gimpblendtool.c \
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "tool_manager.h"
|
||||
|
||||
#include "gimpairbrushtool.h"
|
||||
#include "gimpaligntool.h"
|
||||
#include "gimpblendtool.h"
|
||||
#include "gimpbrightnesscontrasttool.h"
|
||||
#include "gimpbucketfilltool.h"
|
||||
@ -148,6 +149,7 @@ gimp_tools_init (Gimp *gimp)
|
||||
gimp_rotate_tool_register,
|
||||
gimp_crop_tool_register,
|
||||
gimp_move_tool_register,
|
||||
gimp_align_tool_register,
|
||||
|
||||
/* non-modifying tools */
|
||||
|
||||
|
176
app/tools/gimpalignoptions.c
Normal file
176
app/tools/gimpalignoptions.c
Normal file
@ -0,0 +1,176 @@
|
||||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (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
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpconfig/gimpconfig.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "tools-types.h"
|
||||
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "widgets/gimpwidgets-utils.h"
|
||||
|
||||
#include "gimpalignoptions.h"
|
||||
#include "gimptooloptions-gui.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
PROP_0,
|
||||
PROP_ALIGN_TYPE
|
||||
};
|
||||
|
||||
|
||||
static void gimp_align_options_class_init (GimpAlignOptionsClass *options_class);
|
||||
|
||||
static void gimp_align_options_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec);
|
||||
static void gimp_align_options_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec);
|
||||
|
||||
|
||||
static GimpToolOptionsClass *parent_class = NULL;
|
||||
|
||||
|
||||
GType
|
||||
gimp_align_options_get_type (void)
|
||||
{
|
||||
static GType type = 0;
|
||||
|
||||
if (! type)
|
||||
{
|
||||
static const GTypeInfo info =
|
||||
{
|
||||
sizeof (GimpAlignOptionsClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gimp_align_options_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpAlignOptions),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) NULL
|
||||
};
|
||||
|
||||
type = g_type_register_static (GIMP_TYPE_TOOL_OPTIONS,
|
||||
"GimpAlignOptions",
|
||||
&info, 0);
|
||||
}
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_align_options_class_init (GimpAlignOptionsClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->set_property = gimp_align_options_set_property;
|
||||
object_class->get_property = gimp_align_options_get_property;
|
||||
|
||||
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_ALIGN_TYPE,
|
||||
"align-type", NULL,
|
||||
GIMP_TYPE_TRANSFORM_TYPE,
|
||||
GIMP_TRANSFORM_TYPE_LAYER,
|
||||
0);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_align_options_set_property (GObject *object,
|
||||
guint property_id,
|
||||
const GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpAlignOptions *options = GIMP_ALIGN_OPTIONS (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_ALIGN_TYPE:
|
||||
options->align_type = g_value_get_enum (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_align_options_get_property (GObject *object,
|
||||
guint property_id,
|
||||
GValue *value,
|
||||
GParamSpec *pspec)
|
||||
{
|
||||
GimpAlignOptions *options = GIMP_ALIGN_OPTIONS (object);
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case PROP_ALIGN_TYPE:
|
||||
g_value_set_enum (value, options->align_type);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
gimp_align_options_gui (GimpToolOptions *tool_options)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *controls_container;
|
||||
|
||||
#if 0
|
||||
GObject *config = G_OBJECT (tool_options);
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *label;
|
||||
#endif
|
||||
|
||||
vbox = gimp_tool_options_gui (tool_options);
|
||||
|
||||
#if 0
|
||||
hbox = gimp_prop_enum_stock_box_new (config, "align-type", "gimp", 0, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
||||
gtk_widget_show (hbox);
|
||||
|
||||
label = gtk_label_new (_("Affect:"));
|
||||
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
||||
gtk_box_reorder_child (GTK_BOX (hbox), label, 0);
|
||||
gtk_widget_show (label);
|
||||
#endif
|
||||
|
||||
controls_container = gtk_vbox_new (FALSE, 0);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), controls_container, FALSE, FALSE, 0);
|
||||
gtk_widget_show (controls_container);
|
||||
g_object_set_data (G_OBJECT (tool_options),
|
||||
"controls-container", controls_container);
|
||||
|
||||
return vbox;
|
||||
}
|
||||
|
50
app/tools/gimpalignoptions.h
Normal file
50
app/tools/gimpalignoptions.h
Normal file
@ -0,0 +1,50 @@
|
||||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (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
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_ALIGN_OPTIONS_H__
|
||||
#define __GIMP_ALIGN_OPTIONS_H__
|
||||
|
||||
|
||||
#include "core/gimptooloptions.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_ALIGN_OPTIONS (gimp_align_options_get_type ())
|
||||
#define GIMP_ALIGN_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_ALIGN_OPTIONS, GimpAlignOptions))
|
||||
#define GIMP_ALIGN_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_ALIGN_OPTIONS, GimpAlignOptionsClass))
|
||||
#define GIMP_IS_ALIGN_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_ALIGN_OPTIONS))
|
||||
#define GIMP_IS_ALIGN_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_ALIGN_OPTIONS))
|
||||
#define GIMP_ALIGN_OPTIONS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_ALIGN_OPTIONS, GimpAlignOptionsClass))
|
||||
|
||||
|
||||
typedef struct _GimpAlignOptions GimpAlignOptions;
|
||||
typedef struct _GimpToolOptionsClass GimpAlignOptionsClass;
|
||||
|
||||
struct _GimpAlignOptions
|
||||
{
|
||||
GimpToolOptions parent_instence;
|
||||
|
||||
GimpTransformType align_type;
|
||||
};
|
||||
|
||||
|
||||
GType gimp_align_options_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_align_options_gui (GimpToolOptions *tool_options);
|
||||
|
||||
|
||||
#endif /* __GIMP_ALIGN_OPTIONS_H__ */
|
681
app/tools/gimpaligntool.c
Normal file
681
app/tools/gimpaligntool.c
Normal file
@ -0,0 +1,681 @@
|
||||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (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
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "tools-types.h"
|
||||
|
||||
#include "config/gimpdisplayconfig.h"
|
||||
#include "config/gimpguiconfig.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimplayer.h"
|
||||
#include "core/gimplayermask.h"
|
||||
#include "core/gimplayer-floating-sel.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
#include "display/gimpdisplayshell.h"
|
||||
#include "display/gimpdisplayshell-appearance.h"
|
||||
#include "display/gimpdisplayshell-draw.h"
|
||||
#include "display/gimpdisplayshell-transform.h"
|
||||
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
|
||||
#include "gimpdrawtool.h"
|
||||
#include "gimpalignoptions.h"
|
||||
#include "gimpaligntool.h"
|
||||
#include "gimptoolcontrol.h"
|
||||
|
||||
#include "gimp-intl.h"
|
||||
|
||||
/* local function prototypes */
|
||||
|
||||
static void gimp_align_tool_class_init (GimpAlignToolClass *klass);
|
||||
static void gimp_align_tool_init (GimpAlignTool *align_tool);
|
||||
|
||||
static GObject * gimp_align_tool_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params);
|
||||
static gboolean gimp_align_tool_initialize (GimpTool *tool,
|
||||
GimpDisplay *gdisp);
|
||||
static void gimp_align_tool_finalize (GObject *object);
|
||||
|
||||
static void gimp_align_tool_button_press (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
static void gimp_align_tool_cursor_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp);
|
||||
|
||||
static void gimp_align_tool_draw (GimpDrawTool *draw_tool);
|
||||
|
||||
static GtkWidget *button_with_stock (GimpAlignmentType action,
|
||||
GimpAlignTool *align_tool);
|
||||
static GtkWidget *gimp_align_tool_controls (GimpAlignTool *align_tool);
|
||||
static void set_action (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void do_horizontal_alignment (GtkWidget *widget,
|
||||
gpointer data);
|
||||
static void do_vertical_alignment (GtkWidget *widget,
|
||||
gpointer data);
|
||||
|
||||
static GimpDrawToolClass *parent_class = NULL;
|
||||
|
||||
|
||||
void
|
||||
gimp_align_tool_register (GimpToolRegisterCallback callback,
|
||||
gpointer data)
|
||||
{
|
||||
(* callback) (GIMP_TYPE_ALIGN_TOOL,
|
||||
GIMP_TYPE_ALIGN_OPTIONS,
|
||||
gimp_align_options_gui,
|
||||
0,
|
||||
"gimp-align-tool",
|
||||
_("Align"),
|
||||
_("Align layers & other items"),
|
||||
N_("_Align"), "Q",
|
||||
NULL, GIMP_HELP_TOOL_MOVE,
|
||||
GIMP_STOCK_CENTER,
|
||||
data);
|
||||
}
|
||||
|
||||
GType
|
||||
gimp_align_tool_get_type (void)
|
||||
{
|
||||
static GType tool_type = 0;
|
||||
|
||||
if (! tool_type)
|
||||
{
|
||||
static const GTypeInfo tool_info =
|
||||
{
|
||||
sizeof (GimpAlignToolClass),
|
||||
(GBaseInitFunc) NULL,
|
||||
(GBaseFinalizeFunc) NULL,
|
||||
(GClassInitFunc) gimp_align_tool_class_init,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GimpAlignTool),
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gimp_align_tool_init,
|
||||
};
|
||||
|
||||
tool_type = g_type_register_static (GIMP_TYPE_DRAW_TOOL,
|
||||
"GimpAlignTool",
|
||||
&tool_info, 0);
|
||||
}
|
||||
|
||||
return tool_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_align_tool_class_init (GimpAlignToolClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GimpToolClass *tool_class = GIMP_TOOL_CLASS (klass);
|
||||
GimpDrawToolClass *draw_tool_class = GIMP_DRAW_TOOL_CLASS (klass);
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gimp_align_tool_finalize;
|
||||
object_class->constructor = gimp_align_tool_constructor;
|
||||
|
||||
tool_class->initialize = gimp_align_tool_initialize;
|
||||
tool_class->button_press = gimp_align_tool_button_press;
|
||||
tool_class->cursor_update = gimp_align_tool_cursor_update;
|
||||
|
||||
draw_tool_class->draw = gimp_align_tool_draw;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_align_tool_finalize (GObject *object)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (object);
|
||||
GimpAlignTool *align_tool = GIMP_ALIGN_TOOL (object);
|
||||
|
||||
if (gimp_draw_tool_is_active (GIMP_DRAW_TOOL (object)))
|
||||
gimp_draw_tool_stop (GIMP_DRAW_TOOL (object));
|
||||
|
||||
if (gimp_tool_control_is_active (tool->control))
|
||||
gimp_tool_control_halt (tool->control);
|
||||
|
||||
if (align_tool->controls)
|
||||
{
|
||||
gtk_widget_destroy (align_tool->controls);
|
||||
align_tool->controls = NULL;
|
||||
}
|
||||
|
||||
if (align_tool->reference_item)
|
||||
g_object_remove_weak_pointer (G_OBJECT (align_tool->reference_item),
|
||||
(gpointer) &align_tool->reference_item);
|
||||
|
||||
if (align_tool->target_item)
|
||||
g_object_remove_weak_pointer (G_OBJECT (align_tool->target_item),
|
||||
(gpointer) &align_tool->target_item);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_align_tool_initialize (GimpTool *tool,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpAlignTool *align_tool = GIMP_ALIGN_TOOL (tool);
|
||||
|
||||
if (tool->gdisp != gdisp)
|
||||
{
|
||||
/* align_tool->target_item = NULL; */
|
||||
/* align_tool->reference_item = NULL; */
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_align_tool_init (GimpAlignTool *align_tool)
|
||||
{
|
||||
GimpTool *tool = GIMP_TOOL (align_tool);
|
||||
|
||||
align_tool->controls = NULL;
|
||||
|
||||
align_tool->target_item = NULL;
|
||||
align_tool->reference_item = NULL;
|
||||
|
||||
align_tool->target_horz_align_type = GIMP_ALIGN_LEFT;
|
||||
align_tool->ref_horz_align_type = GIMP_ALIGN_LEFT;
|
||||
align_tool->target_vert_align_type = GIMP_ALIGN_TOP;
|
||||
align_tool->ref_vert_align_type = GIMP_ALIGN_TOP;
|
||||
|
||||
align_tool->horz_offset = 0;
|
||||
align_tool->vert_offset = 0;
|
||||
|
||||
gimp_tool_control_set_snap_to (tool->control, FALSE);
|
||||
gimp_tool_control_set_tool_cursor (tool->control,
|
||||
GIMP_TOOL_CURSOR_MOVE);
|
||||
|
||||
}
|
||||
|
||||
static GObject *
|
||||
gimp_align_tool_constructor (GType type,
|
||||
guint n_params,
|
||||
GObjectConstructParam *params)
|
||||
{
|
||||
GObject *object;
|
||||
GimpTool *tool;
|
||||
GimpAlignTool *align_tool;
|
||||
GtkContainer *controls_container;
|
||||
GObject *options;
|
||||
|
||||
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
|
||||
|
||||
tool = GIMP_TOOL (object);
|
||||
align_tool = GIMP_ALIGN_TOOL (object);
|
||||
|
||||
g_assert (GIMP_IS_TOOL_INFO (tool->tool_info));
|
||||
|
||||
options = G_OBJECT (tool->tool_info->tool_options);
|
||||
|
||||
controls_container = GTK_CONTAINER (g_object_get_data (options,
|
||||
"controls-container"));
|
||||
|
||||
align_tool->controls = gimp_align_tool_controls (align_tool);
|
||||
gtk_container_add (controls_container, align_tool->controls);
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_align_tool_button_press (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
guint32 time,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpAlignTool *align_tool = GIMP_ALIGN_TOOL (tool);
|
||||
GimpAlignOptions *options = GIMP_ALIGN_OPTIONS (tool->tool_info->tool_options);
|
||||
GimpItem *item = NULL;
|
||||
|
||||
/* If the tool was being used in another image...reset it */
|
||||
|
||||
if (gdisp != tool->gdisp)
|
||||
{
|
||||
if (gimp_draw_tool_is_active (GIMP_DRAW_TOOL (tool)))
|
||||
gimp_draw_tool_stop (GIMP_DRAW_TOOL (tool));
|
||||
|
||||
align_tool->target_item = NULL;
|
||||
align_tool->reference_item = NULL;
|
||||
}
|
||||
|
||||
if (! gimp_tool_control_is_active (tool->control))
|
||||
gimp_tool_control_activate (tool->control);
|
||||
|
||||
tool->gdisp = gdisp;
|
||||
|
||||
if (! gimp_draw_tool_is_active (GIMP_DRAW_TOOL (tool)))
|
||||
gimp_draw_tool_start (GIMP_DRAW_TOOL (tool), gdisp);
|
||||
|
||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (tool));
|
||||
|
||||
if (options->align_type == GIMP_TRANSFORM_TYPE_PATH)
|
||||
{
|
||||
GimpVectors *vectors;
|
||||
|
||||
if (gimp_draw_tool_on_vectors (GIMP_DRAW_TOOL (tool), gdisp,
|
||||
coords, 7, 7,
|
||||
NULL, NULL, NULL, NULL, NULL,
|
||||
&vectors))
|
||||
{
|
||||
item = GIMP_ITEM (vectors);
|
||||
}
|
||||
}
|
||||
else if (options->align_type == GIMP_TRANSFORM_TYPE_LAYER)
|
||||
{
|
||||
|
||||
GimpLayer *layer;
|
||||
|
||||
if ((layer = gimp_image_pick_correlate_layer (gdisp->gimage,
|
||||
coords->x,
|
||||
coords->y)))
|
||||
{
|
||||
item = GIMP_ITEM (layer);
|
||||
}
|
||||
}
|
||||
|
||||
if (item)
|
||||
{
|
||||
if (state & GDK_CONTROL_MASK)
|
||||
{
|
||||
if (align_tool->reference_item)
|
||||
g_object_remove_weak_pointer (G_OBJECT (align_tool->reference_item),
|
||||
(gpointer) &align_tool->reference_item);
|
||||
align_tool->reference_item = item;
|
||||
g_object_add_weak_pointer (G_OBJECT (align_tool->reference_item),
|
||||
(gpointer) &align_tool->reference_item);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (align_tool->target_item)
|
||||
g_object_remove_weak_pointer (G_OBJECT (align_tool->target_item),
|
||||
(gpointer) &align_tool->target_item);
|
||||
align_tool->target_item = item;
|
||||
g_object_add_weak_pointer (G_OBJECT (align_tool->target_item),
|
||||
(gpointer) &align_tool->target_item);
|
||||
}
|
||||
}
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (tool));
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_align_tool_cursor_update (GimpTool *tool,
|
||||
GimpCoords *coords,
|
||||
GdkModifierType state,
|
||||
GimpDisplay *gdisp)
|
||||
{
|
||||
GimpAlignOptions *options = GIMP_ALIGN_OPTIONS (tool->tool_info->tool_options);
|
||||
|
||||
GimpCursorType cursor = GIMP_CURSOR_BAD;
|
||||
GimpToolCursorType tool_cursor = GIMP_TOOL_CURSOR_MOVE;
|
||||
GimpCursorModifier modifier = GIMP_CURSOR_MODIFIER_NONE;
|
||||
|
||||
if (options->align_type == GIMP_TRANSFORM_TYPE_PATH)
|
||||
{
|
||||
tool_cursor = GIMP_TOOL_CURSOR_PATHS;
|
||||
modifier = GIMP_CURSOR_MODIFIER_MOVE;
|
||||
|
||||
if (gimp_draw_tool_on_vectors (GIMP_DRAW_TOOL (tool), gdisp,
|
||||
coords, 7, 7,
|
||||
NULL, NULL, NULL, NULL, NULL, NULL))
|
||||
{
|
||||
cursor = GDK_HAND2;
|
||||
tool_cursor = GIMP_TOOL_CURSOR_HAND;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
GimpLayer *layer;
|
||||
|
||||
if ((layer = gimp_image_pick_correlate_layer (gdisp->gimage,
|
||||
coords->x, coords->y)))
|
||||
{
|
||||
/* if there is a floating selection, and this aint it... */
|
||||
if (gimp_image_floating_sel (gdisp->gimage) &&
|
||||
! gimp_layer_is_floating_sel (layer))
|
||||
{
|
||||
cursor = GIMP_CURSOR_MOUSE;
|
||||
tool_cursor = GIMP_TOOL_CURSOR_MOVE;
|
||||
modifier = GIMP_CURSOR_MODIFIER_ANCHOR;
|
||||
}
|
||||
else if (layer == gimp_image_get_active_layer (gdisp->gimage))
|
||||
{
|
||||
cursor = GIMP_CURSOR_MOUSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
cursor = GDK_HAND2;
|
||||
tool_cursor = GIMP_TOOL_CURSOR_HAND;
|
||||
modifier = GIMP_CURSOR_MODIFIER_MOVE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gimp_tool_control_set_cursor (tool->control, cursor);
|
||||
gimp_tool_control_set_tool_cursor (tool->control, tool_cursor);
|
||||
gimp_tool_control_set_cursor_modifier (tool->control, modifier);
|
||||
|
||||
GIMP_TOOL_CLASS (parent_class)->cursor_update (tool, coords, state, gdisp);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_align_tool_draw (GimpDrawTool *draw_tool)
|
||||
{
|
||||
GimpAlignTool *align = GIMP_ALIGN_TOOL (draw_tool);
|
||||
GimpItem *item;
|
||||
|
||||
if ((item = align->target_item))
|
||||
{
|
||||
gimp_draw_tool_draw_rectangle (draw_tool, FALSE,
|
||||
item->offset_x + 1, item->offset_y + 1,
|
||||
item->width - 2, item->height - 2,
|
||||
FALSE);
|
||||
}
|
||||
|
||||
if ((item = align->reference_item))
|
||||
{
|
||||
gimp_draw_tool_draw_rectangle (draw_tool, FALSE,
|
||||
item->offset_x, item->offset_y,
|
||||
item->width, item->height,
|
||||
FALSE);
|
||||
gimp_draw_tool_draw_dashed_line (draw_tool,
|
||||
item->offset_x,
|
||||
item->offset_y,
|
||||
item->offset_x + item->width,
|
||||
item->offset_y + item->height,
|
||||
FALSE);
|
||||
gimp_draw_tool_draw_dashed_line (draw_tool,
|
||||
item->offset_x,
|
||||
item->offset_y + item->height,
|
||||
item->offset_x + item->width,
|
||||
item->offset_y,
|
||||
FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static GtkWidget *
|
||||
gimp_align_tool_controls (GimpAlignTool *align_tool)
|
||||
{
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *label;
|
||||
GtkWidget *button;
|
||||
GtkWidget *spinbutton;
|
||||
gint row, col;
|
||||
|
||||
hbox = gtk_hbox_new (FALSE, 0);
|
||||
|
||||
main_vbox = gtk_vbox_new (FALSE, 4);
|
||||
gtk_box_pack_start (GTK_BOX (hbox), main_vbox, FALSE, FALSE, 0);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 4);
|
||||
gtk_widget_show (main_vbox);
|
||||
|
||||
label = gtk_label_new (_("Ctrl-click to select reference."));
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
label = gtk_label_new (_("Click to select target."));
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
table = gtk_table_new (7, 9, FALSE);
|
||||
gtk_box_pack_start (GTK_BOX (main_vbox), table, FALSE, FALSE, 10);
|
||||
gtk_widget_show (table);
|
||||
|
||||
gtk_table_set_row_spacings (GTK_TABLE (table), 10);
|
||||
|
||||
row = col = 0;
|
||||
|
||||
/* Top row */
|
||||
label = gtk_label_new (_("Horizontal"));
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 4, row, row + 1);
|
||||
gtk_widget_show (label);
|
||||
|
||||
row++;
|
||||
|
||||
/* second row */
|
||||
|
||||
col = 0;
|
||||
|
||||
button = button_with_stock (GIMP_ALIGN_LEFT, align_tool);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), button, col, col + 2, row, row + 1);
|
||||
gimp_help_set_help_data (button, _("Align left edge of target"), NULL);
|
||||
++col;
|
||||
++col;
|
||||
|
||||
button = button_with_stock (GIMP_ALIGN_CENTER, align_tool);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), button, col, col + 2, row, row + 1);
|
||||
gimp_help_set_help_data (button, _("Align center of target"), NULL);
|
||||
++col;
|
||||
++col;
|
||||
|
||||
button = button_with_stock (GIMP_ALIGN_RIGHT, align_tool);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), button, col, col + 2, row, row + 1);
|
||||
gimp_help_set_help_data (button, _("Align right edge of target"), NULL);
|
||||
++col;
|
||||
++col;
|
||||
|
||||
row++;
|
||||
|
||||
/* next row */
|
||||
label = gtk_label_new (_("Offset"));
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 3, row, row + 1);
|
||||
gtk_widget_show (label);
|
||||
|
||||
spinbutton = gimp_spin_button_new (&align_tool->horz_offset_adjustment,
|
||||
0,
|
||||
-100000.,
|
||||
100000.,
|
||||
1., 20., 20., 1., 0);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), spinbutton, 3, 7, row, row + 1);
|
||||
g_signal_connect (align_tool->horz_offset_adjustment, "value-changed",
|
||||
G_CALLBACK (gimp_double_adjustment_update),
|
||||
&align_tool->horz_offset);
|
||||
gtk_widget_show (spinbutton);
|
||||
|
||||
row++;
|
||||
|
||||
label = gtk_label_new (_("Vertical"));
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 4, row, row + 1);
|
||||
gtk_widget_show (label);
|
||||
|
||||
row++;
|
||||
|
||||
/* second row */
|
||||
|
||||
col = 0;
|
||||
|
||||
button = button_with_stock (GIMP_ALIGN_TOP, align_tool);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), button, col, col + 2, row, row + 1);
|
||||
gimp_help_set_help_data (button, _("Align top edge of target"), NULL);
|
||||
++col;
|
||||
++col;
|
||||
|
||||
button = button_with_stock (GIMP_ALIGN_MIDDLE, align_tool);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), button, col, col + 2, row, row + 1);
|
||||
gimp_help_set_help_data (button, _("Align middle of target"), NULL);
|
||||
++col;
|
||||
++col;
|
||||
|
||||
button = button_with_stock (GIMP_ALIGN_BOTTOM, align_tool);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), button, col, col + 2, row, row + 1);
|
||||
gimp_help_set_help_data (button, _("Align bottom of target"), NULL);
|
||||
++col;
|
||||
++col;
|
||||
|
||||
row++;
|
||||
|
||||
/* next row */
|
||||
label = gtk_label_new (_("Offset"));
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), label, 0, 3, row, row + 1);
|
||||
gtk_widget_show (label);
|
||||
|
||||
spinbutton = gimp_spin_button_new (&align_tool->vert_offset_adjustment,
|
||||
0,
|
||||
-100000.,
|
||||
100000.,
|
||||
1., 20., 20., 1., 0);
|
||||
gtk_table_attach_defaults (GTK_TABLE (table), spinbutton, 3, 7, row, row + 1);
|
||||
g_signal_connect (align_tool->vert_offset_adjustment, "value-changed",
|
||||
G_CALLBACK (gimp_double_adjustment_update),
|
||||
&align_tool->vert_offset);
|
||||
gtk_widget_show (spinbutton);
|
||||
|
||||
gtk_widget_show (hbox);
|
||||
return hbox;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
do_horizontal_alignment (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpAlignTool *align_tool = data;
|
||||
|
||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (align_tool));
|
||||
|
||||
if (align_tool->target_item)
|
||||
gimp_item_align (align_tool->target_item,
|
||||
align_tool->target_horz_align_type,
|
||||
align_tool->reference_item,
|
||||
align_tool->ref_horz_align_type,
|
||||
align_tool->horz_offset,
|
||||
TRUE);
|
||||
|
||||
gimp_image_flush (GIMP_TOOL (align_tool)->gdisp->gimage);
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (align_tool));
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
do_vertical_alignment (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpAlignTool *align_tool = data;
|
||||
|
||||
gimp_draw_tool_pause (GIMP_DRAW_TOOL (align_tool));
|
||||
|
||||
if (align_tool->target_item)
|
||||
gimp_item_align (align_tool->target_item,
|
||||
align_tool->target_vert_align_type,
|
||||
align_tool->reference_item,
|
||||
align_tool->ref_vert_align_type,
|
||||
align_tool->vert_offset,
|
||||
TRUE);
|
||||
|
||||
gimp_image_flush (GIMP_TOOL (align_tool)->gdisp->gimage);
|
||||
|
||||
gimp_draw_tool_resume (GIMP_DRAW_TOOL (align_tool));
|
||||
}
|
||||
|
||||
|
||||
|
||||
static GtkWidget *
|
||||
button_with_stock (GimpAlignmentType action,
|
||||
GimpAlignTool *align_tool)
|
||||
{
|
||||
GtkWidget *button;
|
||||
gchar *stock_id;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case GIMP_ALIGN_LEFT:
|
||||
stock_id = GIMP_STOCK_GRAVITY_WEST;
|
||||
break;
|
||||
case GIMP_ALIGN_CENTER:
|
||||
stock_id = GIMP_STOCK_HCENTER;
|
||||
break;
|
||||
case GIMP_ALIGN_RIGHT:
|
||||
stock_id = GIMP_STOCK_GRAVITY_EAST;
|
||||
break;
|
||||
case GIMP_ALIGN_TOP:
|
||||
stock_id = GIMP_STOCK_GRAVITY_NORTH;
|
||||
break;
|
||||
case GIMP_ALIGN_MIDDLE:
|
||||
stock_id = GIMP_STOCK_VCENTER;
|
||||
break;
|
||||
case GIMP_ALIGN_BOTTOM:
|
||||
stock_id = GIMP_STOCK_GRAVITY_SOUTH;
|
||||
break;
|
||||
default:
|
||||
stock_id = "?";
|
||||
break;
|
||||
}
|
||||
|
||||
button = gtk_button_new_from_stock (stock_id);
|
||||
|
||||
g_object_set_data (G_OBJECT (button), "action", GINT_TO_POINTER (action));
|
||||
|
||||
g_signal_connect (button, "pressed",
|
||||
G_CALLBACK (set_action),
|
||||
align_tool);
|
||||
|
||||
|
||||
gtk_widget_show (button);
|
||||
|
||||
return button;
|
||||
}
|
||||
|
||||
static void
|
||||
set_action (GtkWidget *widget,
|
||||
gpointer data)
|
||||
{
|
||||
GimpAlignTool *align_tool = data;
|
||||
GimpAlignmentType action;
|
||||
|
||||
action = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (widget), "action"));
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case GIMP_ALIGN_LEFT:
|
||||
case GIMP_ALIGN_CENTER:
|
||||
case GIMP_ALIGN_RIGHT:
|
||||
align_tool->ref_horz_align_type = action;
|
||||
align_tool->target_horz_align_type = action;
|
||||
do_horizontal_alignment (widget, data);
|
||||
break;
|
||||
case GIMP_ALIGN_TOP:
|
||||
case GIMP_ALIGN_MIDDLE:
|
||||
case GIMP_ALIGN_BOTTOM:
|
||||
align_tool->ref_vert_align_type = action;
|
||||
align_tool->target_vert_align_type = action;
|
||||
do_vertical_alignment (widget, data);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
71
app/tools/gimpaligntool.h
Normal file
71
app/tools/gimpaligntool.h
Normal file
@ -0,0 +1,71 @@
|
||||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (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
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_ALIGN_TOOL_H__
|
||||
#define __GIMP_ALIGN_TOOL_H__
|
||||
|
||||
|
||||
#include "gimpdrawtool.h"
|
||||
|
||||
|
||||
#define GIMP_TYPE_ALIGN_TOOL (gimp_align_tool_get_type ())
|
||||
#define GIMP_ALIGN_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_ALIGN_TOOL, GimpAlignTool))
|
||||
#define GIMP_ALIGN_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_ALIGN_TOOL, GimpAlignToolClass))
|
||||
#define GIMP_IS_ALIGN_TOOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_ALIGN_TOOL))
|
||||
#define GIMP_IS_ALIGN_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_ALIGN_TOOL))
|
||||
#define GIMP_ALIGN_TOOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_ALIGN_TOOL, GimpAlignToolClass))
|
||||
|
||||
|
||||
typedef struct _GimpAlignTool GimpAlignTool;
|
||||
typedef struct _GimpAlignToolClass GimpAlignToolClass;
|
||||
|
||||
struct _GimpAlignTool
|
||||
{
|
||||
GimpDrawTool parent_instance;
|
||||
|
||||
GtkWidget *controls;
|
||||
|
||||
GimpItem *target_item;
|
||||
GimpItem *reference_item;
|
||||
|
||||
GimpAlignmentType target_horz_align_type;
|
||||
GimpAlignmentType target_vert_align_type;
|
||||
GimpAlignmentType ref_horz_align_type;
|
||||
GimpAlignmentType ref_vert_align_type;
|
||||
|
||||
gdouble horz_offset;
|
||||
gdouble vert_offset;
|
||||
|
||||
GtkObject *horz_offset_adjustment;
|
||||
GtkObject *vert_offset_adjustment;
|
||||
|
||||
};
|
||||
|
||||
struct _GimpAlignToolClass
|
||||
{
|
||||
GimpDrawToolClass parent_class;
|
||||
};
|
||||
|
||||
|
||||
void gimp_align_tool_register (GimpToolRegisterCallback callback,
|
||||
gpointer data);
|
||||
|
||||
GType gimp_align_tool_get_type (void) G_GNUC_CONST;
|
||||
|
||||
|
||||
#endif /* __GIMP_ALIGN_TOOL_H__ */
|
@ -141,6 +141,9 @@ static GtkStockItem gimp_stock_items[] =
|
||||
{ GIMP_STOCK_GRAVITY_SOUTH_WEST, NULL, 0, 0, LIBGIMP_DOMAIN },
|
||||
{ GIMP_STOCK_GRAVITY_WEST, NULL, 0, 0, LIBGIMP_DOMAIN },
|
||||
|
||||
{ GIMP_STOCK_HCENTER, NULL, 0, 0, LIBGIMP_DOMAIN },
|
||||
{ GIMP_STOCK_VCENTER, NULL, 0, 0, LIBGIMP_DOMAIN },
|
||||
|
||||
{ GIMP_STOCK_HCHAIN, NULL, 0, 0, LIBGIMP_DOMAIN },
|
||||
{ GIMP_STOCK_HCHAIN_BROKEN, NULL, 0, 0, LIBGIMP_DOMAIN },
|
||||
{ GIMP_STOCK_VCHAIN, NULL, 0, 0, LIBGIMP_DOMAIN },
|
||||
@ -323,6 +326,9 @@ gimp_stock_button_pixbufs[] =
|
||||
{ GIMP_STOCK_GRAVITY_SOUTH_WEST, stock_gravity_south_west_24 },
|
||||
{ GIMP_STOCK_GRAVITY_WEST, stock_gravity_west_24 },
|
||||
|
||||
{ GIMP_STOCK_HCENTER, stock_hcenter_24 },
|
||||
{ GIMP_STOCK_VCENTER, stock_vcenter_24 },
|
||||
|
||||
{ GIMP_STOCK_HCHAIN, stock_hchain_24 },
|
||||
{ GIMP_STOCK_HCHAIN_BROKEN, stock_hchain_broken_24 },
|
||||
{ GIMP_STOCK_VCHAIN, stock_vchain_24 },
|
||||
|
@ -62,6 +62,9 @@ G_BEGIN_DECLS
|
||||
#define GIMP_STOCK_GRAVITY_SOUTH_WEST "gimp-gravity-south-west"
|
||||
#define GIMP_STOCK_GRAVITY_WEST "gimp-gravity-west"
|
||||
|
||||
#define GIMP_STOCK_HCENTER "gimp-hcenter"
|
||||
#define GIMP_STOCK_VCENTER "gimp-vcenter"
|
||||
|
||||
#define GIMP_STOCK_HCHAIN "gimp-hchain"
|
||||
#define GIMP_STOCK_HCHAIN_BROKEN "gimp-hchain-broken"
|
||||
#define GIMP_STOCK_VCHAIN "gimp-vchain"
|
||||
|
@ -161,6 +161,7 @@ STOCK_BUTTON_IMAGES = \
|
||||
stock-gravity-south-east-24.png \
|
||||
stock-gravity-south-west-24.png \
|
||||
stock-gravity-west-24.png \
|
||||
stock-hcenter-24.png \
|
||||
stock-hchain-24.png \
|
||||
stock-hchain-broken-24.png \
|
||||
stock-histogram-22.png \
|
||||
@ -199,6 +200,7 @@ STOCK_BUTTON_IMAGES = \
|
||||
stock-tool-options-24.png \
|
||||
stock-tools-24.png \
|
||||
stock-transparency-24.png \
|
||||
stock-vcenter-24.png \
|
||||
stock-vchain-24.png \
|
||||
stock-vchain-broken-24.png \
|
||||
stock-video-24.png \
|
||||
|
@ -89,6 +89,7 @@ STOCK_VARIABLES = \
|
||||
stock_gravity_south_west_24 stock-gravity-south-west-24.png \
|
||||
stock_gravity_west_24 stock-gravity-west-24.png \
|
||||
stock_grid_16 stock-grid-16.png \
|
||||
stock_hcenter_24 stock-hcenter-24.png \
|
||||
stock_histogram_16 stock-histogram-16.png \
|
||||
stock_histogram_22 stock-histogram-22.png \
|
||||
stock_histogram_linear_16 stock-histogram-linear-16.png \
|
||||
@ -192,6 +193,7 @@ STOCK_VARIABLES = \
|
||||
stock_transparency_24 stock-transparency-24.png \
|
||||
stock_undo_history_16 stock-undo-history-16.png \
|
||||
stock_undo_history_24 stock-undo-history-24.png \
|
||||
stock_vcenter_24 stock-vcenter-24.png \
|
||||
stock_vchain_24 stock-vchain-24.png \
|
||||
stock_vchain_broken_24 stock-vchain-broken-24.png \
|
||||
stock_video_16 stock-video-16.png \
|
||||
|
BIN
themes/Default/images/stock-hcenter-24.png
Normal file
BIN
themes/Default/images/stock-hcenter-24.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 762 B |
BIN
themes/Default/images/stock-vcenter-24.png
Normal file
BIN
themes/Default/images/stock-vcenter-24.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 688 B |
Reference in New Issue
Block a user