gimpselection.c 2.83 KB
Newer Older
1 2 3 4 5
/* LIBGIMP - The GIMP Library
 * Copyright (C) 1995-2000 Peter Mattis and Spencer Kimball
 *
 * gimpselection.c
 *
6
 * This library is free software: you can redistribute it and/or
7 8
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
9
 * version 3 of the License, or (at your option) any later version.
10 11 12 13 14 15 16
 *
 * 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
17
 * License along with this library.  If not, see
18
 * <https://www.gnu.org/licenses/>.
19 20
 */

Sven Neumann's avatar
Sven Neumann committed
21 22
#include "config.h"

23 24
#include "gimp.h"

25

26 27 28 29 30 31 32
struct _GimpSelectionPrivate
{
  gpointer unused;
};


G_DEFINE_TYPE_WITH_PRIVATE (GimpSelection, gimp_selection, GIMP_TYPE_CHANNEL)
33 34 35

#define parent_class gimp_selection_parent_class

36

37 38 39 40 41 42 43 44
static void
gimp_selection_class_init (GimpSelectionClass *klass)
{
}

static void
gimp_selection_init (GimpSelection *selection)
{
45
  selection->priv = gimp_selection_get_instance_private (selection);
46
}
47

48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
/**
 * gimp_selection_get_by_id:
 * @selection_id: The selection id.
 *
 * Returns a #GimpSelection representing @selection_id. This function
 * calls gimp_item_get_by_id() and returns the item if it is selection
 * or %NULL otherwise.
 *
 * Returns: (nullable) (transfer none): a #GimpSelection for
 *          @selection_id or %NULL if @selection_id does not represent
 *          a valid selection. The object belongs to libgimp and you
 *          must not modify or unref it.
 *
 * Since: 3.0
 **/
GimpSelection *
gimp_selection_get_by_id (gint32 selection_id)
{
  GimpItem *item = gimp_item_get_by_id (selection_id);

  if (GIMP_IS_SELECTION (item))
    return (GimpSelection *) item;

  return NULL;
}

74 75
/**
 * gimp_selection_float:
76
 * @image:    ignored
77
 * @drawable: The drawable from which to float selection.
78 79
 * @offx:     x offset for translation.
 * @offy:     y offset for translation.
80 81 82 83 84 85 86 87 88 89
 *
 * Float the selection from the specified drawable with initial offsets
 * as specified.
 *
 * This procedure determines the region of the specified drawable that
 * lies beneath the current selection. The region is then cut from the
 * drawable and the resulting data is made into a new layer which is
 * instantiated as a floating selection. The offsets allow initial
 * positioning of the new floating selection.
 *
90
 * Returns: (transfer none): The floated layer.
91 92 93 94 95 96 97 98 99 100 101
 */
GimpLayer *
gimp_selection_float (GimpImage    *image,
                      GimpDrawable *drawable,
                      gint          offx,
                      gint          offy)
{
  return _gimp_selection_float (drawable,
                                offx,
                                offy);
}