2024-04-15 18:07:48 -04:00
|
|
|
|
|
|
|
static GimpValueArray *
|
|
|
|
gimp_c_test_run (GimpProcedure *procedure,
|
|
|
|
GimpRunMode run_mode,
|
|
|
|
GimpImage *image,
|
|
|
|
gint n_drawables,
|
|
|
|
GimpDrawable **drawables,
|
|
|
|
GimpProcedureConfig *config,
|
|
|
|
gpointer run_data)
|
|
|
|
{
|
|
|
|
GimpImage *img;
|
|
|
|
GimpDrawable *layer1;
|
|
|
|
GimpDrawable *layer2;
|
|
|
|
GimpDrawable *group1;
|
|
|
|
GimpLayer *float_layer;
|
|
|
|
|
|
|
|
/* Setup */
|
|
|
|
|
|
|
|
GIMP_TEST_START("gimp_image_new()")
|
|
|
|
img = gimp_image_new (32, 32, GIMP_RGB);
|
|
|
|
GIMP_TEST_END(GIMP_IS_IMAGE (img))
|
|
|
|
|
|
|
|
layer1 = GIMP_DRAWABLE (gimp_layer_new (img, "layer1", 20, 10,
|
|
|
|
GIMP_RGBA_IMAGE, 100.0, GIMP_LAYER_MODE_NORMAL));
|
|
|
|
layer2 = GIMP_DRAWABLE (gimp_layer_new (img, "layer2", 10, 20,
|
|
|
|
GIMP_RGBA_IMAGE, 100.0, GIMP_LAYER_MODE_NORMAL));
|
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! :-)
2024-07-06 17:24:11 +02:00
|
|
|
group1 = GIMP_DRAWABLE (gimp_group_layer_new (img, NULL));
|
2024-04-15 18:07:48 -04:00
|
|
|
|
|
|
|
GIMP_TEST_START("insert layer")
|
|
|
|
GIMP_TEST_END(gimp_image_insert_layer (img, GIMP_LAYER (layer1), NULL, 0))
|
|
|
|
|
|
|
|
GIMP_TEST_START("insert group layer")
|
|
|
|
GIMP_TEST_END(gimp_image_insert_layer (img, GIMP_LAYER (group1), NULL, -1))
|
|
|
|
|
|
|
|
GIMP_TEST_START("insert layer inside group")
|
|
|
|
GIMP_TEST_END(gimp_image_insert_layer (img, GIMP_LAYER (layer2),
|
|
|
|
GIMP_LAYER (group1), -1))
|
|
|
|
|
|
|
|
|
|
|
|
/* Floating selection tests */
|
|
|
|
|
|
|
|
/* 1. Fail with no selection */
|
|
|
|
GIMP_TEST_START("Gimp.Selection.float - no selection")
|
|
|
|
GIMP_TEST_END(gimp_selection_float (img, 1, &layer1, 10, 10) == NULL)
|
|
|
|
|
|
|
|
/* 2. Fail on a group layer */
|
|
|
|
GIMP_TEST_START("Gimp.Selection.float - group layer")
|
|
|
|
GIMP_TEST_END(gimp_selection_float (img, 1, &group1, 10, 10) == NULL)
|
|
|
|
|
|
|
|
/* 3. Succeed on a normal layer */
|
|
|
|
gimp_image_select_rectangle (img, GIMP_CHANNEL_OP_REPLACE, 5, 5, 20, 20);
|
|
|
|
|
|
|
|
GIMP_TEST_START("gimp_selection_float - normal layer")
|
|
|
|
float_layer = gimp_selection_float (img, 1, &layer1, 10, 10);
|
|
|
|
GIMP_TEST_END(GIMP_IS_LAYER (float_layer))
|
|
|
|
|
|
|
|
GIMP_TEST_START("gimp_floating_sel_remove")
|
|
|
|
GIMP_TEST_END(gimp_floating_sel_remove (float_layer) == TRUE);
|
|
|
|
|
|
|
|
/* 4. Succeed on a layer inside a group */
|
|
|
|
gimp_image_select_rectangle (img, GIMP_CHANNEL_OP_REPLACE, 5, 5, 20, 20);
|
|
|
|
|
|
|
|
GIMP_TEST_START("gimp_selection_float - layer inside group")
|
|
|
|
float_layer = gimp_selection_float (img, 1, &layer2, 10, 10);
|
|
|
|
GIMP_TEST_END(GIMP_IS_LAYER (float_layer))
|
|
|
|
|
|
|
|
GIMP_TEST_START("gimp_floating_sel_remove")
|
|
|
|
GIMP_TEST_END(gimp_floating_sel_remove (float_layer) == TRUE);
|
|
|
|
|
|
|
|
|
|
|
|
/* Teardown */
|
|
|
|
gimp_image_delete (img);
|
|
|
|
|
|
|
|
GIMP_TEST_RETURN
|
|
|
|
}
|