inspector works. i can edit a value wow
This commit is contained in:
parent
abca3eb397
commit
5c4ecbafdb
3 changed files with 57 additions and 28 deletions
|
|
@ -26,34 +26,40 @@ button = config \
|
||||||
|
|
||||||
# scrollable
|
# scrollable
|
||||||
scrollable = config \
|
scrollable = config \
|
||||||
showVBar = config.totalHeight > config.h;
|
defaults = {
|
||||||
vBarHeight = max 20 (config.h * config.h / config.totalHeight);
|
scrollX = 0,
|
||||||
vBarY = config.scrollY * config.h / config.totalHeight;
|
scrollY = 0
|
||||||
|
};
|
||||||
|
c = { ...defaults, ...config };
|
||||||
|
|
||||||
showHBar = config.totalWidth > config.w;
|
showVBar = c.totalHeight > c.h;
|
||||||
vBarWidth = max 20 (config.w * config.w / config.totalWidth);
|
vBarHeight = max 20 (c.h * c.h / c.totalHeight);
|
||||||
vBarX = config.scrollX * config.w / config.totalWidth;
|
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 {
|
ui.stack {
|
||||||
children = [
|
children = [
|
||||||
ui.scrollable {
|
ui.scrollable {
|
||||||
w = config.w,
|
w = c.w,
|
||||||
h = config.h,
|
h = c.h,
|
||||||
scrollX = config.scrollX,
|
scrollX = c.scrollX,
|
||||||
scrollY = config.scrollY,
|
scrollY = c.scrollY,
|
||||||
onScroll = config.onScroll,
|
onScroll = c.onScroll,
|
||||||
child = config.child
|
child = c.child
|
||||||
},
|
},
|
||||||
...(showVBar
|
...(showVBar
|
||||||
| True \ [ui.positioned {
|
| True \ [ui.positioned {
|
||||||
x = config.w - 4,
|
x = c.w - 4,
|
||||||
y = vBarY,
|
y = vBarY,
|
||||||
child = ui.rect { w = 4, h = vBarHeight, color = "rgba(255,255,255,0.3)", radius = 2 }
|
child = ui.rect { w = 4, h = vBarHeight, color = "rgba(255,255,255,0.3)", radius = 2 }
|
||||||
}]
|
}]
|
||||||
| False \ []),
|
| False \ []),
|
||||||
...(showHBar
|
...(showHBar
|
||||||
| True \ [ui.positioned {
|
| True \ [ui.positioned {
|
||||||
x = config.h - 4,
|
x = c.h - 4,
|
||||||
y = hBarX,
|
y = hBarX,
|
||||||
child = ui.rect { h = 4, w = hBarWidth, color = "rgba(255,255,255,0.3)", radius = 2 }
|
child = ui.rect { h = 4, w = hBarWidth, color = "rgba(255,255,255,0.3)", radius = 2 }
|
||||||
}]
|
}]
|
||||||
|
|
@ -99,9 +105,14 @@ box = config \
|
||||||
};
|
};
|
||||||
|
|
||||||
textInput = config \
|
textInput = config \
|
||||||
defaults = { onSubmit = _ \ noOp };
|
defaults = {
|
||||||
|
onSubmit = _ \ noOp,
|
||||||
|
onChange = _ \ noOp,
|
||||||
|
initialValue = "",
|
||||||
|
initialFocus = False,
|
||||||
|
};
|
||||||
|
|
||||||
c = { ...defaults, ...config };
|
c = { ...defaults, ...config };
|
||||||
_ = debug "c" c;
|
|
||||||
|
|
||||||
insertChar = text pos char \
|
insertChar = text pos char \
|
||||||
before = slice text 0 pos;
|
before = slice text 0 pos;
|
||||||
|
|
|
||||||
|
|
@ -3,8 +3,8 @@ inspector = config \
|
||||||
windowWidth = 600;
|
windowWidth = 600;
|
||||||
|
|
||||||
source = getSource config.name;
|
source = getSource config.name;
|
||||||
_ = debug "inspector source" source;
|
|
||||||
sourceLines = split "\n" source;
|
sourceLines = split "\n" source;
|
||||||
|
lineHeight = 20;
|
||||||
|
|
||||||
dialogPadding = 0;
|
dialogPadding = 0;
|
||||||
|
|
||||||
|
|
@ -14,17 +14,34 @@ inspector = config \
|
||||||
|
|
||||||
ui.column {
|
ui.column {
|
||||||
gap = 0,
|
gap = 0,
|
||||||
children = mapWithIndex (line i \
|
children = [
|
||||||
textInput {
|
# display source
|
||||||
key = "palette-query" & (show i),
|
scrollable {
|
||||||
initialValue = line,
|
w = config.w,
|
||||||
initialFocus = i == 0,
|
h = config.h - textInputHeight,
|
||||||
color = "white",
|
totalWidth = config.w,
|
||||||
backgroundColor = "rgba(0,0,0,0.0)",
|
totalHeight = (len sourceLines) * lineHeight,
|
||||||
w = contentWidth,
|
onScroll = _ \ noOp,
|
||||||
h = textInputHeight,
|
child = ui.column {
|
||||||
# onChange = text \ batch [config.state.query := text, config.state.focusedIndex := 0],
|
gap = 0,
|
||||||
onChange = text \ batch []
|
children = map (line \
|
||||||
|
ui.positioned {
|
||||||
|
x = 8,
|
||||||
|
y = 2,
|
||||||
|
child = ui.text { content = line, color = "#ccc" }
|
||||||
}
|
}
|
||||||
) sourceLines
|
) sourceLines
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
# definition bar
|
||||||
|
textInput {
|
||||||
|
key = "inspector-redefine-" & config.name,
|
||||||
|
color = "white",
|
||||||
|
backgroundColor = "rgba(0,0,0,1)",
|
||||||
|
w = config.w,
|
||||||
|
h = textInputHeight,
|
||||||
|
onSubmit = text \ redefine config.name text
|
||||||
|
}
|
||||||
|
]
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ os =
|
||||||
child = ui.clip {
|
child = ui.clip {
|
||||||
w = (windowWidth window),
|
w = (windowWidth window),
|
||||||
h = viewport.height - titleBarHeight,
|
h = viewport.height - titleBarHeight,
|
||||||
child = window.content 0
|
child = window.content { w = (windowWidth window), h = viewport.height - titleBarHeight }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -170,9 +170,10 @@ os =
|
||||||
|
|
||||||
onSelect = input \
|
onSelect = input \
|
||||||
result = eval input;
|
result = eval input;
|
||||||
|
_ = debug "onSelect eval result" result;
|
||||||
result
|
result
|
||||||
| Value v \ openWindow input (_ \ ui.text { content = show v, color = "white" })
|
| Value v \ openWindow input (_ \ ui.text { content = show v, color = "white" })
|
||||||
| Defined name \ openWindow name (_ \ inspector { name = name })
|
| Defined name \ openWindow name (size \ inspector { name = name, w = size.w, h = size.h })
|
||||||
| Err msg \ openWindow "Error" (_ \ ui.text { content = msg, color = "red" });
|
| Err msg \ openWindow "Error" (_ \ ui.text { content = msg, color = "red" });
|
||||||
|
|
||||||
handleFocusLeftEvent = state \
|
handleFocusLeftEvent = state \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue