//================================================================
// lib2D
//
// - Tools
//
// Tools are functional units (objects) that can be connected
// into operation trees.
//
//
// AUTHOR:  Gabor Nagy
// DATE:    2025-Jul-20 16:51:38
//
// Copyright (C) 2014-2026 by Gabor Nagy. All rights reserved.
//================================================================

#ifndef _EPicTools_h
#define _EPicTools_h

#include <ETool.h>

#ifdef EpGUI
	#include <Image/2DWindow.h>
#else
	#include <Image/Image.h>
#endif  // EpGUI

#if defined (__cplusplus) && (!(defined (__CPLUSLIBS)))
extern "C" {
#endif


typedef struct EpToolClass_S  EpToolClass;

typedef struct EpTool_S       EpTool;


#ifdef EpGUI

// For EpToolGUI->WindowMode
#define EpWindowSOURCE  0x01
#define EpWindowRESULT  0x02
#define EpWindowCUSTOM  0x04

typedef struct
{
	uint32_t    WindowMode;
	EBool       ShowResult,
	            Interactive,
	            UseHardware;
	EBool       ResultDisplayed,
	            ReCenterWindow;        // Auto re-center in EpTool_Execute

// GUI
//
	XeWidget    DialogW;
	XeWidget    DialogTopMatrixW,
							OptionsMatrixW,  ShowResultBW, InteractiveBW, CacheResultBW, InteractivePropagateBW, UseHardwareBW, SeparatorW;

	XeWidget    WindowsHMatrixW;
	EpWindow*   SourceWindow;
	EpWindow*   ResultWindow;
} EpToolGUI;

#endif  // EpGUI



#define EpToolCore\
	EToolCore;\
	EpImage*  Image;\
	uint16_t  InfoPanelComponents;\
	void*     GUI

struct EpTool_S
{
	EpToolCore;
};




struct EpToolClass_S
{
	EToolClassCore;

	int  (*GUI)(ETool* PTool, const char PAction);

	EpImage*  IconImages;

	uint16_t  HotKey;unsigned int  HotKeyModifiers;char  Mnemonic;  // Key shortcut
};


extern const EpToolClass  EpTool_class[];




#ifdef EpGUI
extern void    (*EpTool_ActivateFunc)(EToolClass* PToolClass);
extern void    (*EpToolCB_ActivateFunc)(XeWidget PW, EPointer PClientData, EPointer PCallData);
extern void    (*EpTool_CloseFunc)(EpTool* PTool);

extern void    EpTool_SourceWindowCreate(EpTool* PTool, EpImage* PImage,  XeWidget PShellW, XeWidget PParentW, const uint16_t PInfoPanelFlags);
extern void    EpTool_ResultWindowOnOff(EpTool* PTool, XeWidget PShellW, XeWidget PParentW, const uint16_t PInfoPanelFlags);

extern XeWidget  EpTool_CreateStandardDialog(EpTool* PTool, const char* PTitle, const char* PIconName, XeCallbackFunc PApplyCallback, XeCallbackFunc POkCallback);
extern XeWidget  EpTool_CreateFolders(XeWidget PParentW, XeWidget* PFolderTipsMatrixPtr);
extern XeWidget  EpTool_CreateAnimationTab(EpTool* PGUITool, XeWidget PTabPanelMatrixW);
#endif  // EpGUI

extern void    (*Ep_ExitFunc)(void);
extern int     (*EpTool_ClassRegisterFunc)(EpToolClass* PClass);
extern int     (*EpTool_ClassRemoveFunc)(EpToolClass* PClass);

extern int           Ep_BinMasks[];

EList(extern, EpToolClass*, Ep_ToolClasses);
EListA(extern, ETool*, Ep_Tools);

extern EpToolClass*  EpTool_ClassRegister(EpToolClass* PTemplate);
extern void          EpTool_ClassDeactivate(EpToolClass* PClass);
extern void          EpTool_ClassesFree(void);
extern void          EpTools_Free(void);



#if defined (__cplusplus) && (!(defined (__CPLUSLIBS)))
}	// Close scope of 'extern "C"' declaration
#endif

#endif // _EPicTools_h
