/* 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_CURVE_VIEW_H__
#define __PIKA_CURVE_VIEW_H__


#include "pikahistogramview.h"


#define PIKA_TYPE_CURVE_VIEW            (pika_curve_view_get_type ())
#define PIKA_CURVE_VIEW(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_CURVE_VIEW, PikaCurveView))
#define PIKA_CURVE_VIEW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_CURVE_VIEW, PikaCurveViewClass))
#define PIKA_IS_CURVE_VIEW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_CURVE_VIEW))
#define PIKA_IS_CURVE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_CURVE_VIEW))
#define PIKA_CURVE_VIEW_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_CURVE_VIEW, PikaCurveViewClass))


typedef struct _PikaCurveViewClass  PikaCurveViewClass;

struct _PikaCurveView
{
  PikaHistogramView  parent_instance;

  Pika              *pika; /* only needed for copy & paste */

  PikaCurve         *curve;
  PikaRGB           *curve_color;

  GList             *bg_curves;

  gboolean           draw_base_line;
  gint               grid_rows;
  gint               grid_columns;

  gint               selected;
  gdouble            offset_x;
  gdouble            offset_y;
  PikaCurvePointType point_type;
  gdouble            last_x;
  gdouble            last_y;
  gdouble            leftmost;
  gdouble            rightmost;
  gboolean           grabbed;
  PikaCurve         *orig_curve;

  GdkCursorType      cursor_type;

  gdouble            xpos;

  PangoLayout       *layout;

  gdouble            range_x_min;
  gdouble            range_x_max;
  gdouble            range_y_min;
  gdouble            range_y_max;

  gdouble            cursor_x;
  gdouble            cursor_y;
  PangoLayout       *cursor_layout;
  PangoRectangle     cursor_rect;

  gchar             *x_axis_label;
  gchar             *y_axis_label;
};

struct _PikaCurveViewClass
{
  PikaHistogramViewClass  parent_class;

  /* signals */
  void (* selection_changed) (PikaCurveView *view);

  void (* cut_clipboard)     (PikaCurveView *view);
  void (* copy_clipboard)    (PikaCurveView *view);
  void (* paste_clipboard)   (PikaCurveView *view);
};


GType       pika_curve_view_get_type          (void) G_GNUC_CONST;

GtkWidget * pika_curve_view_new               (void);

void        pika_curve_view_set_curve         (PikaCurveView *view,
                                               PikaCurve     *curve,
                                               const PikaRGB *color);
PikaCurve * pika_curve_view_get_curve         (PikaCurveView *view);

void        pika_curve_view_add_background    (PikaCurveView *view,
                                               PikaCurve     *curve,
                                               const PikaRGB *color);
void        pika_curve_view_remove_background (PikaCurveView *view,
                                               PikaCurve     *curve);

void   pika_curve_view_remove_all_backgrounds (PikaCurveView *view);

void        pika_curve_view_set_selected      (PikaCurveView *view,
                                               gint           selected);
gint        pika_curve_view_get_selected      (PikaCurveView *view);

void        pika_curve_view_set_range_x       (PikaCurveView *view,
                                               gdouble        min,
                                               gdouble        max);
void        pika_curve_view_set_range_y       (PikaCurveView *view,
                                               gdouble        min,
                                               gdouble        max);
void        pika_curve_view_set_xpos          (PikaCurveView *view,
                                               gdouble        x);

void        pika_curve_view_set_x_axis_label  (PikaCurveView *view,
                                               const gchar   *label);
void        pika_curve_view_set_y_axis_label  (PikaCurveView *view,
                                               const gchar   *label);


#endif /* __PIKA_CURVE_VIEW_H__ */
