ref: 72ea71f4d629f81f7c5eb34d31cf4b873162d06b
dir: /blie.h/
typedef struct Layer Layer; typedef struct Editor Editor; typedef struct Vdata Vdata; typedef struct Vstate Vstate; typedef enum { Rnil = 0, Rdrawing = 1, Rtools = 2, Rlayers = 4, } Redrawwin; extern Vdata vdata; extern Vstate vstate; extern int bliedebug; extern int headless; /* could be extracted to libdraw */ int eentercolor(char*, ulong*, Mouse*); /* could be extracted to separate library */ typedef struct Ask Ask; struct Ask { char *label; char *value; int nval; }; int ask(Ask*, Mouse); struct Layer { char *name; char *label; Drawop op; Editor *editor; Memimage *composited; int num; void *data; }; enum { UP, DOWN }; void addlayer(char *name); void movelayer(Layer*, int); void savelayermeta(Layer*); void dirtylayer(Layer*); void redrawlayers(Image*, Layer*); Redrawwin clicklayer(Event, Layer*, Image*, void (*f)(Layer*)); int foreachlayer(void (*f)(Layer*, int, 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 *transparent; Image *gray; Memimage *mgray; Memimage *mtransparent; }; enum { Dpan = 1, Dzoom = 2, Dcontent = Dpan|Dzoom, }; struct Vstate { Point offset; float zoom; int dirty; int mdirty; int maxquality; Point mousepos; Mouse lastmouse; }; void setmodedirty(int); void setdrawingdirty(int); Image **reqwin(Rectangle, ulong, void (*f)(Image*)); void unreqwin(Image**); /* writes memimage to drawing image, considering pan and zoom using dirty flags */ void sampleview(Image*, Memimage*, int quality); /* see editor.txt */ struct Editor { char *name; void (*init)(void); void (*initlayer)(Layer*); Memimage *(*composite)(Layer*, Memimage*); Memimage *(*raw)(Layer*); Memimage *(*mask)(Layer*); int (*overlay)(Layer*, Image*); Rectangle (*toolrect)(Layer*); void (*drawtools)(Layer*, Image*); void (*drawlwin)(Layer*, Image*, Rectangle); Redrawwin (*drawinput)(Layer*, int, Event); Redrawwin (*toolinput)(Layer*, int, Event); Redrawwin (*lwininput)(Layer*, int, Event); int (*savedata)(Layer*); int (*savetools)(Layer*); }; extern Editor p9image; extern Editor efilter; 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*); Point scalepos(Point); uchar rgb2k(uchar r, uchar g, uchar b); uchar ilerp(uchar A, uchar B, uchar α); double flerp(double A, double B, double α); uchar imul(uchar A, uchar B); Memimage* gencomposite(Memimage*, Memimage*, Memimage*, Drawop); Memimage* gencanvas(Memimage*); Memimage* dupmemimage(Memimage*);