LingSys
↓ 0 downloadsYour machine's memory, GPU, motherboard and network, drawn and played in the Ling design system: LingSys, a small build for USB liquid-cooler displays, LingNet for IPv4/IPv6, DNS and packets, and a LingOS edition. 64-bit and 32-bit Windows builds included.
Keywords system-monitor, visualization, network, ipv6, gpu, lcd, lingos, ling
lingfu install LingSysCode / Files (48)
src/80_menu_hud.ling
# ───────────────────────────── menu and hud ──────────────────────────────────
# The menu sits in the bottom 66 px: five section buttons, then the views of the current section.
# Everything is drawn from menu_geom/tab_rect, and the same functions answer the mouse.
bind VIEW_COUNT = [1, 4, 4, 3, 3]
bind MENU_H = 66.0
# [x of first button, y, button width, button height, gap]
fn menu_geom(W, FH) {
return [18.0, FH - 62.0, clamp(W * 0.088, 92.0, 150.0), 26.0, 8.0]
}
# [x, y, w, h] of view tab j of a section
fn tab_rect(sec, j, W, FH) {
bind g = menu_geom(W, FH)
bind x = g[0] + 5.0 * (g[2] + g[4]) + 18.0
bind names = SUB_NAME[sec]
bind k = 0
while k < j {
bind x = x + text_w(names[k], 11.0) + 32.0
bind k = k + 1
}
return [x, g[1] + 2.0, text_w(names[j], 11.0) + 26.0, g[3] - 4.0]
}
fn inside(mx, my, r) {
if mx >= r[0] {
if mx <= r[0] + r[2] {
if my >= r[1] {
if my <= r[1] + r[3] { return 1 }
}
}
}
return 0
}
# -1 nothing, 0..4 a section button, 10 + j a view tab
fn menu_hit(mx, my, W, FH, sec) {
bind g = menu_geom(W, FH)
bind i = 0
while i < 5 {
if inside(mx, my, [g[0] + i * (g[2] + g[4]), g[1], g[2], g[3]]) == 1 { return i }
bind i = i + 1
}
if VIEW_COUNT[sec] > 1 {
bind j = 0
while j < VIEW_COUNT[sec] {
if inside(mx, my, tab_rect(sec, j, W, FH)) == 1 { return 10 + j }
bind j = j + 1
}
}
return 0 - 1
}
fn menu_bar(Z, sec, view) {
bind W = Z[Z_W]
bind FH = Z[Z_FH]
bind sat = Z[Z_SAT]
bind hs = Z[Z_HS]
bind mx = Z[Z_MX]
bind my = Z[Z_MY]
bind g = menu_geom(W, FH)
bind i = 0
while i < 5 {
bind r = [g[0] + i * (g[2] + g[4]), g[1], g[2], g[3]]
bind k = SEC_HUE[i]
bind hov = inside(mx, my, r)
bind on = 0
if i == sec { bind on = 1 }
bind fl = 30.0 + 18.0 * hov
if on == 1 { bind fl = 82.0 }
col(k, sat * 0.8, fl, hs)
brect(r[0], r[1], 1.0, 0.0, 0.0, r[2], r[3])
if on == 1 {
col(k, sat * 0.8, 26.0, hs)
bhatch(r[0], r[1], 1.0, 2.0, 2.0, r[2] - 2.0, r[3] - 2.0, 5.0)
col(k, sat, 84.0, hs)
bline(r[0], r[1] + r[3] + 4.0, 1.0, 0.0, 0.0, r[2], 0.0)
}
bind lab = num_str(i) + " " + SEC_NAME[i]
bind tl = 52.0 + 24.0 * hov
if on == 1 { bind tl = 94.0 }
col(k, sat, tl, hs)
daemon_text(lab, r[0] + (r[2] - text_w(lab, 12.0)) / 2.0, r[1] + r[3] / 2.0, 12.0)
bind i = i + 1
}
if VIEW_COUNT[sec] > 1 {
bind k = SEC_HUE[sec]
bind j = 0
while j < VIEW_COUNT[sec] {
bind r = tab_rect(sec, j, W, FH)
bind hov = inside(mx, my, r)
bind tl = 46.0 + 24.0 * hov
if j == view {
bind tl = 90.0
col(k, sat, 80.0, hs)
bline(r[0], r[1] + r[3] + 3.0, 1.0, 0.0, 0.0, r[2], 0.0)
bline(r[0], r[1] + r[3] + 6.0, 1.0, 0.0, 0.0, r[2], 0.0)
}
col(k, sat * 0.9, tl, hs)
daemon_text(SUB_NAME[sec][j], r[0] + 13.0, r[1] + r[3] / 2.0, 11.0)
bind j = j + 1
}
}
}
fn hud(Z, sec, view, auto, mute, pluck, alOn) {
bind W = Z[Z_W]
bind FH = Z[Z_FH]
bind sat = Z[Z_SAT]
bind hs = Z[Z_HS]
bind k = SEC_HUE[sec]
col(2, sat, 72.0, hs)
daemon_text("HATCHSYS", 18.0, 26.0, 20.0)
col(k, sat, 66.0, hs)
bind mode = "SIM"
if Z[Z_LIVE] == 1 { bind mode = "LIVE" }
if Z[Z_LIVE] == 2 { bind mode = "STALE" }
if Z[Z_LIVE] == 3 { bind mode = "PARTIAL" }
bind tag = SEC_NAME[sec] + " " + SUB_NAME[sec][view] + " " + mode
if sec == 2 {
bind gp = Z[Z_D][D_GPU]
bind tag = tag + " GPU " + num_str(gp[GP_SEL]) + " OF " + num_str(gp[GP_N])
}
if auto == 1 { bind tag = tag + " AUTO" }
if pluck == 1 { bind tag = tag + " PLUCK" }
if alOn == 0 { bind tag = tag + " NO ALERTS" }
if mute == 1 { bind tag = tag + " MUTE" }
daemon_text(tag, 18.0, 52.0, 13.0)
ink(52.0)
daemon_text(Z[Z_STAT], 18.0, FH - 18.0, 13.0)
bind keyhint = "0-4 SECTION TAB VIEW A AUTO P PLUCK N ALERTS H HUD M MUTE ESC"
if sec == 2 { bind keyhint = "UP/DN GPU " + keyhint }
ink(40.0)
daemon_text(keyhint, W - text_w(keyhint, 10.0) - 18.0, FH - 18.0, 10.0)
}