app, libgimp, pdb: new procedures gimp_vector_layer_get_(fill|stroke)_pattern().

This commit is contained in:
Jehan 2025-10-15 00:10:54 +02:00
parent e1b6e93727
commit cf9cfbb4ab
6 changed files with 400 additions and 13 deletions

View file

@ -30,7 +30,7 @@
#include "internal-procs.h"
/* 777 procedures registered total */
/* 779 procedures registered total */
void
internal_procs_init (GimpPDB *pdb)

View file

@ -38,6 +38,7 @@
#include "core/gimpdashpattern.h"
#include "core/gimpimage.h"
#include "core/gimpparamspecs.h"
#include "core/gimppattern.h"
#include "core/gimprasterizable.h"
#include "core/gimpstrokeoptions.h"
#include "path/gimppath.h"
@ -225,9 +226,16 @@ vector_layer_get_fill_color_invoker (GimpProcedure *procedure,
success = FALSE;
if (success)
color =
gegl_color_duplicate (gimp_context_get_foreground (
GIMP_CONTEXT (options->fill_options)));
{
GimpCustomStyle style = gimp_fill_options_get_custom_style (options->fill_options);
if (style == GIMP_CUSTOM_STYLE_SOLID_COLOR ||
! gimp_context_get_pattern (GIMP_CONTEXT (options->fill_options)))
color =
gegl_color_duplicate (gimp_context_get_foreground (GIMP_CONTEXT (options->fill_options)));
else
success = FALSE;
}
}
return_vals = gimp_procedure_get_return_values (procedure, success,
@ -239,6 +247,50 @@ vector_layer_get_fill_color_invoker (GimpProcedure *procedure,
return return_vals;
}
static GimpValueArray *
vector_layer_get_fill_pattern_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
GimpVectorLayer *layer;
GimpPattern *pattern = NULL;
layer = g_value_get_object (gimp_value_array_index (args, 0));
if (success)
{
GimpVectorLayerOptions *options;
options = gimp_vector_layer_get_options (layer);
if (! options)
success = FALSE;
if (success)
{
GimpCustomStyle style = gimp_fill_options_get_custom_style (options->fill_options);
if (style == GIMP_CUSTOM_STYLE_PATTERN)
pattern = gimp_context_get_pattern (GIMP_CONTEXT (options->fill_options));
if (pattern == NULL)
success = FALSE;
}
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_object (gimp_value_array_index (return_vals, 1), pattern);
return return_vals;
}
static GimpValueArray *
vector_layer_get_path_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -331,8 +383,15 @@ vector_layer_get_stroke_color_invoker (GimpProcedure *procedure,
success = FALSE;
if (success)
color = gegl_color_duplicate (gimp_context_get_foreground (
GIMP_CONTEXT (options->stroke_options)));
{
GimpCustomStyle style = gimp_fill_options_get_custom_style (GIMP_FILL_OPTIONS (options->stroke_options));
if (style == GIMP_CUSTOM_STYLE_SOLID_COLOR ||
! gimp_context_get_pattern (GIMP_CONTEXT (options->stroke_options)))
color = gegl_color_duplicate (gimp_context_get_foreground (GIMP_CONTEXT (options->stroke_options)));
else
success = FALSE;
}
}
return_vals = gimp_procedure_get_return_values (procedure, success,
@ -344,6 +403,50 @@ vector_layer_get_stroke_color_invoker (GimpProcedure *procedure,
return return_vals;
}
static GimpValueArray *
vector_layer_get_stroke_pattern_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
GimpVectorLayer *layer;
GimpPattern *pattern = NULL;
layer = g_value_get_object (gimp_value_array_index (args, 0));
if (success)
{
GimpVectorLayerOptions *options;
options = gimp_vector_layer_get_options (layer);
if (! options)
success = FALSE;
if (success)
{
GimpCustomStyle style = gimp_fill_options_get_custom_style (GIMP_FILL_OPTIONS (options->stroke_options));
if (style == GIMP_CUSTOM_STYLE_PATTERN)
pattern = gimp_context_get_pattern (GIMP_CONTEXT (options->stroke_options));
if (pattern == NULL)
success = FALSE;
}
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_object (gimp_value_array_index (return_vals, 1), pattern);
return return_vals;
}
static GimpValueArray *
vector_layer_get_stroke_dash_offset_invoker (GimpProcedure *procedure,
Gimp *gimp,
@ -1074,7 +1177,9 @@ register_vector_layer_procs (GimpPDB *pdb)
"gimp-vector-layer-get-fill-color");
gimp_procedure_set_static_help (procedure,
"Get the color of the fill in a vector layer.",
"This procedure returns the color of the fill in a vector layer.",
"This procedure returns the color of the fill in a vector layer.\n"
"\n"
"Note that there won't be both a fill color and pattern, so either this procedure or [method@Gimp.VectorLayer.get_fill_pattern] will return %NULL at any given time.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Alex S.",
@ -1096,6 +1201,39 @@ register_vector_layer_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-vector-layer-get-fill-pattern
*/
procedure = gimp_procedure_new (vector_layer_get_fill_pattern_invoker, FALSE);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-vector-layer-get-fill-pattern");
gimp_procedure_set_static_help (procedure,
"Get the pattern of the fill in a vector layer.",
"This procedure returns the pattern of the fill in a vector layer.\n"
"\n"
"Note that there won't be both a fill color and pattern, so either this procedure or [method@Gimp.VectorLayer.get_fill_color] will return %NULL at any given time.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Jehan",
"Jehan",
"2025");
gimp_procedure_add_argument (procedure,
gimp_param_spec_vector_layer ("layer",
"layer",
"The vector layer.",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_pattern ("pattern",
"pattern",
"The pattern of the fill.",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-vector-layer-get-path
*/
@ -1163,7 +1301,9 @@ register_vector_layer_procs (GimpPDB *pdb)
"gimp-vector-layer-get-stroke-color");
gimp_procedure_set_static_help (procedure,
"Get the color of the stroke in a vector layer.",
"This procedure returns the color of the stroke in a vector layer.",
"This procedure returns the color of the stroke in a vector layer.\n"
"\n"
"Note that there won't be both a stroke color and pattern, so either this procedure or [method@Gimp.VectorLayer.get_stroke_pattern] will return %NULL at any given time.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Alex S.",
@ -1185,6 +1325,39 @@ register_vector_layer_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-vector-layer-get-stroke-pattern
*/
procedure = gimp_procedure_new (vector_layer_get_stroke_pattern_invoker, FALSE);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-vector-layer-get-stroke-pattern");
gimp_procedure_set_static_help (procedure,
"Get the pattern of the stroke in a vector layer.",
"This procedure returns the pattern of the fill in a vector layer.\n"
"\n"
"Note that there won't be both a stroke color and pattern, so either this procedure or [method@Gimp.VectorLayer.get_stroke_color] will return %NULL at any given time.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Jehan",
"Jehan",
"2025");
gimp_procedure_add_argument (procedure,
gimp_param_spec_vector_layer ("layer",
"layer",
"The vector layer.",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_pattern ("pattern",
"pattern",
"The pattern of the fill.",
FALSE,
NULL,
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-vector-layer-get-stroke-dash-offset
*/

View file

@ -1115,6 +1115,7 @@ EXPORTS
gimp_vector_layer_get_enable_fill
gimp_vector_layer_get_enable_stroke
gimp_vector_layer_get_fill_color
gimp_vector_layer_get_fill_pattern
gimp_vector_layer_get_path
gimp_vector_layer_get_stroke_cap_style
gimp_vector_layer_get_stroke_color
@ -1122,6 +1123,7 @@ EXPORTS
gimp_vector_layer_get_stroke_dash_pattern
gimp_vector_layer_get_stroke_join_style
gimp_vector_layer_get_stroke_miter_limit
gimp_vector_layer_get_stroke_pattern
gimp_vector_layer_get_stroke_width
gimp_vector_layer_get_stroke_width_unit
gimp_vector_layer_get_type

View file

@ -204,6 +204,10 @@ gimp_vector_layer_get_enable_stroke (GimpVectorLayer *layer)
*
* This procedure returns the color of the fill in a vector layer.
*
* Note that there won't be both a fill color and pattern, so either
* this procedure or [method@Gimp.VectorLayer.get_fill_pattern] will
* return %NULL at any given time.
*
* Returns: (transfer full): The color of the fill.
*
* Since: 3.2
@ -232,6 +236,46 @@ gimp_vector_layer_get_fill_color (GimpVectorLayer *layer)
return color;
}
/**
* gimp_vector_layer_get_fill_pattern:
* @layer: The vector layer.
*
* Get the pattern of the fill in a vector layer.
*
* This procedure returns the pattern of the fill in a vector layer.
*
* Note that there won't be both a fill color and pattern, so either
* this procedure or [method@Gimp.VectorLayer.get_fill_color] will
* return %NULL at any given time.
*
* Returns: (transfer none): The pattern of the fill.
*
* Since: 3.2
**/
GimpPattern *
gimp_vector_layer_get_fill_pattern (GimpVectorLayer *layer)
{
GimpValueArray *args;
GimpValueArray *return_vals;
GimpPattern *pattern = NULL;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_VECTOR_LAYER, layer,
G_TYPE_NONE);
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-vector-layer-get-fill-pattern",
args);
gimp_value_array_unref (args);
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
pattern = GIMP_VALUES_GET_PATTERN (return_vals, 1);
gimp_value_array_unref (return_vals);
return pattern;
}
/**
* gimp_vector_layer_get_path:
* @layer: The vector layer.
@ -313,6 +357,10 @@ gimp_vector_layer_get_stroke_cap_style (GimpVectorLayer *layer)
*
* This procedure returns the color of the stroke in a vector layer.
*
* Note that there won't be both a stroke color and pattern, so either
* this procedure or [method@Gimp.VectorLayer.get_stroke_pattern] will
* return %NULL at any given time.
*
* Returns: (transfer full): The color of the stroke.
*
* Since: 3.2
@ -341,6 +389,46 @@ gimp_vector_layer_get_stroke_color (GimpVectorLayer *layer)
return color;
}
/**
* gimp_vector_layer_get_stroke_pattern:
* @layer: The vector layer.
*
* Get the pattern of the stroke in a vector layer.
*
* This procedure returns the pattern of the fill in a vector layer.
*
* Note that there won't be both a stroke color and pattern, so either
* this procedure or [method@Gimp.VectorLayer.get_stroke_color] will
* return %NULL at any given time.
*
* Returns: (transfer none): The pattern of the fill.
*
* Since: 3.2
**/
GimpPattern *
gimp_vector_layer_get_stroke_pattern (GimpVectorLayer *layer)
{
GimpValueArray *args;
GimpValueArray *return_vals;
GimpPattern *pattern = NULL;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_VECTOR_LAYER, layer,
G_TYPE_NONE);
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-vector-layer-get-stroke-pattern",
args);
gimp_value_array_unref (args);
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
pattern = GIMP_VALUES_GET_PATTERN (return_vals, 1);
gimp_value_array_unref (return_vals);
return pattern;
}
/**
* gimp_vector_layer_get_stroke_dash_offset:
* @layer: The vector layer.

View file

@ -38,9 +38,11 @@ gboolean gimp_vector_layer_refresh (GimpVectorLayer *la
gboolean gimp_vector_layer_get_enable_fill (GimpVectorLayer *layer);
gboolean gimp_vector_layer_get_enable_stroke (GimpVectorLayer *layer);
GeglColor* gimp_vector_layer_get_fill_color (GimpVectorLayer *layer);
GimpPattern* gimp_vector_layer_get_fill_pattern (GimpVectorLayer *layer);
GimpPath* gimp_vector_layer_get_path (GimpVectorLayer *layer);
GimpCapStyle gimp_vector_layer_get_stroke_cap_style (GimpVectorLayer *layer);
GeglColor* gimp_vector_layer_get_stroke_color (GimpVectorLayer *layer);
GimpPattern* gimp_vector_layer_get_stroke_pattern (GimpVectorLayer *layer);
gdouble gimp_vector_layer_get_stroke_dash_offset (GimpVectorLayer *layer);
gboolean gimp_vector_layer_get_stroke_dash_pattern (GimpVectorLayer *layer,
gsize *num_dashes,

View file

@ -209,6 +209,11 @@ sub vector_layer_get_stroke_color {
$help = <<'HELP';
This procedure returns the color of the stroke in a vector layer.
Note that there won't be both a stroke color and pattern, so either this
procedure or [method@Gimp.VectorLayer.get_stroke_pattern] will return
%NULL at any given time.
HELP
&alxsa_pdb_misc('2025', '3.2');
@ -233,8 +238,63 @@ HELP
success = FALSE;
if (success)
color = gegl_color_duplicate (gimp_context_get_foreground (
GIMP_CONTEXT (options->stroke_options)));
{
GimpCustomStyle style = gimp_fill_options_get_custom_style (GIMP_FILL_OPTIONS (options->stroke_options));
if (style == GIMP_CUSTOM_STYLE_SOLID_COLOR ||
! gimp_context_get_pattern (GIMP_CONTEXT (options->stroke_options)))
color = gegl_color_duplicate (gimp_context_get_foreground (GIMP_CONTEXT (options->stroke_options)));
else
success = FALSE;
}
}
CODE
);
}
sub vector_layer_get_stroke_pattern {
$blurb = 'Get the pattern of the stroke in a vector layer.';
$help = <<'HELP';
This procedure returns the pattern of the fill in a vector layer.
Note that there won't be both a stroke color and pattern, so either this
procedure or [method@Gimp.VectorLayer.get_stroke_color] will return
%NULL at any given time.
HELP
&jehan_pdb_misc('2025', '3.2');
@inargs = (
{ name => 'layer', type => 'vector_layer',
desc => 'The vector layer.' }
);
@outargs = (
{ name => 'pattern', type => 'pattern',
desc => 'The pattern of the fill.' }
);
%invoke = (
code => <<'CODE'
{
GimpVectorLayerOptions *options;
options = gimp_vector_layer_get_options (layer);
if (! options)
success = FALSE;
if (success)
{
GimpCustomStyle style = gimp_fill_options_get_custom_style (GIMP_FILL_OPTIONS (options->stroke_options));
if (style == GIMP_CUSTOM_STYLE_PATTERN)
pattern = gimp_context_get_pattern (GIMP_CONTEXT (options->stroke_options));
if (pattern == NULL)
success = FALSE;
}
}
CODE
);
@ -850,6 +910,11 @@ sub vector_layer_get_fill_color {
$help = <<'HELP';
This procedure returns the color of the fill in a vector layer.
Note that there won't be both a fill color and pattern, so either this
procedure or [method@Gimp.VectorLayer.get_fill_pattern] will return
%NULL at any given time.
HELP
&alxsa_pdb_misc('2025', '3.2');
@ -874,9 +939,64 @@ HELP
success = FALSE;
if (success)
color =
gegl_color_duplicate (gimp_context_get_foreground (
GIMP_CONTEXT (options->fill_options)));
{
GimpCustomStyle style = gimp_fill_options_get_custom_style (options->fill_options);
if (style == GIMP_CUSTOM_STYLE_SOLID_COLOR ||
! gimp_context_get_pattern (GIMP_CONTEXT (options->fill_options)))
color =
gegl_color_duplicate (gimp_context_get_foreground (GIMP_CONTEXT (options->fill_options)));
else
success = FALSE;
}
}
CODE
);
}
sub vector_layer_get_fill_pattern {
$blurb = 'Get the pattern of the fill in a vector layer.';
$help = <<'HELP';
This procedure returns the pattern of the fill in a vector layer.
Note that there won't be both a fill color and pattern, so either this
procedure or [method@Gimp.VectorLayer.get_fill_color] will return
%NULL at any given time.
HELP
&jehan_pdb_misc('2025', '3.2');
@inargs = (
{ name => 'layer', type => 'vector_layer',
desc => 'The vector layer.' }
);
@outargs = (
{ name => 'pattern', type => 'pattern',
desc => 'The pattern of the fill.' }
);
%invoke = (
code => <<'CODE'
{
GimpVectorLayerOptions *options;
options = gimp_vector_layer_get_options (layer);
if (! options)
success = FALSE;
if (success)
{
GimpCustomStyle style = gimp_fill_options_get_custom_style (options->fill_options);
if (style == GIMP_CUSTOM_STYLE_PATTERN)
pattern = gimp_context_get_pattern (GIMP_CONTEXT (options->fill_options));
if (pattern == NULL)
success = FALSE;
}
}
CODE
);
@ -931,9 +1051,11 @@ CODE
vector_layer_get_enable_fill
vector_layer_get_enable_stroke
vector_layer_get_fill_color
vector_layer_get_fill_pattern
vector_layer_get_path
vector_layer_get_stroke_cap_style
vector_layer_get_stroke_color
vector_layer_get_stroke_pattern
vector_layer_get_stroke_dash_offset
vector_layer_get_stroke_dash_pattern
vector_layer_get_stroke_join_style