app, libgimp, pdb, plug-ins: new GimpGroupLayer class in libgimp.

Also:

- renaming gimp_layer_group_new() to gimp_group_layer_new() in order to keep the
  same name as in core code (i.e. GimpGroupLayer, not GimpLayerGroup).
- renaming gimp_image_merge_layer_group() to gimp_group_layer_merge()
- new functions: gimp_procedure_add_group_layer_argument(),
  gimp_procedure_add_group_layer_aux_argument() and
  gimp_procedure_add_group_layer_return_value().

This can be tested, e.g. in Python with these calls:

```py
i = Gimp.get_images()[0]
g = Gimp.GroupLayer.new(i, "hello")
i.insert_layer(g, None, 1)
g2 = Gimp.GroupLayer.new(i, "world")
i.insert_layer(g2, g, 1)
g.merge()
```

This was work started long ago, stored in an old stash which I finally
finish now! :-)
This commit is contained in:
Jehan 2024-07-06 17:24:11 +02:00
parent 98d3956fef
commit b1736a6736
43 changed files with 1059 additions and 327 deletions

View file

@ -28,6 +28,7 @@
#include "gimpbrush.h" #include "gimpbrush.h"
#include "gimpdisplay.h" #include "gimpdisplay.h"
#include "gimpgradient.h" #include "gimpgradient.h"
#include "gimpgrouplayer.h"
#include "gimpimage.h" #include "gimpimage.h"
#include "gimplayer.h" #include "gimplayer.h"
#include "gimplayermask.h" #include "gimplayermask.h"

187
app/pdb/group-layer-cmds.c Normal file
View file

