PIKApp/app/core/pikalayer.h

258 lines
15 KiB
C

/* PIKA - Photo and Image Kooker Application
* a rebranding of The GNU Image Manipulation Program (created with heckimp)
* A derived work which may be trivial. However, any changes may be (C)2023 by Aldercone Studio
*
* Original copyright, applying to most contents (license remains unchanged):
* 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/>.
*/
#ifndef __PIKA_LAYER_H__
#define __PIKA_LAYER_H__
#include "pikadrawable.h"
#define PIKA_TYPE_LAYER (pika_layer_get_type ())
#define PIKA_LAYER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_LAYER, PikaLayer))
#define PIKA_LAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_LAYER, PikaLayerClass))
#define PIKA_IS_LAYER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_LAYER))
#define PIKA_IS_LAYER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_LAYER))
#define PIKA_LAYER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_LAYER, PikaLayerClass))
typedef struct _PikaLayerClass PikaLayerClass;
struct _PikaLayer
{
PikaDrawable parent_instance;
gdouble opacity; /* layer opacity */
PikaLayerMode mode; /* layer combination mode */
PikaLayerColorSpace blend_space; /* layer blend space */
PikaLayerColorSpace composite_space; /* layer composite space */
PikaLayerCompositeMode composite_mode; /* layer composite mode */
PikaLayerMode effective_mode; /* layer effective combination mode */
PikaLayerColorSpace effective_blend_space; /* layer effective blend space */
PikaLayerColorSpace effective_composite_space; /* layer effective composite space */
PikaLayerCompositeMode effective_composite_mode; /* layer effective composite mode */
gboolean excludes_backdrop; /* layer clips backdrop */
gboolean lock_alpha; /* lock the alpha channel */
PikaLayerMask *mask; /* possible layer mask */
gboolean apply_mask; /* controls mask application */
gboolean edit_mask; /* edit mask or layer? */
gboolean show_mask; /* show mask or layer? */
GSList *move_stack; /* ancestors affected by move */
GeglNode *layer_offset_node;
GeglNode *mask_offset_node;
/* Floating selections */
struct
{
PikaDrawable *drawable; /* floating sel is attached to */
gboolean boundary_known; /* is the current boundary valid */
PikaBoundSeg *segs; /* boundary of floating sel */
gint num_segs; /* number of segs in boundary */
} fs;
};
struct _PikaLayerClass
{
PikaDrawableClass parent_class;
/* signals */
void (* opacity_changed) (PikaLayer *layer);
void (* mode_changed) (PikaLayer *layer);
void (* blend_space_changed) (PikaLayer *layer);
void (* composite_space_changed) (PikaLayer *layer);
void (* composite_mode_changed) (PikaLayer *layer);
void (* effective_mode_changed) (PikaLayer *layer);
void (* excludes_backdrop_changed) (PikaLayer *layer);
void (* lock_alpha_changed) (PikaLayer *layer);
void (* mask_changed) (PikaLayer *layer);
void (* apply_mask_changed) (PikaLayer *layer);
void (* edit_mask_changed) (PikaLayer *layer);
void (* show_mask_changed) (PikaLayer *layer);
/* virtual functions */
gboolean (* is_alpha_locked) (PikaLayer *layer,
PikaLayer **locked_layer);
void (* translate) (PikaLayer *layer,
gint offset_x,
gint offset_y);
void (* scale) (PikaLayer *layer,
gint new_width,
gint new_height,
gint new_offset_x,
gint new_offset_y,
PikaInterpolationType interpolation_type,
PikaProgress *progress);
void (* resize) (PikaLayer *layer,
PikaContext *context,
PikaFillType fill_type,
gint new_width,
gint new_height,
gint offset_x,
gint offset_y);
void (* flip) (PikaLayer *layer,
PikaContext *context,
PikaOrientationType flip_type,
gdouble axis,
gboolean clip_result);
void (* rotate) (PikaLayer *layer,
PikaContext *context,
PikaRotationType rotate_type,
gdouble center_x,
gdouble center_y,
gboolean clip_result);
void (* transform) (PikaLayer *layer,
PikaContext *context,
const PikaMatrix3 *matrix,
PikaTransformDirection direction,
PikaInterpolationType interpolation_type,
PikaTransformResize clip_result,
PikaProgress *progress);
void (* convert_type) (PikaLayer *layer,
PikaImage *dest_image,
const Babl *new_format,
PikaColorProfile *src_profile,
PikaColorProfile *dest_profile,
GeglDitherMethod layer_dither_type,
GeglDitherMethod mask_dither_type,
gboolean push_undo,
PikaProgress *progress);
GeglRectangle (* get_bounding_box) (PikaLayer *layer);
void (* get_effective_mode) (PikaLayer *layer,
PikaLayerMode *mode,
PikaLayerColorSpace *blend_space,
PikaLayerColorSpace *composite_space,
PikaLayerCompositeMode *composite_mode);
gboolean (* get_excludes_backdrop) (PikaLayer *layer);
};
/* function declarations */
GType pika_layer_get_type (void) G_GNUC_CONST;
void pika_layer_fix_format_space (PikaLayer *layer,
gboolean copy_buffer,
gboolean push_undo);
PikaLayer * pika_layer_get_parent (PikaLayer *layer);
PikaLayerMask * pika_layer_get_mask (PikaLayer *layer);
PikaLayerMask * pika_layer_create_mask (PikaLayer *layer,
PikaAddMaskType mask_type,
PikaChannel *channel);
PikaLayerMask * pika_layer_add_mask (PikaLayer *layer,
PikaLayerMask *mask,
gboolean push_undo,
GError **error);
void pika_layer_apply_mask (PikaLayer *layer,
PikaMaskApplyMode mode,
gboolean push_undo);
void pika_layer_set_apply_mask (PikaLayer *layer,
gboolean apply,
gboolean push_undo);
gboolean pika_layer_get_apply_mask (PikaLayer *layer);
void pika_layer_set_edit_mask (PikaLayer *layer,
gboolean edit);
gboolean pika_layer_get_edit_mask (PikaLayer *layer);
void pika_layer_set_show_mask (PikaLayer *layer,
gboolean show,
gboolean push_undo);
gboolean pika_layer_get_show_mask (PikaLayer *layer);
void pika_layer_add_alpha (PikaLayer *layer);
void pika_layer_remove_alpha (PikaLayer *layer,
PikaContext *context);
void pika_layer_resize_to_image (PikaLayer *layer,
PikaContext *context,
PikaFillType fill_type);
PikaDrawable * pika_layer_get_floating_sel_drawable (PikaLayer *layer);
void pika_layer_set_floating_sel_drawable (PikaLayer *layer,
PikaDrawable *drawable);
gboolean pika_layer_is_floating_sel (PikaLayer *layer);
void pika_layer_set_opacity (PikaLayer *layer,
gdouble opacity,
gboolean push_undo);
gdouble pika_layer_get_opacity (PikaLayer *layer);
void pika_layer_set_mode (PikaLayer *layer,
PikaLayerMode mode,
gboolean push_undo);
PikaLayerMode pika_layer_get_mode (PikaLayer *layer);
void pika_layer_set_blend_space (PikaLayer *layer,
PikaLayerColorSpace blend_space,
gboolean push_undo);
PikaLayerColorSpace
pika_layer_get_blend_space (PikaLayer *layer);
PikaLayerColorSpace
pika_layer_get_real_blend_space (PikaLayer *layer);
void pika_layer_set_composite_space (PikaLayer *layer,
PikaLayerColorSpace composite_space,
gboolean push_undo);
PikaLayerColorSpace
pika_layer_get_composite_space (PikaLayer *layer);
PikaLayerColorSpace
pika_layer_get_real_composite_space (PikaLayer *layer);
void pika_layer_set_composite_mode (PikaLayer *layer,
PikaLayerCompositeMode composite_mode,
gboolean push_undo);
PikaLayerCompositeMode
pika_layer_get_composite_mode (PikaLayer *layer);
PikaLayerCompositeMode
pika_layer_get_real_composite_mode (PikaLayer *layer);
void pika_layer_get_effective_mode (PikaLayer *layer,
PikaLayerMode *mode,
PikaLayerColorSpace *blend_space,
PikaLayerColorSpace *composite_space,
PikaLayerCompositeMode *composite_mode);
gboolean pika_layer_get_excludes_backdrop (PikaLayer *layer);
void pika_layer_set_lock_alpha (PikaLayer *layer,
gboolean lock_alpha,
gboolean push_undo);
gboolean pika_layer_get_lock_alpha (PikaLayer *layer);
gboolean pika_layer_can_lock_alpha (PikaLayer *layer);
gboolean pika_layer_is_alpha_locked (PikaLayer *layer,
PikaLayer **locked_layer);
/* protected */
void pika_layer_update_effective_mode (PikaLayer *layer);
void pika_layer_update_excludes_backdrop (PikaLayer *layer);
#endif /* __PIKA_LAYER_H__ */