rustploy-gui 0.1.2

Rustploy — desktop client (glacier-ui) for the Rustploy PaaS daemon
// O app Rustploy: a raiz do arquivo é o `app(...)`, e as telas — a janela
// principal e as cinco janelas auxiliares — são filhas dele (glacier-ui 0.117+).
app(
  id = rustploy,
  single_instance = true,
  remember_geometry = true,
  size = "1280 820",
  min_size = "480 680",
  icon = "views/assets/rustploy.png",
  decorations = false,
  font = "JetBrains Mono",
  application_id = "rustploy-gui",
  antialiasing = false,
  toast_period = 250,
) {
  // Declarações GLOBAIS: valem para todas as janelas (cada janela é um motor
  // isolado e as carrega).
  resources {
    link(rel = theme, href = "views/styles/theme.json")
    link(rel = stylesheet, href = "views/styles/app.gss")

    // JetBrains Mono, embutida no binário de release (src/embedded.rs).
    font(src = "assets/fonts/JetBrainsMono-Regular.ttf", family = "JetBrains Mono")
    font(src = "assets/fonts/JetBrainsMono-Bold.ttf")

    tray(icon = "views/assets/rustploy.png", tooltip = Rustploy) {
      item(label = "Open Rustploy", on_click = tray:open)
      check(label = Notifications, checked = @__notifications, on_click = notifications:toggle)
      separator
      item(label = "Quit Rustploy", on_click = tray:quit)
    }
  }

  // A janela principal: mostra o Login ou o Shell (app conectado), com a
  // titlebar customizada. Script: scripts/app.luau.
  screen(name = app, initial = true, title = Rustploy) {
    resources {
      link(rel = import, href = login.gvb, as = Login)
      link(rel = import, href = shell.gvb, as = Shell)

      style """
        /* ── Resize handles (6px frame around the borderless window) ───────────── */
        .rz_top    { width: fill; height: 6; }
        .rz_bottom { width: fill; height: 6; }
        .rz_mid    { width: fill; height: fill; }
        .rz_body   { width: fill; height: fill; }
        .rz_corner { width: 6; height: fill; }
        .rz_h      { width: fill; height: fill; cursor: resize-v; }
        .rz_v      { width: 6; height: fill; cursor: resize-h; }
        /* Cursores diagonais dos cantos (2ª classe sobre .rz_corner) */
        .rz_nw     { cursor: resize-nw; }
        .rz_ne     { cursor: resize-ne; }
        .rz_sw     { cursor: resize-sw; }
        .rz_se     { cursor: resize-se; }
        /* ── Custom titlebar (borderless window) ──────────────────────────────── */
        .titlebar       { width: fill; height: 32; background: var(--surface); align-y: center; }
        .titlebar_drag  { width: fill; height: fill; align-y: center; padding: 0 0 0 16; spacing: 9; }
        .titlebar_dot   { size: 10; color: var(--blue); }
        .titlebar_title { size: 12; bold: true; color: var(--muted); }
        .win_btn        { width: 48; padding: 5 0; color: var(--border); text-align: center; }
        .win_close      { width: 48; padding: 5 0; color: var(--danger); text-align: center; }
      """

      script(src = "scripts/app.luau")
    }

    column(class = screen) {
      // ── Top edge + top corners (north / nw / ne) ───────────────────────────
      row(class = rz_top) {
        column(class = "rz_corner rz_nw", on_press = window:resize:nw)
        column(class = rz_h, on_press = window:resize:n)
        column(class = "rz_corner rz_ne", on_press = window:resize:ne)
      }

      // ── Middle band: left edge | body | right edge (west / east) ────────────
      row(class = rz_mid) {
        column(class = rz_v, on_press = window:resize:w)

        column(class = rz_body) {
          // ── Custom titlebar ───────────────────────────────────────────
          row(class = titlebar) {
            row(
              class = titlebar_drag,
              on_press = window:drag,
              on_double_click = window:maximize,
            ) {
              text(class = titlebar_dot, content = "●")
              text(class = titlebar_title, content = "Rustploy")
            }

            button(class = win_btn, on_click = window:minimize, text = "—")
            button(class = win_btn, on_click = window:maximize, text = "▢")
            button(class = win_close, on_click = window:close, text = "✕")
          }

          if @screen == "login" {
            Login
          } else {
            Shell
          }
        }

        column(class = rz_v, on_press = window:resize:e)
      }

      // ── Bottom edge + bottom corners (south / sw / se) ──────────────────────
      row(class = rz_bottom) {
        column(class = "rz_corner rz_sw", on_press = window:resize:sw)
        column(class = rz_h, on_press = window:resize:s)
        column(class = "rz_corner rz_se", on_press = window:resize:se)
      }
    }
  }

  screen(name = log, src = "log_window.gvb")
  screen(name = new_job, src = "new_job_window.gvb")
  screen(name = new_service, src = "new_service_window.gvb")
  screen(name = new_project, src = "new_project_form.gvb")
  screen(name = new_registry_token, src = "new_registry_token_window.gvb")
}