Files
chandra/components/rotate/gen/interface/chandra/desktop/plasmoid/stub.mbt
T
nandi c790f96e58
CI / test (push) Failing after 52s
Lock: add session lock from power button and chandra-ctl lock
- Lock the session from the power button or `chandra-ctl lock`
- Unlock with a face or the password; the password always works
- Add compositor lock module with tests, and a polkit unlock policy (org.chandra.unlock)
- Document the lock flow in docs/lock.md and link it from the README
- Add generated interface bindings for the compositor and widget components
2026-11-29 03:24:46 -08:00

46 lines
1.2 KiB
MoonBit

///| Implementation of `chandra:desktop/plasmoid` for display rotation ("Rot"):
/// a compact panel button that rotates the output 90° clockwise on click.
///|
pub fn info() -> PlasmoidInfo {
{
id: "org.chandra.rotate",
name: "Rotate",
preferred: { w: 44, h: 34 },
min_width: 34,
stretch: false,
}
}
///|
pub fn render(size : @types.Size) -> Array[@types.DrawOp] {
let t = @theme.get_tokens()
let w = size.w.reinterpret_as_int()
let h = size.h.reinterpret_as_int()
let on = @rotation.current() != 0U
let bg = if on { t.palette.accent } else { t.palette.surface_hover }
let fg = if on { t.palette.accent_foreground } else { t.palette.foreground }
let fs = t.font_size.reinterpret_as_int()
let rfs = if fs - 2 < 10 { 10 } else { fs - 2 }
[
@ui.fill_rect(@ui.rect(0, 0, w, h), bg, radius=t.radius.reinterpret_as_int()),
@ui.text(w / 2, h / 2, "Rot", rfs, fg, align=CENTER, bold=true),
]
}
///|
pub fn popup() -> PopupSurface? {
None
}
///|
pub fn on_event(target : Surface, event : @types.InputEvent) -> Bool {
match (target, event) {
(WIDGET, PointerDown(_)) => {
@rotation.set_rotation((@rotation.current() + 1U) % 4U)
true
}
_ => false
}
}