Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
38573a0
Add typescript example
parro-it Dec 7, 2018
b9a9217
button
parro-it Dec 7, 2018
1ad4b99
Add tslint to lint typescript defs file.
parro-it Dec 9, 2018
11827b3
Use namespace to nest enums.
parro-it Dec 9, 2018
0af5b7e
Add custom tslint rules
parro-it Dec 9, 2018
a7302e4
Example lint
parro-it Dec 9, 2018
1c4c4b0
Example lint
parro-it Dec 9, 2018
a0b69f6
Add getters and setters
parro-it Dec 9, 2018
2d10522
Add startTimer arguments
parro-it Dec 9, 2018
e194dee
onClosing cb return a void
parro-it Dec 9, 2018
72dbd5f
UiLabel text is a string not any
parro-it Dec 9, 2018
086d630
UiRadioButtons selected is a numbre not a string
parro-it Dec 9, 2018
6a65246
UICombobox onSelected cb return void
parro-it Dec 9, 2018
bbae53e
UiEditableCombobox cb return void
parro-it Dec 9, 2018
75852ce
Fix enums and forEach return types
mischnic Dec 9, 2018
04c78d1
Merge remote-tracking branch 'refs/remotes/origin/mapped-getters-sett…
mischnic Dec 9, 2018
f66e55c
typeings: AreaDrawContext
mischnic Dec 9, 2018
3830bb3
Use tsc instead of tslint
mischnic Dec 9, 2018
4d6f286
Merge pull request #59 from mischnic/mapped-getters-setters
parro-it Dec 10, 2018
f5d4006
DateTimePickerBase cb return void
parro-it Dec 10, 2018
8c4fb86
Merge branch 'mapped-getters-setters' of https://github.com/parro-it/…
parro-it Dec 10, 2018
ba195eb
Merge pull request #60 from mischnic/tsc
parro-it Dec 10, 2018
cbf50a1
Merge branch 'mapped-getters-setters' of https://github.com/parro-it/…
parro-it Dec 10, 2018
b6d93a2
Fix matrix typings
mischnic Dec 10, 2018
10702b8
Remove npx from npm script
mischnic Dec 10, 2018
dade525
Merge pull request #62 from mischnic/matrix-type
parro-it Dec 10, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions example/area-adv.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const libui = require('..');

const solidBrush = new libui.DrawBrush();
solidBrush.type = libui.brushType.solid;
solidBrush.type = libui.DrawBrush.type.solid;
solidBrush.color = new libui.Color(1, 0, 0, 1);
console.log(solidBrush.color)

Expand All @@ -12,7 +12,7 @@ dashedStroke.dashes = [10, 5];
console.log(dashedStroke.dashes);

const linearBrush = new libui.DrawBrush();
linearBrush.type = libui.brushType.linearGradient;
linearBrush.type = libui.DrawBrush.type.linearGradient;
linearBrush.start = new libui.Point(0, 0);
linearBrush.end = new libui.Point(200, 200);
console.log(linearBrush.end)
Expand All @@ -22,7 +22,7 @@ linearBrush.stops = [
];

const radialBrush = new libui.DrawBrush();
radialBrush.type = libui.brushType.radialGradient;
radialBrush.type = libui.DrawBrush.type.radialGradient;
radialBrush.start = new libui.Point(250, 300);
radialBrush.end = new libui.Point(250, 300);
radialBrush.outerRadius = 40;
Expand All @@ -37,26 +37,26 @@ matrix.setIdentity();
matrix.rotate(70, 280, (Math.PI / 180) * 45)

