|
|
|
@ -5,17 +5,29 @@ osState = {
|
|
|
|
windows = [],
|
|
|
|
windows = [],
|
|
|
|
wm = {
|
|
|
|
wm = {
|
|
|
|
focusedIndex = 0,
|
|
|
|
focusedIndex = 0,
|
|
|
|
scrollOffset = 0
|
|
|
|
scrollOffset = 0,
|
|
|
|
|
|
|
|
defaultWindowWidth = 800
|
|
|
|
},
|
|
|
|
},
|
|
|
|
nextId = 0
|
|
|
|
nextId = 0
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
windowWidth = window \ window.fullWidth
|
|
|
|
|
|
|
|
| True \ viewport.width
|
|
|
|
|
|
|
|
| False \ window.width;
|
|
|
|
|
|
|
|
|
|
|
|
openWindow = title content \
|
|
|
|
openWindow = title content \
|
|
|
|
id = osState.nextId;
|
|
|
|
id = osState.nextId;
|
|
|
|
batch [
|
|
|
|
batch [
|
|
|
|
osState.nextId := id + 1,
|
|
|
|
osState.nextId := id + 1,
|
|
|
|
osState.windows := osState.windows & [{ id = id, title = title, content = content, width = 400 }],
|
|
|
|
osState.windows := osState.windows & [{
|
|
|
|
osState.palette.visible := False
|
|
|
|
id = id,
|
|
|
|
|
|
|
|
title = title,
|
|
|
|
|
|
|
|
content = content,
|
|
|
|
|
|
|
|
width = osState.wm.defaultWindowWidth,
|
|
|
|
|
|
|
|
fullWidth = False
|
|
|
|
|
|
|
|
}],
|
|
|
|
|
|
|
|
osState.palette.visible := False,
|
|
|
|
|
|
|
|
focusWindow id
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
closeWindowByIndex = i \
|
|
|
|
closeWindowByIndex = i \
|
|
|
|
@ -28,7 +40,8 @@ closeWindowByIndex = i \
|
|
|
|
|
|
|
|
|
|
|
|
batch [
|
|
|
|
batch [
|
|
|
|
osState.windows := (take i osState.windows) & (drop (i + 1) osState.windows),
|
|
|
|
osState.windows := (take i osState.windows) & (drop (i + 1) osState.windows),
|
|
|
|
osState.wm.focusedIndex := min newFocused (len osState.windows - 2)
|
|
|
|
focusWindow newFocused
|
|
|
|
|
|
|
|
# osState.wm.focusedIndex := min newFocused (len osState.windows - 2)
|
|
|
|
];
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
closeFocusedWindow = _ \ closeWindowByIndex osState.wm.focusedIndex;
|
|
|
|
closeFocusedWindow = _ \ closeWindowByIndex osState.wm.focusedIndex;
|
|
|
|
@ -37,12 +50,16 @@ closeWindowById = id \
|
|
|
|
i = index id (map (w \ w.id) osState.windows);
|
|
|
|
i = index id (map (w \ w.id) osState.windows);
|
|
|
|
closeWindowByIndex (unwrapOr 0 i);
|
|
|
|
closeWindowByIndex (unwrapOr 0 i);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
toggleMaximizeFocusedWindow = _ \
|
|
|
|
|
|
|
|
idx = osState.wm.focusedIndex;
|
|
|
|
|
|
|
|
osState.windows := updateAt idx (w \ w.{ fullWidth = not w.fullWidth }) osState.windows;
|
|
|
|
|
|
|
|
|
|
|
|
scrollToWindow = index \
|
|
|
|
scrollToWindow = index \
|
|
|
|
windows = osState.windows;
|
|
|
|
windows = osState.windows;
|
|
|
|
widths = map (w \ w.width) windows;
|
|
|
|
widths = map windowWidth windows;
|
|
|
|
gap = 1;
|
|
|
|
gap = 1;
|
|
|
|
windowX = (sum (take index widths)) + (index * gap);
|
|
|
|
windowX = (sum (take index widths)) + (index * gap);
|
|
|
|
windowW = unwrapOr 400 (nth index widths);
|
|
|
|
windowW = unwrapOr osState.wm.defaultWindowWidth (nth index widths);
|
|
|
|
scrollOffset = osState.wm.scrollOffset;
|
|
|
|
scrollOffset = osState.wm.scrollOffset;
|
|
|
|
vw = viewport.width;
|
|
|
|
vw = viewport.width;
|
|
|
|
(windowX < scrollOffset
|
|
|
|
(windowX < scrollOffset
|
|
|
|
@ -66,10 +83,11 @@ onSelect = input \
|
|
|
|
|
|
|
|
|
|
|
|
renderWindow = window isActive \
|
|
|
|
renderWindow = window isActive \
|
|
|
|
titleBarHeight = 30;
|
|
|
|
titleBarHeight = 30;
|
|
|
|
|
|
|
|
|
|
|
|
ui.stack {
|
|
|
|
ui.stack {
|
|
|
|
children = [
|
|
|
|
children = [
|
|
|
|
# background
|
|
|
|
# background
|
|
|
|
ui.rect { w = window.width, h = viewport.height, color = (isActive | True \ "#0a2a3a" | False \ "#061820")},
|
|
|
|
ui.rect { w = (windowWidth window), h = viewport.height, color = (isActive | True \ "#0a2a3a" | False \ "#061820")},
|
|
|
|
|
|
|
|
|
|
|
|
# title bar
|
|
|
|
# title bar
|
|
|
|
ui.positioned {
|
|
|
|
ui.positioned {
|
|
|
|
@ -77,7 +95,7 @@ renderWindow = window isActive \
|
|
|
|
child = ui.stack {
|
|
|
|
child = ui.stack {
|
|
|
|
children = [
|
|
|
|
children = [
|
|
|
|
# background
|
|
|
|
# background
|
|
|
|
ui.rect { w = window.width, h = titleBarHeight, color = (isActive | True \ "#a15f80" | False \ "#0f3348") },
|
|
|
|
ui.rect { w = (windowWidth window), h = titleBarHeight, color = (isActive | True \ "#a15f80" | False \ "#0f3348") },
|
|
|
|
ui.row {
|
|
|
|
ui.row {
|
|
|
|
children = [
|
|
|
|
children = [
|
|
|
|
# close button
|
|
|
|
# close button
|
|
|
|
@ -107,7 +125,7 @@ renderWindow = window isActive \
|
|
|
|
ui.positioned {
|
|
|
|
ui.positioned {
|
|
|
|
x = 0, y = titleBarHeight,
|
|
|
|
x = 0, y = titleBarHeight,
|
|
|
|
child = ui.clip {
|
|
|
|
child = ui.clip {
|
|
|
|
w = window.width,
|
|
|
|
w = (windowWidth window),
|
|
|
|
h = viewport.height - titleBarHeight,
|
|
|
|
h = viewport.height - titleBarHeight,
|
|
|
|
child = window.content
|
|
|
|
child = window.content
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -161,6 +179,8 @@ os = ui.stateful {
|
|
|
|
)
|
|
|
|
)
|
|
|
|
| Key { key = "d", meta = True } \
|
|
|
|
| Key { key = "d", meta = True } \
|
|
|
|
{ state = state, emit = [closeFocusedWindow 0] }
|
|
|
|
{ state = state, emit = [closeFocusedWindow 0] }
|
|
|
|
|
|
|
|
| Key { key = "f", meta = True } \
|
|
|
|
|
|
|
|
{ state = state, emit = [toggleMaximizeFocusedWindow 0] }
|
|
|
|
| _ \ { state = state, emit = [] },
|
|
|
|
| _ \ { state = state, emit = [] },
|
|
|
|
|
|
|
|
|
|
|
|
view = state \
|
|
|
|
view = state \
|
|
|
|
|