|
|
|
@ -1,45 +1,45 @@
|
|
|
|
centerH = parentW child \
|
|
|
|
centerH = parentW child \
|
|
|
|
childW = (measure child).width;
|
|
|
|
childW = (ui.measure child).width;
|
|
|
|
Positioned { x = (parentW - childW) / 2, y = 0, child = child };
|
|
|
|
ui.positioned { x = (parentW - childW) / 2, y = 0, child = child };
|
|
|
|
|
|
|
|
|
|
|
|
centerV = parentH child \
|
|
|
|
centerV = parentH child \
|
|
|
|
childH = (measure child).height;
|
|
|
|
childH = (ui.measure child).height;
|
|
|
|
Positioned { y = (parentH - childH) / 2, x = 0, child = child };
|
|
|
|
ui.positioned { y = (parentH - childH) / 2, x = 0, child = child };
|
|
|
|
|
|
|
|
|
|
|
|
center = parentW parentH child \
|
|
|
|
center = parentW parentH child \
|
|
|
|
childSize = measure child;
|
|
|
|
childSize = ui.measure child;
|
|
|
|
Positioned { x = (parentW - childSize.width) / 2, y = (parentH - childSize.height) / 2, child = child };
|
|
|
|
ui.positioned { x = (parentW - childSize.width) / 2, y = (parentH - childSize.height) / 2, child = child };
|
|
|
|
|
|
|
|
|
|
|
|
# button : Record -> UI
|
|
|
|
# button : Record -> ui
|
|
|
|
button = config \
|
|
|
|
button = config \
|
|
|
|
Clickable {
|
|
|
|
ui.clickable {
|
|
|
|
event = config.event,
|
|
|
|
event = config.event,
|
|
|
|
child = Stack {
|
|
|
|
child = ui.stack {
|
|
|
|
children = [
|
|
|
|
children = [
|
|
|
|
Rect { w = 100, h = 40, color = "#eee" },
|
|
|
|
ui.rect { w = 100, h = 40, color = "#eee" },
|
|
|
|
Text { content = config.label, x = 10, y = 25, color = "#222" }
|
|
|
|
ui.text { content = config.label, x = 10, y = 25, color = "#222" }
|
|
|
|
]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
box = config \ Stack {
|
|
|
|
box = config \ ui.stack {
|
|
|
|
children = [
|
|
|
|
children = [
|
|
|
|
# background
|
|
|
|
# background
|
|
|
|
Rect { w = config.w, h = config.h, color = config.color },
|
|
|
|
ui.rect { w = config.w, h = config.h, color = config.color },
|
|
|
|
# top border
|
|
|
|
# top border
|
|
|
|
Rect { w = config.w, h = config.borderTop, color = config.borderColor },
|
|
|
|
ui.rect { w = config.w, h = config.borderTop, color = config.borderColor },
|
|
|
|
# bottom border
|
|
|
|
# bottom border
|
|
|
|
Positioned { x = 0, y = config.h - config.borderBottom, child =
|
|
|
|
ui.positioned { x = 0, y = config.h - config.borderBottom, child =
|
|
|
|
Rect { w = config.w, h = config.borderBottom, color = config.borderColor }
|
|
|
|
ui.rect { w = config.w, h = config.borderBottom, color = config.borderColor }
|
|
|
|
},
|
|
|
|
},
|
|
|
|
# left border
|
|
|
|
# left border
|
|
|
|
Rect { w = config.borderLeft, h = config.h, color = config.borderColor },
|
|
|
|
ui.rect { w = config.borderLeft, h = config.h, color = config.borderColor },
|
|
|
|
# right border
|
|
|
|
# right border
|
|
|
|
Positioned { x = config.w - config.borderRight, y = 0, child =
|
|
|
|
ui.positioned { x = config.w - config.borderRight, y = 0, child =
|
|
|
|
Rect { w = config.borderRight, h = config.h, color = config.borderColor }
|
|
|
|
ui.rect { w = config.borderRight, h = config.h, color = config.borderColor }
|
|
|
|
},
|
|
|
|
},
|
|
|
|
# content
|
|
|
|
# content
|
|
|
|
Positioned { x = config.paddingLeft, y = config.paddingTop, child = config.child }
|
|
|
|
ui.positioned { x = config.paddingLeft, y = config.paddingTop, child = config.child }
|
|
|
|
]};
|
|
|
|
]};
|
|
|
|
|
|
|
|
|
|
|
|
insertChar = text pos char \
|
|
|
|
insertChar = text pos char \
|
|
|
|
@ -57,7 +57,7 @@ deleteChar = text pos \
|
|
|
|
|
|
|
|
|
|
|
|
calcScrollOffset = text cursorPos scrollOffset inputWidth \
|
|
|
|
calcScrollOffset = text cursorPos scrollOffset inputWidth \
|
|
|
|
textBeforeCursor = slice text 0 cursorPos;
|
|
|
|
textBeforeCursor = slice text 0 cursorPos;
|
|
|
|
cursorX = measureText textBeforeCursor;
|
|
|
|
cursorX = ui.measureText textBeforeCursor;
|
|
|
|
(cursorX < scrollOffset
|
|
|
|
(cursorX < scrollOffset
|
|
|
|
| True \ max 0 (cursorX - 20)
|
|
|
|
| True \ max 0 (cursorX - 20)
|
|
|
|
| False \
|
|
|
|
| False \
|
|
|
|
@ -69,8 +69,8 @@ findPosHelper = text targetX index \
|
|
|
|
(index >= len text)
|
|
|
|
(index >= len text)
|
|
|
|
| True \ len text
|
|
|
|
| True \ len text
|
|
|
|
| False \ (
|
|
|
|
| False \ (
|
|
|
|
widthSoFar = measureText (slice text 0 index);
|
|
|
|
widthSoFar = ui.measureText (slice text 0 index);
|
|
|
|
widthNext = measureText (slice text 0 (index + 1));
|
|
|
|
widthNext = ui.measureText (slice text 0 (index + 1));
|
|
|
|
midpoint = (widthSoFar + widthNext) / 2;
|
|
|
|
midpoint = (widthSoFar + widthNext) / 2;
|
|
|
|
(targetX < midpoint
|
|
|
|
(targetX < midpoint
|
|
|
|
| True \ index
|
|
|
|
| True \ index
|
|
|
|
@ -81,7 +81,7 @@ findCursorPos = text clickX scrollOffset inputPadding \
|
|
|
|
adjustedX = clickX + scrollOffset - inputPadding;
|
|
|
|
adjustedX = clickX + scrollOffset - inputPadding;
|
|
|
|
findPosHelper text adjustedX 0;
|
|
|
|
findPosHelper text adjustedX 0;
|
|
|
|
|
|
|
|
|
|
|
|
textInput = config \ Stateful {
|
|
|
|
textInput = config \ ui.stateful {
|
|
|
|
key = config.key,
|
|
|
|
key = config.key,
|
|
|
|
focusable = True,
|
|
|
|
focusable = True,
|
|
|
|
|
|
|
|
|
|
|
|
@ -133,29 +133,29 @@ textInput = config \ Stateful {
|
|
|
|
|
|
|
|
|
|
|
|
view = state \
|
|
|
|
view = state \
|
|
|
|
textBeforeCursor = slice state.text 0 state.cursorPos;
|
|
|
|
textBeforeCursor = slice state.text 0 state.cursorPos;
|
|
|
|
cursorX = measureText textBeforeCursor;
|
|
|
|
cursorX = ui.measureText textBeforeCursor;
|
|
|
|
padding = 8;
|
|
|
|
padding = 8;
|
|
|
|
|
|
|
|
|
|
|
|
Clip {
|
|
|
|
ui.clip {
|
|
|
|
w = config.w,
|
|
|
|
w = config.w,
|
|
|
|
h = config.h,
|
|
|
|
h = config.h,
|
|
|
|
child = Stack {
|
|
|
|
child = ui.stack {
|
|
|
|
children = [
|
|
|
|
children = [
|
|
|
|
Rect { w = config.w, h = config.h, color = config.backgroundColor, radius = 0 },
|
|
|
|
ui.rect { w = config.w, h = config.h, color = config.backgroundColor, radius = 0 },
|
|
|
|
|
|
|
|
|
|
|
|
Positioned {
|
|
|
|
ui.positioned {
|
|
|
|
x = 8 - state.scrollOffset,
|
|
|
|
x = 8 - state.scrollOffset,
|
|
|
|
y = 0,
|
|
|
|
y = 0,
|
|
|
|
child = Positioned { x = 0, y = 12, child = Text { content = state.text, color = config.color } }
|
|
|
|
child = ui.positioned { x = 0, y = 12, child = ui.text { content = state.text, color = config.color } }
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
(state.focused
|
|
|
|
(state.focused
|
|
|
|
| True \ Positioned {
|
|
|
|
| True \ ui.positioned {
|
|
|
|
x = 8 + cursorX - state.scrollOffset,
|
|
|
|
x = 8 + cursorX - state.scrollOffset,
|
|
|
|
y = 8,
|
|
|
|
y = 8,
|
|
|
|
child = Rect { w = 2, h = 24, color = config.color }
|
|
|
|
child = ui.rect { w = 2, h = 24, color = config.color }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
| _ \ Rect { w = 0, h = 0, color = "transparent" })
|
|
|
|
| _ \ ui.rect { w = 0, h = 0, color = "transparent" })
|
|
|
|
]
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|