@ -0,0 +1,187 @@
/* GIMP - The GNU Image Manipulation Program
* Copyright (C) 1995-2003 Spencer Kimball and Peter Mattis
*
* 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/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl. */
#include "config.h"
#include "stamp-pdbgen.h"
#include <cairo.h>
#include <gegl.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpbase/gimpbase.h"
#include "pdb-types.h"
#include "core/gimp.h"
#include "core/gimpgrouplayer.h"
#include "core/gimpimage-merge.h"
#include "core/gimpimage.h"
#include "core/gimplayer.h"
#include "core/gimpparamspecs.h"
#include "gimppdb.h"
#include "gimppdb-utils.h"
#include "gimpprocedure.h"
#include "internal-procs.h"
#include "gimp-intl.h"
static GimpValueArray *
group_layer_new_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
GimpImage *image;
GimpGroupLayer *group_layer = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0));
if (success)
{
group_layer = GIMP_GROUP_LAYER (gimp_group_layer_new (image));
if (! group_layer)
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), group_layer);
return return_vals;
}
static GimpValueArray *
group_layer_merge_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
GimpGroupLayer *group_layer;
GimpLayer *layer = NULL;
group_layer = g_value_get_object (gimp_value_array_index (args, 0));
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (group_layer), NULL, 0, error) &&
gimp_pdb_item_is_group (GIMP_ITEM (group_layer), error))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (group_layer));
layer = gimp_image_merge_group_layer (image, group_layer);
if (! layer)
success = FALSE;
}
else
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), layer);
return return_vals;
}
void
register_group_layer_procs (GimpPDB *pdb)
{
GimpProcedure *procedure;
/*
* gimp-group-layer-new
*/
procedure = gimp_procedure_new (group_layer_new_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-group-layer-new");
gimp_procedure_set_static_help (procedure,
"Create a new group layer.",
"This procedure creates a new group layer. Attributes such as layer mode and opacity should be set with explicit procedure calls. Add the new group layer (which is a kind of layer) with [method@image.insert_layer].\n"
"Other procedures useful with group layers: [method@image_reorder_item], [method@item.get_parent], [method@item.get_children], [method@item.is_group].",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Barak Itkin <lightningismyname@gmail.com>",
"Barak Itkin",
"2010");
gimp_procedure_add_argument (procedure,
gimp_param_spec_image ("image",
"image",
"The image to which to add the layer group",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_group_layer ("group-layer",
"group layer",
"The newly created group layer",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/*
* gimp-group-layer-merge
*/
procedure = gimp_procedure_new (group_layer_merge_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-group-layer-merge");
gimp_procedure_set_static_help (procedure,
"Merge the passed group layer's layers into one normal layer.",
"This procedure combines the layers of the passed group layer into a single normal layer, replacing the group.\n"
"The group layer is expected to be attached to an image.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Ell",
"Ell",
"2019");
gimp_procedure_add_argument (procedure,
gimp_param_spec_group_layer ("group-layer",
"group layer",
"The layer group to merge",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_layer ("layer",
"layer",
"The resulting layer",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
}

View file

@ -39,7 +39,6 @@
#include "core/gimpchannel.h" #include "core/gimpchannel.h"
#include "core/gimpcontainer.h" #include "core/gimpcontainer.h"
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpgrouplayer.h"
#include "core/gimpimage-color-profile.h" #include "core/gimpimage-color-profile.h"
#include "core/gimpimage-colormap.h" #include "core/gimpimage-colormap.h"
#include "core/gimpimage-duplicate.h" #include "core/gimpimage-duplicate.h"
@ -1472,47 +1471,6 @@ image_merge_down_invoker (GimpProcedure *procedure,
return return_vals; return return_vals;
} }
static GimpValueArray *
image_merge_layer_group_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
GimpImage *image;
GimpLayer *layer_group;
GimpLayer *layer = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0));
layer_group = g_value_get_object (gimp_value_array_index (args, 1));
if (success)
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (layer_group), image, 0, error) &&
gimp_pdb_item_is_group (GIMP_ITEM (layer_group), error))
{
layer = gimp_image_merge_group_layer (image,
GIMP_GROUP_LAYER (layer_group));
if (! layer)
success = FALSE;
}
else
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), layer);
return return_vals;
}
static GimpValueArray * static GimpValueArray *
image_get_colormap_invoker (GimpProcedure *procedure, image_get_colormap_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
@ -4287,41 +4245,6 @@ register_image_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);
/*
* gimp-image-merge-layer-group
*/
procedure = gimp_procedure_new (image_merge_layer_group_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-image-merge-layer-group");
gimp_procedure_set_static_help (procedure,
"Merge the passed layer group's layers into one normal layer.",
"This procedure combines the layers of the passed layer group into a single normal layer, replacing the group.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Ell",
"Ell",
"2019");
gimp_procedure_add_argument (procedure,
gimp_param_spec_image ("image",
"image",
"The image",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_argument (procedure,
gimp_param_spec_layer ("layer-group",
"layer group",
"The layer group to merge",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_layer ("layer",
"layer",
"The resulting layer",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/* /*
* gimp-image-get-colormap * gimp-image-get-colormap
*/ */

View file

@ -30,7 +30,7 @@
#include "internal-procs.h" #include "internal-procs.h"
/* 785 procedures registered total */ /* 786 procedures registered total */
void void
internal_procs_init (GimpPDB *pdb) internal_procs_init (GimpPDB *pdb)
@ -61,6 +61,7 @@ internal_procs_init (GimpPDB *pdb)
register_gradient_procs (pdb); register_gradient_procs (pdb);
register_gradient_select_procs (pdb); register_gradient_select_procs (pdb);
register_gradients_procs (pdb); register_gradients_procs (pdb);
register_group_layer_procs (pdb);
register_help_procs (pdb); register_help_procs (pdb);
register_image_procs (pdb); register_image_procs (pdb);
register_image_color_profile_procs (pdb); register_image_color_profile_procs (pdb);

View file

@ -48,6 +48,7 @@ void register_gimprc_procs (GimpPDB *pdb);
void register_gradient_procs (GimpPDB *pdb); void register_gradient_procs (GimpPDB *pdb);
void register_gradient_select_procs (GimpPDB *pdb); void register_gradient_select_procs (GimpPDB *pdb);
void register_gradients_procs (GimpPDB *pdb); void register_gradients_procs (GimpPDB *pdb);
void register_group_layer_procs (GimpPDB *pdb);
void register_help_procs (GimpPDB *pdb); void register_help_procs (GimpPDB *pdb);
void register_image_procs (GimpPDB *pdb); void register_image_procs (GimpPDB *pdb);
void register_image_color_profile_procs (GimpPDB *pdb); void register_image_color_profile_procs (GimpPDB *pdb);

View file

@ -31,6 +31,7 @@
#include "pdb-types.h" #include "pdb-types.h"
#include "core/gimpgrouplayer.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
#include "core/gimpitem.h" #include "core/gimpitem.h"
#include "core/gimplayermask.h" #include "core/gimplayermask.h"
@ -178,6 +179,37 @@ item_id_is_text_layer_invoker (GimpProcedure *procedure,
return return_vals; return return_vals;
} }
static GimpValueArray *
item_id_is_group_layer_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
gint item_id;
gboolean group_layer = FALSE;
item_id = g_value_get_int (gimp_value_array_index (args, 0));
if (success)
{
GimpItem *item = gimp_item_get_by_id (gimp, item_id);
group_layer = (GIMP_IS_GROUP_LAYER (item) && ! gimp_item_is_removed (item));
}
return_vals = gimp_procedure_get_return_values (procedure, success,
error ? *error : NULL);
if (success)
g_value_set_boolean (gimp_value_array_index (return_vals, 1), group_layer);
return return_vals;
}
static GimpValueArray * static GimpValueArray *
item_id_is_channel_invoker (GimpProcedure *procedure, item_id_is_channel_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
@ -1145,6 +1177,35 @@ register_item_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);
/*
* gimp-item-id-is-group-layer
*/
procedure = gimp_procedure_new (item_id_is_group_layer_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-item-id-is-group-layer");
gimp_procedure_set_static_help (procedure,
"Returns whether the item ID is a group layer.",
"This procedure returns TRUE if the specified item ID is a group layer.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Jehan",
"Jehan",
"2024");
gimp_procedure_add_argument (procedure,
g_param_spec_int ("item-id",
"item id",
"The item ID",
G_MININT32, G_MAXINT32, 0,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
g_param_spec_boolean ("group-layer",
"group layer",
"TRUE if the item is a group layer, FALSE otherwise.",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/* /*
* gimp-item-id-is-channel * gimp-item-id-is-channel
*/ */

View file

@ -36,7 +36,6 @@
#include "core/gimp.h" #include "core/gimp.h"
#include "core/gimpdrawable.h" #include "core/gimpdrawable.h"
#include "core/gimpgrouplayer.h"
#include "core/gimpimage-color-profile.h" #include "core/gimpimage-color-profile.h"
#include "core/gimpimage-undo.h" #include "core/gimpimage-undo.h"
#include "core/gimpimage.h" #include "core/gimpimage.h"
@ -249,38 +248,6 @@ layer_new_from_drawable_invoker (GimpProcedure *procedure,
return return_vals; return return_vals;
} }
static GimpValueArray *
layer_group_new_invoker (GimpProcedure *procedure,
Gimp *gimp,
GimpContext *context,
GimpProgress *progress,
const GimpValueArray *args,
GError **error)
{
gboolean success = TRUE;
GimpValueArray *return_vals;
GimpImage *image;
GimpLayer *layer_group = NULL;
image = g_value_get_object (gimp_value_array_index (args, 0));
if (success)
{
layer_group = gimp_group_layer_new (image);
if (! layer_group)
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), layer_group);
return return_vals;
}
static GimpValueArray * static GimpValueArray *
layer_copy_invoker (GimpProcedure *procedure, layer_copy_invoker (GimpProcedure *procedure,
Gimp *gimp, Gimp *gimp,
@ -1394,36 +1361,6 @@ register_layer_procs (GimpPDB *pdb)
gimp_pdb_register_procedure (pdb, procedure); gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure); g_object_unref (procedure);
/*
* gimp-layer-group-new
*/
procedure = gimp_procedure_new (layer_group_new_invoker);
gimp_object_set_static_name (GIMP_OBJECT (procedure),
"gimp-layer-group-new");
gimp_procedure_set_static_help (procedure,
"Create a new layer group.",
"This procedure creates a new layer group. Attributes such as layer mode and opacity should be set with explicit procedure calls. Add the new layer group (which is a kind of layer) with the 'gimp-image-insert-layer' command.\n"
"Other procedures useful with layer groups: 'gimp-image-reorder-item', 'gimp-item-get-parent', 'gimp-item-get-children', 'gimp-item-is-group'.",
NULL);
gimp_procedure_set_static_attribution (procedure,
"Barak Itkin <lightningismyname@gmail.com>",
"Barak Itkin",
"2010");
gimp_procedure_add_argument (procedure,
gimp_param_spec_image ("image",
"image",
"The image to which to add the layer group",
FALSE,
GIMP_PARAM_READWRITE));
gimp_procedure_add_return_value (procedure,
gimp_param_spec_layer ("layer-group",
"layer group",
"The newly created layer group",
FALSE,
GIMP_PARAM_READWRITE));
gimp_pdb_register_procedure (pdb, procedure);
g_object_unref (procedure);
/* /*
* gimp-layer-copy * gimp-layer-copy
*/ */

View file

@ -32,6 +32,7 @@ libappinternalprocs_sources = [
'gradient-cmds.c', 'gradient-cmds.c',
'gradient-select-cmds.c', 'gradient-select-cmds.c',
'gradients-cmds.c', 'gradients-cmds.c',
'group-layer-cmds.c',
'help-cmds.c', 'help-cmds.c',
'image-cmds.c', 'image-cmds.c',
'image-color-profile-cmds.c', 'image-color-profile-cmds.c',

View file

@ -368,6 +368,10 @@ EXPORTS
gimp_gradients_popup gimp_gradients_popup
gimp_gradients_refresh gimp_gradients_refresh
gimp_gradients_set_popup gimp_gradients_set_popup
gimp_group_layer_get_by_id
gimp_group_layer_get_type
gimp_group_layer_merge
gimp_group_layer_new
gimp_heal gimp_heal
gimp_heal_default gimp_heal_default
gimp_help gimp_help
@ -474,7 +478,6 @@ EXPORTS
gimp_image_lower_item gimp_image_lower_item
gimp_image_lower_item_to_bottom gimp_image_lower_item_to_bottom
gimp_image_merge_down gimp_image_merge_down
gimp_image_merge_layer_group
gimp_image_merge_visible_layers gimp_image_merge_visible_layers
gimp_image_metadata_load_finish gimp_image_metadata_load_finish
gimp_image_metadata_load_prepare gimp_image_metadata_load_prepare
@ -559,6 +562,7 @@ EXPORTS
gimp_item_get_visible gimp_item_get_visible
gimp_item_id_is_channel gimp_item_id_is_channel
gimp_item_id_is_drawable gimp_item_id_is_drawable
gimp_item_id_is_group_layer
gimp_item_id_is_layer gimp_item_id_is_layer
gimp_item_id_is_layer_mask gimp_item_id_is_layer_mask
gimp_item_id_is_selection gimp_item_id_is_selection
@ -568,6 +572,7 @@ EXPORTS
gimp_item_is_channel gimp_item_is_channel
gimp_item_is_drawable gimp_item_is_drawable
gimp_item_is_group gimp_item_is_group
gimp_item_is_group_layer
gimp_item_is_layer gimp_item_is_layer
gimp_item_is_layer_mask gimp_item_is_layer_mask
gimp_item_is_selection gimp_item_is_selection
@ -613,7 +618,6 @@ EXPORTS
gimp_layer_get_opacity gimp_layer_get_opacity
gimp_layer_get_show_mask gimp_layer_get_show_mask
gimp_layer_get_type gimp_layer_get_type
gimp_layer_group_new
gimp_layer_is_floating_sel gimp_layer_is_floating_sel
gimp_layer_mask_get_by_id gimp_layer_mask_get_by_id
gimp_layer_mask_get_type gimp_layer_mask_get_type
@ -675,6 +679,7 @@ EXPORTS
gimp_param_drawable_get_type gimp_param_drawable_get_type
gimp_param_font_get_type gimp_param_font_get_type
gimp_param_gradient_get_type gimp_param_gradient_get_type
gimp_param_group_layer_get_type
gimp_param_image_get_type gimp_param_image_get_type
gimp_param_item_get_type gimp_param_item_get_type
gimp_param_layer_get_type gimp_param_layer_get_type
@ -690,6 +695,7 @@ EXPORTS
gimp_param_spec_font gimp_param_spec_font
gimp_param_spec_get_desc gimp_param_spec_get_desc
gimp_param_spec_gradient gimp_param_spec_gradient
gimp_param_spec_group_layer
gimp_param_spec_image gimp_param_spec_image
gimp_param_spec_item gimp_param_spec_item
gimp_param_spec_layer gimp_param_spec_layer
@ -779,6 +785,9 @@ EXPORTS
gimp_procedure_add_gradient_argument gimp_procedure_add_gradient_argument
gimp_procedure_add_gradient_aux_argument gimp_procedure_add_gradient_aux_argument
gimp_procedure_add_gradient_return_value gimp_procedure_add_gradient_return_value
gimp_procedure_add_group_layer_argument
gimp_procedure_add_group_layer_aux_argument
gimp_procedure_add_group_layer_return_value
gimp_procedure_add_image_argument gimp_procedure_add_image_argument
gimp_procedure_add_image_aux_argument gimp_procedure_add_image_aux_argument
gimp_procedure_add_image_return_value gimp_procedure_add_image_return_value

View file

@ -46,6 +46,7 @@
#include <libgimp/gimpfont.h> #include <libgimp/gimpfont.h>
#include <libgimp/gimpgimprc.h> #include <libgimp/gimpgimprc.h>
#include <libgimp/gimpgradient.h> #include <libgimp/gimpgradient.h>
#include <libgimp/gimpgrouplayer.h>
#include <libgimp/gimpimage.h> #include <libgimp/gimpimage.h>
#include <libgimp/gimpimagecolorprofile.h> #include <libgimp/gimpimagecolorprofile.h>
#include <libgimp/gimpimagemetadata.h> #include <libgimp/gimpimagemetadata.h>

View file

@ -51,6 +51,7 @@
#include <libgimp/gimpgradient_pdb.h> #include <libgimp/gimpgradient_pdb.h>
#include <libgimp/gimpgradients_pdb.h> #include <libgimp/gimpgradients_pdb.h>
#include <libgimp/gimpgradientselect_pdb.h> #include <libgimp/gimpgradientselect_pdb.h>
#include <libgimp/gimpgrouplayer_pdb.h>
#include <libgimp/gimphelp_pdb.h> #include <libgimp/gimphelp_pdb.h>
#include <libgimp/gimpimage_pdb.h> #include <libgimp/gimpimage_pdb.h>
#include <libgimp/gimpimagecolorprofile_pdb.h> #include <libgimp/gimpimagecolorprofile_pdb.h>

View file

@ -242,7 +242,7 @@ export_apply_masks (GimpImage *image,
* first * first
*/ */
if (gimp_item_is_group (iter->data)) if (gimp_item_is_group (iter->data))
iter->data = gimp_image_merge_layer_group (image, iter->data); iter->data = gimp_group_layer_merge (iter->data);
gimp_layer_remove_mask (iter->data, GIMP_MASK_APPLY); gimp_layer_remove_mask (iter->data, GIMP_MASK_APPLY);
} }

View file

@ -238,6 +238,11 @@ _gimp_gp_param_def_to_param_spec (const GPParamDef *param_def)
param_def->meta.m_id.none_ok, param_def->meta.m_id.none_ok,
flags); flags);
if (! strcmp (param_def->type_name, "GimpParamGroupLayer"))
return gimp_param_spec_group_layer (name, nick, blurb,
param_def->meta.m_id.none_ok,
flags);
if (! strcmp (param_def->type_name, "GimpParamChannel")) if (! strcmp (param_def->type_name, "GimpParamChannel"))
return gimp_param_spec_channel (name, nick, blurb, return gimp_param_spec_channel (name, nick, blurb,
param_def->meta.m_id.none_ok, param_def->meta.m_id.none_ok,

109
libgimp/gimpgrouplayer.c Normal file
View file

@ -0,0 +1,109 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
*
* gimpgrouplayer.c
* Copyright (C) 2022 Jehan
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include "gimp.h"
struct _GimpGroupLayer
{
GimpLayer parent_instance;
};
G_DEFINE_TYPE (GimpGroupLayer, gimp_group_layer, GIMP_TYPE_LAYER)
#define parent_class gimp_group_layer_parent_class
static void
gimp_group_layer_class_init (GimpGroupLayerClass *klass)
{
}
static void
gimp_group_layer_init (GimpGroupLayer *layer)
{
}
/* Public API. */
/**
* gimp_group_layer_get_by_id:
* @layer_id: The layer id.
*
* Returns a #GimpGroupLayer representing @layer_id. This function calls
* gimp_item_get_by_id() and returns the item if it is a group layer or
* %NULL otherwise.
*
* Returns: (nullable) (transfer none): a #GimpGroupLayer for @layer_id or
* %NULL if @layer_id does not represent a valid group layer.
* The object belongs to libgimp and you must not modify or
* unref it.
*
* Since: 3.0
**/
GimpGroupLayer *
gimp_group_layer_get_by_id (gint32 layer_id)
{
GimpItem *item = gimp_item_get_by_id (layer_id);
if (GIMP_IS_GROUP_LAYER (item))
return (GimpGroupLayer *) item;
return NULL;
}
/**
* gimp_group_layer_new:
* @image: The image to which to add the layer.
* @name: (nullable): The group layer name.
*
* Create a new group layer.
*
* This procedure creates a new group layer with a given @name. If @name is
* %NULL, GIMP will choose a name using its default layer name algorithm.
*
* The new group layer still needs to be added to the image, as this is
* not automatic. Add the new layer with the [method@Image.insert_layer]
* method.
*
* Other attributes such as layer mask modes, and offsets should be set
* with explicit procedure calls.
*
* Returns: (transfer none): The newly created group layer.
* The object belongs to libgimp and you should not free it.
*
* Since: 3.0
*/
GimpGroupLayer *
gimp_group_layer_new (GimpImage *image,
const gchar *name)
{
GimpGroupLayer *layer = _gimp_group_layer_new (image);
if (name != NULL)
gimp_item_set_name (GIMP_ITEM (layer), name);
return layer;
}

49
libgimp/gimpgrouplayer.h Normal file
View file

@ -0,0 +1,49 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
*
* gimpgrouplayer.h
* Copyright (C) 2022 Jehan
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
#if !defined (__GIMP_H_INSIDE__) && !defined (GIMP_COMPILATION)
#error "Only <libgimp/gimp.h> can be included directly."
#endif
#ifndef __GIMP_GROUP_LAYER_H__
#define __GIMP_GROUP_LAYER_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
#include <libgimp/gimplayer.h>
#define GIMP_TYPE_GROUP_LAYER (gimp_group_layer_get_type ())
G_DECLARE_FINAL_TYPE (GimpGroupLayer, gimp_group_layer, GIMP, GROUP_LAYER, GimpLayer)
GimpGroupLayer * gimp_group_layer_get_by_id (gint32 layer_id);
GimpGroupLayer * gimp_group_layer_new (GimpImage *image,
const gchar *name);
G_END_DECLS
#endif /* __GIMP_GROUP_LAYER_H__ */

View file

@ -0,0 +1,117 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* gimpgrouplayer_pdb.c
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#include "config.h"
#include "stamp-pdbgen.h"
#include "gimp.h"
/**
* SECTION: gimpgrouplayer
* @title: gimpgrouplayer
* @short_description: Operations on a group layer.
*
* Operations on a group layer.
**/
/**
* _gimp_group_layer_new:
* @image: The image to which to add the layer group.
*
* Create a new group layer.
*
* This procedure creates a new group layer. Attributes such as layer
* mode and opacity should be set with explicit procedure calls. Add
* the new group layer (which is a kind of layer) with
* [method@image.insert_layer].
* Other procedures useful with group layers:
* [method@image_reorder_item], [method@item.get_parent],
* [method@item.get_children], [method@item.is_group].
*
* Returns: (transfer none): The newly created group layer.
*
* Since: 2.8
**/
GimpGroupLayer *
_gimp_group_layer_new (GimpImage *image)
{
GimpValueArray *args;
GimpValueArray *return_vals;
GimpGroupLayer *group_layer = NULL;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image,
G_TYPE_NONE);
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-group-layer-new",
args);
gimp_value_array_unref (args);
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
group_layer = GIMP_VALUES_GET_GROUP_LAYER (return_vals, 1);
gimp_value_array_unref (return_vals);
return group_layer;
}
/**
* gimp_group_layer_merge:
* @group_layer: The layer group to merge.
*
* Merge the passed group layer's layers into one normal layer.
*
* This procedure combines the layers of the passed group layer into a
* single normal layer, replacing the group.
* The group layer is expected to be attached to an image.
*
* Returns: (transfer none): The resulting layer.
*
* Since: 2.10.14
**/
GimpLayer *
gimp_group_layer_merge (GimpGroupLayer *group_layer)
{
GimpValueArray *args;
GimpValueArray *return_vals;
GimpLayer *layer = NULL;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_GROUP_LAYER, group_layer,
G_TYPE_NONE);
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-group-layer-merge",
args);
gimp_value_array_unref (args);
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
layer = GIMP_VALUES_GET_LAYER (return_vals, 1);
gimp_value_array_unref (return_vals);
return layer;
}

View file

@ -0,0 +1,41 @@
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-2003 Peter Mattis and Spencer Kimball
*
* gimpgrouplayer_pdb.h
*
* This library is free software: you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <https://www.gnu.org/licenses/>.
*/
/* NOTE: This file is auto-generated by pdbgen.pl */
#if !defined (__GIMP_H_INSIDE__) && !defined (GIMP_COMPILATION)
#error "Only <libgimp/gimp.h> can be included directly."
#endif
#ifndef __GIMP_GROUP_LAYER_PDB_H__
#define __GIMP_GROUP_LAYER_PDB_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
G_GNUC_INTERNAL GimpGroupLayer* _gimp_group_layer_new (GimpImage *image);
GimpLayer* gimp_group_layer_merge (GimpGroupLayer *group_layer);
G_END_DECLS
#endif /* __GIMP_GROUP_LAYER_PDB_H__ */

View file

@ -1705,46 +1705,6 @@ gimp_image_merge_down (GimpImage *image,
return layer; return layer;
} }
/**
* gimp_image_merge_layer_group:
* @image: The image.
* @layer_group: The layer group to merge.
*
* Merge the passed layer group's layers into one normal layer.
*
* This procedure combines the layers of the passed layer group into a
* single normal layer, replacing the group.
*
* Returns: (transfer none): The resulting layer.
*
* Since: 2.10.14
**/
GimpLayer *
gimp_image_merge_layer_group (GimpImage *image,
GimpLayer *layer_group)
{
GimpValueArray *args;
GimpValueArray *return_vals;
GimpLayer *layer = NULL;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image,
GIMP_TYPE_LAYER, layer_group,
G_TYPE_NONE);
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-image-merge-layer-group",
args);
gimp_value_array_unref (args);
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
layer = GIMP_VALUES_GET_LAYER (return_vals, 1);
gimp_value_array_unref (return_vals);
return layer;
}
/** /**
* _gimp_image_get_colormap: * _gimp_image_get_colormap:
* @image: The image. * @image: The image.

View file

@ -113,8 +113,6 @@ GimpLayer* gimp_image_merge_visible_layers (GimpImage
GimpLayer* gimp_image_merge_down (GimpImage *image, GimpLayer* gimp_image_merge_down (GimpImage *image,
GimpLayer *merge_layer, GimpLayer *merge_layer,
GimpMergeType merge_type); GimpMergeType merge_type);
GimpLayer* gimp_image_merge_layer_group (GimpImage *image,
GimpLayer *layer_group);
G_GNUC_INTERNAL GBytes* _gimp_image_get_colormap (GimpImage *image); G_GNUC_INTERNAL GBytes* _gimp_image_get_colormap (GimpImage *image);
G_GNUC_INTERNAL gboolean _gimp_image_set_colormap (GimpImage *image, G_GNUC_INTERNAL gboolean _gimp_image_set_colormap (GimpImage *image,
GBytes *colormap); GBytes *colormap);

View file

@ -256,6 +256,25 @@ gimp_item_is_text_layer (GimpItem *item)
return gimp_item_id_is_text_layer (gimp_item_get_id (item)); return gimp_item_id_is_text_layer (gimp_item_get_id (item));
} }
/**
* gimp_item_is_group_layer:
* @item: The item.
*
* Returns whether the item is a group layer.
*
* This procedure returns TRUE if the specified item is a group
* layer.
*
* Returns: TRUE if the item is a group layer, FALSE otherwise.
*
* Since: 3.0
**/
gboolean
gimp_item_is_group_layer (GimpItem *item)
{
return gimp_item_id_is_group_layer (gimp_item_get_id (item));
}
/** /**
* gimp_item_is_channel: * gimp_item_is_channel:
* @item: The item. * @item: The item.

View file

@ -58,6 +58,7 @@ gboolean gimp_item_is_valid (GimpItem *item);
gboolean gimp_item_is_drawable (GimpItem *item); gboolean gimp_item_is_drawable (GimpItem *item);
gboolean gimp_item_is_layer (GimpItem *item); gboolean gimp_item_is_layer (GimpItem *item);
gboolean gimp_item_is_text_layer (GimpItem *item); gboolean gimp_item_is_text_layer (GimpItem *item);
gboolean gimp_item_is_group_layer (GimpItem *item);
gboolean gimp_item_is_channel (GimpItem *item); gboolean gimp_item_is_channel (GimpItem *item);
gboolean gimp_item_is_layer_mask (GimpItem *item); gboolean gimp_item_is_layer_mask (GimpItem *item);
gboolean gimp_item_is_selection (GimpItem *item); gboolean gimp_item_is_selection (GimpItem *item);

View file

@ -182,6 +182,43 @@ gimp_item_id_is_text_layer (gint item_id)
return text_layer; return text_layer;
} }
/**
* gimp_item_id_is_group_layer:
* @item_id: The item ID.
*
* Returns whether the item ID is a group layer.
*
* This procedure returns TRUE if the specified item ID is a group
* layer.
*
* Returns: TRUE if the item is a group layer, FALSE otherwise.
*
* Since: 3.0
**/
gboolean
gimp_item_id_is_group_layer (gint item_id)
{
GimpValueArray *args;
GimpValueArray *return_vals;
gboolean group_layer = FALSE;
args = gimp_value_array_new_from_types (NULL,
G_TYPE_INT, item_id,
G_TYPE_NONE);
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-item-id-is-group-layer",
args);
gimp_value_array_unref (args);
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
group_layer = GIMP_VALUES_GET_BOOLEAN (return_vals, 1);
gimp_value_array_unref (return_vals);
return group_layer;
}
/** /**
* gimp_item_id_is_channel: * gimp_item_id_is_channel:
* @item_id: The item ID. * @item_id: The item ID.

View file

@ -36,6 +36,7 @@ gboolean gimp_item_id_is_valid (gint item_id);
gboolean gimp_item_id_is_drawable (gint item_id); gboolean gimp_item_id_is_drawable (gint item_id);
gboolean gimp_item_id_is_layer (gint item_id); gboolean gimp_item_id_is_layer (gint item_id);
gboolean gimp_item_id_is_text_layer (gint item_id); gboolean gimp_item_id_is_text_layer (gint item_id);
gboolean gimp_item_id_is_group_layer (gint item_id);
gboolean gimp_item_id_is_channel (gint item_id); gboolean gimp_item_id_is_channel (gint item_id);
gboolean gimp_item_id_is_layer_mask (gint item_id); gboolean gimp_item_id_is_layer_mask (gint item_id);
gboolean gimp_item_id_is_selection (gint item_id); gboolean gimp_item_id_is_selection (gint item_id);

View file

@ -181,48 +181,6 @@ gimp_layer_new_from_drawable (GimpDrawable *drawable,
return layer_copy; return layer_copy;
} }
/**
* gimp_layer_group_new:
* @image: The image to which to add the layer group.
*
* Create a new layer group.
*
* This procedure creates a new layer group. Attributes such as layer
* mode and opacity should be set with explicit procedure calls. Add
* the new layer group (which is a kind of layer) with the
* gimp_image_insert_layer() command.
* Other procedures useful with layer groups:
* gimp_image_reorder_item(), gimp_item_get_parent(),
* gimp_item_get_children(), gimp_item_is_group().
*
* Returns: (transfer none): The newly created layer group.
*
* Since: 2.8
**/
GimpLayer *
gimp_layer_group_new (GimpImage *image)
{
GimpValueArray *args;
GimpValueArray *return_vals;
GimpLayer *layer_group = NULL;
args = gimp_value_array_new_from_types (NULL,
GIMP_TYPE_IMAGE, image,
G_TYPE_NONE);
return_vals = _gimp_pdb_run_procedure_array (gimp_get_pdb (),
"gimp-layer-group-new",
args);
gimp_value_array_unref (args);
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
layer_group = GIMP_VALUES_GET_LAYER (return_vals, 1);
gimp_value_array_unref (return_vals);
return layer_group;
}
/** /**
* _gimp_layer_copy: * _gimp_layer_copy:
* @layer: The layer to copy. * @layer: The layer to copy.

View file

@ -44,7 +44,6 @@ GimpLayer* gimp_layer_new_from_visible (GimpImage
const gchar *name); const gchar *name);
GimpLayer* gimp_layer_new_from_drawable (GimpDrawable *drawable, GimpLayer* gimp_layer_new_from_drawable (GimpDrawable *drawable,
GimpImage *dest_image); GimpImage *dest_image);
GimpLayer* gimp_layer_group_new (GimpImage *image);
G_GNUC_INTERNAL GimpLayer* _gimp_layer_copy (GimpLayer *layer, G_GNUC_INTERNAL GimpLayer* _gimp_layer_copy (GimpLayer *layer,
gboolean add_alpha); gboolean add_alpha);
gboolean gimp_layer_add_alpha (GimpLayer *layer); gboolean gimp_layer_add_alpha (GimpLayer *layer);

View file

@ -478,6 +478,86 @@ gimp_param_spec_text_layer (const gchar *name,
} }
/*
* GIMP_TYPE_PARAM_GROUP_LAYER
*/
static void gimp_param_group_layer_class_init (GParamSpecClass *klass);
static void gimp_param_group_layer_init (GParamSpec *pspec);
GType
gimp_param_group_layer_get_type (void)
{
static GType type = 0;
if (! type)
{
const GTypeInfo info =
{
sizeof (GParamSpecClass),
NULL, NULL,
(GClassInitFunc) gimp_param_group_layer_class_init,
NULL, NULL,
sizeof (GimpParamSpecGroupLayer),
0,
(GInstanceInitFunc) gimp_param_group_layer_init
};
type = g_type_register_static (GIMP_TYPE_PARAM_LAYER,
"GimpParamGroupLayer", &info, 0);
}
return type;
}
static void
gimp_param_group_layer_class_init (GParamSpecClass *klass)
{
klass->value_type = GIMP_TYPE_GROUP_LAYER;
}
static void
gimp_param_group_layer_init (GParamSpec *pspec)
{
}
/**
* gimp_param_spec_group_layer:
* @name: Canonical name of the property specified.
* @nick: Nick name of the property specified.
* @blurb: Description of the property specified.
* @none_ok: Whether %NULL is a valid value.
* @flags: Flags for the property specified.
*
* Creates a new #GimpParamSpecGroupLayer specifying a
* [type@GroupLayer] property.
*
* See g_param_spec_internal() for details on property names.
*
* Returns: (transfer full): The newly created #GimpParamSpecGroupLayer.
*
* Since: 3.0
**/
GParamSpec *
gimp_param_spec_group_layer (const gchar *name,
const gchar *nick,
const gchar *blurb,
gboolean none_ok,
GParamFlags flags)
{
GimpParamSpecItem *ispec;
ispec = g_param_spec_internal (GIMP_TYPE_PARAM_GROUP_LAYER,
name, nick, blurb, flags);
g_return_val_if_fail (ispec, NULL);
ispec->none_ok = none_ok ? TRUE : FALSE;
return G_PARAM_SPEC (ispec);
}
/* /*
* GIMP_TYPE_PARAM_CHANNEL * GIMP_TYPE_PARAM_CHANNEL
*/ */

