2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2005-03-02 18:18:19 +00:00
|
|
|
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2005-03-02 18:18:19 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2005-03-02 18:18:19 +00: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
|
2018-07-11 23:27:07 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2005-03-02 18:18:19 +00:00
|
|
|
*/
|
|
|
|
|
2025-07-13 09:26:04 +02:00
|
|
|
#pragma once
|
2005-03-02 18:18:19 +00:00
|
|
|
|
|
|
|
|
2005-09-03 19:48:22 +00:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_0,
|
2007-10-14 19:48:56 +00:00
|
|
|
|
2006-09-23 20:45:06 +00:00
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_AUTO_SHRINK,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_SHRINK_MERGED,
|
2005-09-03 19:48:22 +00:00
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_HIGHLIGHT,
|
2017-12-13 16:01:48 +01:00
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_HIGHLIGHT_OPACITY,
|
2006-06-05 18:50:13 +00:00
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_GUIDE,
|
2007-10-14 19:48:56 +00:00
|
|
|
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_X,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_Y,
|
2005-09-03 19:48:22 +00:00
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_WIDTH,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_HEIGHT,
|
2007-10-15 16:47:07 +00:00
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_POSITION_UNIT,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_SIZE_UNIT,
|
2007-10-14 19:48:56 +00:00
|
|
|
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_RULE_ACTIVE,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_RULE,
|
2007-08-04 20:20:44 +00:00
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_WIDTH,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_HEIGHT,
|
2007-08-08 06:10:00 +00:00
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_SIZE_WIDTH,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_DESIRED_FIXED_SIZE_HEIGHT,
|
2007-08-10 14:57:27 +00:00
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_DEFAULT_FIXED_SIZE_WIDTH,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_DEFAULT_FIXED_SIZE_HEIGHT,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_OVERRIDDEN_FIXED_SIZE,
|
2006-09-14 17:11:24 +00:00
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_NUMERATOR,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_DENOMINATOR,
|
2007-08-10 14:57:27 +00:00
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_DEFAULT_ASPECT_NUMERATOR,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_DEFAULT_ASPECT_DENOMINATOR,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_OVERRIDDEN_FIXED_ASPECT,
|
2007-10-09 20:54:07 +00:00
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_USE_STRING_CURRENT,
|
2007-10-14 18:51:58 +00:00
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_UNIT,
|
2007-10-14 19:48:56 +00:00
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER,
|
2007-10-14 19:55:10 +00:00
|
|
|
|
2007-11-11 07:44:17 +00:00
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_LAST = GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER
|
2005-09-03 19:48:22 +00:00
|
|
|
} GimpRectangleOptionsProp;
|
|
|
|
|
|
|
|
|
2018-05-27 04:23:24 -04:00
|
|
|
#define GIMP_TYPE_RECTANGLE_OPTIONS (gimp_rectangle_options_get_type ())
|
2005-08-15 14:23:28 +00:00
|
|
|
#define GIMP_IS_RECTANGLE_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_RECTANGLE_OPTIONS))
|
|
|
|
#define GIMP_RECTANGLE_OPTIONS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_RECTANGLE_OPTIONS, GimpRectangleOptions))
|
|
|
|
#define GIMP_RECTANGLE_OPTIONS_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GIMP_TYPE_RECTANGLE_OPTIONS, GimpRectangleOptionsInterface))
|
2005-03-02 18:18:19 +00:00
|
|
|
|
2007-03-31 16:38:55 +00:00
|
|
|
#define GIMP_RECTANGLE_OPTIONS_GET_PRIVATE(obj) (gimp_rectangle_options_get_private (GIMP_RECTANGLE_OPTIONS (obj)))
|
|
|
|
|
2005-03-02 18:18:19 +00:00
|
|
|
|
2005-08-15 14:23:28 +00:00
|
|
|
typedef struct _GimpRectangleOptions GimpRectangleOptions;
|
|
|
|
typedef struct _GimpRectangleOptionsInterface GimpRectangleOptionsInterface;
|
2007-03-31 16:38:55 +00:00
|
|
|
typedef struct _GimpRectangleOptionsPrivate GimpRectangleOptionsPrivate;
|
2005-03-02 18:18:19 +00:00
|
|
|
|
2005-08-15 14:23:28 +00:00
|
|
|
struct _GimpRectangleOptionsInterface
|
2005-03-02 18:18:19 +00:00
|
|
|
{
|
2005-08-15 14:23:28 +00:00
|
|
|
GTypeInterface base_iface;
|
|
|
|
};
|
2005-03-02 18:18:19 +00:00
|
|
|
|
2007-03-31 16:38:55 +00:00
|
|
|
struct _GimpRectangleOptionsPrivate
|
|
|
|
{
|
2017-06-24 19:47:19 +02:00
|
|
|
gboolean auto_shrink;
|
|
|
|
gboolean shrink_merged;
|
2007-03-31 16:38:55 +00:00
|
|
|
|
2017-06-24 19:47:19 +02:00
|
|
|
gboolean highlight;
|
2017-12-13 16:01:48 +01:00
|
|
|
gdouble highlight_opacity;
|
2017-06-24 19:47:19 +02:00
|
|
|
GimpGuidesType guide;
|
2007-03-31 16:38:55 +00:00
|
|
|
|
2017-06-24 19:47:19 +02:00
|
|
|
gdouble x;
|
|
|
|
gdouble y;
|
|
|
|
gdouble width;
|
|
|
|
gdouble height;
|
2007-03-31 16:38:55 +00:00
|
|
|
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
This fixes all our GObject Introspection issues with GimpUnit which was
both an enum and an int-derived type of user-defined units *completing*
the enum values. GIR clearly didn't like this!
Now GimpUnit is a proper class and units are unique objects, allowing to
compare them with an identity test (i.e. `unit == gimp_unit_pixel ()`
tells us if unit is the pixel unit or not), which makes it easy to use,
just like with int, yet adding also methods, making for nicer
introspected API.
As an aside, this also fixes #10738, by having all the built-in units
retrievable even if libgimpbase had not been properly initialized with
gimp_base_init().
I haven't checked in details how GIR works to introspect, but it looks
like it loads the library to inspect and runs functions, hence
triggering some CRITICALS because virtual methods (supposed to be
initialized with gimp_base_init() run by libgimp) are not set. This new
code won't trigger any critical because the vtable method are now not
necessary, at least for all built-in units.
Note that GimpUnit is still in libgimpbase. It could have been moved to
libgimp in order to avoid any virtual method table (since we need to
keep core and libgimp side's units in sync, PDB is required), but too
many libgimpwidgets widgets were already using GimpUnit. And technically
most of GimpUnit logic doesn't require PDB (only the creation/sync
part). This is one of the reasons why user-created GimpUnit list is
handled and stored differently from other types of objects.
Globally this simplifies the code a lot too and we don't need separate
implementations of various utils for core and libgimp, which means less
prone to errors.
2024-07-25 20:55:21 +02:00
|
|
|
GimpUnit *position_unit;
|
|
|
|
GimpUnit *size_unit;
|
2007-10-14 19:48:56 +00:00
|
|
|
|
2017-06-24 19:47:19 +02:00
|
|
|
gboolean fixed_rule_active;
|
|
|
|
GimpRectangleFixedRule fixed_rule;
|
2007-10-14 19:48:56 +00:00
|
|
|
|
2017-06-24 19:47:19 +02:00
|
|
|
gdouble desired_fixed_width;
|
|
|
|
gdouble desired_fixed_height;
|
2007-03-31 16:38:55 +00:00
|
|
|
|
2017-06-24 19:47:19 +02:00
|
|
|
gdouble desired_fixed_size_width;
|
|
|
|
gdouble desired_fixed_size_height;
|
2007-08-08 06:10:00 +00:00
|
|
|
|
2017-06-24 19:47:19 +02:00
|
|
|
gdouble default_fixed_size_width;
|
|
|
|
gdouble default_fixed_size_height;
|
|
|
|
gboolean overridden_fixed_size;
|
2007-08-10 14:57:27 +00:00
|
|
|
|
2017-06-24 19:47:19 +02:00
|
|
|
gdouble aspect_numerator;
|
|
|
|
gdouble aspect_denominator;
|
2007-03-31 16:38:55 +00:00
|
|
|
|
2017-06-24 19:47:19 +02:00
|
|
|
gdouble default_aspect_numerator;
|
|
|
|
gdouble default_aspect_denominator;
|
|
|
|
gboolean overridden_fixed_aspect;
|
2007-08-10 14:57:27 +00:00
|
|
|
|
2017-06-24 19:47:19 +02:00
|
|
|
gboolean fixed_center;
|
2007-11-11 07:44:17 +00:00
|
|
|
|
2007-10-14 19:48:56 +00:00
|
|
|
/* This gboolean is not part of the actual rectangle tool options,
|
|
|
|
* and should be refactored out along with the pointers to widgets.
|
|
|
|
*/
|
2017-06-24 19:47:19 +02:00
|
|
|
gboolean use_string_current;
|
2007-03-31 16:38:55 +00:00
|
|
|
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
This fixes all our GObject Introspection issues with GimpUnit which was
both an enum and an int-derived type of user-defined units *completing*
the enum values. GIR clearly didn't like this!
Now GimpUnit is a proper class and units are unique objects, allowing to
compare them with an identity test (i.e. `unit == gimp_unit_pixel ()`
tells us if unit is the pixel unit or not), which makes it easy to use,
just like with int, yet adding also methods, making for nicer
introspected API.
As an aside, this also fixes #10738, by having all the built-in units
retrievable even if libgimpbase had not been properly initialized with
gimp_base_init().
I haven't checked in details how GIR works to introspect, but it looks
like it loads the library to inspect and runs functions, hence
triggering some CRITICALS because virtual methods (supposed to be
initialized with gimp_base_init() run by libgimp) are not set. This new
code won't trigger any critical because the vtable method are now not
necessary, at least for all built-in units.
Note that GimpUnit is still in libgimpbase. It could have been moved to
libgimp in order to avoid any virtual method table (since we need to
keep core and libgimp side's units in sync, PDB is required), but too
many libgimpwidgets widgets were already using GimpUnit. And technically
most of GimpUnit logic doesn't require PDB (only the creation/sync
part). This is one of the reasons why user-created GimpUnit list is
handled and stored differently from other types of objects.
Globally this simplifies the code a lot too and we don't need separate
implementations of various utils for core and libgimp, which means less
prone to errors.
2024-07-25 20:55:21 +02:00
|
|
|
GimpUnit *fixed_unit;
|
2007-10-14 18:51:58 +00:00
|
|
|
|
2007-03-31 16:38:55 +00:00
|
|
|
/* options gui */
|
2007-10-09 20:54:07 +00:00
|
|
|
|
2017-06-24 19:47:19 +02:00
|
|
|
GtkWidget *auto_shrink_button;
|
2007-08-04 20:20:44 +00:00
|
|
|
|
2017-06-24 19:47:19 +02:00
|
|
|
GtkWidget *fixed_width_entry;
|
|
|
|
GtkWidget *fixed_height_entry;
|
2007-08-04 20:20:44 +00:00
|
|
|
|
2017-06-24 19:47:19 +02:00
|
|
|
GtkWidget *fixed_aspect_hbox;
|
|
|
|
GtkWidget *aspect_button_box;
|
|
|
|
GtkListStore *aspect_history;
|
2007-08-04 20:20:44 +00:00
|
|
|
|
2017-06-24 19:47:19 +02:00
|
|
|
GtkWidget *fixed_size_hbox;
|
|
|
|
GtkWidget *size_button_box;
|
|
|
|
GtkListStore *size_history;
|
2007-08-04 20:20:44 +00:00
|
|
|
|
2017-10-04 12:39:28 -04:00
|
|
|
GtkWidget *position_entry;
|
|
|
|
GtkWidget *size_entry;
|
2007-03-31 16:38:55 +00:00
|
|
|
};
|
|
|
|
|
2005-03-08 23:17:19 +00:00
|
|
|
|
2018-05-27 04:23:24 -04:00
|
|
|
GType gimp_rectangle_options_get_type (void) G_GNUC_CONST;
|
2005-03-08 23:17:19 +00:00
|
|
|
|
2007-10-14 19:48:56 +00:00
|
|
|
GtkWidget * gimp_rectangle_options_gui (GimpToolOptions *tool_options);
|
2007-03-31 16:38:55 +00:00
|
|
|
|
2017-06-26 18:32:05 +02:00
|
|
|
void gimp_rectangle_options_connect (GimpRectangleOptions *options,
|
|
|
|
GimpImage *image,
|
|
|
|
GCallback shrink_callback,
|
|
|
|
gpointer shrink_object);
|
|
|
|
void gimp_rectangle_options_disconnect (GimpRectangleOptions *options,
|
|
|
|
GCallback shrink_callback,
|
|
|
|
gpointer shrink_object);
|
|
|
|
|
2007-10-14 19:48:56 +00:00
|
|
|
gboolean gimp_rectangle_options_fixed_rule_active (GimpRectangleOptions *rectangle_options,
|
2017-06-24 19:47:19 +02:00
|
|
|
GimpRectangleFixedRule fixed_rule);
|
2007-08-04 20:20:44 +00:00
|
|
|
|
2007-03-31 16:38:55 +00:00
|
|
|
GimpRectangleOptionsPrivate *
|
2007-10-14 19:48:56 +00:00
|
|
|
gimp_rectangle_options_get_private (GimpRectangleOptions *options);
|
2005-03-02 18:18:19 +00:00
|
|
|
|
|
|
|
|
2005-09-03 19:48:22 +00:00
|
|
|
/* convenience functions */
|
|
|
|
|
2007-03-31 16:38:55 +00:00
|
|
|
void gimp_rectangle_options_install_properties (GObjectClass *klass);
|
|
|
|
void gimp_rectangle_options_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
void gimp_rectangle_options_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2005-09-03 19:48:22 +00:00
|
|
|
|
2007-10-14 19:48:56 +00:00
|
|
|
|
2010-10-31 15:09:03 +01:00
|
|
|
/* testing helper functions */
|
|
|
|
|
2017-10-04 12:39:28 -04:00
|
|
|
GtkWidget * gimp_rectangle_options_get_size_entry (GimpRectangleOptions *rectangle_options);
|