New upstream version 2.10.20

This commit is contained in:
Simon McVittie
2020-08-26 11:05:56 +01:00
794 changed files with 93349 additions and 84053 deletions

View File

@ -60,6 +60,8 @@ libappdisplay_a_sources = \
gimpcanvasitem-utils.h \
gimpcanvaslayerboundary.c \
gimpcanvaslayerboundary.h \
gimpcanvaslimit.c \
gimpcanvaslimit.h \
gimpcanvasline.c \
gimpcanvasline.h \
gimpcanvaspassepartout.c \
@ -180,6 +182,8 @@ libappdisplay_a_sources = \
gimptoolgui.h \
gimptoolcompass.c \
gimptoolcompass.h \
gimptoolfocus.h \
gimptoolfocus.c \
gimptoolgyroscope.c \
gimptoolgyroscope.h \
gimptoolhandlegrid.c \

View File

@ -1,7 +1,7 @@
# Makefile.in generated by automake 1.16.1 from Makefile.am.
# Makefile.in generated by automake 1.16.2 from Makefile.am.
# @configure_input@
# Copyright (C) 1994-2018 Free Software Foundation, Inc.
# Copyright (C) 1994-2020 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@ -90,8 +90,14 @@ build_triplet = @build@
host_triplet = @host@
subdir = app/display
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/m4macros/alsa.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4macros/gtk-doc.m4 \
$(top_srcdir)/m4macros/intltool.m4 \
$(top_srcdir)/m4macros/libtool.m4 \
$(top_srcdir)/m4macros/ltoptions.m4 \
$(top_srcdir)/m4macros/ltsugar.m4 \
$(top_srcdir)/m4macros/ltversion.m4 \
$(top_srcdir)/m4macros/lt~obsolete.m4 \
$(top_srcdir)/acinclude.m4 $(top_srcdir)/m4macros/alsa.m4 \
$(top_srcdir)/m4macros/ax_compare_version.m4 \
$(top_srcdir)/m4macros/ax_cxx_compile_stdcxx.m4 \
$(top_srcdir)/m4macros/ax_gcc_func_attribute.m4 \
@ -123,11 +129,11 @@ am__objects_2 = gimpcanvas.$(OBJEXT) gimpcanvas-style.$(OBJEXT) \
gimpcanvasgroup.$(OBJEXT) gimpcanvasguide.$(OBJEXT) \
gimpcanvashandle.$(OBJEXT) gimpcanvasitem.$(OBJEXT) \
gimpcanvasitem-utils.$(OBJEXT) \
gimpcanvaslayerboundary.$(OBJEXT) gimpcanvasline.$(OBJEXT) \
gimpcanvaspassepartout.$(OBJEXT) gimpcanvaspath.$(OBJEXT) \
gimpcanvaspen.$(OBJEXT) gimpcanvaspolygon.$(OBJEXT) \
gimpcanvasprogress.$(OBJEXT) gimpcanvasproxygroup.$(OBJEXT) \
gimpcanvasrectangle.$(OBJEXT) \
gimpcanvaslayerboundary.$(OBJEXT) gimpcanvaslimit.$(OBJEXT) \
gimpcanvasline.$(OBJEXT) gimpcanvaspassepartout.$(OBJEXT) \
gimpcanvaspath.$(OBJEXT) gimpcanvaspen.$(OBJEXT) \
gimpcanvaspolygon.$(OBJEXT) gimpcanvasprogress.$(OBJEXT) \
gimpcanvasproxygroup.$(OBJEXT) gimpcanvasrectangle.$(OBJEXT) \
gimpcanvasrectangleguides.$(OBJEXT) \
gimpcanvassamplepoint.$(OBJEXT) gimpcanvastextcursor.$(OBJEXT) \
gimpcanvastransformguides.$(OBJEXT) \
@ -169,11 +175,12 @@ am__objects_2 = gimpcanvas.$(OBJEXT) gimpcanvas-style.$(OBJEXT) \
gimpnavigationeditor.$(OBJEXT) gimpscalecombobox.$(OBJEXT) \
gimpsinglewindowstrategy.$(OBJEXT) gimpstatusbar.$(OBJEXT) \
gimptooldialog.$(OBJEXT) gimptoolgui.$(OBJEXT) \
gimptoolcompass.$(OBJEXT) gimptoolgyroscope.$(OBJEXT) \
gimptoolhandlegrid.$(OBJEXT) gimptoolline.$(OBJEXT) \
gimptoolpath.$(OBJEXT) gimptoolpolygon.$(OBJEXT) \
gimptoolrectangle.$(OBJEXT) gimptoolrotategrid.$(OBJEXT) \
gimptoolsheargrid.$(OBJEXT) gimptooltransform3dgrid.$(OBJEXT) \
gimptoolcompass.$(OBJEXT) gimptoolfocus.$(OBJEXT) \
gimptoolgyroscope.$(OBJEXT) gimptoolhandlegrid.$(OBJEXT) \
gimptoolline.$(OBJEXT) gimptoolpath.$(OBJEXT) \
gimptoolpolygon.$(OBJEXT) gimptoolrectangle.$(OBJEXT) \
gimptoolrotategrid.$(OBJEXT) gimptoolsheargrid.$(OBJEXT) \
gimptooltransform3dgrid.$(OBJEXT) \
gimptooltransformgrid.$(OBJEXT) gimptoolwidget.$(OBJEXT) \
gimptoolwidgetgroup.$(OBJEXT)
am_libappdisplay_a_OBJECTS = $(am__objects_1) $(am__objects_2)
@ -205,7 +212,7 @@ am__depfiles_remade = ./$(DEPDIR)/display-enums.Po \
./$(DEPDIR)/gimpcanvasitem-utils.Po \
./$(DEPDIR)/gimpcanvasitem.Po \
./$(DEPDIR)/gimpcanvaslayerboundary.Po \
./$(DEPDIR)/gimpcanvasline.Po \
./$(DEPDIR)/gimpcanvaslimit.Po ./$(DEPDIR)/gimpcanvasline.Po \
./$(DEPDIR)/gimpcanvaspassepartout.Po \
./$(DEPDIR)/gimpcanvaspath.Po ./$(DEPDIR)/gimpcanvaspen.Po \
./$(DEPDIR)/gimpcanvaspolygon.Po \
@ -258,8 +265,8 @@ am__depfiles_remade = ./$(DEPDIR)/display-enums.Po \
./$(DEPDIR)/gimpscalecombobox.Po \
./$(DEPDIR)/gimpsinglewindowstrategy.Po \
./$(DEPDIR)/gimpstatusbar.Po ./$(DEPDIR)/gimptoolcompass.Po \
./$(DEPDIR)/gimptooldialog.Po ./$(DEPDIR)/gimptoolgui.Po \
./$(DEPDIR)/gimptoolgyroscope.Po \
./$(DEPDIR)/gimptooldialog.Po ./$(DEPDIR)/gimptoolfocus.Po \
./$(DEPDIR)/gimptoolgui.Po ./$(DEPDIR)/gimptoolgyroscope.Po \
./$(DEPDIR)/gimptoolhandlegrid.Po ./$(DEPDIR)/gimptoolline.Po \
./$(DEPDIR)/gimptoolpath.Po ./$(DEPDIR)/gimptoolpolygon.Po \
./$(DEPDIR)/gimptoolrectangle.Po \
@ -451,8 +458,6 @@ GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
GLIB_LIBS = @GLIB_LIBS@
GLIB_MKENUMS = @GLIB_MKENUMS@
GLIB_REQUIRED_VERSION = @GLIB_REQUIRED_VERSION@
GLIB_WIN_BUG_CFLAGS = @GLIB_WIN_BUG_CFLAGS@
GLIB_WIN_BUG_LIBS = @GLIB_WIN_BUG_LIBS@
GMODULE_NO_EXPORT_CFLAGS = @GMODULE_NO_EXPORT_CFLAGS@
GMODULE_NO_EXPORT_LIBS = @GMODULE_NO_EXPORT_LIBS@
GMOFILES = @GMOFILES@
@ -790,6 +795,8 @@ libappdisplay_a_sources = \
gimpcanvasitem-utils.h \
gimpcanvaslayerboundary.c \
gimpcanvaslayerboundary.h \
gimpcanvaslimit.c \
gimpcanvaslimit.h \
gimpcanvasline.c \
gimpcanvasline.h \
gimpcanvaspassepartout.c \
@ -910,6 +917,8 @@ libappdisplay_a_sources = \
gimptoolgui.h \
gimptoolcompass.c \
gimptoolcompass.h \
gimptoolfocus.h \
gimptoolfocus.c \
gimptoolgyroscope.c \
gimptoolgyroscope.h \
gimptoolhandlegrid.c \
@ -1011,6 +1020,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimpcanvasitem-utils.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimpcanvasitem.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimpcanvaslayerboundary.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimpcanvaslimit.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimpcanvasline.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimpcanvaspassepartout.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimpcanvaspath.Po@am__quote@ # am--include-marker
@ -1070,6 +1080,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimpstatusbar.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimptoolcompass.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimptooldialog.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimptoolfocus.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimptoolgui.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimptoolgyroscope.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gimptoolhandlegrid.Po@am__quote@ # am--include-marker
@ -1259,6 +1270,7 @@ distclean: distclean-am
-rm -f ./$(DEPDIR)/gimpcanvasitem-utils.Po
-rm -f ./$(DEPDIR)/gimpcanvasitem.Po
-rm -f ./$(DEPDIR)/gimpcanvaslayerboundary.Po
-rm -f ./$(DEPDIR)/gimpcanvaslimit.Po
-rm -f ./$(DEPDIR)/gimpcanvasline.Po
-rm -f ./$(DEPDIR)/gimpcanvaspassepartout.Po
-rm -f ./$(DEPDIR)/gimpcanvaspath.Po
@ -1318,6 +1330,7 @@ distclean: distclean-am
-rm -f ./$(DEPDIR)/gimpstatusbar.Po
-rm -f ./$(DEPDIR)/gimptoolcompass.Po
-rm -f ./$(DEPDIR)/gimptooldialog.Po
-rm -f ./$(DEPDIR)/gimptoolfocus.Po
-rm -f ./$(DEPDIR)/gimptoolgui.Po
-rm -f ./$(DEPDIR)/gimptoolgyroscope.Po
-rm -f ./$(DEPDIR)/gimptoolhandlegrid.Po
@ -1392,6 +1405,7 @@ maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/gimpcanvasitem-utils.Po
-rm -f ./$(DEPDIR)/gimpcanvasitem.Po
-rm -f ./$(DEPDIR)/gimpcanvaslayerboundary.Po
-rm -f ./$(DEPDIR)/gimpcanvaslimit.Po
-rm -f ./$(DEPDIR)/gimpcanvasline.Po
-rm -f ./$(DEPDIR)/gimpcanvaspassepartout.Po
-rm -f ./$(DEPDIR)/gimpcanvaspath.Po
@ -1451,6 +1465,7 @@ maintainer-clean: maintainer-clean-am
-rm -f ./$(DEPDIR)/gimpstatusbar.Po
-rm -f ./$(DEPDIR)/gimptoolcompass.Po
-rm -f ./$(DEPDIR)/gimptooldialog.Po
-rm -f ./$(DEPDIR)/gimptoolfocus.Po
-rm -f ./$(DEPDIR)/gimptoolgui.Po
-rm -f ./$(DEPDIR)/gimptoolgyroscope.Po
-rm -f ./$(DEPDIR)/gimptoolhandlegrid.Po

