/* 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-1999 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_PAINT_OPTIONS_H__
#define __PIKA_PAINT_OPTIONS_H__


#include "core/pikatooloptions.h"


#define PIKA_PAINT_OPTIONS_CONTEXT_MASK PIKA_CONTEXT_PROP_MASK_FOREGROUND | \
                                        PIKA_CONTEXT_PROP_MASK_BACKGROUND | \
                                        PIKA_CONTEXT_PROP_MASK_OPACITY    | \
                                        PIKA_CONTEXT_PROP_MASK_PAINT_MODE | \
                                        PIKA_CONTEXT_PROP_MASK_BRUSH      | \
                                        PIKA_CONTEXT_PROP_MASK_DYNAMICS   | \
                                        PIKA_CONTEXT_PROP_MASK_PALETTE


typedef struct _PikaJitterOptions        PikaJitterOptions;
typedef struct _PikaFadeOptions          PikaFadeOptions;
typedef struct _PikaGradientPaintOptions PikaGradientPaintOptions;
typedef struct _PikaSmoothingOptions     PikaSmoothingOptions;

struct _PikaJitterOptions
{
  gboolean  use_jitter;
  gdouble   jitter_amount;
};

struct _PikaFadeOptions
{
  gboolean        fade_reverse;
  gdouble         fade_length;
  PikaUnit        fade_unit;
  PikaRepeatMode  fade_repeat;
};

struct _PikaGradientPaintOptions
{
  gboolean                    gradient_reverse;
  PikaGradientBlendColorSpace gradient_blend_color_space;
  PikaRepeatMode              gradient_repeat; /* only used by gradient tool */
};

struct _PikaSmoothingOptions
{
  gboolean use_smoothing;
  gint     smoothing_quality;
  gdouble  smoothing_factor;
};


#define PIKA_TYPE_PAINT_OPTIONS            (pika_paint_options_get_type ())
#define PIKA_PAINT_OPTIONS(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_PAINT_OPTIONS, PikaPaintOptions))
#define PIKA_PAINT_OPTIONS_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_PAINT_OPTIONS, PikaPaintOptionsClass))
#define PIKA_IS_PAINT_OPTIONS(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_PAINT_OPTIONS))
#define PIKA_IS_PAINT_OPTIONS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_PAINT_OPTIONS))
#define PIKA_PAINT_OPTIONS_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_PAINT_OPTIONS, PikaPaintOptionsClass))


typedef struct _PikaPaintOptionsClass PikaPaintOptionsClass;

struct _PikaPaintOptions
{
  PikaToolOptions           parent_instance;

  PikaPaintInfo            *paint_info;

  gboolean                  use_applicator;

  PikaBrush                *brush; /* weak-refed storage for the GUI */

  gdouble                   brush_size;
  gdouble                   brush_angle;
  gdouble                   brush_aspect_ratio;
  gdouble                   brush_spacing;
  gdouble                   brush_hardness;
  gdouble                   brush_force;

  gboolean                  brush_link_size;
  gboolean                  brush_link_aspect_ratio;
  gboolean                  brush_link_angle;
  gboolean                  brush_link_spacing;
  gboolean                  brush_link_hardness;

  gboolean                  brush_lock_to_view;

  PikaPaintApplicationMode  application_mode;
  PikaPaintApplicationMode  application_mode_save;

  gboolean                  hard;

  PikaJitterOptions        *jitter_options;

  gboolean                  dynamics_enabled;
  PikaFadeOptions          *fade_options;
  PikaGradientPaintOptions *gradient_options;
  PikaSmoothingOptions     *smoothing_options;

  PikaViewType              brush_view_type;
  PikaViewSize              brush_view_size;
  PikaViewType              dynamics_view_type;
  PikaViewSize              dynamics_view_size;
  PikaViewType              pattern_view_type;
  PikaViewSize              pattern_view_size;
  PikaViewType              gradient_view_type;
  PikaViewSize              gradient_view_size;
};

struct _PikaPaintOptionsClass
{
  PikaToolOptionsClass  parent_instance;
};


GType    pika_paint_options_get_type (void) G_GNUC_CONST;

PikaPaintOptions *
         pika_paint_options_new                (PikaPaintInfo       *paint_info);

gdouble  pika_paint_options_get_fade           (PikaPaintOptions    *options,
                                                PikaImage           *image,
                                                gdouble              pixel_dist);

gdouble  pika_paint_options_get_jitter         (PikaPaintOptions    *options,
                                                PikaImage           *image);

gboolean pika_paint_options_get_gradient_color (PikaPaintOptions    *options,
                                                PikaImage           *image,
                                                gdouble              grad_point,
                                                gdouble              pixel_dist,
                                                PikaRGB             *color);

PikaBrushApplicationMode
         pika_paint_options_get_brush_mode     (PikaPaintOptions    *options);

void     pika_paint_options_set_default_brush_size
                                               (PikaPaintOptions    *options,
                                                PikaBrush           *brush);
void     pika_paint_options_set_default_brush_angle
                                               (PikaPaintOptions    *options,
                                                PikaBrush           *brush);
void     pika_paint_options_set_default_brush_aspect_ratio
                                               (PikaPaintOptions    *options,
                                                PikaBrush           *brush);
void     pika_paint_options_set_default_brush_spacing
                                               (PikaPaintOptions    *options,
                                                PikaBrush           *brush);

void     pika_paint_options_set_default_brush_hardness
                                               (PikaPaintOptions    *options,
                                                PikaBrush           *brush);

gboolean pika_paint_options_are_dynamics_enabled (PikaPaintOptions *paint_options);
void     pika_paint_options_enable_dynamics      (PikaPaintOptions *paint_options,
                                                  gboolean          enable);

gboolean pika_paint_options_is_prop            (const gchar         *prop_name,
                                                PikaContextPropMask  prop_mask);
void     pika_paint_options_copy_props         (PikaPaintOptions    *src,
                                                PikaPaintOptions    *dest,
                                                PikaContextPropMask  prop_mask);


#endif  /*  __PIKA_PAINT_OPTIONS_H__  */