View file

@ -168,6 +168,34 @@ GParamSpec * gimp_param_spec_text_layer (const gchar *name,
gboolean none_ok, gboolean none_ok,
GParamFlags flags); GParamFlags flags);
/*
* GIMP_TYPE_PARAM_GROUP_LAYER
*/
#define GIMP_VALUE_HOLDS_GROUP_LAYER(value) (G_TYPE_CHECK_VALUE_TYPE ((value),\
GIMP_TYPE_GROUP_LAYER))
#define GIMP_TYPE_PARAM_GROUP_LAYER (gimp_param_group_layer_get_type ())
#define GIMP_PARAM_SPEC_GROUP_LAYER(pspec) (G_TYPE_CHECK_INSTANCE_CAST ((pspec), GIMP_TYPE_PARAM_GROUP_LAYER, GimpParamSpecGroupLayer))
#define GIMP_IS_PARAM_SPEC_GROUP_LAYER(pspec) (G_TYPE_CHECK_INSTANCE_TYPE ((pspec), GIMP_TYPE_PARAM_GROUP_LAYER))
typedef struct _GimpParamSpecGroupLayer GimpParamSpecGroupLayer;
struct _GimpParamSpecGroupLayer
{
GimpParamSpecLayer parent_instance;
};
GType gimp_param_group_layer_get_type (void) G_GNUC_CONST;
GParamSpec * gimp_param_spec_group_layer (const gchar *name,
const gchar *nick,
const gchar *blurb,
gboolean none_ok,
GParamFlags flags);
/* /*
* GIMP_TYPE_PARAM_CHANNEL * GIMP_TYPE_PARAM_CHANNEL
*/ */

