PIKApp/app/core/pikadrawable.h

243 lines
14 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_DRAWABLE_H__
#define __PIKA_DRAWABLE_H__
#include "pikaitem.h"
#define PIKA_TYPE_DRAWABLE (pika_drawable_get_type ())
#define PIKA_DRAWABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_DRAWABLE, PikaDrawable))
#define PIKA_DRAWABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_DRAWABLE, PikaDrawableClass))
#define PIKA_IS_DRAWABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_DRAWABLE))
#define PIKA_IS_DRAWABLE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_DRAWABLE))
#define PIKA_DRAWABLE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_DRAWABLE, PikaDrawableClass))
typedef struct _PikaDrawablePrivate PikaDrawablePrivate;
typedef struct _PikaDrawableClass PikaDrawableClass;
struct _PikaDrawable
{
PikaItem parent_instance;
PikaDrawablePrivate *private;
};
struct _PikaDrawableClass
{
PikaItemClass parent_class;
/* signals */
void (* update) (PikaDrawable *drawable,
gint x,
gint y,
gint width,
gint height);
void (* format_changed) (PikaDrawable *drawable);
void (* alpha_changed) (PikaDrawable *drawable);
void (* bounding_box_changed) (PikaDrawable *drawable);
/* virtual functions */
gint64 (* estimate_memsize) (PikaDrawable *drawable,
PikaComponentType component_type,
gint width,
gint height);
void (* update_all) (PikaDrawable *drawable);
void (* invalidate_boundary) (PikaDrawable *drawable);
void (* get_active_components) (PikaDrawable *drawable,
gboolean *active);
PikaComponentMask (* get_active_mask) (PikaDrawable *drawable);
gboolean (* supports_alpha) (PikaDrawable *drawable);
void (* convert_type) (PikaDrawable *drawable,
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);
void (* apply_buffer) (PikaDrawable *drawable,
GeglBuffer *buffer,
const GeglRectangle *buffer_region,
gboolean push_undo,
const gchar *undo_desc,
gdouble opacity,
PikaLayerMode mode,
PikaLayerColorSpace blend_space,
PikaLayerColorSpace composite_space,
PikaLayerCompositeMode composite_mode,
GeglBuffer *base_buffer,
gint base_x,
gint base_y);
GeglBuffer * (* get_buffer) (PikaDrawable *drawable);
void (* set_buffer) (PikaDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
GeglBuffer *buffer,
const GeglRectangle *bounds);
GeglRectangle (* get_bounding_box) (PikaDrawable *drawable);
void (* push_undo) (PikaDrawable *drawable,
const gchar *undo_desc,
GeglBuffer *buffer,
gint x,
gint y,
gint width,
gint height);
void (* swap_pixels) (PikaDrawable *drawable,
GeglBuffer *buffer,
gint x,
gint y);
GeglNode * (* get_source_node) (PikaDrawable *drawable);
};
GType pika_drawable_get_type (void) G_GNUC_CONST;
PikaDrawable * pika_drawable_new (GType type,
PikaImage *image,
const gchar *name,
gint offset_x,
gint offset_y,
gint width,
gint height,
const Babl *format);
gint64 pika_drawable_estimate_memsize (PikaDrawable *drawable,
PikaComponentType component_type,
gint width,
gint height);
void pika_drawable_update (PikaDrawable *drawable,
gint x,
gint y,
gint width,
gint height);
void pika_drawable_update_all (PikaDrawable *drawable);
void pika_drawable_invalidate_boundary (PikaDrawable *drawable);
void pika_drawable_get_active_components (PikaDrawable *drawable,
gboolean *active);
PikaComponentMask pika_drawable_get_active_mask (PikaDrawable *drawable);
gboolean pika_drawable_supports_alpha (PikaDrawable *drawable);
void pika_drawable_convert_type (PikaDrawable *drawable,
PikaImage *dest_image,
PikaImageBaseType new_base_type,
PikaPrecision new_precision,
gboolean new_has_alpha,
PikaColorProfile *src_profile,
PikaColorProfile *dest_profile,
GeglDitherMethod layer_dither_type,
GeglDitherMethod mask_dither_type,
gboolean push_undo,
PikaProgress *progress);
void pika_drawable_apply_buffer (PikaDrawable *drawable,
GeglBuffer *buffer,
const GeglRectangle *buffer_rect,
gboolean push_undo,
const gchar *undo_desc,
gdouble opacity,
PikaLayerMode mode,
PikaLayerColorSpace blend_space,
PikaLayerColorSpace composite_space,
PikaLayerCompositeMode composite_mode,
GeglBuffer *base_buffer,
gint base_x,
gint base_y);
GeglBuffer * pika_drawable_get_buffer (PikaDrawable *drawable);
void pika_drawable_set_buffer (PikaDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
GeglBuffer *buffer);
void pika_drawable_set_buffer_full (PikaDrawable *drawable,
gboolean push_undo,
const gchar *undo_desc,
GeglBuffer *buffer,
const GeglRectangle *bounds,
gboolean update);
void pika_drawable_steal_buffer (PikaDrawable *drawable,
PikaDrawable *src_drawable);
void pika_drawable_set_format (PikaDrawable *drawable,
const Babl *format,
gboolean copy_buffer,
gboolean push_undo);
GeglNode * pika_drawable_get_source_node (PikaDrawable *drawable);
GeglNode * pika_drawable_get_mode_node (PikaDrawable *drawable);
GeglRectangle pika_drawable_get_bounding_box (PikaDrawable *drawable);
gboolean pika_drawable_update_bounding_box
(PikaDrawable *drawable);
void pika_drawable_swap_pixels (PikaDrawable *drawable,
GeglBuffer *buffer,
gint x,
gint y);
void pika_drawable_push_undo (PikaDrawable *drawable,
const gchar *undo_desc,
GeglBuffer *buffer,
gint x,
gint y,
gint width,
gint height);
void pika_drawable_disable_resize_undo (PikaDrawable *drawable);
void pika_drawable_enable_resize_undo (PikaDrawable *drawable);
const Babl * pika_drawable_get_space (PikaDrawable *drawable);
const Babl * pika_drawable_get_format (PikaDrawable *drawable);
const Babl * pika_drawable_get_format_with_alpha(PikaDrawable *drawable);
const Babl * pika_drawable_get_format_without_alpha
(PikaDrawable *drawable);
PikaTRCType pika_drawable_get_trc (PikaDrawable *drawable);
gboolean pika_drawable_has_alpha (PikaDrawable *drawable);
PikaImageBaseType pika_drawable_get_base_type (PikaDrawable *drawable);
PikaComponentType pika_drawable_get_component_type (PikaDrawable *drawable);
PikaPrecision pika_drawable_get_precision (PikaDrawable *drawable);
gboolean pika_drawable_is_rgb (PikaDrawable *drawable);
gboolean pika_drawable_is_gray (PikaDrawable *drawable);
gboolean pika_drawable_is_indexed (PikaDrawable *drawable);
const Babl * pika_drawable_get_component_format (PikaDrawable *drawable,
PikaChannelType channel);
gint pika_drawable_get_component_index (PikaDrawable *drawable,
PikaChannelType channel);
guchar * pika_drawable_get_colormap (PikaDrawable *drawable);
void pika_drawable_start_paint (PikaDrawable *drawable);
gboolean pika_drawable_end_paint (PikaDrawable *drawable);
gboolean pika_drawable_flush_paint (PikaDrawable *drawable);
gboolean pika_drawable_is_painting (PikaDrawable *drawable);
#endif /* __PIKA_DRAWABLE_H__ */