~yerinalexey/hare-libui

405ed6c2227501be59736ad2bc4dbb21015d35c7 — Alexey Yerin 1 year, 3 months ago 7af8596
Update per stdlib changes
M ui/area/area.ha => ui/area/area.ha +1 -1
@@ 41,4 41,4 @@ fn mouse_crossed_noop(self: *handler, a: *area, left: int) void = void;
fn drag_broken_noop(self: *handler, a: *area) void = void;
fn key_event_noop(self: *handler, a: *area, ke: *key_event) int = 0;

@symbol("uiNewArea") fn c_uiNewArea(_: *handler) *area;
@symbol("uiNewArea") fn c_uiNewArea(*handler) *area;

M ui/area/draw.ha => ui/area/draw.ha +6 -3
@@ 57,7 57,10 @@ export fn draw_fill(context: *draw_context, p: *draw_path, b: draw_brush) void =
};

fn draw_brush_to_c(b: draw_brush) *c_draw_brush = {
	let cb = alloc(c_draw_brush { ... });
	let cb = alloc(c_draw_brush {
		grad_stop_arr = null: *grad_stop,
		...
	});
	match (b) {
	case let sb: solid_brush =>
		cb.brush_type = c_draw_brush_type::Solid;


@@ 99,5 102,5 @@ type c_draw_brush_type = enum uint {
	Image, //ToDo
};

@symbol("uiDrawFill") fn c_uiDrawFill(_: *draw_context, _: *draw_path, _: *c_draw_brush) void;
@symbol("uiAreaQueueRedrawAll") fn c_uiAreaQueueRedrawAll(_: *area) void;
@symbol("uiDrawFill") fn c_uiDrawFill(*draw_context, *draw_path, *c_draw_brush) void;
@symbol("uiAreaQueueRedrawAll") fn c_uiAreaQueueRedrawAll(*area) void;

M ui/area/draw_path.ha => ui/area/draw_path.ha +4 -4
@@ 34,7 34,7 @@ export fn add_rectangle(path: *draw_path, top_left: coord, width: f64, height: f
	c_uiDrawPathAddRectangle(path, top_left.x, top_left.y, width, height);
};

@symbol("uiDrawNewPath") fn c_uiDrawNewPath(_: draw_fill_mode) *draw_path;
@symbol("uiDrawFreePath") fn c_uiDrawFreePath(_: *draw_path) void;
@symbol("uiDrawPathAddRectangle") fn c_uiDrawPathAddRectangle(_: *draw_path, _: f64, _: f64, _: f64, _: f64) void;
@symbol("uiDrawPathEnd") fn c_uiDrawPathEnd(_: *draw_path) void;
@symbol("uiDrawNewPath") fn c_uiDrawNewPath(draw_fill_mode) *draw_path;
@symbol("uiDrawFreePath") fn c_uiDrawFreePath(*draw_path) void;
@symbol("uiDrawPathAddRectangle") fn c_uiDrawPathAddRectangle(*draw_path, f64, f64, f64, f64) void;
@symbol("uiDrawPathEnd") fn c_uiDrawPathEnd(*draw_path) void;

M ui/box.ha => ui/box.ha +4 -4
@@ 38,7 38,7 @@ export fn box_is_padded(b: *box) bool = {

@symbol("uiNewHorizontalBox") fn c_uiNewHorizontalBox() *box;
@symbol("uiNewVerticalBox") fn c_uiNewVerticalBox() *box;
@symbol("uiBoxAppend") fn c_uiBoxAppend(_: *box, _: *void, _: int) void;
@symbol("uiBoxDelete") fn c_uiBoxDelete(_: *box, _: int) void;
@symbol("uiBoxSetPadded") fn c_uiBoxSetPadded(_: *box, _: int) void;
@symbol("uiBoxPadded") fn c_uiBoxPadded(_: *box) int;
@symbol("uiBoxAppend") fn c_uiBoxAppend(*box, *void, int) void;
@symbol("uiBoxDelete") fn c_uiBoxDelete(*box, int) void;
@symbol("uiBoxSetPadded") fn c_uiBoxSetPadded(*box, int) void;
@symbol("uiBoxPadded") fn c_uiBoxPadded(*box) int;

M ui/button.ha => ui/button.ha +10 -10
@@ 1,10 1,10 @@
use strings;
use types::c;

export type button = void;

// Creates a new butten.
export fn button_new(text: const str) *button = {
	const text = strings::to_c(text);
	const text = c::fromstr(text);
	defer free(text);

	return c_uiNewButton(text);


@@ 12,7 12,7 @@ export fn button_new(text: const str) *button = {

// Sets text of a button.
export fn button_set_text(btn: *button, text: const str) void = {
	const text = strings::to_c(text);
	const text = c::fromstr(text);
	defer free(text);

	c_uiButtonSetText(btn, text);


@@ 20,7 20,7 @@ export fn button_set_text(btn: *button, text: const str) void = {

// Gets the text of a button.
export fn button_get_text(btn: *button) const str = {
	return strings::fromc(c_uiButtonText(btn))!;
	return c::tostr(c_uiButtonText(btn))!;
};

// Registers an event handler for a button click.


@@ 32,11 32,11 @@ export fn button_on_clicked(
	c_uiButtonOnClicked(btn, callback, data);
};

@symbol("uiNewButton") fn c_uiNewButton(_: *const char) *button;
@symbol("uiButtonText") fn c_uiButtonText(_: *button) *const char;
@symbol("uiButtonSetText") fn c_uiButtonSetText(_: *button, _: *const char) void;
@symbol("uiNewButton") fn c_uiNewButton(*const c::char) *button;
@symbol("uiButtonText") fn c_uiButtonText(*button) *const c::char;
@symbol("uiButtonSetText") fn c_uiButtonSetText(*button, *const c::char) void;
@symbol("uiButtonOnClicked") fn c_uiButtonOnClicked(
	_: *button,
	_: *fn(_: *button, _: nullable *void) void,
	_: nullable *void,
	*button,
	*fn(*button, nullable *void) void,
	nullable *void,
) void;

M ui/checkbox.ha => ui/checkbox.ha +12 -12
@@ 1,10 1,10 @@
use strings;
use types::c;

export type checkbox = void;

// Creates a new checkbox.
export fn checkbox_new(text: const str) *checkbox = {
	const text = strings::to_c(text);
	const text = c::fromstr(text);
	defer free(text);

	return c_uiNewCheckbox(text);


@@ 12,7 12,7 @@ export fn checkbox_new(text: const str) *checkbox = {

// Sets the text of a checkbox.
export fn checkbox_set_text(cb: *checkbox, text: const str) void = {
	const text = strings::to_c(text);
	const text = c::fromstr(text);
	defer free(text);

	c_uiCheckboxSetText(cb, text);


@@ 20,7 20,7 @@ export fn checkbox_set_text(cb: *checkbox, text: const str) void = {

// Returns the text of a checkbox.
export fn checkbox_get_text(cb: *checkbox) const str = {
	return strings::fromc(c_uiCheckboxText(cb))!;
	return c::tostr(c_uiCheckboxText(cb))!;
};

// Checks or un-checks a checkbox.


@@ 47,13 47,13 @@ export fn checkbox_on_toggled(
	c_uiCheckboxOnToggled(cb, callback, data);
};

@symbol("uiNewCheckbox") fn c_uiNewCheckbox(_: *const char) *checkbox;
@symbol("uiCheckboxSetText") fn c_uiCheckboxSetText(_: *checkbox, _: *const char) void;
@symbol("uiCheckboxText") fn c_uiCheckboxText(_: *checkbox) *const char;
@symbol("uiCheckboxSetChecked") fn c_uiCheckboxSetChecked(_: *checkbox, _: int) void;
@symbol("uiCheckboxChecked") fn c_uiCheckboxChecked(_: *checkbox) int;
@symbol("uiNewCheckbox") fn c_uiNewCheckbox(*const c::char) *checkbox;
@symbol("uiCheckboxSetText") fn c_uiCheckboxSetText(*checkbox, *const c::char) void;
@symbol("uiCheckboxText") fn c_uiCheckboxText(*checkbox) *const c::char;
@symbol("uiCheckboxSetChecked") fn c_uiCheckboxSetChecked(*checkbox, int) void;
@symbol("uiCheckboxChecked") fn c_uiCheckboxChecked(*checkbox) int;
@symbol("uiCheckboxOnToggled") fn c_uiCheckboxOnToggled(
	_: *checkbox,
	_: *fn(_: *checkbox, _: nullable *void) void,
	_: nullable *void,
	*checkbox,
	*fn(*checkbox, nullable *void) void,
	nullable *void,
) void;

M ui/controls.ha => ui/controls.ha +4 -4
@@ 30,7 30,7 @@ export fn control_disable(c: control) void = {
	c_uiControlDisable(control_ptr(c));
};

@symbol("uiControlShow") fn c_uiControlShow(_: *void) void;
@symbol("uiControlHide") fn c_uiControlHide(_: *void) void;
@symbol("uiControlEnable") fn c_uiControlEnable(_: *void) void;
@symbol("uiControlDisable") fn c_uiControlDisable(_: *void) void;
@symbol("uiControlShow") fn c_uiControlShow(*void) void;
@symbol("uiControlHide") fn c_uiControlHide(*void) void;
@symbol("uiControlEnable") fn c_uiControlEnable(*void) void;
@symbol("uiControlDisable") fn c_uiControlDisable(*void) void;

M ui/entry.ha => ui/entry.ha +10 -10
@@ 1,4 1,4 @@
use strings;
use types::c;

export type entry = void;



@@ 23,12 23,12 @@ export fn entry_new(mode: entry_mode) *entry = {

// Returns the text of an entry.
export fn entry_get_text(ent: *entry) const str = {
	return strings::fromc(c_uiEntryText(ent))!;
	return c::tostr(c_uiEntryText(ent))!;
};

// Sets the text of an entry.
export fn entry_set_text(ent: *entry, text: const str) void = {
	const text = strings::to_c(text);
	const text = c::fromstr(text);
	defer free(text);

	c_uiEntrySetText(ent, text);


@@ 61,12 61,12 @@ export fn entry_on_changed(
@symbol("uiNewEntry") fn c_uiNewEntry() *entry;
@symbol("uiNewPasswordEntry") fn c_uiNewPasswordEntry() *entry;
@symbol("uiNewSearchEntry") fn c_uiNewSearchEntry() *entry;
@symbol("uiEntryText") fn c_uiEntryText(_: *entry) *const char;
@symbol("uiEntrySetText") fn c_uiEntrySetText(_: *entry, _: *const char) void;
@symbol("uiEntryReadOnly") fn c_uiEntryReadOnly(_: *entry) int;
@symbol("uiEntrySetReadOnly") fn c_uiEntrySetReadOnly(_: *entry, _: int) void;
@symbol("uiEntryText") fn c_uiEntryText(*entry) *const c::char;
@symbol("uiEntrySetText") fn c_uiEntrySetText(*entry, *const c::char) void;
@symbol("uiEntryReadOnly") fn c_uiEntryReadOnly(*entry) int;
@symbol("uiEntrySetReadOnly") fn c_uiEntrySetReadOnly(*entry, int) void;
@symbol("uiEntryOnChanged") fn c_uiEntryOnChanged(
	_: *entry,
	_: *fn(_: *entry, _: nullable *void) void,
	_: nullable *void,
	*entry,
	*fn(*entry, nullable *void) void,
	nullable *void,
) void;

M ui/group.ha => ui/group.ha +10 -10
@@ 1,24 1,24 @@
use strings;
use types::c;

export type group = void;

// Creates a new group.
export fn group_new(title: const str) *group = {
	const title = strings::to_c(title);
	const title = c::fromstr(title);
	defer free(title);
	return c_uiNewGroup(title);
};

// Sets the title for a group.
export fn group_set_title(group: *group, title: const str) void = {
	const title = strings::to_c(title);
	const title = c::fromstr(title);
	defer free(title);
	c_uiGroupSetTitle(group, title);
};

// Returns the title of a group.
export fn group_get_title(group: *group) const str = {
	return strings::fromc(c_uiGroupTitle(group))!;
	return c::tostr(c_uiGroupTitle(group))!;
};

// Sets the child element for a group.


@@ 36,9 36,9 @@ export fn group_is_margined(group: *group) bool = {
	return c_uiGroupMargined(group) != 0;
};

@symbol("uiNewGroup") fn c_uiNewGroup(_: *const char) *group;
@symbol("uiGroupSetTitle") fn c_uiGroupSetTitle(_: *group, _: *const char) void;
@symbol("uiGroupTitle") fn c_uiGroupTitle(_: *group) *const char;
@symbol("uiGroupSetChild") fn c_uiGroupSetChild(_: *group, _: *void) void;
@symbol("uiGroupSetMargined") fn c_uiGroupSetMargined(_: *group, _: int) void;
@symbol("uiGroupMargined") fn c_uiGroupMargined(_: *group) int;
@symbol("uiNewGroup") fn c_uiNewGroup(*const c::char) *group;
@symbol("uiGroupSetTitle") fn c_uiGroupSetTitle(*group, *const c::char) void;
@symbol("uiGroupTitle") fn c_uiGroupTitle(*group) *const c::char;
@symbol("uiGroupSetChild") fn c_uiGroupSetChild(*group, *void) void;
@symbol("uiGroupSetMargined") fn c_uiGroupSetMargined(*group, int) void;
@symbol("uiGroupMargined") fn c_uiGroupMargined(*group) int;

M ui/init.ha => ui/init.ha +6 -6
@@ 1,4 1,4 @@
use strings;
use types::c;

type init_options = struct {
	sz: size,


@@ 14,8 14,8 @@ export fn init() (void | error) = {
	let opts = init_options { ... };
	match (c_uiInit(&opts)) {
	case null => void;
	case let err: *const char =>
		return strings::fromc(err)!;
	case let err: *const c::char =>
		return c::tostr(err)!;
	};
};



@@ 37,11 37,11 @@ export fn on_shouldquit(
	c_uiOnShouldQuit(callback, data);
};

@symbol("uiInit") fn c_uiInit(_: *init_options) nullable *const char;
@symbol("uiInit") fn c_uiInit(*init_options) nullable *const c::char;
@symbol("uiUninit") fn c_uiUninit() void;
@symbol("uiMain") fn c_uiMain() void;
@symbol("uiQuit") fn c_uiQuit() void;
@symbol("uiOnShouldQuit") fn c_uiOnShouldQuit(
	_: *fn(_: nullable *void) void,
	_: nullable *void,
	*fn(nullable *void) void,
	nullable *void,
) void;

M ui/label.ha => ui/label.ha +7 -7
@@ 1,10 1,10 @@
use strings;
use types::c;

export type label = void;

// Creates a label.
export fn label_new(text: const str) *label = {
	const text = strings::to_c(text);
	const text = c::fromstr(text);
	defer free(text);

	return c_uiNewLabel(text);


@@ 12,17 12,17 @@ export fn label_new(text: const str) *label = {

// Returns the text of a label.
export fn label_get_text(l: *label) const str = {
	return strings::fromc(c_uiLabelText(l))!;
	return c::tostr(c_uiLabelText(l))!;
};

// Sets the text of a label.
export fn label_set_text(l: *label, text: const str) void = {
	const text = strings::to_c(text);
	const text = c::fromstr(text);
	defer free(text);

	c_uiLabelSetText(l, text);
};

@symbol("uiNewLabel") fn c_uiNewLabel(_: *const char) *label;
@symbol("uiLabelText") fn c_uiLabelText(_: *label) *const char;
@symbol("uiLabelSetText") fn c_uiLabelSetText(_: *label, _: *const char) void;
@symbol("uiNewLabel") fn c_uiNewLabel(*const c::char) *label;
@symbol("uiLabelText") fn c_uiLabelText(*label) *const c::char;
@symbol("uiLabelSetText") fn c_uiLabelSetText(*label, *const c::char) void;

M ui/slider.ha => ui/slider.ha +6 -6
@@ 24,11 24,11 @@ export fn slider_on_changed(
	c_uiSliderOnChanged(sl, callback, data);
};

@symbol("uiNewSlider") fn c_uiNewSlider(_: int, _: int) *slider;
@symbol("uiSliderSetValue") fn c_uiSliderSetValue(_: *slider, _: int) void;
@symbol("uiSliderValue") fn c_uiSliderValue(_: *slider) int;
@symbol("uiNewSlider") fn c_uiNewSlider(int, int) *slider;
@symbol("uiSliderSetValue") fn c_uiSliderSetValue(*slider, int) void;
@symbol("uiSliderValue") fn c_uiSliderValue(*slider) int;
@symbol("uiSliderOnChanged") fn c_uiSliderOnChanged(
	_: *slider,
	_: *fn(_: *slider, _: nullable *void) void,
	_: nullable *void,
	*slider,
	*fn(*slider, nullable *void) void,
	nullable *void,
) void;

M ui/spinbox.ha => ui/spinbox.ha +6 -6
@@ 24,11 24,11 @@ export fn spinbox_on_changed(
	c_uiSpinboxOnChanged(sb, callback, data);
};

@symbol("uiNewSpinbox") fn c_uiNewSpinbox(_: int, _: int) *spinbox;
@symbol("uiSpinboxSetValue") fn c_uiSpinboxSetValue(_: *spinbox, _: int) void;
@symbol("uiSpinboxValue") fn c_uiSpinboxValue(_: *spinbox) int;
@symbol("uiNewSpinbox") fn c_uiNewSpinbox(int, int) *spinbox;
@symbol("uiSpinboxSetValue") fn c_uiSpinboxSetValue(*spinbox, int) void;
@symbol("uiSpinboxValue") fn c_uiSpinboxValue(*spinbox) int;
@symbol("uiSpinboxOnChanged") fn c_uiSpinboxOnChanged(
	_: *spinbox,
	_: *fn(_: *spinbox, _: nullable *void) void,
	_: nullable *void,
	*spinbox,
	*fn(*spinbox, nullable *void) void,
	nullable *void,
) void;

M ui/tab.ha => ui/tab.ha +7 -7
@@ 1,4 1,4 @@
use strings;
use types::c;
// TODO: extend the docs

export type tab = void;


@@ 10,14 10,14 @@ export fn tab_new() *tab = {

// Appends a tab to the view.
export fn tab_append(t: *tab, name: const str, c: control) void = {
	const name = strings::to_c(name);
	const name = c::fromstr(name);
	defer free(name);
	c_uiTabAppend(t, name, control_ptr(c));
};

// Inserts a tab after the one at index 'idx'.
export fn tab_insert(t: *tab, idx: size, name: const str, c: control) void = {
	const name = strings::to_c(name);
	const name = c::fromstr(name);
	defer free(name);
	c_uiTabInsertAt(t, name, idx: int, control_ptr(c));
};


@@ 35,7 35,7 @@ export fn tab_pages(t: *tab) size = {
// TODO: uiTab{,Set}Margined

@symbol("uiNewTab") fn c_uiNewTab() *tab;
@symbol("uiTabAppend") fn c_uiTabAppend(_: *tab, _: *const char, _: *void) void;
@symbol("uiTabInsertAt") fn c_uiTabInsertAt(_: *tab, _: *const char, _: int, _: *void) void;
@symbol("uiTabDelete") fn c_uiTabDelete(_: *tab, _: int) void;
@symbol("uiTabNumPages") fn c_uiTabNumPages(_: *tab) int;
@symbol("uiTabAppend") fn c_uiTabAppend(*tab, *const c::char, *void) void;
@symbol("uiTabInsertAt") fn c_uiTabInsertAt(*tab, *const c::char, int, *void) void;
@symbol("uiTabDelete") fn c_uiTabDelete(*tab, int) void;
@symbol("uiTabNumPages") fn c_uiTabNumPages(*tab) int;

M ui/window.ha => ui/window.ha +12 -12
@@ 1,4 1,4 @@
use strings;
use types::c;

export type window = void;



@@ 10,14 10,14 @@ export fn window_new(
	height: int,
	menubar: bool,
) *window = {
	const title = strings::to_c(title);
	const title = c::fromstr(title);
	defer free(title);
	return c_uiNewWindow(title, width, height, if (menubar) 1 else 0);
};

// Sets a title for a window.
export fn window_set_title(win: *window, title: const str) void = {
	const title = strings::to_c(title);
	const title = c::fromstr(title);
	defer free(title);

	c_uiWindowSetTitle(win, title);


@@ 26,8 26,8 @@ export fn window_set_title(win: *window, title: const str) void = {
// Gets title of a window.
export fn window_get_title(win: *window) const str = {
	match(c_uiWindowTitle(win)) {
	case let t: *const char =>
		return strings::fromc(t)!;
	case let t: *const c::char =>
		return c::tostr(t)!;
	case null =>
		return "";
	};


@@ 55,12 55,12 @@ export fn window_on_closing(
// - _{set,get}_fullscreen (uiWindow{Set,}Fullscreen)
// - _{set,get}_margined (uiWindow{Set,}Margined)

@symbol("uiNewWindow") fn c_uiNewWindow(_: *const char, _: int, _: int, _: int) *window;
@symbol("uiWindowSetTitle") fn c_uiWindowSetTitle(_: *window, _: *const char) void;
@symbol("uiWindowTitle") fn c_uiWindowTitle(_: *window) nullable *const char;
@symbol("uiWindowSetChild") fn c_uiWindowSetChild(_: *window, _: *void) void;
@symbol("uiNewWindow") fn c_uiNewWindow(*const c::char, int, int, int) *window;
@symbol("uiWindowSetTitle") fn c_uiWindowSetTitle(*window, *const c::char) void;
@symbol("uiWindowTitle") fn c_uiWindowTitle(*window) nullable *const c::char;
@symbol("uiWindowSetChild") fn c_uiWindowSetChild(*window, *void) void;
@symbol("uiWindowOnClosing") fn c_uiWindowOnClosing(
	_: *window,
	_: *fn(_: *window, _: nullable *void) void,
	_: nullable *void,
	*window,
	*fn(*window, nullable *void) void,
	nullable *void,
) void;