PIKApp/app/core/pikacontext.h

373 lines
16 KiB
C
Raw Permalink Normal View History

2023-09-26 00:35:21 +02:00
/* 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
*
* pikacontext.h
* Copyright (C) 1999-2010 Michael Natterer
*
* 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_CONTEXT_H__
#define __PIKA_CONTEXT_H__
#include "pikaviewable.h"
#define PIKA_TYPE_CONTEXT (pika_context_get_type ())
#define PIKA_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_CONTEXT, PikaContext))
#define PIKA_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, PIKA_TYPE_CONTEXT, PikaContextClass))
#define PIKA_IS_CONTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_CONTEXT))
#define PIKA_IS_CONTEXT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_CONTEXT))
#define PIKA_CONTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS (obj, PIKA_TYPE_CONTEXT, PikaContextClass))
typedef struct _PikaContextClass PikaContextClass;
/**
* PikaContext:
*
* Holds state such as the active image, active display, active brush,
* active foreground and background color, and so on. There can many
* instances of contexts. The user context is what the user sees and
* interacts with but there can also be contexts for docks and for
* plug-ins.
*/
struct _PikaContext
{
PikaViewable parent_instance;
Pika *pika;
PikaContext *parent;
guint32 defined_props;
guint32 serialize_props;
PikaImage *image;
PikaDisplay *display;
PikaToolInfo *tool_info;
gchar *tool_name;
PikaPaintInfo *paint_info;
gchar *paint_name;
PikaRGB foreground;
PikaRGB background;
gdouble opacity;
PikaLayerMode paint_mode;
PikaBrush *brush;
gchar *brush_name;
PikaDynamics *dynamics;
gchar *dynamics_name;
PikaMybrush *mybrush;
gchar *mybrush_name;
PikaPattern *pattern;
gchar *pattern_name;
PikaGradient *gradient;
gchar *gradient_name;
PikaPalette *palette;
gchar *palette_name;
PikaFont *font;
gchar *font_name;
PikaToolPreset *tool_preset;
gchar *tool_preset_name;
PikaBuffer *buffer;
gchar *buffer_name;
PikaImagefile *imagefile;
gchar *imagefile_name;
PikaTemplate *template;
gchar *template_name;
PikaLineArt *line_art;
guint line_art_timeout_id;
};
struct _PikaContextClass
{
PikaViewableClass parent_class;
void (* image_changed) (PikaContext *context,
PikaImage *image);
void (* display_changed) (PikaContext *context,
PikaDisplay *display);
void (* tool_changed) (PikaContext *context,
PikaToolInfo *tool_info);
void (* paint_info_changed) (PikaContext *context,
PikaPaintInfo *paint_info);
void (* foreground_changed) (PikaContext *context,
PikaRGB *color);
void (* background_changed) (PikaContext *context,
PikaRGB *color);
void (* opacity_changed) (PikaContext *context,
gdouble opacity);
void (* paint_mode_changed) (PikaContext *context,
PikaLayerMode paint_mode);
void (* brush_changed) (PikaContext *context,
PikaBrush *brush);
void (* dynamics_changed) (PikaContext *context,
PikaDynamics *dynamics);
void (* mybrush_changed) (PikaContext *context,
PikaMybrush *brush);
void (* pattern_changed) (PikaContext *context,
PikaPattern *pattern);
void (* gradient_changed) (PikaContext *context,
PikaGradient *gradient);
void (* palette_changed) (PikaContext *context,
PikaPalette *palette);
void (* font_changed) (PikaContext *context,
PikaFont *font);
void (* tool_preset_changed)(PikaContext *context,
PikaToolPreset *tool_preset);
void (* buffer_changed) (PikaContext *context,
PikaBuffer *buffer);
void (* imagefile_changed) (PikaContext *context,
PikaImagefile *imagefile);
void (* template_changed) (PikaContext *context,
PikaTemplate *template);
void (* prop_name_changed) (PikaContext *context,
PikaContextPropType prop);
};
GType pika_context_get_type (void) G_GNUC_CONST;
PikaContext * pika_context_new (Pika *pika,
const gchar *name,
PikaContext *template);
PikaContext * pika_context_get_parent (PikaContext *context);
void pika_context_set_parent (PikaContext *context,
PikaContext *parent);
/* define / undefinine context properties
*
* the value of an undefined property will be taken from the parent context.
*/
void pika_context_define_property (PikaContext *context,
PikaContextPropType prop,
gboolean defined);
gboolean pika_context_property_defined (PikaContext *context,
PikaContextPropType prop);
void pika_context_define_properties (PikaContext *context,
PikaContextPropMask props_mask,
gboolean defined);
/* specify which context properties will be serialized
*/
void pika_context_set_serialize_properties (PikaContext *context,
PikaContextPropMask props_mask);
PikaContextPropMask
pika_context_get_serialize_properties (PikaContext *context);
/* copying context properties
*/
void pika_context_copy_property (PikaContext *src,
PikaContext *dest,
PikaContextPropType prop);
void pika_context_copy_properties (PikaContext *src,
PikaContext *dest,
PikaContextPropMask props_mask);
/* manipulate by GType */
PikaContextPropType pika_context_type_to_property (GType type);
const gchar * pika_context_type_to_prop_name (GType type);
const gchar * pika_context_type_to_signal_name (GType type);
PikaObject * pika_context_get_by_type (PikaContext *context,
GType type);
void pika_context_set_by_type (PikaContext *context,
GType type,
PikaObject *object);
void pika_context_changed_by_type (PikaContext *context,
GType type);
/* image */
PikaImage * pika_context_get_image (PikaContext *context);
void pika_context_set_image (PikaContext *context,
PikaImage *image);
void pika_context_image_changed (PikaContext *context);
/* display */
PikaDisplay * pika_context_get_display (PikaContext *context);
void pika_context_set_display (PikaContext *context,
PikaDisplay *display);
void pika_context_display_changed (PikaContext *context);
/* tool */
PikaToolInfo * pika_context_get_tool (PikaContext *context);
void pika_context_set_tool (PikaContext *context,
PikaToolInfo *tool_info);
void pika_context_tool_changed (PikaContext *context);
/* paint info */
PikaPaintInfo * pika_context_get_paint_info (PikaContext *context);
void pika_context_set_paint_info (PikaContext *context,
PikaPaintInfo *paint_info);
void pika_context_paint_info_changed (PikaContext *context);
/* foreground color */
void pika_context_get_foreground (PikaContext *context,
PikaRGB *color);
void pika_context_set_foreground (PikaContext *context,
const PikaRGB *color);
void pika_context_foreground_changed (PikaContext *context);
/* background color */
void pika_context_get_background (PikaContext *context,
PikaRGB *color);
void pika_context_set_background (PikaContext *context,
const PikaRGB *color);
void pika_context_background_changed (PikaContext *context);
/* color utility functions */
void pika_context_set_default_colors (PikaContext *context);
void pika_context_swap_colors (PikaContext *context);
/* opacity */
gdouble pika_context_get_opacity (PikaContext *context);
void pika_context_set_opacity (PikaContext *context,
gdouble opacity);
void pika_context_opacity_changed (PikaContext *context);
/* paint mode */
PikaLayerMode pika_context_get_paint_mode (PikaContext *context);
void pika_context_set_paint_mode (PikaContext *context,
PikaLayerMode paint_mode);
void pika_context_paint_mode_changed (PikaContext *context);
/* brush */
PikaBrush * pika_context_get_brush (PikaContext *context);
void pika_context_set_brush (PikaContext *context,
PikaBrush *brush);
void pika_context_brush_changed (PikaContext *context);
/* dynamics */
PikaDynamics * pika_context_get_dynamics (PikaContext *context);
void pika_context_set_dynamics (PikaContext *context,
PikaDynamics *dynamics);
void pika_context_dynamics_changed (PikaContext *context);
/* mybrush */
PikaMybrush * pika_context_get_mybrush (PikaContext *context);
void pika_context_set_mybrush (PikaContext *context,
PikaMybrush *brush);
void pika_context_mybrush_changed (PikaContext *context);
/* pattern */
PikaPattern * pika_context_get_pattern (PikaContext *context);
void pika_context_set_pattern (PikaContext *context,
PikaPattern *pattern);
void pika_context_pattern_changed (PikaContext *context);
/* gradient */
PikaGradient * pika_context_get_gradient (PikaContext *context);
void pika_context_set_gradient (PikaContext *context,
PikaGradient *gradient);
void pika_context_gradient_changed (PikaContext *context);
/* palette */
PikaPalette * pika_context_get_palette (PikaContext *context);
void pika_context_set_palette (PikaContext *context,
PikaPalette *palette);
void pika_context_palette_changed (PikaContext *context);
/* font */
PikaFont * pika_context_get_font (PikaContext *context);
void pika_context_set_font (PikaContext *context,
PikaFont *font);
const gchar * pika_context_get_font_name (PikaContext *context);
void pika_context_set_font_name (PikaContext *context,
const gchar *name);
void pika_context_font_changed (PikaContext *context);
/* tool_preset */
PikaToolPreset * pika_context_get_tool_preset (PikaContext *context);
void pika_context_set_tool_preset (PikaContext *context,
PikaToolPreset *tool_preset);
void pika_context_tool_preset_changed (PikaContext *context);
/* buffer */
PikaBuffer * pika_context_get_buffer (PikaContext *context);
void pika_context_set_buffer (PikaContext *context,
PikaBuffer *palette);
void pika_context_buffer_changed (PikaContext *context);
/* imagefile */
PikaImagefile * pika_context_get_imagefile (PikaContext *context);
void pika_context_set_imagefile (PikaContext *context,
PikaImagefile *imagefile);
void pika_context_imagefile_changed (PikaContext *context);
/* template */
PikaTemplate * pika_context_get_template (PikaContext *context);
void pika_context_set_template (PikaContext *context,
PikaTemplate *template);
void pika_context_template_changed (PikaContext *context);
/* line art */
PikaLineArt * pika_context_take_line_art (PikaContext *context);
void pika_context_store_line_art (PikaContext *context,
PikaLineArt *line_art);
#endif /* __PIKA_CONTEXT_H__ */