Commit 23aaf697 authored by Michael Natterer's avatar Michael Natterer 😴

pdb: add a lot of state for a new item-based transform API

interpolation, transform-direction, transform-resize, transform-recursion
parent d96b4910
......@@ -769,6 +769,186 @@ context_set_feather_radius_invoker (GimpProcedure *procedure,
error ? *error : NULL);
}
static GValueArray *
context_get_interpolation_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
GValueArray *return_vals;
gint32 interpolation = 0;
g_object_get (context,
"interpolation", &interpolation,
NULL);
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
g_value_set_enum (&return_vals->values[1], interpolation);
return return_vals;
}
static GValueArray *
context_set_interpolation_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
gint32 interpolation;
interpolation = g_value_get_enum (&args->values[0]);
if (success)
{
g_object_set (context,
"interpolation", interpolation,
NULL);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GValueArray *
context_get_transform_direction_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
GValueArray *return_vals;
gint32 transform_direction = 0;
g_object_get (context,
"transform-direction", &transform_direction,
NULL);
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
g_value_set_enum (&return_vals->values[1], transform_direction);
return return_vals;
}
static GValueArray *
context_set_transform_direction_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
gint32 transform_direction;
transform_direction = g_value_get_enum (&args->values[0]);
if (success)
{
g_object_set (context,
"transform-direction", transform_direction,
NULL);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GValueArray *
context_get_transform_resize_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
GValueArray *return_vals;
gint32 transform_resize = 0;
g_object_get (context,
"transform-resize", &transform_resize,
NULL);
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
g_value_set_enum (&return_vals->values[1], transform_resize);
return return_vals;
}
static GValueArray *
context_set_transform_resize_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
gint32 transform_resize;
transform_resize = g_value_get_enum (&args->values[0]);
if (success)
{
g_object_set (context,
"transform-resize", transform_resize,
NULL);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
static GValueArray *
context_get_transform_recursion_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
GValueArray *return_vals;
gint32 transform_recursion = 0;
g_object_get (context,
"transform-recursion", &transform_recursion,
NULL);
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
g_value_set_int (&return_vals->values[1], transform_recursion);
return return_vals;
}
static GValueArray *
context_set_transform_recursion_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GValueArray *args,
GError **error)
{
gboolean success = TRUE;
gint32 transform_recursion;
transform_recursion = g_value_get_int (&args->values[0]);
if (success)
{
g_object_set (context,
"transform-recursion", transform_recursion,
NULL);
}
return gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
}
void
register_context_procs (GimpPDB *pdb)
{
......@@ -1497,4 +1677,194 @@ register_context_procs (GimpPDB *pdb)
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-get-interpolation
*/
procedure = gimp_procedure_new (context_get_interpolation_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-get-interpolation");
gimp_procedure_set_static_strings (procedure,
"gimp-context-get-interpolation",
"Get the interpolation type.",
"This procedure returns the interpolation setting. The return value is an integer which corresponds to the values listed in the argument description.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_return_value (procedure,
g_param_spec_enum ("interpolation",
"interpolation",
"The interpolation type",
GIMP_TYPE_INTERPOLATION_TYPE,
GIMP_INTERPOLATION_NONE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-set-interpolation
*/
procedure = gimp_procedure_new (context_set_interpolation_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-set-interpolation");
gimp_procedure_set_static_strings (procedure,
"gimp-context-set-interpolation",
"Set the interpolation type.",
"This procedure modifies the interpolation setting. It affects all transform procedures which can produce sub-pixel results.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("interpolation",
"interpolation",
"The interpolation type",
GIMP_TYPE_INTERPOLATION_TYPE,
GIMP_INTERPOLATION_NONE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-get-transform-direction
*/
procedure = gimp_procedure_new (context_get_transform_direction_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-get-transform-direction");
gimp_procedure_set_static_strings (procedure,
"gimp-context-get-transform-direction",
"Get the transform direction.",
"This procedure returns the transform direction. The return value is an integer which corresponds to the values listed in the argument description.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_return_value (procedure,
g_param_spec_enum ("transform-direction",
"transform direction",
"The transform direction",
GIMP_TYPE_TRANSFORM_DIRECTION,
GIMP_TRANSFORM_FORWARD,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-set-transform-direction
*/
procedure = gimp_procedure_new (context_set_transform_direction_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-set-transform-direction");
gimp_procedure_set_static_strings (procedure,
"gimp-context-set-transform-direction",
"Set the transform direction.",
"This procedure modifies the transform direction setting.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("transform-direction",
"transform direction",
"The transform direction",
GIMP_TYPE_TRANSFORM_DIRECTION,
GIMP_TRANSFORM_FORWARD,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-get-transform-resize
*/
procedure = gimp_procedure_new (context_get_transform_resize_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-get-transform-resize");
gimp_procedure_set_static_strings (procedure,
"gimp-context-get-transform-resize",
"Get the transform resize type.",
"This procedure returns the transform resize setting. The return value is an integer which corresponds to the values listed in the argument description.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_return_value (procedure,
g_param_spec_enum ("transform-resize",
"transform resize",
"The transform resize type",
GIMP_TYPE_TRANSFORM_RESIZE,
GIMP_TRANSFORM_RESIZE_ADJUST,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-set-transform-resize
*/
procedure = gimp_procedure_new (context_set_transform_resize_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-set-transform-resize");
gimp_procedure_set_static_strings (procedure,
"gimp-context-set-transform-resize",
"Set the transform resize type.",
"This procedure modifies the transform resize setting. When transforming pixels, if the result of a transform operation has a different size than the original area, this setting determines how the resulting area is sized.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_argument (procedure,
g_param_spec_enum ("transform-resize",
"transform resize",
"The transform resize type",
GIMP_TYPE_TRANSFORM_RESIZE,
GIMP_TRANSFORM_RESIZE_ADJUST,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-get-transform-recursion
*/
procedure = gimp_procedure_new (context_get_transform_recursion_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-get-transform-recursion");
gimp_procedure_set_static_strings (procedure,
"gimp-context-get-transform-recursion",
"Get the transform supersampling recursion.",
"This procedure returns the transform supersampling recursion level.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_return_value (procedure,
gimp_param_spec_int32 ("transform-recursion",
"transform recursion",
"The transform recursion level",
1, G_MAXINT32, 1,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-context-set-transform-recursion
*/
procedure = gimp_procedure_new (context_set_transform_recursion_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-context-set-transform-recursion");
gimp_procedure_set_static_strings (procedure,
"gimp-context-set-transform-recursion",
"Set the transform supersampling recursion.",
"This procedure modifies the transform supersampling recursion level setting. Whether or not a transformation does supersampling is determined by the interplolation type. The recursion level defaults to 3, which is a nice default value.",
"Michael Natterer <mitch@gimp.org>",
"Michael Natterer",
"2010",
NULL);
gimp_procedure_add_argument (procedure,
gimp_param_spec_int32 ("transform-recursion",
"transform recursion",
"The transform recursion level",
1, G_MAXINT32, 1,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}
......@@ -38,7 +38,11 @@ enum
PROP_ANTIALIAS,
PROP_FEATHER,
PROP_FEATHER_RADIUS_X,
PROP_FEATHER_RADIUS_Y
PROP_FEATHER_RADIUS_Y,
PROP_INTERPOLATION,
PROP_TRANSFORM_DIRECTION,
PROP_TRANSFORM_RESIZE,
PROP_TRANSFORM_RECURSION
};
......@@ -85,6 +89,29 @@ gimp_pdb_context_class_init (GimpPDBContextClass *klass)
"feather-radius-y", NULL,
0.0, 1000.0, 10.0,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_INTERPOLATION,
"interpolation", NULL,
GIMP_TYPE_INTERPOLATION_TYPE,
GIMP_INTERPOLATION_CUBIC,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_TRANSFORM_DIRECTION,
"transform-direction", NULL,
GIMP_TYPE_TRANSFORM_DIRECTION,
GIMP_TRANSFORM_FORWARD,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_TRANSFORM_RESIZE,
"transform-resize", NULL,
GIMP_TYPE_TRANSFORM_RESIZE,
GIMP_TRANSFORM_RESIZE_ADJUST,
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_INSTALL_PROP_INT (object_class, PROP_TRANSFORM_RECURSION,
"transform-recursion", NULL,
1, G_MAXINT32, 3,
GIMP_PARAM_STATIC_STRINGS);
}
static void
......@@ -118,6 +145,22 @@ gimp_pdb_context_set_property (GObject *object,
options->feather_radius_y = g_value_get_double (value);
break;
case PROP_INTERPOLATION:
options->interpolation = g_value_get_enum (value);
break;
case PROP_TRANSFORM_DIRECTION:
options->transform_direction = g_value_get_enum (value);
break;
case PROP_TRANSFORM_RESIZE:
options->transform_resize = g_value_get_enum (value);
break;
case PROP_TRANSFORM_RECURSION:
options->transform_recursion = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......@@ -150,6 +193,22 @@ gimp_pdb_context_get_property (GObject *object,
g_value_set_double (value, options->feather_radius_y);
break;
case PROP_INTERPOLATION:
g_value_set_enum (value, options->interpolation);
break;
case PROP_TRANSFORM_DIRECTION:
g_value_set_enum (value, options->transform_direction);
break;
case PROP_TRANSFORM_RESIZE:
g_value_set_enum (value, options->transform_resize);
break;
case PROP_TRANSFORM_RECURSION:
g_value_set_int (value, options->transform_recursion);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
......
......@@ -37,12 +37,17 @@ typedef struct _GimpPDBContextClass GimpPDBContextClass;
struct _GimpPDBContext
{
GimpContext parent_instance;
GimpContext parent_instance;
gboolean antialias;
gboolean feather;
gdouble feather_radius_x;
gdouble feather_radius_y;
gboolean antialias;
gboolean feather;
gdouble feather_radius_x;
gdouble feather_radius_y;
GimpInterpolationType interpolation;
GimpTransformDirection transform_direction;
GimpTransformResize transform_resize;
gint transform_recursion;
};
struct _GimpPDBContextClass
......
......@@ -28,7 +28,7 @@
#include "internal-procs.h"
/* 640 procedures registered total */
/* 648 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)
......
......@@ -76,11 +76,15 @@ EXPORTS
gimp_context_get_font
gimp_context_get_foreground
gimp_context_get_gradient
gimp_context_get_interpolation
gimp_context_get_opacity
gimp_context_get_paint_method
gimp_context_get_paint_mode
gimp_context_get_palette
gimp_context_get_pattern
gimp_context_get_transform_direction
gimp_context_get_transform_recursion
gimp_context_get_transform_resize
gimp_context_list_paint_methods
gimp_context_pop
gimp_context_push
......@@ -93,11 +97,15 @@ EXPORTS
gimp_context_set_font
gimp_context_set_foreground
gimp_context_set_gradient
gimp_context_set_interpolation
gimp_context_set_opacity
gimp_context_set_paint_method
gimp_context_set_paint_mode
gimp_context_set_palette
gimp_context_set_pattern
gimp_context_set_transform_direction
gimp_context_set_transform_recursion
gimp_context_set_transform_resize
gimp_context_swap_colors
gimp_convert_dither_type_get_type
gimp_convert_palette_type_get_type
......
......@@ -1065,3 +1065,260 @@ gimp_context_set_feather_radius (gdouble feather_radius_x,
return success;
}
/**
* gimp_context_get_interpolation:
*
* Get the interpolation type.
*
* This procedure returns the interpolation setting. The return value
* is an integer which corresponds to the values listed in the argument
* description.
*
* Returns: The interpolation type.
*
* Since: GIMP 2.8
*/
GimpInterpolationType
gimp_context_get_interpolation (void)
{
GimpParam *return_vals;
gint nreturn_vals;
GimpInterpolationType interpolation = 0;
return_vals = gimp_run_procedure ("gimp-context-get-interpolation",
&nreturn_vals,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
interpolation = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return interpolation;
}
/**
* gimp_context_set_interpolation:
* @interpolation: The interpolation type.
*
* Set the interpolation type.
*
* This procedure modifies the interpolation setting. It affects all
* transform procedures which can produce sub-pixel results.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
*/
gboolean
gimp_context_set_interpolation (GimpInterpolationType interpolation)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-context-set-interpolation",
&nreturn_vals,
GIMP_PDB_INT32, interpolation,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_context_get_transform_direction:
*
* Get the transform direction.
*
* This procedure returns the transform direction. The return value is
* an integer which corresponds to the values listed in the argument
* description.
*
* Returns: The transform direction.
*
* Since: GIMP 2.8
*/
GimpTransformDirection
gimp_context_get_transform_direction (void)
{
GimpParam *return_vals;
gint nreturn_vals;
GimpTransformDirection transform_direction = 0;
return_vals = gimp_run_procedure ("gimp-context-get-transform-direction",
&nreturn_vals,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
transform_direction = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return transform_direction;
}
/**
* gimp_context_set_transform_direction:
* @transform_direction: The transform direction.
*
* Set the transform direction.
*
* This procedure modifies the transform direction setting.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
*/
gboolean
gimp_context_set_transform_direction (GimpTransformDirection transform_direction)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-context-set-transform-direction",
&nreturn_vals,
GIMP_PDB_INT32, transform_direction,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_context_get_transform_resize:
*
* Get the transform resize type.
*
* This procedure returns the transform resize setting. The return
* value is an integer which corresponds to the values listed in the
* argument description.
*
* Returns: The transform resize type.
*
* Since: GIMP 2.8
*/
GimpTransformResize
gimp_context_get_transform_resize (void)
{
GimpParam *return_vals;
gint nreturn_vals;
GimpTransformResize transform_resize = 0;
return_vals = gimp_run_procedure ("gimp-context-get-transform-resize",
&nreturn_vals,
GIMP_PDB_END);
if (return_vals[0].data.d_status == GIMP_PDB_SUCCESS)
transform_resize = return_vals[1].data.d_int32;
gimp_destroy_params (return_vals, nreturn_vals);
return transform_resize;
}
/**
* gimp_context_set_transform_resize:
* @transform_resize: The transform resize type.
*
* Set the transform resize type.
*
* This procedure modifies the transform resize setting. When
* transforming pixels, if the result of a transform operation has a
* different size than the original area, this setting determines how
* the resulting area is sized.
*
* Returns: TRUE on success.
*
* Since: GIMP 2.8
*/
gboolean
gimp_context_set_transform_resize (GimpTransformResize transform_resize)
{
GimpParam *return_vals;
gint nreturn_vals;
gboolean success = TRUE;
return_vals = gimp_run_procedure ("gimp-context-set-transform-resize",
&nreturn_vals,
GIMP_PDB_INT32, transform_resize,
GIMP_PDB_END);
success = return_vals[0].data.d_status == GIMP_PDB_SUCCESS;
gimp_destroy_params (return_vals, nreturn_vals);
return success;
}
/**
* gimp_context_get_transform_recursion:
*
* Get the transform supersampling recursion.
*
* This procedure returns the transform supersampling recursion level.
*
* Returns: The transform recursion level.
*
* Since: GIMP 2.8
*/
gint
gimp_context_get_transform_recursion (void)