|
|
|
|
@ -26,34 +26,40 @@ button = config \
|
|
|
|
|
|
|
|
|
|
# scrollable
|
|
|
|
|
scrollable = config \
|
|
|
|
|
showVBar = config.totalHeight > config.h;
|
|
|
|
|
vBarHeight = max 20 (config.h * config.h / config.totalHeight);
|
|
|
|
|
vBarY = config.scrollY * config.h / config.totalHeight;
|
|
|
|
|
defaults = {
|
|
|
|
|
scrollX = 0,
|
|
|
|
|
scrollY = 0
|
|
|
|
|
};
|
|
|
|
|
c = { ...defaults, ...config };
|
|
|
|
|
|
|
|
|
|
showHBar = config.totalWidth > config.w;
|
|
|
|
|
vBarWidth = max 20 (config.w * config.w / config.totalWidth);
|
|
|
|
|
vBarX = config.scrollX * config.w / config.totalWidth;
|
|
|
|
|
showVBar = c.totalHeight > c.h;
|
|
|
|
|
vBarHeight = max 20 (c.h * c.h / c.totalHeight);
|
|
|
|
|
vBarY = c.scrollY * c.h / c.totalHeight;
|
|
|
|
|
|
|
|
|
|
showHBar = c.totalWidth > c.w;
|
|
|
|
|
vBarWidth = max 20 (c.w * c.w / c.totalWidth);
|
|
|
|
|
vBarX = c.scrollX * c.w / c.totalWidth;
|
|
|
|
|
|
|
|
|
|
ui.stack {
|
|
|
|
|
children = [
|
|
|
|
|
ui.scrollable {
|
|
|
|
|
w = config.w,
|
|
|
|
|
h = config.h,
|
|
|
|
|
scrollX = config.scrollX,
|
|
|
|
|
scrollY = config.scrollY,
|
|
|
|
|
onScroll = config.onScroll,
|
|
|
|
|
child = config.child
|
|
|
|
|
w = c.w,
|
|
|
|
|
h = c.h,
|
|
|
|
|
scrollX = c.scrollX,
|
|
|
|
|
scrollY = c.scrollY,
|
|
|
|
|
onScroll = c.onScroll,
|
|
|
|
|
child = c.child
|
|
|
|
|
},
|
|
|
|
|
...(showVBar
|
|
|
|
|
| True \ [ui.positioned {
|
|
|
|
|
x = config.w - 4,
|
|
|
|
|
x = c.w - 4,
|
|
|
|
|
y = vBarY,
|
|
|
|
|
child = ui.rect { w = 4, h = vBarHeight, color = "rgba(255,255,255,0.3)", radius = 2 }
|
|
|
|
|
}]
|
|
|
|
|
| False \ []),
|
|
|
|
|
...(showHBar
|
|
|
|
|
| True \ [ui.positioned {
|
|
|
|
|
x = config.h - 4,
|
|
|
|
|
x = c.h - 4,
|
|
|
|
|
y = hBarX,
|
|
|
|
|
child = ui.rect { h = 4, w = hBarWidth, color = "rgba(255,255,255,0.3)", radius = 2 }
|
|
|
|
|
}]
|
|
|
|
|
@ -99,9 +105,14 @@ box = config \
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
textInput = config \
|
|
|
|
|
defaults = { onSubmit = _ \ noOp };
|
|
|
|
|
defaults = {
|
|
|
|
|
onSubmit = _ \ noOp,
|
|
|
|
|
onChange = _ \ noOp,
|
|
|
|
|
initialValue = "",
|
|
|
|
|
initialFocus = False,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
c = { ...defaults, ...config };
|
|
|
|
|
_ = debug "c" c;
|
|
|
|
|
|
|
|
|
|
insertChar = text pos char \
|
|
|
|
|
before = slice text 0 pos;
|
|
|
|
|
|