/* 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
 *
 * pikaitemtreeview.h
 * Copyright (C) 2001-2003 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_ITEM_TREE_VIEW_H__
#define __PIKA_ITEM_TREE_VIEW_H__


#include "pikacontainertreeview.h"


typedef PikaContainer * (* PikaGetContainerFunc) (PikaImage *image);
typedef PikaItem      * (* PikaGetItemFunc)      (PikaImage *image);
typedef void            (* PikaSetItemFunc)      (PikaImage *image,
                                                  PikaItem  *item);
typedef GList         * (* PikaGetItemsFunc)     (PikaImage *image);
typedef void            (* PikaSetItemsFunc)     (PikaImage *image,
                                                  GList     *items);
typedef void            (* PikaAddItemFunc)      (PikaImage *image,
                                                  PikaItem  *item,
                                                  PikaItem  *parent,
                                                  gint       index,
                                                  gboolean   push_undo);
typedef void            (* PikaRemoveItemFunc)   (PikaImage *image,
                                                  PikaItem  *item,
                                                  gboolean   push_undo,
                                                  PikaItem  *new_active);
typedef PikaItem      * (* PikaNewItemFunc)      (PikaImage *image);


typedef gboolean        (* PikaIsLockedFunc)     (PikaItem  *item);
typedef gboolean        (* PikaCanLockFunc)      (PikaItem  *item);
typedef void            (* PikaSetLockFunc)      (PikaItem  *item,
                                                  gboolean   lock,
                                                  gboolean   push_undo);
typedef PikaUndo      * (*PikaUndoLockPush)      (PikaImage     *image,
                                                  const gchar   *undo_desc,
                                                  PikaItem      *item);


#define PIKA_TYPE_ITEM_TREE_VIEW            (pika_item_tree_view_get_type ())
#define PIKA_ITEM_TREE_VIEW(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), PIKA_TYPE_ITEM_TREE_VIEW, PikaItemTreeView))
#define PIKA_ITEM_TREE_VIEW_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), PIKA_TYPE_ITEM_TREE_VIEW, PikaItemTreeViewClass))
#define PIKA_IS_ITEM_TREE_VIEW(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PIKA_TYPE_ITEM_TREE_VIEW))
#define PIKA_IS_ITEM_TREE_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PIKA_TYPE_ITEM_TREE_VIEW))
#define PIKA_ITEM_TREE_VIEW_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS ((obj), PIKA_TYPE_ITEM_TREE_VIEW, PikaItemTreeViewClass))


typedef struct _PikaItemTreeViewClass   PikaItemTreeViewClass;
typedef struct _PikaItemTreeViewPrivate PikaItemTreeViewPrivate;

struct _PikaItemTreeView
{
  PikaContainerTreeView    parent_instance;

  PikaItemTreeViewPrivate *priv;
};

struct _PikaItemTreeViewClass
{
  PikaContainerTreeViewClass  parent_class;

  /*  signals  */
  void (* set_image) (PikaItemTreeView *view,
                      PikaImage        *image);

  GType                 item_type;
  const gchar          *signal_name;

  /*  virtual functions for manipulating the image's item tree  */
  PikaGetContainerFunc  get_container;
  PikaGetItemsFunc      get_selected_items;
  PikaSetItemsFunc      set_selected_items;
  PikaAddItemFunc       add_item;
  PikaRemoveItemFunc    remove_item;
  PikaNewItemFunc       new_item;

  /*  action names  */
  const gchar          *action_group;
  const gchar          *activate_action;
  const gchar          *new_action;
  const gchar          *new_default_action;
  const gchar          *raise_action;
  const gchar          *raise_top_action;
  const gchar          *lower_action;
  const gchar          *lower_bottom_action;
  const gchar          *duplicate_action;
  const gchar          *delete_action;

  /*  lock content button appearance  */
  const gchar          *lock_content_icon_name;
  const gchar          *lock_content_tooltip;
  const gchar          *lock_content_help_id;

  /* lock position (translation and transformation) button appearance */
  const gchar          *lock_position_icon_name;
  const gchar          *lock_position_tooltip;
  const gchar          *lock_position_help_id;

  /* lock visibility button appearance */
  const gchar          *lock_visibility_icon_name;
  const gchar          *lock_visibility_tooltip;
  const gchar          *lock_visibility_help_id;
};


GType       pika_item_tree_view_get_type          (void) G_GNUC_CONST;

GtkWidget * pika_item_tree_view_new               (GType             view_type,
                                                   gint              view_size,
                                                   gint              view_border_width,
                                                   gboolean          multiple_selection,
                                                   PikaImage        *image,
                                                   PikaMenuFactory  *menu_facotry,
                                                   const gchar      *menu_identifier,
                                                   const gchar      *ui_identifier);

void        pika_item_tree_view_set_image         (PikaItemTreeView *view,
                                                   PikaImage        *image);
PikaImage * pika_item_tree_view_get_image         (PikaItemTreeView *view);

void        pika_item_tree_view_add_options       (PikaItemTreeView *view,
                                                   const gchar      *label,
                                                   GtkWidget        *options);
void        pika_item_tree_view_add_lock          (PikaItemTreeView *view,
                                                   const gchar      *icon_name,
                                                   PikaIsLockedFunc  is_locked,
                                                   PikaCanLockFunc   can_lock,
                                                   PikaSetLockFunc   lock,
                                                   PikaUndoLockPush  undo_push,
                                                   const gchar      *signal_name,
                                                   PikaUndoType      undo_type,
                                                   PikaUndoType      group_undo_type,
                                                   const gchar      *undo_lock_label,
                                                   const gchar      *undo_unlock_label,
                                                   const gchar      *undo_exclusive_desc,
                                                   const gchar      *tooltip,
                                                   const gchar      *help_id);
void        pika_item_tree_view_blink_lock        (PikaItemTreeView *view,
                                                   PikaItem         *item);

GtkWidget * pika_item_tree_view_get_new_button    (PikaItemTreeView *view);
GtkWidget * pika_item_tree_view_get_delete_button (PikaItemTreeView *view);

gint        pika_item_tree_view_get_drop_index    (PikaItemTreeView *view,
                                                   PikaViewable     *dest_viewable,
                                                   GtkTreeViewDropPosition drop_pos,
                                                   PikaViewable    **parent);


#endif  /*  __PIKA_ITEM_TREE_VIEW_H__  */
