/*
 * Copyright (C) 2006 John Ellis
 * Copyright (C) 2008 - 2016 The Geeqie Team
 *
 * Author: John Ellis
 *
 * 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 2 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, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef PAN_VIEW_PAN_ITEM_H
#define PAN_VIEW_PAN_ITEM_H

#include <vector>

#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdk.h>
#include <glib.h>

#include "geometry.h"
#include "pan-types.h"

class FileData;
struct PixbufRenderer;

enum PanBorderType {
	PAN_BORDER_NONE = 0,
	PAN_BORDER_1 = 1 << 0,
	PAN_BORDER_2 = 1 << 1,
	PAN_BORDER_3 = 1 << 2,
	PAN_BORDER_1_3 = PAN_BORDER_1 | PAN_BORDER_3,
	PAN_BORDER_4 = 1 << 3
};

enum PanTextAttrType {
	PAN_TEXT_ATTR_NONE = 0,
	PAN_TEXT_ATTR_BOLD = 1 << 0,
	PAN_TEXT_ATTR_HEADING = 1 << 1,
	PAN_TEXT_ATTR_BOLD_HEADING = PAN_TEXT_ATTR_BOLD | PAN_TEXT_ATTR_HEADING,
	PAN_TEXT_ATTR_MARKUP = 1 << 2
};

PanItemType get_pan_item_type(PanImageSize size);

void pan_item_list_clear(PanItemList &list);

void pan_item_added(PanWindow *pw, PanItem *pi);
void pan_item_remove_by_key(PanWindow *pw, PanKey key);

// Find items
PanItemList pan_item_find_by_path(PanWindow *pw, PanItemType type, const gchar *path,
                                  gboolean ignore_case, gboolean partial);
PanItem *pan_item_find_by_fd(PanWindow *pw, PanItemType type, FileData *fd,
                             gboolean ignore_case, gboolean partial);
PanItem *pan_item_find_by_coord(PanWindow *pw, PanItemType type,
                                gint x, gint y, PanKey key);

// Item box type
PanItem *pan_item_box_new(PanWindow *pw, FileData *fd, gint x, gint y, gint width, gint height,
                          GqColor base, gint border_size, GqColor border_color);
void pan_item_box_shadow(PanItem *pi, gint offset, gint fade);

// Item triangle type
PanItem *pan_item_tri_new(PanWindow *pw,
                          GqPoint c1, GqPoint c2, GqPoint c3,
                          GqColor color,
                          PanBorderType borders, GqColor border_color);
void pan_item_tri_shift(PanItem *pi, gint x, gint y);

// Item text type
PanItem *pan_item_text_new(PanWindow *pw, gint x, gint y, const gchar *text,
                           PanTextAttrType attr, gint border_size, GqColor color);

// Item thumbnail type
PanItem *pan_item_thumb_new(PanWindow *pw, FileData *fd, gint x, gint y);

// Item image type
PanItem *pan_item_image_new(PanWindow *pw, FileData *fd, gint x, gint y, gint w, gint h);

// Alignment
class PanTextAlignment
{
public:
	PanTextAlignment(PanWindow *pw, gint x, gint y, PanKey key);

	void add(const gchar *label, const gchar *text);
	void calc(PanItem *box);

private:
	PanWindow *pw;

	struct Items
	{
		PanItem *label = nullptr;
		PanItem *text = nullptr;
	};

	std::vector<Items> columns;

	gint x;
	gint y;
	PanKey key;
	int label_width_max = 0;
};

#endif
