text, pdb: Connect text outline unit to PDB

This commit is contained in:
Alx Sa 2025-10-25 12:00:52 -04:00
parent 9bf1152dd8
commit 0b51633021
6 changed files with 61 additions and 9 deletions

View file

@ -1440,6 +1440,7 @@ text_layer_get_outline_width_invoker (GimpProcedure *procedure,
GimpValueArray *return_vals;
GimpTextLayer *layer;
gdouble outline_width = 0.0;
GimpUnit *outline_unit = NULL;
layer = g_value_get_object (gimp_value_array_index (args, 0));
@ -1447,6 +1448,7 @@ text_layer_get_outline_width_invoker (GimpProcedure *procedure,
{
g_object_get (gimp_text_layer_get_text (layer),
"outline-width", &outline_width,
"outline-unit", &outline_unit,
NULL);
}
@ -1454,7 +1456,10 @@ text_layer_get_outline_width_invoker (GimpProcedure *procedure,
error ? *error : NULL);
if (success)
g_value_set_double (gimp_value_array_index (return_vals, 1), outline_width);
{
g_value_set_double (gimp_value_array_index (return_vals, 1), outline_width);
g_value_set_object (gimp_value_array_index (return_vals, 2), outline_unit);
}
return return_vals;
}
@ -1470,15 +1475,18 @@ text_layer_set_outline_width_invoker (GimpProcedure *procedure,
gboolean success = TRUE;
GimpTextLayer *layer;
gdouble outline_width;
GimpUnit *outline_unit;
layer = g_value_get_object (gimp_value_array_index (args, 0));
outline_width = g_value_get_double (gimp_value_array_index (args, 1));
outline_unit = g_value_get_object (gimp_value_array_index (args, 2));
if (success)
{
gimp_text_layer_set (layer,
_("Set text layer attribute"),
"outline-width", outline_width,
"outline-unit", outline_unit,
NULL);
}
@ -2941,6 +2949,14 @@ register_text_layer_procs (GimpPDB *pdb)
"The text outline width",
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_unit ("outline-unit",
"outline unit",
"The unit used for the outline width",
FALSE,
FALSE,
gimp_unit_inch (),
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
@ -2970,6 +2986,14 @@ register_text_layer_procs (GimpPDB *pdb)
"The text outline width",
0.0, 8192.0, 0.0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_unit ("outline-unit",
"outline unit",
"The unit to use for the outline width",
TRUE,
FALSE,
gimp_unit_inch (),
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);

View file

@ -349,6 +349,11 @@ gimp_text_class_init (GimpTextClass *klass)
0.0, 8192.0, 4.0,
GIMP_PARAM_STATIC_STRINGS |
GIMP_CONFIG_PARAM_DEFAULTS);
GIMP_CONFIG_PROP_UNIT (object_class, PROP_OUTLINE_UNIT,
"outline-unit",
NULL, NULL,
TRUE, FALSE, gimp_unit_pixel (),
GIMP_PARAM_STATIC_STRINGS);
GIMP_CONFIG_PROP_ENUM (object_class, PROP_OUTLINE_DIRECTION,
"outline-direction", NULL, NULL,
GIMP_TYPE_TEXT_OUTLINE_DIRECTION,
@ -522,6 +527,9 @@ gimp_text_get_property (GObject *object,
case PROP_OUTLINE_WIDTH:
g_value_set_double (value, text->outline_width);
break;
case PROP_OUTLINE_UNIT:
g_value_set_object (value, text->outline_unit);
break;
case PROP_OUTLINE_DIRECTION:
g_value_set_enum (value, text->outline_direction);
break;
@ -682,6 +690,9 @@ gimp_text_set_property (GObject *object,
case PROP_OUTLINE_WIDTH:
text->outline_width = g_value_get_double (value);
break;
case PROP_OUTLINE_UNIT:
text->outline_unit = g_value_get_object (value);
break;
case PROP_OUTLINE_DIRECTION:
text->outline_direction = g_value_get_enum (value);
break;
@ -857,7 +868,7 @@ gimp_text_serialize_property (GimpConfig *config,
(GimpContainerSearchFunc) gimp_font_match_by_lookup_name,
(gpointer) altered_font_name));
/* in case pango returns a non existant font name */
if (font == NULL)
if (font == NULL)
{
font = GIMP_FONT (gimp_font_get_standard ());
font_name = "gimpfont";

View file

@ -52,6 +52,7 @@ struct _GimpText
GimpPattern *outline_pattern;
GeglColor *outline_foreground;
gdouble outline_width;
GimpUnit *outline_unit;
GimpTextOutlineDirection outline_direction;
GimpCapStyle outline_cap_style;
GimpJoinStyle outline_join_style;

View file

@ -1780,6 +1780,7 @@ gimp_text_layer_set_outline_miter_limit (GimpTextLayer *layer,
/**
* gimp_text_layer_get_outline_width:
* @layer: The text layer.
* @outline_unit: (out) (transfer none): The unit used for the outline width.
*
* Get the outline width from a text layer.
*
@ -1791,7 +1792,8 @@ gimp_text_layer_set_outline_miter_limit (GimpTextLayer *layer,
* Since: 3.2
**/
gdouble
gimp_text_layer_get_outline_width (GimpTextLayer *layer)
gimp_text_layer_get_outline_width (GimpTextLayer *layer,
GimpUnit **outline_unit)
{
GimpValueArray *args;
GimpValueArray *return_vals;
@ -1807,7 +1809,10 @@ gimp_text_layer_get_outline_width (GimpTextLayer *layer)
gimp_value_array_unref (args);
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
outline_width = GIMP_VALUES_GET_DOUBLE (return_vals, 1);
{
outline_width = GIMP_VALUES_GET_DOUBLE (return_vals, 1);
*outline_unit = GIMP_VALUES_GET_UNIT (return_vals, 2);
}
gimp_value_array_unref (return_vals);
@ -1818,6 +1823,7 @@ gimp_text_layer_get_outline_width (GimpTextLayer *layer)
* gimp_text_layer_set_outline_width:
* @layer: The text layer.
* @outline_width: The text outline width.
* @outline_unit: The unit to use for the outline width.
*
* Set the outline width from a text layer.
*
@ -1830,7 +1836,8 @@ gimp_text_layer_get_outline_width (GimpTextLayer *layer)
**/
gboolean
gimp_text_layer_set_outline_width (GimpTextLayer *layer,
gdouble outline_width)
gdouble outline_width,
GimpUnit *outline_unit)
{
GimpValueArray *args;
GimpValueArray *return_vals;
@ -1839,6 +1846,7 @@ gimp_text_layer_set_outline_width (GimpTextLayer *layer,
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_TEXT_LAYER, layer,
G_TYPE_DOUBLE, outline_width,
GIMP_TYPE_UNIT, outline_unit,
G_TYPE_NONE);
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),

View file

@ -105,9 +105,11 @@ gboolean gimp_text_layer_set_outline_join_style (GimpTextLayer
gdouble gimp_text_layer_get_outline_miter_limit (GimpTextLayer *layer);
gboolean gimp_text_layer_set_outline_miter_limit (GimpTextLayer *layer,
gdouble outline_miter_limit);
gdouble gimp_text_layer_get_outline_width (GimpTextLayer *layer);
gdouble gimp_text_layer_get_outline_width (GimpTextLayer *layer,
GimpUnit **outline_unit);
gboolean gimp_text_layer_set_outline_width (GimpTextLayer *layer,
gdouble outline_width);
gdouble outline_width,
GimpUnit *outline_unit);
gboolean gimp_text_layer_resize (GimpTextLayer *layer,
gdouble width,
gdouble height);

View file

@ -1445,7 +1445,9 @@ HELP
@outargs = (
{ name => 'outline_width', type => 'double',
desc => 'The text outline width' }
desc => 'The text outline width' },
{ name => 'outline_unit', type => 'unit',
desc => 'The unit used for the outline width' }
);
%invoke = (
@ -1453,6 +1455,7 @@ HELP
{
g_object_get (gimp_text_layer_get_text (layer),
"outline-width", &outline_width,
"outline-unit", &outline_unit,
NULL);
}
CODE
@ -1472,7 +1475,9 @@ HELP
{ name => 'layer', type => 'text_layer',
desc => 'The text layer' },
{ name => 'outline_width', type => '0.0 <= double <= 8192.0',
desc => 'The text outline width' }
desc => 'The text outline width' },
{ name => 'outline_unit', type => 'unit', allow_pixel => 1,
desc => 'The unit to use for the outline width' }
);
%invoke = (
@ -1481,6 +1486,7 @@ HELP
gimp_text_layer_set (layer,
_("Set text layer attribute"),
"outline-width", outline_width,
"outline-unit", outline_unit,
NULL);
}
CODE