2015-09-04 13:51:10 -05:00
|
|
|
// 4 september 2015
|
|
|
|
|
|
|
|
typedef struct uiArea uiArea;
|
|
|
|
typedef struct uiAreaHandler uiAreaHandler;
|
|
|
|
typedef struct uiAreaDrawParams uiAreaDrawParams;
|
2015-09-10 22:00:29 -05:00
|
|
|
typedef struct uiAreaMouseEvent uiAreaMouseEvent;
|
2015-09-12 22:21:34 -05:00
|
|
|
typedef struct uiAreaKeyEvent uiAreaKeyEvent;
|
2015-09-04 13:51:10 -05:00
|
|
|
|
2015-09-06 15:55:43 -05:00
|
|
|
typedef struct uiDrawContext uiDrawContext;
|
|
|
|
|
2015-09-04 13:51:10 -05:00
|
|
|
struct uiAreaHandler {
|
2015-09-06 15:20:37 -05:00
|
|
|
void (*Draw)(uiAreaHandler *, uiArea *, uiAreaDrawParams *);
|
2015-09-05 19:05:48 -05:00
|
|
|
uintmax_t (*HScrollMax)(uiAreaHandler *, uiArea *);
|
|
|
|
uintmax_t (*VScrollMax)(uiAreaHandler *, uiArea *);
|
2015-09-10 20:17:00 -05:00
|
|
|
int (*RedrawOnResize)(uiAreaHandler *, uiArea *);
|
2015-09-10 22:00:29 -05:00
|
|
|
void (*MouseEvent)(uiAreaHandler *, uiArea *, uiAreaMouseEvent *);
|
2015-09-11 21:59:59 -05:00
|
|
|
void (*DragBroken)(uiAreaHandler *, uiArea *);
|
2015-09-12 22:21:34 -05:00
|
|
|
int (*KeyEvent)(uiAreaHandler *, uiArea *, uiAreaKeyEvent *);
|
2015-09-04 13:51:10 -05:00
|
|
|
};
|
|
|
|
|
2015-09-06 15:20:37 -05:00
|
|
|
struct uiAreaDrawParams {
|
2015-09-06 15:55:43 -05:00
|
|
|
uiDrawContext *Context;
|
2015-09-06 15:20:37 -05:00
|
|
|
|
|
|
|
intmax_t ClientWidth;
|
|
|
|
intmax_t ClientHeight;
|
|
|
|
|
|
|
|
intmax_t ClipX;
|
|
|
|
intmax_t ClipY;
|
|
|
|
intmax_t ClipWidth;
|
|
|
|
intmax_t ClipHeight;
|
|
|
|
|
2015-09-06 15:55:43 -05:00
|
|
|
int DPIX;
|
|
|
|
int DPIY;
|
2015-09-06 15:20:37 -05:00
|
|
|
|
|
|
|
intmax_t HScrollPos;
|
|
|
|
intmax_t VScrollPos;
|
|
|
|
};
|
2015-09-06 19:02:01 -05:00
|
|
|
|
|
|
|
// TODO dotting/dashing
|
|
|
|
|
2015-10-08 07:04:23 -05:00
|
|
|
typedef struct uiDrawPath uiDrawPath;
|
|
|
|
typedef struct uiDrawBrush uiDrawBrush;
|
2015-09-06 19:02:01 -05:00
|
|
|
typedef struct uiDrawStrokeParams uiDrawStrokeParams;
|
2015-10-08 07:04:23 -05:00
|
|
|
|
|
|
|
typedef enum uiDrawBrushType uiDrawBrushType;
|
|
|
|
typedef struct uiDrawBrushGradientStop uiDrawBrushGradientStop;
|
|
|
|
|
2015-09-06 19:02:01 -05:00
|
|
|
typedef enum uiDrawLineCap uiDrawLineCap;
|
|
|
|
typedef enum uiDrawLineJoin uiDrawLineJoin;
|
2015-09-06 21:48:25 -05:00
|
|
|
typedef enum uiDrawFillMode uiDrawFillMode;
|
2015-09-06 19:02:01 -05:00
|
|
|
|
2015-10-08 07:04:23 -05:00
|
|
|
enum uiDrawBrushType {
|
|
|
|
uiDrawBrushTypeSolid,
|
|
|
|
uiDrawBrushTypeLinearGradient,
|
|
|
|
uiDrawBrushTypeRadialGradient,
|
|
|
|
uiDrawBrushTypeImage,
|
|
|
|
};
|
|
|
|
|
2015-09-06 19:02:01 -05:00
|
|
|
enum uiDrawLineCap {
|
|
|
|
uiDrawLineCapFlat,
|
|
|
|
uiDrawLineCapRound,
|
|
|
|
uiDrawLineCapSquare,
|
|
|
|
};
|
|
|
|
|
|
|
|
enum uiDrawLineJoin {
|
|
|
|
uiDrawLineJoinMiter,
|
|
|
|
uiDrawLineJoinRound,
|
|
|
|
uiDrawLineJoinBevel,
|
|
|
|
};
|
|
|
|
|
2015-09-06 21:48:25 -05:00
|
|
|
// this is the default for botoh cairo and GDI
|
|
|
|
// Core Graphics doesn't explicitly specify a default, but NSBezierPath allows you to choose one, and this is the initial value
|
|
|
|
// so we're good to use it too!
|
|
|
|
#define uiDrawDefaultMiterLimit 10.0
|
|
|
|
|
|
|
|
enum uiDrawFillMode {
|
|
|
|
uiDrawFillModeWinding,
|
|
|
|
uiDrawFillModeAlternate,
|
|
|
|
};
|
|
|
|
|
2015-10-08 07:04:23 -05:00
|
|
|
struct uiDrawBrush {
|
|
|
|
uiDrawBrushType Type;
|
|
|
|
|
|
|
|
// solid brushes
|
|
|
|
double R;
|
|
|
|
double G;
|
|
|
|
double B;
|
|
|
|
double A;
|
|
|
|
|
|
|
|
// gradient brushes
|
|
|
|
double X0; // linear: start X, radial: start X
|
|
|
|
double Y0; // linear: start Y, radial: start Y
|
|
|
|
double X1; // linear: end X, radial: outer circle center X
|
|
|
|
double Y1; // linear: end Y, radial: outer circle center Y
|
|
|
|
double OuterRadius; // radial gradients only
|
|
|
|
uiDrawBrushGradientStop *Stops;
|
|
|
|
size_t NumStops;
|
|
|
|
// TODO extend mode
|
|
|
|
// cairo: none, repeat, reflect, pad; no individual control
|
|
|
|
// Direct2D: repeat, reflect, pad; no individual control
|
|
|
|
// Core Graphics: none, pad; before and after individually
|
|
|
|
// TODO cairo documentation is inconsistent about pad
|
|
|
|
|
|
|
|
// TODO images
|
|
|
|
|
|
|
|
// TODO transforms
|
|
|
|
};
|
|
|
|
|
|
|
|
struct uiDrawBrushGradientStop {
|
|
|
|
double Pos;
|
|
|
|
double R;
|
|
|
|
double G;
|
|
|
|
double B;
|
|
|
|
double A;
|
|
|
|
};
|
|
|
|
|
2015-09-06 19:02:01 -05:00
|
|
|
struct uiDrawStrokeParams {
|
|
|
|
uiDrawLineCap Cap;
|
|
|
|
uiDrawLineJoin Join;
|
2015-10-08 07:04:23 -05:00
|
|
|
double Thickness;
|
2015-09-06 21:48:25 -05:00
|
|
|
double MiterLimit;
|
|
|
|
};
|
|
|
|
|
2015-10-08 07:04:23 -05:00
|
|
|
uiDrawPath *uiDrawNewPath(uiDrawFillMode);
|
|
|
|
void uiDrawFreePath(uiDrawPath *);
|
2015-09-06 19:02:01 -05:00
|
|
|
|
2015-10-08 07:04:23 -05:00
|
|
|
void uiDrawPathNewFigure(uiDrawPath *, double, double);
|
|
|
|
void uiDrawPathNewFigureWithArc(uiDrawPath *, double, double, double, double, double);
|
|
|
|
void uiDrawPathLineTo(uiDrawPath *, double, double);
|
2015-09-07 14:34:14 -05:00
|
|
|
// notes: angles are both relative to 0 and go counterclockwise
|
2015-10-08 07:04:23 -05:00
|
|
|
// TODO is the initial line segment on cairo and OS X a proper join?
|
|
|
|
void uiDrawPathArcTo(uiDrawPath *, double, double, double, double, double);
|
|
|
|
void uiDrawPathBezierTo(uiDrawPath *, double, double, double, double, double, double);
|
|
|
|
// TODO quadratic bezier
|
|
|
|
void uiDrawPathCloseFigure(uiDrawPath *);
|
|
|
|
|
|
|
|
// TODO effect of these when a figure is already started
|
|
|
|
void uiDrawPathAddRectangle(uiDrawPath *, double, double, double, double);
|
|
|
|
|
|
|
|
void uiDrawPathEnd(uiDrawPath *);
|
2015-09-07 09:13:15 -05:00
|
|
|
|
2015-10-08 07:04:23 -05:00
|
|
|
void uiDrawStroke(uiDrawContext *, uiDrawPath *, uiDrawBrush *, uiDrawStrokeParams *);
|
|
|
|
void uiDrawFill(uiDrawContext *, uiDrawPath *, uiDrawBrush *);
|
2015-09-06 22:37:05 -05:00
|
|
|
|
2015-09-14 19:02:52 -05:00
|
|
|
// TODO primitives:
|
|
|
|
// - rounded rectangles
|
|
|
|
// - elliptical arcs
|
|
|
|
// - quadratic bezier curves
|
|
|
|
|
2015-09-10 22:00:29 -05:00
|
|
|
typedef enum uiModifiers uiModifiers;
|
|
|
|
|
|
|
|
enum uiModifiers {
|
|
|
|
uiModifierCtrl = 1 << 0,
|
|
|
|
uiModifierAlt = 1 << 1,
|
|
|
|
uiModifierShift = 1 << 2,
|
|
|
|
uiModifierSuper = 1 << 3,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct uiAreaMouseEvent {
|
|
|
|
intmax_t X;
|
|
|
|
intmax_t Y;
|
|
|
|
|
2015-09-11 20:24:39 -05:00
|
|
|
intmax_t ClientWidth;
|
|
|
|
intmax_t ClientHeight;
|
2015-09-10 22:00:29 -05:00
|
|
|
intmax_t HScrollPos;
|
|
|
|
intmax_t VScrollPos;
|
|
|
|
|
|
|
|
uintmax_t Down;
|
|
|
|
uintmax_t Up;
|
|
|
|
|
2015-09-11 12:07:27 -05:00
|
|
|
uintmax_t Count;
|
|
|
|
|
2015-09-10 22:00:29 -05:00
|
|
|
uiModifiers Modifiers;
|
|
|
|
|
|
|
|
uint64_t Held1To64;
|
|
|
|
};
|
2015-09-12 22:21:34 -05:00
|
|
|
|
|
|
|
typedef enum uiExtKey uiExtKey;
|
|
|
|
|
|
|
|
enum uiExtKey {
|
|
|
|
uiExtKeyEscape = 1,
|
|
|
|
uiExtKeyInsert, // equivalent to "Help" on Apple keyboards
|
|
|
|
uiExtKeyDelete,
|
|
|
|
uiExtKeyHome,
|
|
|
|
uiExtKeyEnd,
|
|
|
|
uiExtKeyPageUp,
|
|
|
|
uiExtKeyPageDown,
|
|
|
|
uiExtKeyUp,
|
|
|
|
uiExtKeyDown,
|
|
|
|
uiExtKeyLeft,
|
|
|
|
uiExtKeyRight,
|
|
|
|
uiExtKeyF1, // F1..F12 are guaranteed to be consecutive
|
|
|
|
uiExtKeyF2,
|
|
|
|
uiExtKeyF3,
|
|
|
|
uiExtKeyF4,
|
|
|
|
uiExtKeyF5,
|
|
|
|
uiExtKeyF6,
|
|
|
|
uiExtKeyF7,
|
|
|
|
uiExtKeyF8,
|
|
|
|
uiExtKeyF9,
|
|
|
|
uiExtKeyF10,
|
|
|
|
uiExtKeyF11,
|
|
|
|
uiExtKeyF12,
|
|
|
|
uiExtKeyN0, // numpad keys; independent of Num Lock state
|
|
|
|
uiExtKeyN1, // N0..N9 are guaranteed to be consecutive
|
|
|
|
uiExtKeyN2,
|
|
|
|
uiExtKeyN3,
|
|
|
|
uiExtKeyN4,
|
|
|
|
uiExtKeyN5,
|
|
|
|
uiExtKeyN6,
|
|
|
|
uiExtKeyN7,
|
|
|
|
uiExtKeyN8,
|
|
|
|
uiExtKeyN9,
|
|
|
|
uiExtKeyNDot,
|
|
|
|
uiExtKeyNEnter,
|
|
|
|
uiExtKeyNAdd,
|
|
|
|
uiExtKeyNSubtract,
|
|
|
|
uiExtKeyNMultiply,
|
|
|
|
uiExtKeyNDivide,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct uiAreaKeyEvent {
|
|
|
|
char Key;
|
|
|
|
uiExtKey ExtKey;
|
|
|
|
uiModifiers Modifier;
|
|
|
|
|
|
|
|
uiModifiers Modifiers;
|
|
|
|
|
|
|
|
int Up;
|
|
|
|
};
|