View File

@ -265,6 +265,41 @@ gimp_handle_anchor_get_type (void)
return type;
}
GType
gimp_limit_type_get_type (void)
{
static const GEnumValue values[] =
{
{ GIMP_LIMIT_CIRCLE, "GIMP_LIMIT_CIRCLE", "circle" },
{ GIMP_LIMIT_SQUARE, "GIMP_LIMIT_SQUARE", "square" },
{ GIMP_LIMIT_DIAMOND, "GIMP_LIMIT_DIAMOND", "diamond" },
{ GIMP_LIMIT_HORIZONTAL, "GIMP_LIMIT_HORIZONTAL", "horizontal" },
{ GIMP_LIMIT_VERTICAL, "GIMP_LIMIT_VERTICAL", "vertical" },
{ 0, NULL, NULL }
};
static const GimpEnumDesc descs[] =
{
{ GIMP_LIMIT_CIRCLE, "GIMP_LIMIT_CIRCLE", NULL },
{ GIMP_LIMIT_SQUARE, "GIMP_LIMIT_SQUARE", NULL },
{ GIMP_LIMIT_DIAMOND, "GIMP_LIMIT_DIAMOND", NULL },
{ GIMP_LIMIT_HORIZONTAL, "GIMP_LIMIT_HORIZONTAL", NULL },
{ GIMP_LIMIT_VERTICAL, "GIMP_LIMIT_VERTICAL", NULL },
{ 0, NULL, NULL }
};
static GType type = 0;
if (G_UNLIKELY (! type))
{
type = g_enum_register_static ("GimpLimitType", values);
gimp_type_set_translation_context (type, "limit-type");
gimp_enum_set_value_descriptions (type, descs);
}
return type;
}
GType
gimp_path_style_get_type (void)
{

View File

@ -123,6 +123,20 @@ typedef enum
} GimpHandleAnchor;
#define GIMP_TYPE_LIMIT_TYPE (gimp_limit_type_get_type ())
GType gimp_limit_type_get_type (void) G_GNUC_CONST;
typedef enum
{
GIMP_LIMIT_CIRCLE,
GIMP_LIMIT_SQUARE,
GIMP_LIMIT_DIAMOND,
GIMP_LIMIT_HORIZONTAL,
GIMP_LIMIT_VERTICAL
} GimpLimitType;
#define GIMP_TYPE_PATH_STYLE (gimp_path_style_get_type ())
GType gimp_path_style_get_type (void) G_GNUC_CONST;

