2015-08-16 16:14:46 -05:00
|
|
|
// 6 april 2015
|
|
|
|
|
2015-08-16 22:45:15 -05:00
|
|
|
// TODO rename all uiXxxType() to uiTypeXxx()?
|
|
|
|
|
2015-08-16 16:14:46 -05:00
|
|
|
#ifndef __LIBUI_UI_H__
|
|
|
|
#define __LIBUI_UI_H__
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
2015-11-16 09:55:44 -06:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2015-12-05 17:42:28 -06:00
|
|
|
// TODO add __declspec(dllimport) on windows
|
2015-08-16 16:14:46 -05:00
|
|
|
#ifndef _UI_EXTERN
|
|
|
|
#define _UI_EXTERN extern
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct uiInitOptions uiInitOptions;
|
|
|
|
|
|
|
|
struct uiInitOptions {
|
|
|
|
size_t Size;
|
|
|
|
};
|
|
|
|
|
|
|
|
_UI_EXTERN const char *uiInit(uiInitOptions *options);
|
|
|
|
_UI_EXTERN void uiUninit(void);
|
|
|
|
_UI_EXTERN void uiFreeInitError(const char *err);
|
|
|
|
|
|
|
|
_UI_EXTERN void uiMain(void);
|
|
|
|
_UI_EXTERN void uiQuit(void);
|
|
|
|
|
2015-12-04 22:42:03 -06:00
|
|
|
// TODO write a test for this after adding multiline entries
|
|
|
|
_UI_EXTERN void uiQueueMain(void (*f)(void *data), void *data);
|
|
|
|
|
2015-08-16 16:14:46 -05:00
|
|
|
_UI_EXTERN void uiOnShouldQuit(int (*f)(void *data), void *data);
|
|
|
|
|
|
|
|
_UI_EXTERN void uiFreeText(char *text);
|
|
|
|
|
|
|
|
_UI_EXTERN uintmax_t uiRegisterType(const char *name, uintmax_t parent, size_t size);
|
|
|
|
_UI_EXTERN void *uiIsA(void *p, uintmax_t type, int fail);
|
|
|
|
typedef struct uiTyped uiTyped;
|
|
|
|
struct uiTyped {
|
|
|
|
uintmax_t Type;
|
|
|
|
};
|
|
|
|
#define uiTyped(this) ((uiTyped *) (this))
|
|
|
|
|
|
|
|
/* TODO only on the windows backend now
|
|
|
|
typedef struct uiSizing uiSizing;
|
|
|
|
typedef struct uiSizingSys uiSizingSys;
|
|
|
|
|
|
|
|
struct Sizing {
|
|
|
|
field XPadding intmax_t;
|
|
|
|
field YPadding intmax_t;
|
|
|
|
field Sys *uiSizingSys;
|
|
|
|
};
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct uiControl uiControl;
|
|
|
|
|
|
|
|
struct uiControl {
|
2015-08-16 19:56:39 -05:00
|
|
|
uiTyped t;
|
2015-08-16 16:14:46 -05:00
|
|
|
void *Internal; // for use by libui only
|
|
|
|
void (*CommitDestroy)(uiControl *);
|
|
|
|
uintptr_t (*Handle)(uiControl *);
|
2015-08-25 19:31:43 -05:00
|
|
|
void (*CommitShow)(uiControl *);
|
|
|
|
void (*CommitHide)(uiControl *);
|
2015-08-16 21:19:15 -05:00
|
|
|
void (*ContainerUpdateState)(uiControl *);
|
2015-08-16 16:14:46 -05:00
|
|
|
};
|
|
|
|
_UI_EXTERN uintmax_t uiControlType(void);
|
|
|
|
#define uiControl(this) ((uiControl *) uiIsA((this), uiControlType(), 1))
|
2015-08-16 21:19:15 -05:00
|
|
|
_UI_EXTERN void uiControlDestroy(uiControl *);
|
2015-08-16 22:16:42 -05:00
|
|
|
_UI_EXTERN uintptr_t uiControlHandle(uiControl *);
|
2015-08-17 18:11:35 -05:00
|
|
|
_UI_EXTERN uiControl *uiControlParent(uiControl *);
|
2015-08-16 21:19:15 -05:00
|
|
|
_UI_EXTERN void uiControlSetParent(uiControl *, uiControl *);
|
|
|
|
_UI_EXTERN void uiControlShow(uiControl *);
|
|
|
|
_UI_EXTERN void uiControlHide(uiControl *);
|
|
|
|
_UI_EXTERN void uiControlEnable(uiControl *);
|
|
|
|
_UI_EXTERN void uiControlDisable(uiControl *);
|
2015-08-16 22:20:53 -05:00
|
|
|
_UI_EXTERN uiControl *uiNewControl(uintmax_t type);
|
2015-08-16 16:14:46 -05:00
|
|
|
|
|
|
|
/* TODO
|
|
|
|
func NewControl(type uintmax_t) *Control;
|
|
|
|
|
|
|
|
raw "#define uiDefineControlType(typename, funcname, realtype) \\";
|
|
|
|
raw " static uintmax_t type_ ## typename = 0; \\";
|
|
|
|
raw " uintmax_t funcname(void) \\";
|
|
|
|
raw " { \\";
|
|
|
|
raw " if (type_ ## typename == 0) \\";
|
|
|
|
raw " type_ ## typename = uiRegisterType(#typename, uiTypeControl(), sizeof (realtype)); \\";
|
|
|
|
raw " return type_ ## typename; \\";
|
|
|
|
raw " }";
|
|
|
|
|
|
|
|
func FreeSizing(d *Sizing);
|
|
|
|
|
|
|
|
func MakeContainer(c *Control) uintptr_t;
|
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct uiWindow uiWindow;
|
|
|
|
_UI_EXTERN uintmax_t uiWindowType(void);
|
|
|
|
#define uiWindow(this) ((uiWindow *) uiIsA((this), uiWindowType(), 1))
|
|
|
|
_UI_EXTERN char *uiWindowTitle(uiWindow *w);
|
|
|
|
_UI_EXTERN void uiWindowSetTitle(uiWindow *w, const char *title);
|
|
|
|
_UI_EXTERN void uiWindowOnClosing(uiWindow *w, int (*f)(uiWindow *w, void *data), void *data);
|
|
|
|
_UI_EXTERN void uiWindowSetChild(uiWindow *w, uiControl *child);
|
|
|
|
_UI_EXTERN int uiWindowMargined(uiWindow *w);
|
|
|
|
_UI_EXTERN void uiWindowSetMargined(uiWindow *w, int margined);
|
|
|
|
_UI_EXTERN uiWindow *uiNewWindow(const char *title, int width, int height, int hasMenubar);
|
|
|
|
|
|
|
|
typedef struct uiButton uiButton;
|
|
|
|
_UI_EXTERN uintmax_t uiButtonType(void);
|
|
|
|
#define uiButton(this) ((uiButton *) uiIsA((this), uiButtonType(), 1))
|
|
|
|
_UI_EXTERN char *uiButtonText(uiButton *b);
|
|
|
|
_UI_EXTERN void uiButtonSetText(uiButton *b, const char *text);
|
|
|
|
_UI_EXTERN void uiButtonOnClicked(uiButton *b, void (*f)(uiButton *b, void *data), void *data);
|
|
|
|
_UI_EXTERN uiButton *uiNewButton(const char *text);
|
|
|
|
|
|
|
|
typedef struct uiBox uiBox;
|
|
|
|
_UI_EXTERN uintmax_t uiBoxType(void);
|
|
|
|
#define uiBox(this) ((uiBox *) uiIsA((this), uiBoxType(), 1))
|
|
|
|
_UI_EXTERN void uiBoxAppend(uiBox *b, uiControl *child, int stretchy);
|
|
|
|
_UI_EXTERN void uiBoxDelete(uiBox *b, uintmax_t index);
|
|
|
|
_UI_EXTERN int uiBoxPadded(uiBox *b);
|
|
|
|
_UI_EXTERN void uiBoxSetPadded(uiBox *b, int padded);
|
|
|
|
_UI_EXTERN uiBox *uiNewHorizontalBox(void);
|
|
|
|
_UI_EXTERN uiBox *uiNewVerticalBox(void);
|
|
|
|
|
|
|
|
typedef struct uiEntry uiEntry;
|
|
|
|
_UI_EXTERN uintmax_t uiEntryType(void);
|
|
|
|
#define uiEntry(this) ((uiEntry *) uiIsA((this), uiEntryType(), 1))
|
|
|
|
_UI_EXTERN char *uiEntryText(uiEntry *e);
|
|
|
|
_UI_EXTERN void uiEntrySetText(uiEntry *e, const char *text);
|
|
|
|
_UI_EXTERN void uiEntryOnChanged(uiEntry *e, void (*f)(uiEntry *e, void *data), void *data);
|
|
|
|
_UI_EXTERN int uiEntryReadOnly(uiEntry *e);
|
|
|
|
_UI_EXTERN void uiEntrySetReadOnly(uiEntry *e, int readonly);
|
|
|
|
_UI_EXTERN uiEntry *uiNewEntry(void);
|
|
|
|
|
|
|
|
typedef struct uiCheckbox uiCheckbox;
|
|
|
|
_UI_EXTERN uintmax_t uiCheckboxType(void);
|
|
|
|
#define uiCheckbox(this) ((uiCheckbox *) uiIsA((this), uiCheckboxType(), 1))
|
|
|
|
_UI_EXTERN char *uiCheckboxText(uiCheckbox *c);
|
|
|
|
_UI_EXTERN void uiCheckboxSetText(uiCheckbox *c, const char *text);
|
|
|
|
_UI_EXTERN void uiCheckboxOnToggled(uiCheckbox *c, void (*f)(uiCheckbox *c, void *data), void *data);
|
|
|
|
_UI_EXTERN int uiCheckboxChecked(uiCheckbox *c);
|
|
|
|
_UI_EXTERN void uiCheckboxSetChecked(uiCheckbox *c, int checked);
|
|
|
|
_UI_EXTERN uiCheckbox *uiNewCheckbox(const char *text);
|
|
|
|
|
|
|
|
typedef struct uiLabel uiLabel;
|
|
|
|
_UI_EXTERN uintmax_t uiLabelType(void);
|
|
|
|
#define uiLabel(this) ((uiLabel *) uiIsA((this), uiLabelType(), 1))
|
|
|
|
_UI_EXTERN char *uiLabelText(uiLabel *l);
|
|
|
|
_UI_EXTERN void uiLabelSetText(uiLabel *l, const char *text);
|
2015-08-16 22:08:00 -05:00
|
|
|
_UI_EXTERN uiLabel *uiNewLabel(const char *text);
|
2015-08-16 16:14:46 -05:00
|
|
|
|
|
|
|
typedef struct uiTab uiTab;
|
|
|
|
_UI_EXTERN uintmax_t uiTabType(void);
|
|
|
|
#define uiTab(this) ((uiTab *) uiIsA((this), uiTabType(), 1))
|
2015-08-16 22:08:00 -05:00
|
|
|
_UI_EXTERN void uiTabAppend(uiTab *t, const char *name, uiControl *c);
|
2015-08-16 16:14:46 -05:00
|
|
|
_UI_EXTERN void uiTabInsertAt(uiTab *t, const char *name, uintmax_t before, uiControl *c);
|
|
|
|
_UI_EXTERN void uiTabDelete(uiTab *t, uintmax_t index);
|
|
|
|
_UI_EXTERN uintmax_t uiTabNumPages(uiTab *t);
|
|
|
|
_UI_EXTERN int uiTabMargined(uiTab *t, uintmax_t page);
|
|
|
|
_UI_EXTERN void uiTabSetMargined(uiTab *t, uintmax_t page, int margined);
|
|
|
|
_UI_EXTERN uiTab *uiNewTab(void);
|
|
|
|
|
|
|
|
typedef struct uiGroup uiGroup;
|
|
|
|
_UI_EXTERN uintmax_t uiGroupType(void);
|
|
|
|
#define uiGroup(this) ((uiGroup *) uiIsA((this), uiGroupType(), 1))
|
|
|
|
_UI_EXTERN char *uiGroupTitle(uiGroup *g);
|
|
|
|
_UI_EXTERN void uiGroupSetTitle(uiGroup *g, const char *title);
|
|
|
|
_UI_EXTERN void uiGroupSetChild(uiGroup *g, uiControl *c);
|
|
|
|
_UI_EXTERN int uiGroupMargined(uiGroup *g);
|
|
|
|
_UI_EXTERN void uiGroupSetMargined(uiGroup *g, int margined);
|
|
|
|
_UI_EXTERN uiGroup *uiNewGroup(const char *title);
|
|
|
|
|
|
|
|
// spinbox/slider rules:
|
|
|
|
// setting value outside of range will automatically clamp
|
|
|
|
// initial value is minimum
|
|
|
|
// complaint if min >= max?
|
|
|
|
|
|
|
|
typedef struct uiSpinbox uiSpinbox;
|
|
|
|
_UI_EXTERN uintmax_t uiSpinboxType(void);
|
|
|
|
#define uiSpinbox(this) ((uiSpinbox *) uiIsA((this), uiSpinboxType(), 1))
|
2015-08-16 22:08:00 -05:00
|
|
|
_UI_EXTERN intmax_t uiSpinboxValue(uiSpinbox *s);
|
2015-08-16 16:14:46 -05:00
|
|
|
_UI_EXTERN void uiSpinboxSetValue(uiSpinbox *s, intmax_t value);
|
|
|
|
_UI_EXTERN void uiSpinboxOnChanged(uiSpinbox *s, void (*f)(uiSpinbox *s, void *data), void *data);
|
|
|
|
_UI_EXTERN uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max);
|
|
|
|
|
|
|
|
typedef struct uiProgressBar uiProgressBar;
|
|
|
|
_UI_EXTERN uintmax_t uiProgressBarType(void);
|
|
|
|
#define uiProgressBar(this) ((uiProgressBar *) uiIsA((this), uiProgressBarType(), 1))
|
|
|
|
// TODO uiProgressBarValue()
|
2015-08-16 22:08:00 -05:00
|
|
|
_UI_EXTERN void uiProgressBarSetValue(uiProgressBar *p, int n);
|
2015-08-16 16:14:46 -05:00
|
|
|
_UI_EXTERN uiProgressBar *uiNewProgressBar(void);
|
|
|
|
|
|
|
|
typedef struct uiSlider uiSlider;
|
|
|
|
_UI_EXTERN uintmax_t uiSliderType(void);
|
|
|
|
#define uiSlider(this) ((uiSlider *) uiIsA((this), uiSliderType(), 1))
|
2015-08-16 22:08:00 -05:00
|
|
|
_UI_EXTERN intmax_t uiSliderValue(uiSlider *s);
|
2015-08-16 16:14:46 -05:00
|
|
|
_UI_EXTERN void uiSliderSetValue(uiSlider *s, intmax_t value);
|
|
|
|
_UI_EXTERN void uiSliderOnChanged(uiSlider *s, void (*f)(uiSlider *s, void *data), void *data);
|
|
|
|
_UI_EXTERN uiSlider *uiNewSlider(intmax_t min, intmax_t max);
|
|
|
|
|
|
|
|
typedef struct uiSeparator uiSeparator;
|
|
|
|
_UI_EXTERN uintmax_t uiSeparatorType(void);
|
|
|
|
#define uiSeparator(this) ((uiSeparator *) uiIsA((this), uiSeparatorType(), 1))
|
2015-08-16 22:44:23 -05:00
|
|
|
_UI_EXTERN uiSeparator *uiNewHorizontalSeparator(void);
|
2015-08-16 16:14:46 -05:00
|
|
|
|
|
|
|
typedef struct uiCombobox uiCombobox;
|
|
|
|
_UI_EXTERN uintmax_t uiComboboxType(void);
|
|
|
|
#define uiCombobox(this) ((uiCombobox *) uiIsA((this), uiComboboxType(), 1))
|
|
|
|
_UI_EXTERN void uiComboboxAppend(uiCombobox *c, const char *text);
|
2015-10-08 13:23:04 -05:00
|
|
|
_UI_EXTERN intmax_t uiComboboxSelected(uiCombobox *c);
|
2015-10-09 12:47:02 -05:00
|
|
|
_UI_EXTERN void uiComboboxSetSelected(uiCombobox *c, intmax_t n);
|
2015-10-08 13:23:04 -05:00
|
|
|
_UI_EXTERN void uiComboboxOnSelected(uiCombobox *c, void (*f)(uiCombobox *c, void *data), void *data);
|
2015-08-16 16:14:46 -05:00
|
|
|
_UI_EXTERN uiCombobox *uiNewCombobox(void);
|
|
|
|
_UI_EXTERN uiCombobox *uiNewEditableCombobox(void);
|
|
|
|
|
|
|
|
typedef struct uiRadioButtons uiRadioButtons;
|
|
|
|
_UI_EXTERN uintmax_t uiRadioButtonsType(void);
|
|
|
|
#define uiRadioButtons(this) ((uiRadioButtons *) uiIsA((this), uiRadioButtonsType(), 1))
|
|
|
|
_UI_EXTERN void uiRadioButtonsAppend(uiRadioButtons *r, const char *text);
|
|
|
|
_UI_EXTERN uiRadioButtons *uiNewRadioButtons(void);
|
|
|
|
|
|
|
|
typedef struct uiDateTimePicker uiDateTimePicker;
|
|
|
|
_UI_EXTERN uintmax_t uiDateTimePickerType(void);
|
|
|
|
#define uiDateTimePicker(this) ((uiDateTimePicker *) uiIsA((this), uiDateTimePickerType(), 1))
|
|
|
|
_UI_EXTERN uiDateTimePicker *uiNewDateTimePicker(void);
|
|
|
|
_UI_EXTERN uiDateTimePicker *uiNewDatePicker(void);
|
|
|
|
_UI_EXTERN uiDateTimePicker *uiNewTimePicker(void);
|
|
|
|
|
2015-12-06 00:18:32 -06:00
|
|
|
// TODO merge with uiEntry? some things can't be shared (for instance, the future Invalid()
|
|
|
|
// TODO how are line endings converted?
|
|
|
|
// TODO provide a facility for allowing horizontal scrolling
|
|
|
|
// TODO provide a facility for entering tab stops?
|
|
|
|
typedef struct uiMultilineEntry uiMultilineEntry;
|
|
|
|
_UI_EXTERN uintmax_t uiMultilineEntryType(void);
|
|
|
|
#define uiMultilineEntry(this) ((uiMultilineEntry *) uiIsA((this), uiMultilineEntryType(), 1))
|
|
|
|
_UI_EXTERN char *uiMultilineEntryText(uiMultilineEntry *e);
|
|
|
|
_UI_EXTERN void uiMultilineEntrySetText(uiMultilineEntry *e, const char *text);
|
|
|
|
_UI_EXTERN void uiMultilineEntryAppend(uiMultilineEntry *e, const char *text);
|
|
|
|
_UI_EXTERN void uiMultilineEntryOnChanged(uiMultilineEntry *e, void (*f)(uiMultilineEntry *e, void *data), void *data);
|
|
|
|
_UI_EXTERN int uiMultilineEntryReadOnly(uiMultilineEntry *e);
|
|
|
|
_UI_EXTERN void uiMultilineEntrySetReadOnly(uiMultilineEntry *e, int readonly);
|
|
|
|
_UI_EXTERN uiMultilineEntry *uiNewMultilineEntry(void);
|
|
|
|
|
2015-08-16 16:14:46 -05:00
|
|
|
typedef struct uiMenu uiMenu;
|
|
|
|
typedef struct uiMenuItem uiMenuItem;
|
|
|
|
_UI_EXTERN uintmax_t uiMenuType(void);
|
|
|
|
#define uiMenu(this) ((uiMenu *) uiIsA((this), uiMenuType(), 1))
|
2015-08-16 22:44:23 -05:00
|
|
|
_UI_EXTERN uiMenuItem *uiMenuAppendItem(uiMenu *m, const char *name);
|
2015-08-16 16:14:46 -05:00
|
|
|
_UI_EXTERN uiMenuItem *uiMenuAppendCheckItem(uiMenu *m, const char *name);
|
|
|
|
_UI_EXTERN uiMenuItem *uiMenuAppendQuitItem(uiMenu *m);
|
|
|
|
_UI_EXTERN uiMenuItem *uiMenuAppendPreferencesItem(uiMenu *m);
|
|
|
|
_UI_EXTERN uiMenuItem *uiMenuAppendAboutItem(uiMenu *m);
|
|
|
|
_UI_EXTERN void uiMenuAppendSeparator(uiMenu *m);
|
|
|
|
_UI_EXTERN uiMenu *uiNewMenu(const char *name);
|
|
|
|
|
|
|
|
_UI_EXTERN uintmax_t uiMenuItemType(void);
|
|
|
|
#define uiMenuItem(this) ((uiMenuItem *) uiIsA((this), uiMenuItemType(), 1))
|
|
|
|
_UI_EXTERN void uiMenuItemEnable(uiMenuItem *m);
|
|
|
|
_UI_EXTERN void uiMenuItemDisable(uiMenuItem *m);
|
|
|
|
_UI_EXTERN void uiMenuItemOnClicked(uiMenuItem *m, void (*f)(uiMenuItem *sender, uiWindow *window, void *data), void *data);
|
|
|
|
_UI_EXTERN int uiMenuItemChecked(uiMenuItem *m);
|
|
|
|
_UI_EXTERN void uiMenuItemSetChecked(uiMenuItem *m, int checked);
|
|
|
|
|
2015-11-27 22:23:54 -06:00
|
|
|
_UI_EXTERN char *uiOpenFile(uiWindow *parent);
|
|
|
|
_UI_EXTERN char *uiSaveFile(uiWindow *parent);
|
|
|
|
_UI_EXTERN void uiMsgBox(uiWindow *parent, const char *title, const char *description);
|
|
|
|
_UI_EXTERN void uiMsgBoxError(uiWindow *parent, const char *title, const char *description);
|
2015-08-16 16:14:46 -05:00
|
|
|
|
2015-10-08 17:03:24 -05:00
|
|
|
typedef struct uiArea uiArea;
|
|
|
|
typedef struct uiAreaHandler uiAreaHandler;
|
|
|
|
typedef struct uiAreaDrawParams uiAreaDrawParams;
|
|
|
|
typedef struct uiAreaMouseEvent uiAreaMouseEvent;
|
|
|
|
typedef struct uiAreaKeyEvent uiAreaKeyEvent;
|
|
|
|
|
|
|
|
typedef struct uiDrawContext uiDrawContext;
|
|
|
|
|
|
|
|
struct uiAreaHandler {
|
|
|
|
void (*Draw)(uiAreaHandler *, uiArea *, uiAreaDrawParams *);
|
2015-12-17 12:50:07 -06:00
|
|
|
// TODO document that resizes cause a full redraw for non-scrolling areas; implementation-defined for scrolling areas
|
2015-10-08 17:03:24 -05:00
|
|
|
void (*MouseEvent)(uiAreaHandler *, uiArea *, uiAreaMouseEvent *);
|
2015-12-17 12:50:07 -06:00
|
|
|
// TODO document that on first show if the mouse is already in the uiArea then one gets sent with left=0
|
|
|
|
// TODO what about when the area is hidden and then shown again?
|
2015-12-17 13:20:17 -06:00
|
|
|
void (*MouseCrossed)(uiAreaHandler *, uiArea *, int left);
|
2015-10-08 17:03:24 -05:00
|
|
|
void (*DragBroken)(uiAreaHandler *, uiArea *);
|
|
|
|
int (*KeyEvent)(uiAreaHandler *, uiArea *, uiAreaKeyEvent *);
|
|
|
|
};
|
|
|
|
|
|
|
|
_UI_EXTERN uintmax_t uiMenuItemType(void);
|
2015-10-08 17:24:09 -05:00
|
|
|
#define uiArea(this) ((uiArea *) uiIsA((this), uiAreaType(), 1))
|
2015-12-17 12:50:07 -06:00
|
|
|
// TODO give a better name
|
2015-12-17 18:16:30 -06:00
|
|
|
// TODO document the types of width and height
|
2015-12-17 12:50:07 -06:00
|
|
|
_UI_EXTERN void uiAreaSetSize(uiArea *a, intmax_t width, intmax_t height);
|
2015-10-09 14:27:57 -05:00
|
|
|
// TODO uiAreaQueueRedraw()
|
|
|
|
_UI_EXTERN void uiAreaQueueRedrawAll(uiArea *a);
|
2015-10-08 17:03:24 -05:00
|
|
|
_UI_EXTERN uiArea *uiNewArea(uiAreaHandler *ah);
|
2015-12-17 12:50:07 -06:00
|
|
|
_UI_EXTERN uiArea *uiNewScrollingArea(uiAreaHandler *ah, intmax_t width, intmax_t height);
|
2015-10-08 17:03:24 -05:00
|
|
|
|
|
|
|
struct uiAreaDrawParams {
|
|
|
|
uiDrawContext *Context;
|
|
|
|
|
2015-12-17 12:50:07 -06:00
|
|
|
// TODO document that this is only defined for nonscrolling areas
|
2015-12-17 12:54:54 -06:00
|
|
|
double AreaWidth;
|
|
|
|
double AreaHeight;
|
2015-10-08 17:03:24 -05:00
|
|
|
|
2015-10-14 07:49:06 -05:00
|
|
|
// TODO keep this?
|
2015-12-17 12:54:54 -06:00
|
|
|
double ClipX;
|
|
|
|
double ClipY;
|
|
|
|
double ClipWidth;
|
|
|
|
double ClipHeight;
|
2015-10-08 17:03:24 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct uiDrawPath uiDrawPath;
|
|
|
|
typedef struct uiDrawBrush uiDrawBrush;
|
|
|
|
typedef struct uiDrawStrokeParams uiDrawStrokeParams;
|
2015-10-11 10:13:01 -05:00
|
|
|
typedef struct uiDrawMatrix uiDrawMatrix;
|
2015-10-08 17:03:24 -05:00
|
|
|
|
|
|
|
typedef struct uiDrawBrushGradientStop uiDrawBrushGradientStop;
|
|
|
|
|
2015-11-17 19:01:01 -06:00
|
|
|
// ISO C forbids us from forward declaring enums >:(
|
|
|
|
typedef enum uiDrawBrushType {
|
2015-10-08 17:03:24 -05:00
|
|
|
uiDrawBrushTypeSolid,
|
|
|
|
uiDrawBrushTypeLinearGradient,
|
|
|
|
uiDrawBrushTypeRadialGradient,
|
|
|
|
uiDrawBrushTypeImage,
|
2015-11-17 19:01:01 -06:00
|
|
|
} uiDrawBrushType;
|
2015-10-08 17:03:24 -05:00
|
|
|
|
2015-11-17 19:01:01 -06:00
|
|
|
typedef enum uiDrawLineCap {
|
2015-10-08 17:03:24 -05:00
|
|
|
uiDrawLineCapFlat,
|
|
|
|
uiDrawLineCapRound,
|
|
|
|
uiDrawLineCapSquare,
|
2015-11-17 19:01:01 -06:00
|
|
|
} uiDrawLineCap;
|
2015-10-08 17:03:24 -05:00
|
|
|
|
2015-11-17 19:01:01 -06:00
|
|
|
typedef enum uiDrawLineJoin {
|
2015-10-08 17:03:24 -05:00
|
|
|
uiDrawLineJoinMiter,
|
|
|
|
uiDrawLineJoinRound,
|
|
|
|
uiDrawLineJoinBevel,
|
2015-11-17 19:01:01 -06:00
|
|
|
} uiDrawLineJoin;
|
2015-10-08 17:03:24 -05:00
|
|
|
|
2015-10-10 12:01:48 -05:00
|
|
|
// this is the default for botoh cairo and Direct2D (in the latter case, from the C++ helper functions)
|
2015-10-08 17:03:24 -05:00
|
|
|
// 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
|
|
|
|
|
2015-11-17 19:01:01 -06:00
|
|
|
typedef enum uiDrawFillMode {
|
2015-10-08 17:03:24 -05:00
|
|
|
uiDrawFillModeWinding,
|
|
|
|
uiDrawFillModeAlternate,
|
2015-11-17 19:01:01 -06:00
|
|
|
} uiDrawFillMode;
|
2015-10-08 17:03:24 -05:00
|
|
|
|
2015-10-11 10:13:01 -05:00
|
|
|
struct uiDrawMatrix {
|
|
|
|
double M11;
|
|
|
|
double M12;
|
|
|
|
double M21;
|
|
|
|
double M22;
|
|
|
|
double M31;
|
|
|
|
double M32;
|
|
|
|
};
|
|
|
|
|
2015-10-08 17:03:24 -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;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct uiDrawStrokeParams {
|
|
|
|
uiDrawLineCap Cap;
|
|
|
|
uiDrawLineJoin Join;
|
2015-10-16 09:46:26 -05:00
|
|
|
// TODO what if this is 0? on windows there will be a crash with dashing
|
2015-10-08 17:03:24 -05:00
|
|
|
double Thickness;
|
|
|
|
double MiterLimit;
|
2015-10-16 09:09:41 -05:00
|
|
|
double *Dashes;
|
|
|
|
// TOOD what if this is 1 on Direct2D?
|
|
|
|
// TODO what if a dash is 0 on Cairo or Quartz?
|
|
|
|
size_t NumDashes;
|
|
|
|
double DashPhase;
|
2015-10-08 17:03:24 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
_UI_EXTERN uiDrawPath *uiDrawNewPath(uiDrawFillMode fillMode);
|
|
|
|
_UI_EXTERN void uiDrawFreePath(uiDrawPath *p);
|
|
|
|
|
|
|
|
_UI_EXTERN void uiDrawPathNewFigure(uiDrawPath *p, double x, double y);
|
2015-10-11 20:15:08 -05:00
|
|
|
_UI_EXTERN void uiDrawPathNewFigureWithArc(uiDrawPath *p, double xCenter, double yCenter, double radius, double startAngle, double sweep, int negative);
|
2015-10-08 17:03:24 -05:00
|
|
|
_UI_EXTERN void uiDrawPathLineTo(uiDrawPath *p, double x, double y);
|
|
|
|
// notes: angles are both relative to 0 and go counterclockwise
|
|
|
|
// TODO is the initial line segment on cairo and OS X a proper join?
|
2015-10-09 22:19:21 -05:00
|
|
|
// TODO what if sweep < 0?
|
2015-10-11 20:15:08 -05:00
|
|
|
_UI_EXTERN void uiDrawPathArcTo(uiDrawPath *p, double xCenter, double yCenter, double radius, double startAngle, double sweep, int negative);
|
2015-10-08 17:03:24 -05:00
|
|
|
_UI_EXTERN void uiDrawPathBezierTo(uiDrawPath *p, double c1x, double c1y, double c2x, double c2y, double endX, double endY);
|
|
|
|
// TODO quadratic bezier
|
|
|
|
_UI_EXTERN void uiDrawPathCloseFigure(uiDrawPath *p);
|
|
|
|
|
|
|
|
// TODO effect of these when a figure is already started
|
|
|
|
_UI_EXTERN void uiDrawPathAddRectangle(uiDrawPath *p, double x, double y, double width, double height);
|
|
|
|
|
|
|
|
_UI_EXTERN void uiDrawPathEnd(uiDrawPath *p);
|
|
|
|
|
|
|
|
_UI_EXTERN void uiDrawStroke(uiDrawContext *c, uiDrawPath *path, uiDrawBrush *b, uiDrawStrokeParams *p);
|
|
|
|
_UI_EXTERN void uiDrawFill(uiDrawContext *c, uiDrawPath *path, uiDrawBrush *b);
|
|
|
|
|
|
|
|
// TODO primitives:
|
|
|
|
// - rounded rectangles
|
|
|
|
// - elliptical arcs
|
|
|
|
// - quadratic bezier curves
|
|
|
|
|
2015-10-11 10:13:01 -05:00
|
|
|
_UI_EXTERN void uiDrawMatrixSetIdentity(uiDrawMatrix *m);
|
|
|
|
_UI_EXTERN void uiDrawMatrixTranslate(uiDrawMatrix *m, double x, double y);
|
2015-10-12 00:43:12 -05:00
|
|
|
_UI_EXTERN void uiDrawMatrixScale(uiDrawMatrix *m, double xCenter, double yCenter, double x, double y);
|
2015-10-11 10:13:01 -05:00
|
|
|
_UI_EXTERN void uiDrawMatrixRotate(uiDrawMatrix *m, double x, double y, double amount);
|
2015-10-11 11:36:48 -05:00
|
|
|
_UI_EXTERN void uiDrawMatrixSkew(uiDrawMatrix *m, double x, double y, double xamount, double yamount);
|
2015-10-11 10:13:01 -05:00
|
|
|
_UI_EXTERN void uiDrawMatrixMultiply(uiDrawMatrix *dest, uiDrawMatrix *src);
|
|
|
|
_UI_EXTERN int uiDrawMatrixInvertible(uiDrawMatrix *m);
|
|
|
|
_UI_EXTERN int uiDrawMatrixInvert(uiDrawMatrix *m);
|
|
|
|
_UI_EXTERN void uiDrawMatrixTransformPoint(uiDrawMatrix *m, double *x, double *y);
|
|
|
|
_UI_EXTERN void uiDrawMatrixTransformSize(uiDrawMatrix *m, double *x, double *y);
|
|
|
|
|
2015-10-12 20:11:42 -05:00
|
|
|
_UI_EXTERN void uiDrawTransform(uiDrawContext *c, uiDrawMatrix *m);
|
|
|
|
|
2015-10-13 10:16:06 -05:00
|
|
|
// TODO add a uiDrawPathStrokeToFill() or something like that
|
|
|
|
_UI_EXTERN void uiDrawClip(uiDrawContext *c, uiDrawPath *path);
|
2015-10-12 20:11:42 -05:00
|
|
|
|
2015-10-11 10:13:01 -05:00
|
|
|
_UI_EXTERN void uiDrawSave(uiDrawContext *c);
|
|
|
|
_UI_EXTERN void uiDrawRestore(uiDrawContext *c);
|
|
|
|
|
2015-12-22 18:01:56 -06:00
|
|
|
typedef struct uiDrawFontFamilies uiDrawFontFamilies;
|
|
|
|
|
|
|
|
_UI_EXTERN uiDrawFontFamilies *uiDrawListFontFamilies(void);
|
|
|
|
_UI_EXTERN uintmax_t uiDrawFontFamiliesNumFamilies(uiDrawFontFamilies *ff);
|
|
|
|
_UI_EXTERN char *uiDrawFontFamiliesFamily(uiDrawFontFamilies *ff, uintmax_t n);
|
2015-12-22 18:17:27 -06:00
|
|
|
_UI_EXTERN void uiDrawFreeFontFamilies(uiDrawFontFamilies *ff);
|
2015-12-22 18:01:56 -06:00
|
|
|
|
2015-12-24 17:05:16 -06:00
|
|
|
typedef struct uiDrawTextStyle uiDrawTextStyle;
|
|
|
|
|
|
|
|
typedef enum uiDrawTextWeight {
|
|
|
|
uiDrawTextWeightThin,
|
|
|
|
uiDrawTextWeightUltraLight,
|
|
|
|
uiDrawTextWeightLight,
|
|
|
|
uiDrawTextWeightBook,
|
|
|
|
uiDrawTextWeightNormal,
|
|
|
|
uiDrawTextWeightMedium,
|
|
|
|
uiDrawTextWeightSemiBold,
|
|
|
|
uiDrawTextWeightBold,
|
|
|
|
uiDrawTextWeightUtraBold,
|
|
|
|
uiDrawTextWeightHeavy,
|
|
|
|
uiDrawTextWeightUltraHeavy,
|
|
|
|
} uiDrawTextWeight;
|
|
|
|
|
|
|
|
// TODO drop Oblique?
|
|
|
|
typedef enum uiDrawTextItalic {
|
|
|
|
uiDrawTextItalicNormal,
|
|
|
|
uiDrawTextItalicOblique,
|
|
|
|
uiDrawTextItalicItalic,
|
|
|
|
} uiDrawTextItalic;
|
|
|
|
|
|
|
|
typedef enum uiDrawTextStretch {
|
|
|
|
uiDrawTextStretchUltraCondensed,
|
|
|
|
uiDrawTextStretchExtraCondensed,
|
|
|
|
uiDrawTextStretchCondensed,
|
|
|
|
uiDrawTextStretchSemiCondensed,
|
|
|
|
uiDrawTextStretchNormal,
|
|
|
|
uiDrawTextStretchSemiExpanded,
|
|
|
|
uiDrawTextStretchExpanded,
|
|
|
|
uiDrawTextStretchExtraExpanded,
|
|
|
|
uiDrawTextStretchUltraExpanded,
|
|
|
|
} uiDrawTextStretch;
|
|
|
|
|
|
|
|
struct uiDrawTextStyle {
|
2015-12-24 18:48:57 -06:00
|
|
|
// TODO Language attribute
|
2015-12-24 17:05:16 -06:00
|
|
|
const char *Family;
|
|
|
|
double Size;
|
|
|
|
uiDrawTextWeight Weight;
|
|
|
|
uiDrawTextItalic Italic;
|
|
|
|
int SmallCaps;
|
|
|
|
uiDrawTextStretch Stretch;
|
|
|
|
double TextR;
|
|
|
|
double TextG;
|
|
|
|
double TextB;
|
|
|
|
double TextA;
|
2015-12-24 18:48:57 -06:00
|
|
|
int HasBackground;
|
2015-12-24 17:05:16 -06:00
|
|
|
double BackgroundR;
|
|
|
|
double BackgroundG;
|
2015-12-24 18:48:57 -06:00
|
|
|
double BackgroundB;
|
2015-12-24 17:05:16 -06:00
|
|
|
double BackgroundA; // TODO Pango
|
|
|
|
int HasStrikethrough;
|
|
|
|
double StrikethroughR;
|
|
|
|
double StrikethroughG;
|
|
|
|
double StrikethroughB;
|
|
|
|
double StrikethroughA; // TODO Pango
|
|
|
|
int HasUnderline;
|
|
|
|
double UnderlineR;
|
|
|
|
double UnderlineG;
|
|
|
|
double UnderlineB;
|
|
|
|
double UnderlineA; // TODO Pango
|
2015-12-24 18:48:57 -06:00
|
|
|
// TODO other Pango attributes
|
2015-12-24 17:05:16 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
_UI_EXTERN double uiDrawTextSizeToPoints(double textSize);
|
|
|
|
_UI_EXTERN double uiDrawPointsToTextSize(double points);
|
|
|
|
|
|
|
|
// TODO make this more robust.
|
2015-12-24 18:48:57 -06:00
|
|
|
_UI_EXTERN void uiDrawText(uiDrawContext *c, double x, double y, const char *text, uiDrawTextStyle *style);
|
2015-12-24 17:05:16 -06:00
|
|
|
|
2015-11-17 19:01:01 -06:00
|
|
|
typedef enum uiModifiers {
|
2015-10-08 17:03:24 -05:00
|
|
|
uiModifierCtrl = 1 << 0,
|
|
|
|
uiModifierAlt = 1 << 1,
|
|
|
|
uiModifierShift = 1 << 2,
|
|
|
|
uiModifierSuper = 1 << 3,
|
2015-11-17 19:01:01 -06:00
|
|
|
} uiModifiers;
|
2015-10-08 17:03:24 -05:00
|
|
|
|
2015-12-17 12:54:54 -06:00
|
|
|
// TODO document drag captures
|
2015-10-08 17:03:24 -05:00
|
|
|
struct uiAreaMouseEvent {
|
2015-12-17 12:54:54 -06:00
|
|
|
// TODO document what these mean for scrolling areas
|
2015-10-14 07:49:06 -05:00
|
|
|
double X;
|
|
|
|
double Y;
|
2015-10-08 17:03:24 -05:00
|
|
|
|
2015-12-17 12:54:54 -06:00
|
|
|
// TODO see draw above
|
|
|
|
double AreaWidth;
|
|
|
|
double AreaHeight;
|
2015-10-08 17:03:24 -05:00
|
|
|
|
|
|
|
uintmax_t Down;
|
|
|
|
uintmax_t Up;
|
|
|
|
|
|
|
|
uintmax_t Count;
|
|
|
|
|
|
|
|
uiModifiers Modifiers;
|
|
|
|
|
|
|
|
uint64_t Held1To64;
|
|
|
|
};
|
|
|
|
|
2015-11-17 19:01:01 -06:00
|
|
|
typedef enum uiExtKey {
|
2015-10-08 17:03:24 -05:00
|
|
|
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,
|
2015-11-17 19:01:01 -06:00
|
|
|
} uiExtKey;
|
2015-10-08 17:03:24 -05:00
|
|
|
|
|
|
|
struct uiAreaKeyEvent {
|
|
|
|
char Key;
|
|
|
|
uiExtKey ExtKey;
|
|
|
|
uiModifiers Modifier;
|
|
|
|
|
|
|
|
uiModifiers Modifiers;
|
|
|
|
|
|
|
|
int Up;
|
|
|
|
};
|
|
|
|
|
2015-11-16 09:55:44 -06:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-08-16 16:14:46 -05:00
|
|
|
#endif
|