2008-10-10 13:04:03 -07:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
|
|
|
|
* Copyright (C) 1995-1997 Spencer Kimball and Peter Mattis
|
|
|
|
|
*
|
|
|
|
|
* gimpdrawablestack.c
|
|
|
|
|
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
|
|
|
|
|
*
|
2009-01-17 14:28:01 -08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2008-10-10 13:04:03 -07:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 14:28:01 -08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2008-10-10 13:04:03 -07:00
|
|
|
* (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
|
2018-07-11 14:47:19 -07:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2008-10-10 13:04:03 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
2013-10-14 16:58:39 -07:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2008-10-10 13:04:03 -07:00
|
|
|
#include <gegl.h>
|
|
|
|
|
|
|
|
|
|
#include "core-types.h"
|
|
|
|
|
|
|
|
|
|
#include "gimpdrawable.h"
|
|
|
|
|
#include "gimpdrawablestack.h"
|
2008-11-02 11:53:51 -08:00
|
|
|
#include "gimpmarshal.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
|
{
|
|
|
|
|
UPDATE,
|
|
|
|
|
LAST_SIGNAL
|
|
|
|
|
};
|
2008-10-10 13:04:03 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
/* local function prototypes */
|
|
|
|
|
|
2011-01-12 13:53:58 -08:00
|
|
|
static void gimp_drawable_stack_constructed (GObject *object);
|
|
|
|
|
|
|
|
|
|
static void gimp_drawable_stack_add (GimpContainer *container,
|
|
|
|
|
GimpObject *object);
|
|
|
|
|
static void gimp_drawable_stack_remove (GimpContainer *container,
|
|
|
|
|
GimpObject *object);
|
|
|
|
|
static void gimp_drawable_stack_reorder (GimpContainer *container,
|
|
|
|
|
GimpObject *object,
|
|
|
|
|
gint new_index);
|
|
|
|
|
|
|
|
|
|
static void gimp_drawable_stack_drawable_update (GimpItem *item,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height,
|
|
|
|
|
GimpDrawableStack *stack);
|
app: add GimpFilter::active property; move ::visible to GimpItem
Add an "active" property to GimpFilter, which replaces its
"visible" property. The new property assumes the lower-level role
"visible" had -- controlling whether the filter has any effect as
part of its parent filter-stack.
Add a "visible" property to GimpItem, separate from the "active"
property, which assumes the higher-level role "visible" had --
controlling whether the item is considered "visible", as per the
GUI. By default, the item's "visible" property is bound to the
filter's "active" property, so that changes in visibility directly
affect the filter's "activeness"; this binding can be controlled
using the new gimp_item_bind_visible_to_active() function.
This distinction is currently necessary for floating selections.
Floating selection layers must not be active in their parent stack,
regardless of their visibility, in particular, so that their mode
node doesn't hide the entire backdrop when their composite mode
excludes the backdrop (i.e., when it's dst-atop or src-in).
Instead, their visibility should affect the activeness of the
floating-selection filter of the drawable they're attached to.
This is handled by the next commit.
2017-12-05 10:46:50 -08:00
|
|
|
static void gimp_drawable_stack_drawable_active (GimpItem *item,
|
2011-01-12 13:53:58 -08:00
|
|
|
GimpDrawableStack *stack);
|
2008-10-10 13:04:03 -07:00
|
|
|
|
|
|
|
|
|
2008-11-06 11:09:59 -08:00
|
|
|
G_DEFINE_TYPE (GimpDrawableStack, gimp_drawable_stack, GIMP_TYPE_ITEM_STACK)
|
2008-10-10 13:04:03 -07:00
|
|
|
|
|
|
|
|
#define parent_class gimp_drawable_stack_parent_class
|
|
|
|
|
|
2008-11-02 11:53:51 -08:00
|
|
|
static guint stack_signals[LAST_SIGNAL] = { 0 };
|
|
|
|
|
|
2008-10-10 13:04:03 -07:00
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_drawable_stack_class_init (GimpDrawableStackClass *klass)
|
|
|
|
|
{
|
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
GimpContainerClass *container_class = GIMP_CONTAINER_CLASS (klass);
|
|
|
|
|
|
2008-11-02 11:53:51 -08:00
|
|
|
stack_signals[UPDATE] =
|
|
|
|
|
g_signal_new ("update",
|
|
|
|
|
G_TYPE_FROM_CLASS (klass),
|
|
|
|
|
G_SIGNAL_RUN_FIRST,
|
|
|
|
|
G_STRUCT_OFFSET (GimpDrawableStackClass, update),
|
|
|
|
|
NULL, NULL,
|
|
|
|
|
gimp_marshal_VOID__INT_INT_INT_INT,
|
|
|
|
|
G_TYPE_NONE, 4,
|
|
|
|
|
G_TYPE_INT,
|
|
|
|
|
G_TYPE_INT,
|
|
|
|
|
G_TYPE_INT,
|
|
|
|
|
G_TYPE_INT);
|
|
|
|
|
|
2011-01-12 13:53:58 -08:00
|
|
|
object_class->constructed = gimp_drawable_stack_constructed;
|
2008-11-02 11:53:51 -08:00
|
|
|
|
|
|
|
|
container_class->add = gimp_drawable_stack_add;
|
|
|
|
|
container_class->remove = gimp_drawable_stack_remove;
|
|
|
|
|
container_class->reorder = gimp_drawable_stack_reorder;
|
2008-10-10 13:04:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
2008-11-02 11:53:51 -08:00
|
|
|
gimp_drawable_stack_init (GimpDrawableStack *stack)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-12 13:53:58 -08:00
|
|
|
static void
|
|
|
|
|
gimp_drawable_stack_constructed (GObject *object)
|
2008-10-10 13:04:03 -07:00
|
|
|
{
|
2011-01-12 13:53:58 -08:00
|
|
|
GimpContainer *container = GIMP_CONTAINER (object);
|
2008-11-02 11:53:51 -08:00
|
|
|
|
2012-11-12 12:51:22 -08:00
|
|
|
G_OBJECT_CLASS (parent_class)->constructed (object);
|
2008-11-02 11:53:51 -08:00
|
|
|
|
2018-02-11 13:23:10 -08:00
|
|
|
gimp_assert (g_type_is_a (gimp_container_get_children_type (container),
|
|
|
|
|
GIMP_TYPE_DRAWABLE));
|
2008-11-02 11:53:51 -08:00
|
|
|
|
|
|
|
|
gimp_container_add_handler (container, "update",
|
|
|
|
|
G_CALLBACK (gimp_drawable_stack_drawable_update),
|
|
|
|
|
container);
|
app: add GimpFilter::active property; move ::visible to GimpItem
Add an "active" property to GimpFilter, which replaces its
"visible" property. The new property assumes the lower-level role
"visible" had -- controlling whether the filter has any effect as
part of its parent filter-stack.
Add a "visible" property to GimpItem, separate from the "active"
property, which assumes the higher-level role "visible" had --
controlling whether the item is considered "visible", as per the
GUI. By default, the item's "visible" property is bound to the
filter's "active" property, so that changes in visibility directly
affect the filter's "activeness"; this binding can be controlled
using the new gimp_item_bind_visible_to_active() function.
This distinction is currently necessary for floating selections.
Floating selection layers must not be active in their parent stack,
regardless of their visibility, in particular, so that their mode
node doesn't hide the entire backdrop when their composite mode
excludes the backdrop (i.e., when it's dst-atop or src-in).
Instead, their visibility should affect the activeness of the
floating-selection filter of the drawable they're attached to.
This is handled by the next commit.
2017-12-05 10:46:50 -08:00
|
|
|
gimp_container_add_handler (container, "active-changed",
|
|
|
|
|
G_CALLBACK (gimp_drawable_stack_drawable_active),
|
2008-11-02 11:53:51 -08:00
|
|
|
container);
|
2008-10-10 13:04:03 -07:00
|
|
|
}
|
|
|
|
|
|
2008-10-11 03:18:46 -07:00
|
|
|
static void
|
|
|
|
|
gimp_drawable_stack_add (GimpContainer *container,
|
|
|
|
|
GimpObject *object)
|
|
|
|
|
{
|
|
|
|
|
GimpDrawableStack *stack = GIMP_DRAWABLE_STACK (container);
|
|
|
|
|
|
|
|
|
|
GIMP_CONTAINER_CLASS (parent_class)->add (container, object);
|
|
|
|
|
|
app: add GimpFilter::active property; move ::visible to GimpItem
Add an "active" property to GimpFilter, which replaces its
"visible" property. The new property assumes the lower-level role
"visible" had -- controlling whether the filter has any effect as
part of its parent filter-stack.
Add a "visible" property to GimpItem, separate from the "active"
property, which assumes the higher-level role "visible" had --
controlling whether the item is considered "visible", as per the
GUI. By default, the item's "visible" property is bound to the
filter's "active" property, so that changes in visibility directly
affect the filter's "activeness"; this binding can be controlled
using the new gimp_item_bind_visible_to_active() function.
This distinction is currently necessary for floating selections.
Floating selection layers must not be active in their parent stack,
regardless of their visibility, in particular, so that their mode
node doesn't hide the entire backdrop when their composite mode
excludes the backdrop (i.e., when it's dst-atop or src-in).
Instead, their visibility should affect the activeness of the
floating-selection filter of the drawable they're attached to.
This is handled by the next commit.
2017-12-05 10:46:50 -08:00
|
|
|
if (gimp_filter_get_active (GIMP_FILTER (object)))
|
|
|
|
|
gimp_drawable_stack_drawable_active (GIMP_ITEM (object), stack);
|
2008-10-11 03:18:46 -07:00
|
|
|
}
|
|
|
|
|
|
2008-10-10 13:04:03 -07:00
|
|
|
static void
|
|
|
|
|
gimp_drawable_stack_remove (GimpContainer *container,
|
|
|
|
|
GimpObject *object)
|
|
|
|
|
{
|
2008-10-10 14:18:24 -07:00
|
|
|
GimpDrawableStack *stack = GIMP_DRAWABLE_STACK (container);
|
|
|
|
|
|
2008-10-10 13:04:03 -07:00
|
|
|
GIMP_CONTAINER_CLASS (parent_class)->remove (container, object);
|
2008-11-02 11:53:51 -08:00
|
|
|
|
app: add GimpFilter::active property; move ::visible to GimpItem
Add an "active" property to GimpFilter, which replaces its
"visible" property. The new property assumes the lower-level role
"visible" had -- controlling whether the filter has any effect as
part of its parent filter-stack.
Add a "visible" property to GimpItem, separate from the "active"
property, which assumes the higher-level role "visible" had --
controlling whether the item is considered "visible", as per the
GUI. By default, the item's "visible" property is bound to the
filter's "active" property, so that changes in visibility directly
affect the filter's "activeness"; this binding can be controlled
using the new gimp_item_bind_visible_to_active() function.
This distinction is currently necessary for floating selections.
Floating selection layers must not be active in their parent stack,
regardless of their visibility, in particular, so that their mode
node doesn't hide the entire backdrop when their composite mode
excludes the backdrop (i.e., when it's dst-atop or src-in).
Instead, their visibility should affect the activeness of the
floating-selection filter of the drawable they're attached to.
This is handled by the next commit.
2017-12-05 10:46:50 -08:00
|
|
|
if (gimp_filter_get_active (GIMP_FILTER (object)))
|
|
|
|
|
gimp_drawable_stack_drawable_active (GIMP_ITEM (object), stack);
|
2008-10-10 13:04:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
|
gimp_drawable_stack_reorder (GimpContainer *container,
|
|
|
|
|
GimpObject *object,
|
|
|
|
|
gint new_index)
|
|
|
|
|
{
|
2013-04-10 18:47:07 -07:00
|
|
|
GimpDrawableStack *stack = GIMP_DRAWABLE_STACK (container);
|
2008-10-10 14:18:24 -07:00
|
|
|
|
2008-10-10 13:04:03 -07:00
|
|
|
GIMP_CONTAINER_CLASS (parent_class)->reorder (container, object, new_index);
|
2008-10-10 14:18:24 -07:00
|
|
|
|
app: add GimpFilter::active property; move ::visible to GimpItem
Add an "active" property to GimpFilter, which replaces its
"visible" property. The new property assumes the lower-level role
"visible" had -- controlling whether the filter has any effect as
part of its parent filter-stack.
Add a "visible" property to GimpItem, separate from the "active"
property, which assumes the higher-level role "visible" had --
controlling whether the item is considered "visible", as per the
GUI. By default, the item's "visible" property is bound to the
filter's "active" property, so that changes in visibility directly
affect the filter's "activeness"; this binding can be controlled
using the new gimp_item_bind_visible_to_active() function.
This distinction is currently necessary for floating selections.
Floating selection layers must not be active in their parent stack,
regardless of their visibility, in particular, so that their mode
node doesn't hide the entire backdrop when their composite mode
excludes the backdrop (i.e., when it's dst-atop or src-in).
Instead, their visibility should affect the activeness of the
floating-selection filter of the drawable they're attached to.
This is handled by the next commit.
2017-12-05 10:46:50 -08:00
|
|
|
if (gimp_filter_get_active (GIMP_FILTER (object)))
|
|
|
|
|
gimp_drawable_stack_drawable_active (GIMP_ITEM (object), stack);
|
2008-10-10 13:04:03 -07:00
|
|
|
}
|
|
|
|
|
|
2008-10-10 14:18:24 -07:00
|
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
2008-10-10 13:04:03 -07:00
|
|
|
GimpContainer *
|
|
|
|
|
gimp_drawable_stack_new (GType drawable_type)
|
|
|
|
|
{
|
|
|
|
|
g_return_val_if_fail (g_type_is_a (drawable_type, GIMP_TYPE_DRAWABLE), NULL);
|
|
|
|
|
|
|
|
|
|
return g_object_new (GIMP_TYPE_DRAWABLE_STACK,
|
|
|
|
|
"name", g_type_name (drawable_type),
|
|
|
|
|
"children-type", drawable_type,
|
|
|
|
|
"policy", GIMP_CONTAINER_POLICY_STRONG,
|
|
|
|
|
NULL);
|
|
|
|
|
}
|
2008-10-10 14:18:24 -07:00
|
|
|
|
|
|
|
|
|
2017-05-08 13:02:37 -07:00
|
|
|
/* protected functions */
|
2008-10-10 14:18:24 -07:00
|
|
|
|
2017-05-08 13:02:37 -07:00
|
|
|
void
|
2008-11-02 11:53:51 -08:00
|
|
|
gimp_drawable_stack_update (GimpDrawableStack *stack,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height)
|
|
|
|
|
{
|
2017-05-08 13:02:37 -07:00
|
|
|
g_return_if_fail (GIMP_IS_DRAWABLE_STACK (stack));
|
|
|
|
|
|
2008-11-02 11:53:51 -08:00
|
|
|
g_signal_emit (stack, stack_signals[UPDATE], 0,
|
|
|
|
|
x, y, width, height);
|
|
|
|
|
}
|
|
|
|
|
|
2017-05-08 13:02:37 -07:00
|
|
|
|
|
|
|
|
/* private functions */
|
|
|
|
|
|
2008-11-02 11:53:51 -08:00
|
|
|
static void
|
|
|
|
|
gimp_drawable_stack_drawable_update (GimpItem *item,
|
|
|
|
|
gint x,
|
|
|
|
|
gint y,
|
|
|
|
|
gint width,
|
|
|
|
|
gint height,
|
|
|
|
|
GimpDrawableStack *stack)
|
|
|
|
|
{
|
app: add GimpFilter::active property; move ::visible to GimpItem
Add an "active" property to GimpFilter, which replaces its
"visible" property. The new property assumes the lower-level role
"visible" had -- controlling whether the filter has any effect as
part of its parent filter-stack.
Add a "visible" property to GimpItem, separate from the "active"
property, which assumes the higher-level role "visible" had --
controlling whether the item is considered "visible", as per the
GUI. By default, the item's "visible" property is bound to the
filter's "active" property, so that changes in visibility directly
affect the filter's "activeness"; this binding can be controlled
using the new gimp_item_bind_visible_to_active() function.
This distinction is currently necessary for floating selections.
Floating selection layers must not be active in their parent stack,
regardless of their visibility, in particular, so that their mode
node doesn't hide the entire backdrop when their composite mode
excludes the backdrop (i.e., when it's dst-atop or src-in).
Instead, their visibility should affect the activeness of the
floating-selection filter of the drawable they're attached to.
This is handled by the next commit.
2017-12-05 10:46:50 -08:00
|
|
|
if (gimp_filter_get_active (GIMP_FILTER (item)))
|
2008-11-02 11:53:51 -08:00
|
|
|
{
|
|
|
|
|
gint offset_x;
|
|
|
|
|
gint offset_y;
|
|
|
|
|
|
2008-11-02 15:03:29 -08:00
|
|
|
gimp_item_get_offset (item, &offset_x, &offset_y);
|
2008-11-02 11:53:51 -08:00
|
|
|
|
|
|
|
|
gimp_drawable_stack_update (stack,
|
|
|
|
|
x + offset_x, y + offset_y,
|
|
|
|
|
width, height);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void
|
app: add GimpFilter::active property; move ::visible to GimpItem
Add an "active" property to GimpFilter, which replaces its
"visible" property. The new property assumes the lower-level role
"visible" had -- controlling whether the filter has any effect as
part of its parent filter-stack.
Add a "visible" property to GimpItem, separate from the "active"
property, which assumes the higher-level role "visible" had --
controlling whether the item is considered "visible", as per the
GUI. By default, the item's "visible" property is bound to the
filter's "active" property, so that changes in visibility directly
affect the filter's "activeness"; this binding can be controlled
using the new gimp_item_bind_visible_to_active() function.
This distinction is currently necessary for floating selections.
Floating selection layers must not be active in their parent stack,
regardless of their visibility, in particular, so that their mode
node doesn't hide the entire backdrop when their composite mode
excludes the backdrop (i.e., when it's dst-atop or src-in).
Instead, their visibility should affect the activeness of the
floating-selection filter of the drawable they're attached to.
This is handled by the next commit.
2017-12-05 10:46:50 -08:00
|
|
|
gimp_drawable_stack_drawable_active (GimpItem *item,
|
|
|
|
|
GimpDrawableStack *stack)
|
2008-11-02 11:53:51 -08:00
|
|
|
{
|
|
|
|
|
gint offset_x;
|
|
|
|
|
gint offset_y;
|
|
|
|
|
|
2008-11-02 15:03:29 -08:00
|
|
|
gimp_item_get_offset (item, &offset_x, &offset_y);
|
2008-11-02 11:53:51 -08:00
|
|
|
|
|
|
|
|
gimp_drawable_stack_update (stack,
|
|
|
|
|
offset_x, offset_y,
|
2008-11-02 16:09:01 -08:00
|
|
|
gimp_item_get_width (item),
|
|
|
|
|
gimp_item_get_height (item));
|
2008-11-02 11:53:51 -08:00
|
|
|
}
|