/* 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): 
 *
 * pikawarptool.h
 * Copyright (C) 2011 Michael Muré <batolettre@gmail.com>
 *
 * 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_WARP_TOOL_H__
#define __PIKA_WARP_TOOL_H__


#include "pikadrawtool.h"


#define PIKA_TYPE_WARP_TOOL            (pika_warp_tool_get_type ())
#define PIKA_WARP_TOOL(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_WARP_TOOL, PikaWarpTool))
#define PIKA_WARP_TOOL_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_WARP_TOOL, PikaWarpToolClass))
#define PIKA_IS_WARP_TOOL(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_WARP_TOOL))
#define PIKA_IS_WARP_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_WARP_TOOL))
#define PIKA_WARP_TOOL_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_WARP_TOOL, PikaWarpToolClass))

#define PIKA_WARP_TOOL_GET_OPTIONS(t)  (PIKA_WARP_OPTIONS (pika_tool_get_options (PIKA_TOOL (t))))


typedef struct _PikaWarpTool      PikaWarpTool;
typedef struct _PikaWarpToolClass PikaWarpToolClass;

struct _PikaWarpTool
{
  PikaDrawTool        parent_instance;

  gboolean            show_cursor;
  gboolean            draw_brush;
  gboolean            snap_brush;

  PikaVector2         cursor_pos;    /* Hold the cursor position */

  GeglBuffer         *coords_buffer; /* Buffer where coordinates are stored */

  GeglNode           *graph;         /* Top level GeglNode */
  GeglNode           *render_node;   /* Node to render the transformation */

  GeglPath           *current_stroke;
  guint               stroke_timer;

  PikaVector2         last_pos;
  gdouble             total_dist;

  PikaDrawableFilter *filter;

  GList              *redo_stack;
};

struct _PikaWarpToolClass
{
  PikaDrawToolClass parent_class;
};


void    pika_warp_tool_register (PikaToolRegisterCallback  callback,
                                 gpointer                  data);

GType   pika_warp_tool_get_type (void) G_GNUC_CONST;


#endif  /*  __PIKA_WARP_TOOL_H__  */
