moon-plasma / moonplasma / MoonPlasma / Moon Plasma become chandra / Chandra everywhere: the WIT package (chandra:desktop, chandra:host, chandra:wm), the MoonBit module (chandra/desktop) and generated bindings, the Rust host, identifiers (ChandraCompositor), the session script (chandra-session) and desktop entry (chandra.desktop), config and data paths ($XDG_CONFIG_HOME/chandra, share/chandra/modules), env vars (CHANDRA_*), UI strings, docs and tests. The test fixture components are rebuilt against the renamed WIT. Saved panel.edn and state.edn are still read from the old $XDG_CONFIG_HOME/moon-plasma until the first save writes the new copy. The remote repository keeps its experiments/moon-plasma name for now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DPL5hi3L9oVBoRd373Qr4n
This commit is contained in:
323 files changed
+1055
-1013
No files matched your search
@@ -0,0 +1,62 @@
|
||||
///| Implementation of `chandra:desktop/plasmoid` for the layout toggle:
|
||||
/// a two-segment panel switch, "Tile | Float", that flips the window manager between
|
||||
/// tiling and floating. Monocle (set elsewhere) shows neither segment lit; a click
|
||||
/// then returns to tiling.
|
||||
|
||||
///| Mode indices follow the host's layout list: 0 Tiling, 1 Monocle, 2 Floating.
|
||||
let tiling : UInt = 0
|
||||
|
||||
///|
|
||||
let floating : UInt = 2
|
||||
|
||||
///|
|
||||
pub fn info() -> PlasmoidInfo {
|
||||
{
|
||||
id: "org.chandra.layout-toggle",
|
||||
name: "Tile / Float",
|
||||
preferred: { w: 120, h: 34 },
|
||||
min_width: 90,
|
||||
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 r = t.radius.reinterpret_as_int()
|
||||
let fs = t.font_size.reinterpret_as_int()
|
||||
let cur = @layout.current_layout()
|
||||
let half = w / 2
|
||||
let ops : Array[@types.DrawOp] = [
|
||||
@ui.fill_rect(@ui.rect(0, 0, w, h), t.palette.surface_hover, radius=r),
|
||||
]
|
||||
if cur == tiling {
|
||||
ops.push(@ui.fill_rect(@ui.rect(0, 0, half, h), t.palette.accent, radius=r))
|
||||
} else if cur == floating {
|
||||
ops.push(@ui.fill_rect(@ui.rect(half, 0, w - half, h), t.palette.accent, radius=r))
|
||||
}
|
||||
let on_l = if cur == tiling { t.palette.accent_foreground } else { t.palette.foreground }
|
||||
let on_r = if cur == floating { t.palette.accent_foreground } else { t.palette.foreground }
|
||||
ops.push(@ui.text(half / 2, h / 2, "Tile", fs, on_l, align=CENTER, bold=cur == tiling))
|
||||
ops.push(@ui.text(half + (w - half) / 2, h / 2, "Float", fs, on_r, align=CENTER, bold=cur == floating))
|
||||
ops
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn popup() -> PopupSurface? {
|
||||
None
|
||||
}
|
||||
|
||||
///|
|
||||
pub fn on_event(target : Surface, event : @types.InputEvent) -> Bool {
|
||||
match (target, event) {
|
||||
(WIDGET, PointerDown(_)) => {
|
||||
// Float -> tile; anything else (tiling, monocle) -> float.
|
||||
@layout.set_layout(if @layout.current_layout() == floating { tiling } else { floating })
|
||||
true
|
||||
}
|
||||
_ => false
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user