/* 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
 *
 * pikatooltransformgrid.h
 * Copyright (C) 2017 Michael Natterer <mitch@gimp.org>
 *
 * 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_TOOL_TRANSFORM_GRID_H__
#define __PIKA_TOOL_TRANSFORM_GRID_H__


#include "pikacanvashandle.h"
#include "pikatoolwidget.h"


#define PIKA_TOOL_TRANSFORM_GRID_MAX_HANDLE_SIZE \
  (1.5 * PIKA_CANVAS_HANDLE_SIZE_LARGE)


typedef enum
{
  PIKA_TRANSFORM_HANDLE_NONE,
  PIKA_TRANSFORM_HANDLE_NW_P,     /* north west perspective         */
  PIKA_TRANSFORM_HANDLE_NE_P,     /* north east perspective         */
  PIKA_TRANSFORM_HANDLE_SW_P,     /* south west perspective         */
  PIKA_TRANSFORM_HANDLE_SE_P,     /* south east perspective         */
  PIKA_TRANSFORM_HANDLE_NW,       /* north west                     */
  PIKA_TRANSFORM_HANDLE_NE,       /* north east                     */
  PIKA_TRANSFORM_HANDLE_SW,       /* south west                     */
  PIKA_TRANSFORM_HANDLE_SE,       /* south east                     */
  PIKA_TRANSFORM_HANDLE_N,        /* north                          */
  PIKA_TRANSFORM_HANDLE_S,        /* south                          */
  PIKA_TRANSFORM_HANDLE_E,        /* east                           */
  PIKA_TRANSFORM_HANDLE_W,        /* west                           */
  PIKA_TRANSFORM_HANDLE_CENTER,   /* center for moving              */
  PIKA_TRANSFORM_HANDLE_PIVOT,    /* pivot for rotation and scaling */
  PIKA_TRANSFORM_HANDLE_N_S,      /* north shearing                 */
  PIKA_TRANSFORM_HANDLE_S_S,      /* south shearing                 */
  PIKA_TRANSFORM_HANDLE_E_S,      /* east shearing                  */
  PIKA_TRANSFORM_HANDLE_W_S,      /* west shearing                  */
  PIKA_TRANSFORM_HANDLE_ROTATION, /* rotation                       */

  PIKA_N_TRANSFORM_HANDLES /* keep this last so *handles[] is the right size */
} PikaTransformHandle;


#define PIKA_TYPE_TOOL_TRANSFORM_GRID            (pika_tool_transform_grid_get_type ())
#define PIKA_TOOL_TRANSFORM_GRID(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_TOOL_TRANSFORM_GRID, PikaToolTransformGrid))
#define PIKA_TOOL_TRANSFORM_GRID_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_TOOL_TRANSFORM_GRID, PikaToolTransformGridClass))
#define PIKA_IS_TOOL_TRANSFORM_GRID(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_TOOL_TRANSFORM_GRID))
#define PIKA_IS_TOOL_TRANSFORM_GRID_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_TOOL_TRANSFORM_GRID))
#define PIKA_TOOL_TRANSFORM_GRID_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_TOOL_TRANSFORM_GRID, PikaToolTransformGridClass))


typedef struct _PikaToolTransformGrid        PikaToolTransformGrid;
typedef struct _PikaToolTransformGridPrivate PikaToolTransformGridPrivate;
typedef struct _PikaToolTransformGridClass   PikaToolTransformGridClass;

struct _PikaToolTransformGrid
{
  PikaToolWidget                parent_instance;

  PikaToolTransformGridPrivate *private;
};

struct _PikaToolTransformGridClass
{
  PikaToolWidgetClass  parent_class;
};


GType                 pika_tool_transform_grid_get_type   (void) G_GNUC_CONST;

PikaToolWidget      * pika_tool_transform_grid_new        (PikaDisplayShell      *shell,
                                                           const PikaMatrix3     *transform,
                                                           gdouble                x1,
                                                           gdouble                y1,
                                                           gdouble                x2,
                                                           gdouble                y2);

/*  protected functions  */

PikaTransformHandle   pika_tool_transform_grid_get_handle (PikaToolTransformGrid *grid);


#endif /* __PIKA_TOOL_TRANSFORM_GRID_H__ */
