1 /*	Public domain	*/
2 
3 #ifndef _AGAR_WIDGET_HSVPAL_H_
4 #define _AGAR_WIDGET_HSVPAL_H_
5 
6 #include <agar/gui/scrollbar.h>
7 #include <agar/gui/menu.h>
8 #include <agar/gui/window.h>
9 
10 #include <agar/gui/begin.h>
11 
12 typedef struct ag_hsvpal {
13 	struct ag_widget wid;
14 	Uint flags;
15 #define AG_HSVPAL_PIXEL		0x01	/* Edit the pixel binding */
16 #define AG_HSVPAL_DIRTY		0x02	/* Redraw the palette */
17 #define AG_HSVPAL_HFILL 	0x04
18 #define AG_HSVPAL_VFILL 	0x08
19 #define AG_HSVPAL_NOALPHA	0x10	/* Disable alpha slider by default */
20 #define AG_HSVPAL_FORCE_NOALPHA	0x10	/* Disable alpha regardless of pixel-format */
21 #define AG_HSVPAL_NOPREVIEW	0x20	/* Disable color preview */
22 #define AG_HSVPAL_SHOW_RGB	0x40	/* Print RGB value */
23 #define AG_HSVPAL_SHOW_HSV	0x80	/* Print HSV value */
24 #define AG_HSVPAL_EXPAND (AG_HSVPAL_HFILL|AG_HSVPAL_VFILL)
25 
26 	float h, s, v, a;		/* Default bindings */
27 	Uint32 pixel;			/* Calculated pixel */
28 	AG_Color color;			/* Calculated color */
29 	AG_Rect rAlpha;			/* Alpha selector rectangle */
30 	AG_Surface *surface;		/* Cached surface */
31 	int surfaceId;
32 	int selcircle_r;		/* Radius of selection circles */
33 	struct {
34 		int x, y;		/* Origin for circle of hues */
35 		int rout, rin;		/* Radii of the circle of hues */
36 		int spacing;		/* Spacing between circle and rect */
37 		int width;		/* Width of circular band (rout-rin) */
38 		float dh;		/* Calculated optimal hue increment */
39 	} circle;
40 	struct {
41 		int x, y;		/* Coordinates of triangle */
42 		int w, h;		/* Dimensions of triangle */
43 	} triangle;
44 	enum {
45 		AG_HSVPAL_SEL_NONE,
46 		AG_HSVPAL_SEL_H,	/* Selecting hue */
47 		AG_HSVPAL_SEL_SV,	/* Selecting saturation/value */
48 		AG_HSVPAL_SEL_A		/* Selecting transparency value */
49 	} state;
50 
51 	AG_Menu *menu;
52 	AG_MenuItem *menu_item;
53 	AG_Window *menu_win;
54 	AG_Color cTile;
55 } AG_HSVPal;
56 
57 __BEGIN_DECLS
58 extern AG_WidgetClass agHSVPalClass;
59 AG_HSVPal *AG_HSVPalNew(void *, Uint);
60 __END_DECLS
61 
62 #include <agar/gui/close.h>
63 #endif /* _AGAR_WIDGET_HSVPAL_H_ */
64