shithub: blie

ref: f7ce9af61db9b0d072dad403cb98d8bad4224dda
dir: /blie.h/

View raw version
typedef struct Layer Layer;
typedef struct Editor Editor;
typedef struct Vdata Vdata;
typedef struct Vstate Vstate;

extern Vdata vdata;
extern Vstate vstate;
extern int bliedebug;

struct Layer {
	char *name;
	char *label;
	Drawop op;
	Editor *editor;
	void *data;
};

enum { UP, DOWN };

void addlayer(char *name);
void movelayer(Layer*, int);
void savelayermeta(Layer*);
void redrawlayers(Image*, Layer*);
void clicklayer(Mouse, void (*f)(Layer*));
int foreachlayer(void (*f)(Layer*, int, void*), void*);

void changecursor(Cursor*, Image*, Point);

struct Vdata {
	int layerwinwidth; /* width of layers window */
	int fontheight; /* height of font */
	int keyoffset; /* offset on key input */
	float keyzoom; /* zoom change */
	Image *gray;
};

struct Vstate {	
	Point offset;
	float zoom;
};

/* writes memimage to drawing image, considering pan and zoom */
void sampleview(Image*, Memimage*);

struct Editor {
	char *name;
	Memimage *(*composite)(Layer*, Memimage*);
	Memimage *(*raw)(Layer*);
	Memimage *(*mask)(Layer*);
	void (*overlay)(Layer*, Image*);
	Rectangle (*toolrect)(Layer*);
	void (*drawtools)(Layer*, Image*);
	int (*drawinput)(Layer*, int, Event);
	int (*toolinput)(Layer*, int, Event);
	int (*savedata)(Layer*);
};

extern Editor p9image;

void loadeditors(void);
int addeditor(Editor*);
Editor *geteditor(char*);

/* generic composite of layer (using raw) and the composited image
 * from the previous layer
 */
Memimage* ecomposite(Layer*, Memimage*);

Memimage* gencomposite(Memimage*, Memimage*, Memimage*, Drawop);
Memimage* gencanvas(Memimage*);
Memimage* dupmemimage(Memimage*);