//========================================================================
// Color library GUI
//
// - Color-wheel
//
// AUTHOR:  Gabor Nagy
// DATE:    2024-Apr-28 03:54:52
//
// Copyright (C) 2014-2026 by Gabor Nagy. All rights reserved.
//========================================================================
#ifndef	_EColorWheel_h
#define	_EColorWheel_h

#include <Color/Color.h>

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


#define EcMAX_COLORWHEEL_SIZEX  200
#define EcMAX_COLORWHEEL_SIZEY  200

typedef struct
{
	int  R, G, B, V;
} EcRGBViColor;

typedef struct
{
	float  R, G, B, V;
} EcRGBVfColor;

typedef struct EcColorWheel
{
	XeWidget      MatrixW, DrawW, ValueW;
	int           MarginWidth;
	EInt32_2      Size;
	int           CursorX, CursorY;
	EcRGBViColor  RGBViColor;
	EcRGBVfColor  RGBVfColor;

	EcRGBViColor  ReferenceRGBViColor;  // Remember the exact color set by the application, so we can accurately reproduce it when only V changes.
	EcRGBVfColor  ReferenceRGBVfColor;
	float         Hues[EcMAX_COLORWHEEL_SIZEY][EcMAX_COLORWHEEL_SIZEX];
	float         Saturations[EcMAX_COLORWHEEL_SIZEY][EcMAX_COLORWHEEL_SIZEX];
	int           VType;
	void          (*CallbackFunc)(struct EcColorWheel* PColorWheel, EPointer PClientData, EPointer PCallData);
	EPointer      ClientData;
	EBool         HSValid;

	EpImage*      Image;
	EpImage*      WheelImage;
} EcColorWheel;

typedef void	(*EcColorWheelCallbackFunc)(EcColorWheel* PColorWheel, EPointer PClientData, EPointer PCallData);

typedef struct
{
	int             reason;
	EcRGBAiColor    RGBAiColor;
	EcRGBAf32Color	RGBAfColor;
} EcColorWheelCallbackStruct;



extern EcColorWheel*  EcColorWheel_New(XeWidget PParentW, XeWidget PVWidget, const EBool PCreateVSlider,  const int PSizeX, const int PSizeY,  const int PVType,  const EcRGBAf32Color* PRGBAf32Color, const EcRGBAiColor* PRGBAiColor,  EcColorWheelCallbackFunc PCallback, EPointer PClientData);
extern void      EcColorWheel_Free(EcColorWheel* PColorWheel);

extern void EcColorWheel_SetType(EcColorWheel* PColorWheel, const uint16_t PValueType);

extern void      EcColorWheel_Redraw(EcColorWheel* PCW);
extern void      EcColorWheel_SetRGBiColor(EcColorWheel* PCW, EcRGBiColor* PRGBiColor);
extern void      EcColorWheel_SetRGBfColor(EcColorWheel* PCW, EcRGBf32Color* PRGBfColor);
extern void      EcColorWheel_SetRGBAfColor(EcColorWheel* PCW, EcRGBAf32Color* PRGBfColor);

extern void      _EcCB_ColorWheel_SetValue(XeWidget PW, EPointer PClientData, EPointer PCallData);

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

#endif // _EColorWheel_h