View file

@ -1570,6 +1570,12 @@ _gimp_plug_in_get_item (GimpPlugIn *plug_in,
"id", item_id, "id", item_id,
NULL); NULL);
} }
else if (gimp_item_id_is_group_layer (item_id))
{
item = g_object_new (GIMP_TYPE_GROUP_LAYER,
"id", item_id,
NULL);
}
else if (gimp_item_id_is_layer (item_id)) else if (gimp_item_id_is_layer (item_id))
{ {
item = g_object_new (GIMP_TYPE_LAYER, item = g_object_new (GIMP_TYPE_LAYER,

View file

@ -1884,6 +1884,84 @@ gimp_procedure_add_text_layer_return_value (GimpProcedure *procedure,
none_ok, flags)); none_ok, flags));
} }
/**
* gimp_procedure_add_group_layer_argument:
* @procedure: the #GimpProcedure.
* @name: the name of the argument to be created.
* @nick: the label used in #GimpProcedureDialog.
* @blurb: a more detailed help description.
* @none_ok: Whether no is a valid value.
* @flags: argument flags.
*
* Add a new [class@GroupLayer] argument to @procedure.
*
* Since: 3.0
**/
void
gimp_procedure_add_group_layer_argument (GimpProcedure *procedure,
const gchar *name,
const gchar *nick,
const gchar *blurb,
gboolean none_ok,
GParamFlags flags)
{
_gimp_procedure_add_argument (procedure,
gimp_param_spec_group_layer (name, nick, blurb,
none_ok, flags));
}
/**
* gimp_procedure_add_group_layer_aux_argument:
* @procedure: the #GimpProcedure.
* @name: the name of the argument to be created.
* @nick: the label used in #GimpProcedureDialog.
* @blurb: a more detailed help description.
* @none_ok: Whether no is a valid value.
* @flags: argument flags.
*
* Add a new [class@GroupLayer] auxiliary argument to @procedure.
*
* Since: 3.0
**/
void
gimp_procedure_add_group_layer_aux_argument (GimpProcedure *procedure,
const gchar *name,
const gchar *nick,
const gchar *blurb,
gboolean none_ok,
GParamFlags flags)
{
_gimp_procedure_add_aux_argument (procedure,
gimp_param_spec_group_layer (name, nick, blurb,
none_ok, flags));
}
/**
* gimp_procedure_add_group_layer_return_value:
* @procedure: the #GimpProcedure.
* @name: the name of the argument to be created.
* @nick: the label used in #GimpProcedureDialog.
* @blurb: a more detailed help description.
* @none_ok: Whether no is a valid value.
* @flags: argument flags.
*
* Add a new [class@GroupLayer] return value to @procedure.
*
* Since: 3.0
**/
void
gimp_procedure_add_group_layer_return_value (GimpProcedure *procedure,
const gchar *name,
const gchar *nick,
const gchar *blurb,
gboolean none_ok,
GParamFlags flags)
{
_gimp_procedure_add_return_value (procedure,
gimp_param_spec_group_layer (name, nick, blurb,
none_ok, flags));
}
/** /**
* gimp_procedure_add_channel_argument: * gimp_procedure_add_channel_argument:
* @procedure: the #GimpProcedure. * @procedure: the #GimpProcedure.

View file

@ -315,6 +315,18 @@ G_BEGIN_DECLS
g_value_set_object (gimp_value_array_index (args, n), value) g_value_set_object (gimp_value_array_index (args, n), value)
/* group layer */
#define GIMP_VALUES_GET_GROUP_LAYER(args, n) \
g_value_get_object (gimp_value_array_index (args, n))
#define GIMP_VALUES_GET_GROUP_LAYER_ID(args, n) \
gimp_item_get_id (g_value_get_object (gimp_value_array_index (args, n)))
#define GIMP_VALUES_SET_GROUP_LAYER(args, n, value) \
g_value_set_object (gimp_value_array_index (args, n), value)
/* channel */ /* channel */
#define GIMP_VALUES_GET_CHANNEL(args, n) \ #define GIMP_VALUES_GET_CHANNEL(args, n) \
@ -868,6 +880,25 @@ void gimp_procedure_add_text_layer_return_value (GimpProcedure *procedure
gboolean none_ok, gboolean none_ok,
GParamFlags flags); GParamFlags flags);
void gimp_procedure_add_group_layer_argument (GimpProcedure *procedure,
const gchar *name,
const gchar *nick,
const gchar *blurb,
gboolean none_ok,
GParamFlags flags);
void gimp_procedure_add_group_layer_aux_argument (GimpProcedure *procedure,
const gchar *name,
const gchar *nick,
const gchar *blurb,
gboolean none_ok,
GParamFlags flags);
void gimp_procedure_add_group_layer_return_value (GimpProcedure *procedure,
const gchar *name,
const gchar *nick,
const gchar *blurb,
gboolean none_ok,
GParamFlags flags);
void gimp_procedure_add_channel_argument (GimpProcedure *procedure, void gimp_procedure_add_channel_argument (GimpProcedure *procedure,
const gchar *name, const gchar *name,
const gchar *nick, const gchar *nick,

View file

@ -36,6 +36,7 @@ typedef struct _GimpProcedureConfig GimpProcedureConfig;
typedef struct _GimpImage GimpImage; typedef struct _GimpImage GimpImage;
typedef struct _GimpItem GimpItem; typedef struct _GimpItem GimpItem;
typedef struct _GimpDrawable GimpDrawable; typedef struct _GimpDrawable GimpDrawable;
typedef struct _GimpGroupLayer GimpGroupLayer;
typedef struct _GimpLayer GimpLayer; typedef struct _GimpLayer GimpLayer;
typedef struct _GimpChannel GimpChannel; typedef struct _GimpChannel GimpChannel;
typedef struct _GimpLayerMask GimpLayerMask; typedef struct _GimpLayerMask GimpLayerMask;

View file

@ -84,6 +84,7 @@ pdb_wrappers_sources = [
'gimpgradient_pdb.c', 'gimpgradient_pdb.c',
'gimpgradients_pdb.c', 'gimpgradients_pdb.c',
'gimpgradientselect_pdb.c', 'gimpgradientselect_pdb.c',
'gimpgrouplayer_pdb.c',
'gimphelp_pdb.c', 'gimphelp_pdb.c',
'gimpimage_pdb.c', 'gimpimage_pdb.c',
'gimpimagecolorprofile_pdb.c', 'gimpimagecolorprofile_pdb.c',
@ -139,6 +140,7 @@ pdb_wrappers_headers = [
'gimpgradient_pdb.h', 'gimpgradient_pdb.h',
'gimpgradients_pdb.h', 'gimpgradients_pdb.h',
'gimpgradientselect_pdb.h', 'gimpgradientselect_pdb.h',
'gimpgrouplayer_pdb.h',
'gimphelp_pdb.h', 'gimphelp_pdb.h',
'gimpimage_pdb.h', 'gimpimage_pdb.h',
'gimpimagecolorprofile_pdb.h', 'gimpimagecolorprofile_pdb.h',
@ -179,6 +181,7 @@ libgimp_sources_introspectable = [
'gimpfont.c', 'gimpfont.c',
'gimpgimprc.c', 'gimpgimprc.c',
'gimpgradient.c', 'gimpgradient.c',
'gimpgrouplayer.c',
'gimpimage.c', 'gimpimage.c',
'gimpimagecolorprofile.c', 'gimpimagecolorprofile.c',
'gimpimagemetadata.c', 'gimpimagemetadata.c',
@ -240,6 +243,7 @@ libgimp_headers_introspectable = [
'gimpfont.h', 'gimpfont.h',
'gimpgimprc.h', 'gimpgimprc.h',
'gimpgradient.h', 'gimpgradient.h',
'gimpgrouplayer.h',
'gimpimage.h', 'gimpimage.h',
'gimpimagecolorprofile.h', 'gimpimagecolorprofile.h',
'gimpimagemetadata.h', 'gimpimagemetadata.h',

View file

@ -24,7 +24,7 @@ gimp_c_test_run (GimpProcedure *procedure,
GIMP_RGBA_IMAGE, 100.0, GIMP_LAYER_MODE_NORMAL)); GIMP_RGBA_IMAGE, 100.0, GIMP_LAYER_MODE_NORMAL));
layer2 = GIMP_DRAWABLE (gimp_layer_new (img, "layer2", 10, 20, layer2 = GIMP_DRAWABLE (gimp_layer_new (img, "layer2", 10, 20,
GIMP_RGBA_IMAGE, 100.0, GIMP_LAYER_MODE_NORMAL)); GIMP_RGBA_IMAGE, 100.0, GIMP_LAYER_MODE_NORMAL));
group1 = GIMP_DRAWABLE (gimp_layer_group_new (img)); group1 = GIMP_DRAWABLE (gimp_group_layer_new (img, NULL));
GIMP_TEST_START("insert layer") GIMP_TEST_START("insert layer")
GIMP_TEST_END(gimp_image_insert_layer (img, GIMP_LAYER (layer1), NULL, 0)) GIMP_TEST_END(gimp_image_insert_layer (img, GIMP_LAYER (layer1), NULL, 0))

View file

@ -317,6 +317,16 @@ gimp_param_spec_drawable ("$name",
"$blurb", "$blurb",
$none_ok, $none_ok,
$flags) $flags)
CODE
}
elsif ($pdbtype eq 'group_layer') {
$none_ok = exists $arg->{none_ok} ? 'TRUE' : 'FALSE';
$pspec = <<CODE;
gimp_param_spec_group_layer ("$name",
"$nick",
"$blurb",
$none_ok,
$flags)
CODE CODE
} }
elsif ($pdbtype eq 'text_layer') { elsif ($pdbtype eq 'text_layer') {

View file

@ -24,6 +24,7 @@
gradient gradient
gradient_select gradient_select
gradients gradients
group_layer
help help
image image
image_color_profile image_color_profile

114
pdb/groups/group_layer.pdb Normal file
View file

@ -0,0 +1,114 @@
# GIMP - The GNU Image Manipulation Program
# Copyright (C) 1995 Spencer Kimball and Peter Mattis
# 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/>.
sub group_layer_new {
$blurb = 'Create a new group layer.';
$help = <<'HELP';
This procedure creates a new group layer. Attributes such as layer mode
and opacity should be set with explicit procedure calls. Add the new
group layer (which is a kind of layer) with [method@image.insert_layer].
Other procedures useful with group layers: [method@image_reorder_item],
[method@item.get_parent], [method@item.get_children], [method@item.is_group].
HELP
&barak_pdb_misc('2010', '2.8');
$lib_private = 1;
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image to which to add the group layer' }
);
@outargs = (
{ name => 'group_layer', type => 'group_layer',
desc => 'The newly created group layer' }
);
%invoke = (
code => <<'CODE'
{
group_layer = GIMP_GROUP_LAYER (gimp_group_layer_new (image));
if (! group_layer)
success = FALSE;
}
CODE
);
}
sub group_layer_merge {
$blurb = 'Merge the passed group layer\'s layers into one normal layer.';
$help = <<'HELP';
This procedure combines the layers of the passed group layer into
a single normal layer, replacing the group.
The group layer is expected to be attached to an image.
HELP
&ell_pdb_misc('2019', '2.10.14');
@inargs = (
{ name => 'group_layer', type => 'group_layer',
desc => 'The group layer to merge' },
);
@outargs = (
{ name => 'layer', type => 'layer',
desc => 'The resulting layer' }
);
%invoke = (
headers => [ qw("core/gimpimage-merge.h") ],
code => <<'CODE'
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (group_layer), NULL, 0, error) &&
gimp_pdb_item_is_group (GIMP_ITEM (group_layer), error))
{
GimpImage *image = gimp_item_get_image (GIMP_ITEM (group_layer));
layer = gimp_image_merge_group_layer (image, group_layer);
if (! layer)
success = FALSE;
}
else
success = FALSE;
}
CODE
);
}
@headers = qw(<cairo.h>
"libgimpbase/gimpbase.h"
"core/gimp.h"
"core/gimpgrouplayer.h"
"gimppdb-utils.h"
"gimp-intl.h");
@procs = qw(group_layer_new
group_layer_merge);
%exports = (app => [@procs], lib => [@procs]);
$desc = 'Group Layer';
$doc_title = 'gimpgrouplayer';
$doc_short_desc = 'Operations on a group layer.';
$doc_long_desc = 'Operations on a group layer.';
1;

