|
|
|
|
@ -14,16 +14,86 @@ center = parentW parentH child \
|
|
|
|
|
|
|
|
|
|
# button : Record -> ui
|
|
|
|
|
button = config \
|
|
|
|
|
textSize = ui.measureText config.label;
|
|
|
|
|
|
|
|
|
|
defaults = {
|
|
|
|
|
h = 30,
|
|
|
|
|
w = textSize + 20,
|
|
|
|
|
strokeWidth = 1,
|
|
|
|
|
strokeColor = "#fff",
|
|
|
|
|
textColor = "#fff",
|
|
|
|
|
label = ""
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
c = { ...defaults, ...config };
|
|
|
|
|
|
|
|
|
|
ui.clickable {
|
|
|
|
|
onClick = config.event,
|
|
|
|
|
child = ui.stack {
|
|
|
|
|
children = [
|
|
|
|
|
ui.rect { w = 100, h = 40, color = "#eee" },
|
|
|
|
|
ui.text { content = config.label, x = 10, y = 25, color = "#222" }
|
|
|
|
|
ui.rect { w = c.w, h = c.h, strokeColor = c.strokeColor, strokeWidth = c.strokeWidth },
|
|
|
|
|
ui.positioned {
|
|
|
|
|
x = 10, y = 8,
|
|
|
|
|
child = ui.text { content = config.label, color = c.textColor }
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# inputButton (button that turns into an input)
|
|
|
|
|
inputButton = config \
|
|
|
|
|
textSize = ui.measureText config.label;
|
|
|
|
|
|
|
|
|
|
defaults = {
|
|
|
|
|
h = 30,
|
|
|
|
|
w = textSize + 16,
|
|
|
|
|
strokeWidth = 1,
|
|
|
|
|
strokeColor = "#fff",
|
|
|
|
|
textColor = "#fff",
|
|
|
|
|
backgroundColor = "transparent",
|
|
|
|
|
label = ""
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
c = { ...defaults, ...config };
|
|
|
|
|
|
|
|
|
|
ui.stateful {
|
|
|
|
|
key = c.key,
|
|
|
|
|
focusable = True,
|
|
|
|
|
|
|
|
|
|
init = { editing = False },
|
|
|
|
|
|
|
|
|
|
update = state event \ event
|
|
|
|
|
| Activate \ { state = state.{ editing = True }, emit = [] }
|
|
|
|
|
| Submit text \ { state = state.{ editing = False }, emit = [c.onSubmit text] }
|
|
|
|
|
| Key { key = "Escape" } \ { state = state.{ editing = False }, emit = [] }
|
|
|
|
|
| _ \ { state = state, emit = [] },
|
|
|
|
|
|
|
|
|
|
view = state emit \
|
|
|
|
|
state.editing
|
|
|
|
|
| True \ textInput {
|
|
|
|
|
key = c.key & "-input",
|
|
|
|
|
autoFocus = True,
|
|
|
|
|
w = c.w, h = c.h,
|
|
|
|
|
strokeWidth = 1,
|
|
|
|
|
strokeColor = "#fff",
|
|
|
|
|
color = c.textColor,
|
|
|
|
|
backgroundColor = c.backgroundColor,
|
|
|
|
|
onSubmit = text \ emit (Submit text)
|
|
|
|
|
}
|
|
|
|
|
| False \ ui.clickable {
|
|
|
|
|
onClick = \ emit Activate,
|
|
|
|
|
child = ui.stack {
|
|
|
|
|
children = [
|
|
|
|
|
ui.rect { w = c.w, h = c.h, strokeColor = c.strokeColor, strokeWidth = c.strokeWidth },
|
|
|
|
|
ui.positioned {
|
|
|
|
|
x = 8, y = 8,
|
|
|
|
|
child = ui.text { content = config.label, color = c.textColor }
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
# scrollable
|
|
|
|
|
scrollable = config \
|
|
|
|
|
defaults = {
|
|
|
|
|
@ -111,6 +181,8 @@ textInput = config \
|
|
|
|
|
onChange = _ \ noOp,
|
|
|
|
|
initialValue = "",
|
|
|
|
|
autoFocus = False,
|
|
|
|
|
strokeWidth = 0,
|
|
|
|
|
strokeColor = "transparent"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
c = { ...defaults, ...config };
|
|
|
|
|
@ -228,7 +300,7 @@ textInput = config \
|
|
|
|
|
h = c.h,
|
|
|
|
|
child = ui.stack {
|
|
|
|
|
children = [
|
|
|
|
|
ui.rect { w = c.w, h = c.h, color = c.backgroundColor, radius = 0 },
|
|
|
|
|
ui.rect { w = c.w, h = c.h, color = c.backgroundColor, radius = 0, strokeWidth = c.strokeWidth, strokeColor = c.strokeColor },
|
|
|
|
|
|
|
|
|
|
ui.positioned {
|
|
|
|
|
x = 8 - state.scrollOffset,
|
|
|
|
|
@ -251,7 +323,6 @@ textInput = config \
|
|
|
|
|
glyphView = config \
|
|
|
|
|
defaults = { scale = 1, color = "#fff" };
|
|
|
|
|
c = { ...defaults, ...config };
|
|
|
|
|
_ = debug! "glyphView" c;
|
|
|
|
|
ui.stack {
|
|
|
|
|
children = map (pixel \
|
|
|
|
|
ui.positioned {
|
|
|
|
|
|