View File

@ -0,0 +1,760 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvaslimit.c
* Copyright (C) 2020 Ell
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "display-types.h"
#include "core/gimp-cairo.h"
#include "gimpcanvaslimit.h"
#include "gimpdisplayshell.h"
#define DASH_LENGTH 4.0
#define HIT_DISTANCE 16.0
enum
{
PROP_0,
PROP_TYPE,
PROP_X,
PROP_Y,
PROP_RADIUS,
PROP_ASPECT_RATIO,
PROP_ANGLE,
PROP_DASHED
};
typedef struct _GimpCanvasLimitPrivate GimpCanvasLimitPrivate;
struct _GimpCanvasLimitPrivate
{
GimpLimitType type;
gdouble x;
gdouble y;
gdouble radius;
gdouble aspect_ratio;
gdouble angle;
gboolean dashed;
};
#define GET_PRIVATE(limit) \
((GimpCanvasLimitPrivate *) gimp_canvas_limit_get_instance_private ((GimpCanvasLimit *) (limit)))
/* local function prototypes */
static void gimp_canvas_limit_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_canvas_limit_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec);
static void gimp_canvas_limit_draw (GimpCanvasItem *item,
cairo_t *cr);
static cairo_region_t * gimp_canvas_limit_get_extents (GimpCanvasItem *item);
static gboolean gimp_canvas_limit_hit (GimpCanvasItem *item,
gdouble x,
gdouble y);
G_DEFINE_TYPE_WITH_PRIVATE (GimpCanvasLimit, gimp_canvas_limit,
GIMP_TYPE_CANVAS_ITEM)
#define parent_class gimp_canvas_limit_parent_class
/* private functions */
static void
gimp_canvas_limit_class_init (GimpCanvasLimitClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpCanvasItemClass *item_class = GIMP_CANVAS_ITEM_CLASS (klass);
object_class->set_property = gimp_canvas_limit_set_property;
object_class->get_property = gimp_canvas_limit_get_property;
item_class->draw = gimp_canvas_limit_draw;
item_class->get_extents = gimp_canvas_limit_get_extents;
item_class->hit = gimp_canvas_limit_hit;
g_object_class_install_property (object_class, PROP_TYPE,
g_param_spec_enum ("type", NULL, NULL,
GIMP_TYPE_LIMIT_TYPE,
GIMP_LIMIT_CIRCLE,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_X,
g_param_spec_double ("x", NULL, NULL,
-G_MAXDOUBLE,
+G_MAXDOUBLE,
0.0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_Y,
g_param_spec_double ("y", NULL, NULL,
-G_MAXDOUBLE,
+G_MAXDOUBLE,
0.0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_RADIUS,
g_param_spec_double ("radius", NULL, NULL,
0.0,
+G_MAXDOUBLE,
0.0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_ASPECT_RATIO,
g_param_spec_double ("aspect-ratio", NULL, NULL,
-1.0,
+1.0,
0.0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_ANGLE,
g_param_spec_double ("angle", NULL, NULL,
-G_MAXDOUBLE,
+G_MAXDOUBLE,
0.0,
GIMP_PARAM_READWRITE));
g_object_class_install_property (object_class, PROP_DASHED,
g_param_spec_boolean ("dashed", NULL, NULL,
FALSE,
GIMP_PARAM_READWRITE));
}
static void
gimp_canvas_limit_init (GimpCanvasLimit *limit)
{
}
static void
gimp_canvas_limit_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpCanvasLimitPrivate *priv = GET_PRIVATE (object);
switch (property_id)
{
case PROP_TYPE:
priv->type = g_value_get_enum (value);
break;
case PROP_X:
priv->x = g_value_get_double (value);
break;
case PROP_Y:
priv->y = g_value_get_double (value);
break;
case PROP_RADIUS:
priv->radius = g_value_get_double (value);
break;
case PROP_ASPECT_RATIO:
priv->aspect_ratio = g_value_get_double (value);
break;
case PROP_ANGLE:
priv->angle = g_value_get_double (value);
break;
case PROP_DASHED:
priv->dashed = g_value_get_boolean (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_limit_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
GimpCanvasLimitPrivate *priv = GET_PRIVATE (object);
switch (property_id)
{
case PROP_TYPE:
g_value_set_enum (value, priv->type);
break;
case PROP_X:
g_value_set_double (value, priv->x);
break;
case PROP_Y:
g_value_set_double (value, priv->y);
break;
case PROP_RADIUS:
g_value_set_double (value, priv->radius);
break;
case PROP_ASPECT_RATIO:
g_value_set_double (value, priv->aspect_ratio);
break;
case PROP_ANGLE:
g_value_set_double (value, priv->angle);
break;
case PROP_DASHED:
g_value_set_boolean (value, priv->dashed);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_canvas_limit_transform (GimpCanvasItem *item,
gdouble *x,
gdouble *y,
gdouble *rx,
gdouble *ry)
{
GimpCanvasLimit *limit = GIMP_CANVAS_LIMIT (item);
GimpCanvasLimitPrivate *priv = GET_PRIVATE (item);
gdouble x1, y1;
gdouble x2, y2;
gdouble min_radius = 0.0;
gimp_canvas_limit_get_radii (limit, rx, ry);
gimp_canvas_item_transform_xy_f (item,
priv->x - *rx, priv->y - *ry,
&x1, &y1);
gimp_canvas_item_transform_xy_f (item,
priv->x + *rx, priv->y + *ry,
&x2, &y2);
x1 = floor (x1) + 0.5;
y1 = floor (y1) + 0.5;
x2 = floor (x2) + 0.5;
y2 = floor (y2) + 0.5;
*x = (x1 + x2) / 2.0;
*y = (y1 + y2) / 2.0;
*rx = (x2 - x1) / 2.0;
*ry = (y2 - y1) / 2.0;
switch (priv->type)
{
case GIMP_LIMIT_CIRCLE:
case GIMP_LIMIT_SQUARE:
min_radius = 2.0;
break;
case GIMP_LIMIT_DIAMOND:
min_radius = 3.0;
break;
case GIMP_LIMIT_HORIZONTAL:
case GIMP_LIMIT_VERTICAL:
min_radius = 1.0;
break;
}
*rx = MAX (*rx, min_radius);
*ry = MAX (*ry, min_radius);
}
static void
gimp_canvas_limit_paint (GimpCanvasItem *item,
cairo_t *cr)
{
GimpCanvasLimitPrivate *priv = GET_PRIVATE (item);
GimpDisplayShell *shell = gimp_canvas_item_get_shell (item);
gdouble x, y;
gdouble rx, ry;
gdouble inf;
gimp_canvas_limit_transform (item,
&x, &y,
&rx, &ry);
cairo_save (cr);
cairo_translate (cr, x, y);
cairo_rotate (cr, priv->angle);
cairo_scale (cr, rx, ry);
inf = MAX (x, shell->disp_width - x) +
MAX (y, shell->disp_height - y);
switch (priv->type)
{
case GIMP_LIMIT_CIRCLE:
cairo_arc (cr, 0.0, 0.0, 1.0, 0.0, 2.0 * G_PI);
break;
case GIMP_LIMIT_SQUARE:
cairo_rectangle (cr, -1.0, -1.0, 2.0, 2.0);
break;
case GIMP_LIMIT_DIAMOND:
cairo_move_to (cr, 0.0, -1.0);
cairo_line_to (cr, +1.0, 0.0);
cairo_line_to (cr, 0.0, +1.0);
cairo_line_to (cr, -1.0, 0.0);
cairo_close_path (cr);
break;
case GIMP_LIMIT_HORIZONTAL:
cairo_move_to (cr, -inf / rx, -1.0);
cairo_line_to (cr, +inf / rx, -1.0);
cairo_move_to (cr, -inf / rx, +1.0);
cairo_line_to (cr, +inf / rx, +1.0);
break;
case GIMP_LIMIT_VERTICAL:
cairo_move_to (cr, -1.0, -inf / ry);
cairo_line_to (cr, -1.0, +inf / ry);
cairo_move_to (cr, +1.0, -inf / ry);
cairo_line_to (cr, +1.0, +inf / ry);
break;
}
cairo_restore (cr);
}
static void
gimp_canvas_limit_draw (GimpCanvasItem *item,
cairo_t *cr)
{
GimpCanvasLimitPrivate *priv = GET_PRIVATE (item);
gimp_canvas_limit_paint (item, cr);
cairo_save (cr);
if (priv->dashed)
cairo_set_dash (cr, (const gdouble[]) {DASH_LENGTH}, 1, 0.0);
_gimp_canvas_item_stroke (item, cr);
cairo_restore (cr);
}
static cairo_region_t *
gimp_canvas_limit_get_extents (GimpCanvasItem *item)
{
cairo_t *cr;
cairo_surface_t *surface;
cairo_rectangle_int_t rectangle;
gdouble x1, y1;
gdouble x2, y2;
surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, 1, 1);
cr = cairo_create (surface);
gimp_canvas_limit_paint (item, cr);
cairo_path_extents (cr,
&x1, &y1,
&x2, &y2);
cairo_destroy (cr);
cairo_surface_destroy (surface);
rectangle.x = floor (x1 - 1.5);
rectangle.y = floor (y1 - 1.5);
rectangle.width = ceil (x2 + 1.5) - rectangle.x;
rectangle.height = ceil (y2 + 1.5) - rectangle.y;
return cairo_region_create_rectangle (&rectangle);
}
static gboolean
gimp_canvas_limit_hit (GimpCanvasItem *item,
gdouble x,
gdouble y)
{
GimpCanvasLimit *limit = GIMP_CANVAS_LIMIT (item);
gdouble bx, by;
gimp_canvas_limit_boundary_point (limit,
x, y,
&bx, &by);
return gimp_canvas_item_transform_distance (item,
x, y,
bx, by) <= HIT_DISTANCE;
}
/* public functions */
GimpCanvasItem *
gimp_canvas_limit_new (GimpDisplayShell *shell,
GimpLimitType type,
gdouble x,
gdouble y,
gdouble radius,
gdouble aspect_ratio,
gdouble angle,
gboolean dashed)
{
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), NULL);
return g_object_new (GIMP_TYPE_CANVAS_LIMIT,
"shell", shell,
"type", type,
"x", x,
"y", y,
"radius", radius,
"aspect-ratio", aspect_ratio,
"angle", angle,
"dashed", dashed,
NULL);
}
void
gimp_canvas_limit_get_radii (GimpCanvasLimit *limit,
gdouble *rx,
gdouble *ry)
{
GimpCanvasLimitPrivate *priv;
g_return_if_fail (GIMP_IS_CANVAS_LIMIT (limit));
priv = GET_PRIVATE (limit);
if (priv->aspect_ratio >= 0.0)
{
if (rx) *rx = priv->radius;
if (ry) *ry = priv->radius * (1.0 - priv->aspect_ratio);
}
else
{
if (rx) *rx = priv->radius * (1.0 + priv->aspect_ratio);
if (ry) *ry = priv->radius;
}
}
gboolean
gimp_canvas_limit_is_inside (GimpCanvasLimit *limit,
gdouble x,
gdouble y)
{
GimpCanvasLimitPrivate *priv;
GimpVector2 p;
gdouble rx, ry;
g_return_val_if_fail (GIMP_IS_CANVAS_LIMIT (limit), FALSE);
priv = GET_PRIVATE (limit);
gimp_canvas_limit_get_radii (limit, &rx, &ry);
if (rx == 0.0 || ry == 0.0)
return FALSE;
p.x = x - priv->x;
p.y = y - priv->y;
gimp_vector2_rotate (&p, +priv->angle);
p.x = fabs (p.x / rx);
p.y = fabs (p.y / ry);
switch (priv->type)
{
case GIMP_LIMIT_CIRCLE:
return gimp_vector2_length (&p) < 1.0;
case GIMP_LIMIT_SQUARE:
return p.x < 1.0 && p.y < 1.0;
case GIMP_LIMIT_DIAMOND:
return p.x + p.y < 1.0;
case GIMP_LIMIT_HORIZONTAL:
return p.y < 1.0;
case GIMP_LIMIT_VERTICAL:
return p.x < 1.0;
}
g_return_val_if_reached (FALSE);
}
void
gimp_canvas_limit_boundary_point (GimpCanvasLimit *limit,
gdouble x,
gdouble y,
gdouble *bx,
gdouble *by)
{
GimpCanvasLimitPrivate *priv;
GimpVector2 p;
gdouble rx, ry;
gboolean flip_x = FALSE;
gboolean flip_y = FALSE;
g_return_if_fail (GIMP_IS_CANVAS_LIMIT (limit));
g_return_if_fail (bx != NULL);
g_return_if_fail (by != NULL);
priv = GET_PRIVATE (limit);
gimp_canvas_limit_get_radii (limit, &rx, &ry);
p.x = x - priv->x;
p.y = y - priv->y;
gimp_vector2_rotate (&p, +priv->angle);
if (p.x < 0.0)
{
p.x = -p.x;
flip_x = TRUE;
}
if (p.y < 0.0)
{
p.y = -p.y;
flip_y = TRUE;
}
switch (priv->type)
{
case GIMP_LIMIT_CIRCLE:
if (rx == ry)
{
gimp_vector2_normalize (&p);
gimp_vector2_mul (&p, rx);
}
else
{
gdouble a0 = 0.0;
gdouble a1 = G_PI / 2.0;
gdouble a;
gint i;
for (i = 0; i < 20; i++)
{
GimpVector2 r;
GimpVector2 n;
a = (a0 + a1) / 2.0;
r.x = p.x - rx * cos (a);
r.y = p.y - ry * sin (a);
n.x = 1.0;
n.y = tan (a) * rx / ry;
if (gimp_vector2_cross_product (&r, &n).x >= 0.0)
a1 = a;
else
a0 = a;
}
a = (a0 + a1) / 2.0;
p.x = rx * cos (a);
p.y = ry * sin (a);
}
break;
case GIMP_LIMIT_SQUARE:
if (p.x <= rx || p.y <= ry)
{
if (rx - p.x <= ry - p.y)
p.x = rx;
else
p.y = ry;
}
else
{
p.x = rx;
p.y = ry;
}
break;
case GIMP_LIMIT_DIAMOND:
{
GimpVector2 l;
GimpVector2 r;
gdouble t;
l.x = rx;
l.y = -ry;
r.x = p.x;
r.y = p.y - ry;
t = gimp_vector2_inner_product (&r, &l) /
gimp_vector2_inner_product (&l, &l);
t = CLAMP (t, 0.0, 1.0);
p.x = rx * t;
p.y = ry * (1.0 - t);
}
break;
case GIMP_LIMIT_HORIZONTAL:
p.y = ry;
break;
case GIMP_LIMIT_VERTICAL:
p.x = rx;
break;
}
if (flip_x)
p.x = -p.x;
if (flip_y)
p.y = -p.y;
gimp_vector2_rotate (&p, -priv->angle);
*bx = priv->x + p.x;
*by = priv->y + p.y;
}
gdouble
gimp_canvas_limit_boundary_radius (GimpCanvasLimit *limit,
gdouble x,
gdouble y)
{
GimpCanvasLimitPrivate *priv;
GimpVector2 p;
g_return_val_if_fail (GIMP_IS_CANVAS_LIMIT (limit), 0.0);
priv = GET_PRIVATE (limit);
p.x = x - priv->x;
p.y = y - priv->y;
gimp_vector2_rotate (&p, +priv->angle);
p.x = fabs (p.x);
p.y = fabs (p.y);
if (priv->aspect_ratio >= 0.0)
p.y /= 1.0 - priv->aspect_ratio;
else
p.x /= 1.0 + priv->aspect_ratio;
switch (priv->type)
{
case GIMP_LIMIT_CIRCLE:
return gimp_vector2_length (&p);
case GIMP_LIMIT_SQUARE:
return MAX (p.x, p.y);
case GIMP_LIMIT_DIAMOND:
return p.x + p.y;
case GIMP_LIMIT_HORIZONTAL:
return p.y;
case GIMP_LIMIT_VERTICAL:
return p.x;
}
g_return_val_if_reached (0.0);
}
void
gimp_canvas_limit_center_point (GimpCanvasLimit *limit,
gdouble x,
gdouble y,
gdouble *cx,
gdouble *cy)
{
GimpCanvasLimitPrivate *priv;
GimpVector2 p;
g_return_if_fail (GIMP_IS_CANVAS_LIMIT (limit));
g_return_if_fail (cx != NULL);
g_return_if_fail (cy != NULL);
priv = GET_PRIVATE (limit);
p.x = x - priv->x;
p.y = y - priv->y;
gimp_vector2_rotate (&p, +priv->angle);
switch (priv->type)
{
case GIMP_LIMIT_CIRCLE:
case GIMP_LIMIT_SQUARE:
case GIMP_LIMIT_DIAMOND:
p.x = 0.0;
p.y = 0.0;
break;
case GIMP_LIMIT_HORIZONTAL:
p.y = 0.0;
break;
case GIMP_LIMIT_VERTICAL:
p.x = 0.0;
break;
}
gimp_vector2_rotate (&p, -priv->angle);
*cx = priv->x + p.x;
*cy = priv->y + p.y;
}

View File

@ -0,0 +1,84 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimpcanvaslimit.h
* Copyright (C) 2020 Ell
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_CANVAS_LIMIT_H__
#define __GIMP_CANVAS_LIMIT_H__
#include "gimpcanvasitem.h"
#define GIMP_TYPE_CANVAS_LIMIT (gimp_canvas_limit_get_type ())
#define GIMP_CANVAS_LIMIT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_CANVAS_LIMIT, GimpCanvasLimit))
#define GIMP_CANVAS_LIMIT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_CANVAS_LIMIT, GimpCanvasLimitClass))
#define GIMP_IS_CANVAS_LIMIT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_CANVAS_LIMIT))
#define GIMP_IS_CANVAS_LIMIT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_CANVAS_LIMIT))
#define GIMP_CANVAS_LIMIT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_CANVAS_LIMIT, GimpCanvasLimitClass))
typedef struct _GimpCanvasLimit GimpCanvasLimit;
typedef struct _GimpCanvasLimitClass GimpCanvasLimitClass;
struct _GimpCanvasLimit
{
GimpCanvasItem parent_instance;
};
struct _GimpCanvasLimitClass
{
GimpCanvasItemClass parent_class;
};
GType gimp_canvas_limit_get_type (void) G_GNUC_CONST;
GimpCanvasItem * gimp_canvas_limit_new (GimpDisplayShell *shell,
GimpLimitType type,
gdouble x,
gdouble y,
gdouble radius,
gdouble aspect_ratio,
gdouble angle,
gboolean dashed);
void gimp_canvas_limit_get_radii (GimpCanvasLimit *limit,
gdouble *rx,
gdouble *ry);
gboolean gimp_canvas_limit_is_inside (GimpCanvasLimit *limit,
gdouble x,
gdouble y);
void gimp_canvas_limit_boundary_point (GimpCanvasLimit *limit,
gdouble x,
gdouble y,
gdouble *bx,
gdouble *by);
gdouble gimp_canvas_limit_boundary_radius (GimpCanvasLimit *limit,
gdouble x,
gdouble y);
void gimp_canvas_limit_center_point (GimpCanvasLimit *limit,
gdouble x,
gdouble y,
gdouble *cx,
gdouble *cy);
#endif /* __GIMP_CANVAS_LIMIT_H__ */

View File

@ -727,7 +727,7 @@ gimp_cursor_view_cursor_idle (GimpCursorView *view)
gboolean in_image;
gchar buf[32];
const Babl *sample_format;
guchar pixel[32];
gdouble pixel[4];
GimpRGB color;
gdouble xres;
gdouble yres;

View File

@ -46,6 +46,7 @@
#include "gimpdisplayshell-icon.h"
#include "gimpdisplayshell-scroll.h"
#include "gimpdisplayshell-scrollbars.h"
#include "gimpdisplayshell-title.h"
#include "gimpdisplayshell-transform.h"
#include "gimpimagewindow.h"
@ -696,9 +697,14 @@ gimp_display_set_image (GimpDisplay *display,
if (shell)
{
if (image)
gimp_display_shell_reconnect (shell);
{
gimp_display_shell_reconnect (shell);
}
else
gimp_display_shell_icon_update (shell);
{
gimp_display_shell_title_update (shell);
gimp_display_shell_icon_update (shell);
}
}
if (old_image != image)
@ -864,7 +870,12 @@ gimp_display_flush (GimpDisplay *display)
{
g_return_if_fail (GIMP_IS_DISPLAY (display));
gimp_display_flush_whenever (display, FALSE);
/* FIXME: we can end up being called during shell construction if "show all"
* is enabled by default, in which case the shell's display pointer is still
* NULL
*/
if (gimp_display_get_shell (display))
gimp_display_flush_whenever (display, FALSE);
}
void

View File

@ -68,6 +68,9 @@ gimp_display_shell_flip (GimpDisplayShell *shell,
/* Maintain the current center of the viewport. */
gimp_display_shell_save_viewport_center (shell, &cx, &cy);
/* freeze the active tool */
gimp_display_shell_pause (shell);
/* Adjust the rotation angle so that the image gets reflected across the
* horizontal, and/or vertical, axes in screen space, regardless of the
* current rotation.
@ -87,6 +90,9 @@ gimp_display_shell_flip (GimpDisplayShell *shell,
gimp_display_shell_restore_viewport_center (shell, cx, cy);
gimp_display_shell_expose_full (shell);
/* re-enable the active tool */
gimp_display_shell_resume (shell);
}
}
@ -117,6 +123,9 @@ gimp_display_shell_rotate_to (GimpDisplayShell *shell,
shell->rotate_angle = value;
/* freeze the active tool */
gimp_display_shell_pause (shell);
gimp_display_shell_scroll_clamp_and_update (shell);
gimp_display_shell_rotated (shell);
@ -124,6 +133,9 @@ gimp_display_shell_rotate_to (GimpDisplayShell *shell,
gimp_display_shell_restore_viewport_center (shell, cx, cy);
gimp_display_shell_expose_full (shell);
/* re-enable the active tool */
gimp_display_shell_resume (shell);
}
void

View File

@ -89,6 +89,26 @@ gimp_display_shell_constrain_line (GimpDisplayShell *shell,
xres, yres);
}
gdouble
gimp_display_shell_constrain_angle (GimpDisplayShell *shell,
gdouble angle,
gint n_snap_lines)
{
gdouble x, y;
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), 0.0);
x = cos (angle);
y = sin (angle);
gimp_display_shell_constrain_line (shell,
0.0, 0.0,
&x, &y,
n_snap_lines);
return atan2 (y, x);
}
/**
* gimp_display_shell_get_line_status:
* @status: initial status text.

View File

@ -19,23 +19,27 @@
#define __GIMP_DISPLAY_SHELL_UTILS_H__
void gimp_display_shell_get_constrained_line_params (GimpDisplayShell *shell,
gdouble *offset_angle,
gdouble *xres,
gdouble *yres);
void gimp_display_shell_constrain_line (GimpDisplayShell *shell,
gdouble start_x,
gdouble start_y,
gdouble *end_x,
gdouble *end_y,
gint n_snap_lines);
gchar * gimp_display_shell_get_line_status (GimpDisplayShell *shell,
const gchar *status,
const gchar *separator,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2);
void gimp_display_shell_get_constrained_line_params (GimpDisplayShell *shell,
gdouble *offset_angle,
gdouble *xres,
gdouble *yres);
void gimp_display_shell_constrain_line (GimpDisplayShell *shell,
gdouble start_x,
gdouble start_y,
gdouble *end_x,
gdouble *end_y,
gint n_snap_lines);
gdouble gimp_display_shell_constrain_angle (GimpDisplayShell *shell,
gdouble angle,
gint n_snap_lines);
gchar * gimp_display_shell_get_line_status (GimpDisplayShell *shell,
const gchar *status,
const gchar *separator,
gdouble x1,
gdouble y1,
gdouble x2,
gdouble y2);
#endif /* __GIMP_DISPLAY_SHELL_UTILS_H__ */

View File

@ -18,6 +18,7 @@
#include "config.h"
#include <string.h>
#include <stdlib.h>
#include <gegl.h>
#include <gtk/gtk.h>
@ -1537,10 +1538,11 @@ gimp_display_shell_fill (GimpDisplayShell *shell,
gimp_statusbar_fill (GIMP_STATUSBAR (shell->statusbar));
/* A size-allocate will always occur because the scrollbars will
* become visible forcing the canvas to become smaller
/* make sure a size-allocate always occurs, even when the rulers and
* scrollbars are hidden. see issue #4968.
*/
shell->size_allocate_center_image = TRUE;
gtk_widget_queue_resize (GTK_WIDGET (shell->canvas));
if (shell->blink_timeout_id)
{

View File

@ -185,19 +185,21 @@ gimp_tool_compass_class_init (GimpToolCompassClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GimpToolWidgetClass *widget_class = GIMP_TOOL_WIDGET_CLASS (klass);
object_class->constructed = gimp_tool_compass_constructed;
object_class->set_property = gimp_tool_compass_set_property;
object_class->get_property = gimp_tool_compass_get_property;
object_class->constructed = gimp_tool_compass_constructed;
object_class->set_property = gimp_tool_compass_set_property;
object_class->get_property = gimp_tool_compass_get_property;
widget_class->changed = gimp_tool_compass_changed;
widget_class->button_press = gimp_tool_compass_button_press;
widget_class->button_release = gimp_tool_compass_button_release;
widget_class->motion = gimp_tool_compass_motion;
widget_class->hit = gimp_tool_compass_hit;
widget_class->hover = gimp_tool_compass_hover;
widget_class->leave_notify = gimp_tool_compass_leave_notify;
widget_class->motion_modifier = gimp_tool_compass_motion_modifier;
widget_class->get_cursor = gimp_tool_compass_get_cursor;
widget_class->changed = gimp_tool_compass_changed;
widget_class->button_press = gimp_tool_compass_button_press;
widget_class->button_release = gimp_tool_compass_button_release;
widget_class->motion = gimp_tool_compass_motion;
widget_class->hit = gimp_tool_compass_hit;
widget_class->hover = gimp_tool_compass_hover;
widget_class->leave_notify = gimp_tool_compass_leave_notify;
widget_class->motion_modifier = gimp_tool_compass_motion_modifier;
widget_class->get_cursor = gimp_tool_compass_get_cursor;
widget_class->update_on_scale = TRUE;
widget_class->update_on_rotate = TRUE;
compass_signals[CREATE_GUIDES] =
g_signal_new ("create-guides",
@ -297,20 +299,12 @@ gimp_tool_compass_constructed (GObject *object)
{
GimpToolCompass *compass = GIMP_TOOL_COMPASS (object);
GimpToolWidget *widget = GIMP_TOOL_WIDGET (object);
GimpDisplayShell *shell = gimp_tool_widget_get_shell (widget);
GimpToolCompassPrivate *private = compass->private;
GimpCanvasGroup *stroke_group;
gint i;
G_OBJECT_CLASS (parent_class)->constructed (object);
g_signal_connect_object (shell, "scaled",
G_CALLBACK (gimp_tool_compass_changed),
compass, G_CONNECT_SWAPPED);
g_signal_connect_object (shell, "rotated",
G_CALLBACK (gimp_tool_compass_changed),
compass, G_CONNECT_SWAPPED);
stroke_group = gimp_tool_widget_add_stroke_group (widget);
gimp_tool_widget_push_group (widget, stroke_group);

1209
app/display/gimptoolfocus.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,58 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
*
* gimptoolfocus.h
* Copyright (C) 2020 Ell
*
* 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 3 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, see <https://www.gnu.org/licenses/>.
*/
#ifndef __GIMP_TOOL_FOCUS_H__
#define __GIMP_TOOL_FOCUS_H__
#include "gimptoolwidget.h"
#define GIMP_TYPE_TOOL_FOCUS (gimp_tool_focus_get_type ())
#define GIMP_TOOL_FOCUS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_TOOL_FOCUS, GimpToolFocus))
#define GIMP_TOOL_FOCUS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_TOOL_FOCUS, GimpToolFocusClass))
#define GIMP_IS_TOOL_FOCUS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_TOOL_FOCUS))
#define GIMP_IS_TOOL_FOCUS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_TOOL_FOCUS))
#define GIMP_TOOL_FOCUS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_TOOL_FOCUS, GimpToolFocusClass))
typedef struct _GimpToolFocus GimpToolFocus;
typedef struct _GimpToolFocusPrivate GimpToolFocusPrivate;
typedef struct _GimpToolFocusClass GimpToolFocusClass;
struct _GimpToolFocus
{
GimpToolWidget parent_instance;
GimpToolFocusPrivate *priv;
};
struct _GimpToolFocusClass
{
GimpToolWidgetClass parent_class;
};
GType gimp_tool_focus_get_type (void) G_GNUC_CONST;
GimpToolWidget * gimp_tool_focus_new (GimpDisplayShell *shell);
#endif /* __GIMP_TOOL_FOCUS_H__ */

View File

@ -143,7 +143,7 @@ struct _GimpToolRectanglePrivate
gboolean is_first;
/* Whether or not the rectangle currently being rubber-banded was
* created from scatch.
* created from scratch.
*/
gboolean is_new;
@ -463,6 +463,7 @@ gimp_tool_rectangle_class_init (GimpToolRectangleClass *klass)
widget_class->key_press = gimp_tool_rectangle_key_press;
widget_class->motion_modifier = gimp_tool_rectangle_motion_modifier;
widget_class->get_cursor = gimp_tool_rectangle_get_cursor;
widget_class->update_on_scale = TRUE;
rectangle_signals[CHANGE_COMPLETE] =
g_signal_new ("change-complete",
@ -806,10 +807,6 @@ gimp_tool_rectangle_constructed (GObject *object)
gimp_canvas_item_set_highlight (private->highlight_handles[i], TRUE);
}
g_signal_connect_object (gimp_tool_widget_get_shell (widget), "scaled",
G_CALLBACK (gimp_tool_rectangle_changed),
widget, G_CONNECT_SWAPPED);
gimp_tool_rectangle_changed (widget);
}

View File

@ -232,6 +232,7 @@ gimp_tool_transform_grid_class_init (GimpToolTransformGridClass *klass)
widget_class->leave_notify = gimp_tool_transform_grid_leave_notify;
widget_class->hover_modifier = gimp_tool_transform_grid_hover_modifier;
widget_class->get_cursor = gimp_tool_transform_grid_get_cursor;
widget_class->update_on_scale = TRUE;
g_object_class_install_property (object_class, PROP_TRANSFORM,
gimp_param_spec_matrix3 ("transform",

View File

@ -34,6 +34,7 @@
#include "gimpcanvascorner.h"
#include "gimpcanvasgroup.h"
#include "gimpcanvashandle.h"
#include "gimpcanvaslimit.h"
#include "gimpcanvasline.h"
#include "gimpcanvaspath.h"
#include "gimpcanvaspolygon.h"
@ -223,6 +224,7 @@ gimp_tool_widget_constructed (GObject *object)
{
GimpToolWidget *widget = GIMP_TOOL_WIDGET (object);
GimpToolWidgetPrivate *private = widget->private;
GimpToolWidgetClass *klass = GIMP_TOOL_WIDGET_GET_CLASS (widget);
G_OBJECT_CLASS (parent_class)->constructed (object);
@ -231,6 +233,33 @@ gimp_tool_widget_constructed (GObject *object)
private->item = gimp_canvas_group_new (private->shell);
gimp_canvas_item_set_visible (private->item, private->visible);
if (klass->changed)
{
if (klass->update_on_scale)
{
g_signal_connect_object (private->shell, "scaled",
G_CALLBACK (klass->changed),
widget,
G_CONNECT_SWAPPED);
}
if (klass->update_on_scroll)
{
g_signal_connect_object (private->shell, "scrolled",
G_CALLBACK (klass->changed),
widget,
G_CONNECT_SWAPPED);
}
if (klass->update_on_rotate)
{
g_signal_connect_object (private->shell, "rotated",
G_CALLBACK (klass->changed),
widget,
G_CONNECT_SWAPPED);
}
}
}
static void
@ -555,14 +584,13 @@ gimp_tool_widget_remove_item (GimpToolWidget *widget,
}
GimpCanvasGroup *
gimp_tool_widget_add_stroke_group (GimpToolWidget *widget)
gimp_tool_widget_add_group (GimpToolWidget *widget)
{
GimpCanvasItem *item;
g_return_val_if_fail (GIMP_IS_TOOL_WIDGET (widget), NULL);
item = gimp_canvas_group_new (widget->private->shell);
gimp_canvas_group_set_group_stroking (GIMP_CANVAS_GROUP (item), TRUE);
gimp_tool_widget_add_item (widget, item);
g_object_unref (item);
@ -571,19 +599,29 @@ gimp_tool_widget_add_stroke_group (GimpToolWidget *widget)
}
GimpCanvasGroup *
gimp_tool_widget_add_fill_group (GimpToolWidget *widget)
gimp_tool_widget_add_stroke_group (GimpToolWidget *widget)
{
GimpCanvasItem *item;
GimpCanvasGroup *group;
g_return_val_if_fail (GIMP_IS_TOOL_WIDGET (widget), NULL);
item = gimp_canvas_group_new (widget->private->shell);
gimp_canvas_group_set_group_filling (GIMP_CANVAS_GROUP (item), TRUE);
group = gimp_tool_widget_add_group (widget);
gimp_canvas_group_set_group_stroking (group, TRUE);
gimp_tool_widget_add_item (widget, item);
g_object_unref (item);
return group;
}
return GIMP_CANVAS_GROUP (item);
GimpCanvasGroup *
gimp_tool_widget_add_fill_group (GimpToolWidget *widget)
{
GimpCanvasGroup *group;
g_return_val_if_fail (GIMP_IS_TOOL_WIDGET (widget), NULL);
group = gimp_tool_widget_add_group (widget);
gimp_canvas_group_set_group_filling (group, TRUE);
return group;
}
void
@ -684,6 +722,34 @@ gimp_tool_widget_add_arc (GimpToolWidget *widget,
return item;
}
GimpCanvasItem *
gimp_tool_widget_add_limit (GimpToolWidget *widget,
GimpLimitType type,
gdouble x,
gdouble y,
gdouble radius,
gdouble aspect_ratio,
gdouble angle,
gboolean dashed)
{
GimpCanvasItem *item;
g_return_val_if_fail (GIMP_IS_TOOL_WIDGET (widget), NULL);
item = gimp_canvas_limit_new (widget->private->shell,
type,
x, y,
radius,
aspect_ratio,
angle,
dashed);
gimp_tool_widget_add_item (widget, item);
g_object_unref (item);
return item;
}
GimpCanvasItem *
gimp_tool_widget_add_polygon (GimpToolWidget *widget,
GimpMatrix3 *transform,

View File

@ -119,6 +119,10 @@ struct _GimpToolWidgetClass
GimpCursorType *cursor,
GimpToolCursorType *tool_cursor,
GimpCursorModifier *modifier);
gboolean update_on_scale;
gboolean update_on_scroll;
gboolean update_on_rotate;
};
@ -175,6 +179,7 @@ void gimp_tool_widget_add_item (GimpToolWidget *widget,
void gimp_tool_widget_remove_item (GimpToolWidget *widget,
GimpCanvasItem *item);
GimpCanvasGroup * gimp_tool_widget_add_group (GimpToolWidget *widget);
GimpCanvasGroup * gimp_tool_widget_add_stroke_group (GimpToolWidget *widget);
GimpCanvasGroup * gimp_tool_widget_add_fill_group (GimpToolWidget *widget);
@ -203,6 +208,14 @@ GimpCanvasItem * gimp_tool_widget_add_arc (GimpToolWidget *widget,
gdouble start_angle,
gdouble slice_angle,
gboolean filled);
GimpCanvasItem * gimp_tool_widget_add_limit (GimpToolWidget *widget,
GimpLimitType type,
gdouble x,
gdouble y,
gdouble radius,
gdouble aspect_ratio,
gdouble angle,
gboolean dashed);
GimpCanvasItem * gimp_tool_widget_add_polygon (GimpToolWidget *widget,
GimpMatrix3 *transform,
const GimpVector2 *points,