View file

@ -855,48 +855,6 @@ CODE
); );
} }
sub image_merge_layer_group {
$blurb = 'Merge the passed layer group\'s layers into one normal layer.';
$help = <<'HELP';
This procedure combines the layers of the passed layer group into
a single normal layer, replacing the group.
HELP
&ell_pdb_misc('2019', '2.10.14');
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image' },
{ name => 'layer_group', type => 'layer',
desc => 'The layer group to merge' },
);
@outargs = (
{ name => 'layer', type => 'layer',
desc => 'The resulting layer' }
);
%invoke = (
headers => [ qw("core/gimpgrouplayer.h" "core/gimpimage-merge.h") ],
code => <<'CODE'
{
if (gimp_pdb_item_is_attached (GIMP_ITEM (layer_group), image, 0, error) &&
gimp_pdb_item_is_group (GIMP_ITEM (layer_group), error))
{
layer = gimp_image_merge_group_layer (image,
GIMP_GROUP_LAYER (layer_group));
if (! layer)
success = FALSE;
}
else
success = FALSE;
}
CODE
);
}
sub image_flatten { sub image_flatten {
$blurb = <<'BLURB'; $blurb = <<'BLURB';
Flatten all visible layers into a single layer. Discard all invisible layers. Flatten all visible layers into a single layer. Discard all invisible layers.
@ -3219,7 +3177,6 @@ CODE
image_raise_item_to_top image_lower_item_to_bottom image_raise_item_to_top image_lower_item_to_bottom
image_reorder_item image_reorder_item
image_flatten image_merge_visible_layers image_merge_down image_flatten image_merge_visible_layers image_merge_down
image_merge_layer_group
image_get_colormap image_set_colormap image_get_colormap image_set_colormap
image_get_palette image_get_palette
image_get_metadata image_set_metadata image_get_metadata image_set_metadata

View file

@ -144,6 +144,36 @@ CODE
); );
} }
sub item_id_is_group_layer {
$blurb = 'Returns whether the item ID is a group layer.';
$help = <<'HELP';
This procedure returns TRUE if the specified item ID is a group layer.
HELP
&jehan_pdb_misc('2024', '3.0');
@inargs = (
{ name => 'item_id', type => 'int32',
desc => 'The item ID' }
);
@outargs = (
{ name => 'group_layer', type => 'boolean',
desc => 'TRUE if the item is a group layer, FALSE otherwise.' }
);
%invoke = (
code => <<'CODE'
{
GimpItem *item = gimp_item_get_by_id (gimp, item_id);
group_layer = (GIMP_IS_GROUP_LAYER (item) && ! gimp_item_is_removed (item));
}
CODE
);
}
sub item_id_is_channel { sub item_id_is_channel {
$blurb = 'Returns whether the item ID is a channel.'; $blurb = 'Returns whether the item ID is a channel.';
@ -974,7 +1004,8 @@ CODE
); );
} }
@headers = qw("core/gimplayermask.h" @headers = qw("core/gimpgrouplayer.h"
"core/gimplayermask.h"
"core/gimplist.h" "core/gimplist.h"
"core/gimpselection.h" "core/gimpselection.h"
"text/gimptextlayer.h" "text/gimptextlayer.h"
@ -987,6 +1018,7 @@ CODE
item_id_is_drawable item_id_is_drawable
item_id_is_layer item_id_is_layer
item_id_is_text_layer item_id_is_text_layer
item_id_is_group_layer
item_id_is_channel item_id_is_channel
item_id_is_layer_mask item_id_is_layer_mask
item_id_is_selection item_id_is_selection

View file

@ -222,42 +222,6 @@ CODE
); );
} }
sub layer_group_new {
$blurb = 'Create a new layer group.';
$help = <<'HELP';
This procedure creates a new layer group. Attributes such as layer mode
and opacity should be set with explicit procedure calls. Add the new
layer group (which is a kind of layer) with the
gimp_image_insert_layer() command.
Other procedures useful with layer groups: gimp_image_reorder_item(),
gimp_item_get_parent(), gimp_item_get_children(), gimp_item_is_group().
HELP
&barak_pdb_misc('2010', '2.8');
@inargs = (
{ name => 'image', type => 'image',
desc => 'The image to which to add the layer group' }
);
@outargs = (
{ name => 'layer_group', type => 'layer',
desc => 'The newly created layer group' }
);
%invoke = (
code => <<'CODE'
{
layer_group = gimp_group_layer_new (image);
if (! layer_group)
success = FALSE;
}
CODE
);
}
sub layer_copy { sub layer_copy {
$blurb = 'Copy a layer.'; $blurb = 'Copy a layer.';
@ -1285,7 +1249,6 @@ CODE
"core/gimp.h" "core/gimp.h"
"core/gimpimage-color-profile.h" "core/gimpimage-color-profile.h"
"core/gimpimage-undo.h" "core/gimpimage-undo.h"
"core/gimpgrouplayer.h"
"core/gimplayer-new.h" "core/gimplayer-new.h"
"core/gimppickable.h" "core/gimppickable.h"
"core/gimpprogress.h" "core/gimpprogress.h"
@ -1297,7 +1260,6 @@ CODE
@procs = qw(layer_new @procs = qw(layer_new
layer_new_from_visible layer_new_from_visible
layer_new_from_drawable layer_new_from_drawable
layer_group_new
layer_copy layer_copy
layer_add_alpha layer_add_alpha
layer_flatten layer_flatten

View file

@ -26,6 +26,7 @@ pdb_names = [
'gradient_select', 'gradient_select',
'gradient', 'gradient',
'gradients', 'gradients',
'group_layer',
'help', 'help',
'image_color_profile', 'image_color_profile',
'image_convert', 'image_convert',

View file

@ -335,6 +335,18 @@ package Gimp::CodeGen::pdb;
take_value_func => 'g_value_set_object ($value, $var)', take_value_func => 'g_value_set_object ($value, $var)',
headers => [ qw("text/gimptextlayer.h") ] }, headers => [ qw("text/gimptextlayer.h") ] },
group_layer => { name => 'GROUP_LAYER',
gtype => 'GIMP_TYPE_GROUP_LAYER',
type => 'GimpGroupLayer *',
const_type => 'GimpGroupLayer *',
init_value => 'NULL',
out_annotate => '(transfer none)',
get_value_func => '$var = g_value_get_object ($value)',
dup_value_func => '$var = GIMP_VALUES_GET_GROUP_LAYER ($value)',
set_value_func => 'g_value_set_object ($value, $var)',
take_value_func => 'g_value_set_object ($value, $var)',
headers => [ qw("core/gimpgrouplayer.h") ] },
channel => { name => 'CHANNEL', channel => { name => 'CHANNEL',
gtype => 'GIMP_TYPE_CHANNEL', gtype => 'GIMP_TYPE_CHANNEL',
type => 'GimpChannel *', type => 'GimpChannel *',

View file

@ -209,9 +209,8 @@ wavelet_run (GimpProcedure *procedure,
if (create_group) if (create_group)
{ {
parent = gimp_layer_group_new (image); parent = GIMP_LAYER (gimp_group_layer_new (image, _("Decomposition")));
gimp_item_set_name (GIMP_ITEM (parent), _("Decomposition"));
gimp_item_set_visible (GIMP_ITEM (parent), FALSE); gimp_item_set_visible (GIMP_ITEM (parent), FALSE);
gimp_image_insert_layer (image, parent, gimp_image_insert_layer (image, parent,
GIMP_LAYER (gimp_item_get_parent (GIMP_ITEM (drawable))), GIMP_LAYER (gimp_item_get_parent (GIMP_ITEM (drawable))),

View file

@ -2365,7 +2365,7 @@ add_layers (GimpImage *image,
* assemble the layer structure in a single pass * assemble the layer structure in a single pass
*/ */
IFDBG(2) g_debug ("Create placeholder group layer"); IFDBG(2) g_debug ("Create placeholder group layer");
layer = gimp_layer_group_new (image); layer = GIMP_LAYER (gimp_group_layer_new (image, NULL));
/* add this group layer as the new parent */ /* add this group layer as the new parent */
g_array_append_val (parent_group_stack, layer); g_array_append_val (parent_group_stack, layer);
} }
@ -3180,9 +3180,8 @@ add_clipping_group (GimpImage *image,
* composition mode in a different manner than PS. */ * composition mode in a different manner than PS. */
IFDBG(2) g_debug ("Creating a layer group to handle PS transparency clipping correctly."); IFDBG(2) g_debug ("Creating a layer group to handle PS transparency clipping correctly.");
clipping_group = gimp_layer_group_new (image); clipping_group = GIMP_LAYER (gimp_group_layer_new (image, "Group added by GIMP"));
gimp_item_set_name (GIMP_ITEM (clipping_group), "Group added by GIMP");
gimp_layer_set_blend_space (clipping_group, GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL); gimp_layer_set_blend_space (clipping_group, GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL);
gimp_layer_set_composite_space (clipping_group, GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL); gimp_layer_set_composite_space (clipping_group, GIMP_LAYER_COLOR_SPACE_RGB_PERCEPTUAL);
gimp_layer_set_composite_mode (clipping_group, GIMP_LAYER_COMPOSITE_UNION); gimp_layer_set_composite_mode (clipping_group, GIMP_LAYER_COMPOSITE_UNION);