function handlerDraw(area, p) {
let path = new libui.UiDrawPath(libui.fillMode.winding);
let path = new libui.UiDrawPath(libui.UiDrawPath.fillMode.winding);
path.addRectangle(0, 0, 200, 200);
path.end();
p.context.fill(path, linearBrush);

// ------

path = new libui.UiDrawPath(libui.fillMode.winding);
path = new libui.UiDrawPath(libui.UiDrawPath.fillMode.winding);
path.newFigure(0, 0);
path.arcTo(250, 300, 50, 0, 2 * Math.PI, false);
path.end();
p.context.fill(path, radialBrush);

path = new libui.UiDrawPath(libui.fillMode.winding);
path = new libui.UiDrawPath(libui.UiDrawPath.fillMode.winding);
path.newFigure(250, 20);
path.lineTo(300, 150);
path.end();
p.context.stroke(path, solidBrush, dashedStroke);

path = new libui.UiDrawPath(libui.fillMode.winding);
path = new libui.UiDrawPath(libui.UiDrawPath.fillMode.winding);
p.context.transform(matrix);
path.addRectangle(20, 230, 100, 100);
path.end();
Expand All @@ -70,7 +70,7 @@ function onKey() {
}

function main() {
const mainwin = new libui.UiWindow('Area Advanced', 400, 400, 1);
const mainwin = new libui.UiWindow('Area Advanced', 400, 400, true);
mainwin.margined = true;
mainwin.onClosing(() => {
mainwin.close();
Expand Down
4 changes: 2 additions & 2 deletions example/area-scrolling.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
const libui = require('..');

const win = new libui.UiWindow('Area window', 600, 400, false);
win.margined = 1;
win.margined = true;
win.onClosing(() => {
libui.stopLoop();
});

const hBox = new libui.UiHorizontalBox();

const brushRed = new libui.DrawBrush(1, 0, 0);
const brushRed = new libui.DrawBrush();
brushRed.color = new libui.Color(1, 0, 0, 1);

const area = new libui.UiArea(
Expand Down
35 changes: 13 additions & 22 deletions example/area.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const libui = require('..');

const win = new libui.UiWindow('Area window', 600, 400, false);
win.margined = 1;
win.margined = true;
win.onClosing(() => {
libui.stopLoop();
});
Expand All @@ -27,33 +27,23 @@ brushRed.color = new libui.Color(1, 0, 0, 1);
const brushBrown = new libui.DrawBrush();
brushBrown.color = new libui.Color(0.7, 0.5, 0, 1);
const brushLinear = new libui.DrawBrush();
brushLinear.type = libui.brushType.linearGradient;
brushLinear.start = {
x: 10,
y: 10
};
brushLinear.end = {
x: 110,
y: 110
};
brushLinear.type = libui.DrawBrush.type.linearGradient;
brushLinear.start = new libui.Point(10, 10);
brushLinear.end = new libui.Point(110, 110);
brushLinear.stops = [
new libui.BrushGradientStop(0, new libui.Color(1, 0, 0, 1)),
new libui.BrushGradientStop(1, new libui.Color(0, 0, 1, 1))
];
console.log(brushLinear.stops.map(v => ({pos: v.pos, c: v.color})));

const brushRadial = new libui.DrawBrush();
brushRadial.type = libui.brushType.radialGradient;
brushRadial.start = {
x: 210,
y: 45
};
brushRadial.end = {
x: 210,
y: 85
};
brushRadial.stops =
[new libui.BrushGradientStop(0, {r: 1}), new libui.BrushGradientStop(1, {b: 1})];
brushRadial.type = libui.DrawBrush.type.radialGradient;
brushRadial.start = new libui.Point(210, 45);
brushRadial.end = new libui.Point(210, 85);
brushRadial.stops = [
new libui.BrushGradientStop(0, new libui.Color(1, 0, 0, 1)),
new libui.BrushGradientStop(1, new libui.Color(0, 0, 1, 1))
];
brushRadial.outerRadius = 50;

const sp = new libui.DrawStrokeParams();
Expand Down Expand Up @@ -96,7 +86,8 @@ const area = new libui.UiArea(
matrix.translate(0, 350);
},
() => {
const path = new libui.UiDrawPath(libui.fillMode.alternate);
const path =
new libui.UiDrawPath(libui.UiDrawPath.fillMode.alternate);
path.newFigure(230, 230);
path.lineTo(5, 230);
path.lineTo(5, 5);
Expand Down
4 changes: 2 additions & 2 deletions example/core-api.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ menuEdit.appendItem('Cut');
menuEdit.appendItem('Paste');

const win = new libui.UiWindow('Test window', 800, 600, true);
win.margined = 1;
win.margined = true;

const box = new libui.UiVerticalBox();
const hBox = new libui.UiHorizontalBox();
const e1 = new libui.UiEntry();
e1.enabled = 0;
e1.enabled = false;
const lblCiao = new libui.UiLabel('ciao');
hBox.append(lblCiao, false);

Expand Down
12 changes: 6 additions & 6 deletions example/event-loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ let lastTimeout = 0;
let setIntervalLast = Date.now();
console.log(libui.UiWindow)
const win = new libui.UiWindow('Event loop tests', 800, 600, false);
win.margined = 1;
win.margined = true;
console.log(2)
const box = new libui.UiVerticalBox();
box.padded = true;
Expand All @@ -25,13 +25,13 @@ console.log({setIntervalMs})

const sliderLabel = new libui.UiLabel('0');

sliderbox.append(setIntervalMs, 1);
sliderbox.append(sliderLabel, 0);
sliderbox.append(setIntervalMs, true);
sliderbox.append(sliderLabel, false);

const form = new libui.UiForm();
form.padded = true;
form.append('setInterval', sliderbox, 0);
form.append('actions', makeToolbar(), 0);
form.append('setInterval', sliderbox, false);
form.append('actions', makeToolbar(), false);
box.append(form, false);

const log = new libui.UiMultilineEntry();
Expand Down Expand Up @@ -71,7 +71,7 @@ function setIntervalChanged() {
if (Math.abs(ms - lastTimeout) < 100) {
return;
}
sliderLabel.text = ms;
sliderLabel.text = String(ms);
lastTimeout = ms;
if (setIntervalHandle !== null) {
clearInterval(setIntervalHandle);
Expand Down
12 changes: 6 additions & 6 deletions example/forms.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const libui = require('..');

const win = new libui.UiWindow('Forms window', 800, 600, false);
win.margined = 1;
win.margined = true;
win.onClosing(() => {
libui.stopLoop();
});
Expand All @@ -25,12 +25,12 @@ age.value = 40;

const form = new libui.UiForm();
form.padded = true;
form.append('name', name, 0);
form.append('surname', surname, 0);
form.append('age', age, 0);
form.append('name', name, false);
form.append('surname', surname, false);
form.append('age', age, false);

hBox.append(form, 1);
hBox.append(JSONData, 1);
hBox.append(form, true);
hBox.append(JSONData, true);

setJSON();

Expand Down
20 changes: 20 additions & 0 deletions example/gallery-ts/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {startLoop, stopLoop, UiButton, UiWindow} from 'libui-napi';

const win = new UiWindow('Using libui-node with TypeScript', 800, 600, false);
win.onClosing(() => {
win.close();
stopLoop();
});

const btn = new UiButton('full');
btn.setText('full screen');
btn.onClicked(() => {
win.fullscreen = !win.fullscreen;
btn.text = win.fullscreen ? 'normal' : 'fullscreen';
});

win.setChild(btn);

win.show();

startLoop();
Loading