shithub: blie

ref: 13590f759547f4ef544b251f2966b4ed2d82038c
dir: /editor.txt/

View raw version
Editor functions and properties (blie.h:/^struct Editor)

to add new editor:
- add struct declaration to blie.h (blie.h:/^extern Editor)
- add editor in loadeditors (editor.c:/^loadeditors)
- see: p9image.c

PROPERTY name

short name of the editor. Works as an identifier, must be unique!


FUNCTION init (*)

Initialize/load static data, like images and brushes.
Will be called exactly once on startup.


FUNCTION composite (*)

param:  Layer*     Layer to work with
param:  Memimage*  Memimage to composite over
return: Memimage*  composited result


FUNCTION raw (tbd)

param:  Layer*     Layer to work with
return: Memimage*  raw image (no duplicate)


FUNCTION mask (tbd)

param:  Layer*     Layer to work with
return: Memimage*  raw mask (no duplicate)


FUNCTION overlay (*)

param:  Layer*     Layer to work with
param:  Image*     editor image to draw on
return: int        whether overlay fills the full drawing

This function is called in two situations:

1. To determine if we need to draw the image underneath
2. To actually draw the overlay

Case 1 is when the editor image is nil. In this case, only the
return value is relevant.

Case 2 is when the editor image is set. In this case, the return
value is ignored.

Case 1 is important to improve performance. There's no need to
composite and draw the drawing when we will overdraw it with
a full overlay image anyway.


FUNCTION toolrect

param:  Layer*     Layer to work with
return: Rectangle  wanted size of the tool window

For the given layer, return the needed size of the tool window.
In general, the tool window should be pretty small in height.


FUNCTION drawtools

param:  Layer*     Layer to work with
param:  Image*     Image to draw the tools on

For the given layer, draw the tools handles into the supplied
image.


FUNCTION drawlwin*

param:  Layer*     Layer to work with
param:  Image*     Image to draw layer window tools on
param:  Rectangle  Rectangle to draw within

This function is supposed to draw some mini editor into the
layer representation of the given layer in the layer window.
Consider using this for shortcut tools, mostly for visualization
purposes or global layer-wide tools like alpha values.


FUNCTION drawinput

param:  Layer*     Layer to work with
param:  int        Event type (Emouse, Ekeyboard)
param:  Event      Event structure
return: Redrawwin  Redraw parameters

The mouse xy inside the event structure is normalized to the
(0,0) position of the drawing window.

Use the return parameter to specify which window should be
redrawn.


FUNCTION toolinput

param:  Layer*     Layer to work with
param:  int        Event type (Emouse, Ekeyboard)
param:  Event      Event structure
return: Redrawwin  Redraw parameters

This function is analogous to drawinput, just for the tools
window.


FUNCTION lwininput

param:  Layer*     Layer to work with
param:  int        Event type (currently only Emouse)
param:  Event      Event structure
return: Redrawwin  Redraw parameters

This function is analogous to drawinput, just for the small
tools panel in the layers window.


FUNCTION savedata

param:  Layer*     Layer to work with
return: int        1 for success, 0 for fail

If failed, set errstr.