///| Drawing the password dialog (auth.mbt) and its notice. ///| Colours the palette has no slot for: errors and warnings, readable on the card. fn auth_colors(p : @scene.ThemePalette) -> (@scene.Rgba, @scene.Rgba) { // A light card (bright foreground means dark theme). let dark = p.foreground.r.to_int() + p.foreground.g.to_int() + p.foreground.b.to_int() > 384 if dark { (@scene.Rgba::from_hex("#f87171"), @scene.Rgba::from_hex("#fbbf24")) } else { (@scene.Rgba::from_hex("#c62828"), @scene.Rgba::from_hex("#8a5a00")) } } ///| `text` broken into lines no wider than `max_w`, at word boundaries (long words by character). fn wrap_text(text : String, size : Int, bold : Bool, mono : Bool, max_w : Int) -> Array[String] { let out : Array[String] = [] for para in text.split("\n") { let mut line = "" for w in para.split(" ") { let word = w.to_string() let cand = if line == "" { word } else { line + " " + word } if @renderer.text_width(cand, size, bold, mono) <= max_w { line = cand continue } if line != "" { out.push(line) line = "" } // A word wider than the line: split it. let mut part = "" for c in word { let next = part + c.to_string() if @renderer.text_width(next, size, bold, mono) > max_w && part != "" { out.push(part) part = c.to_string() } else { part = next } } line = part } out.push(line) } out } ///| A padlock, for requests without an app icon. fn lock_glyph(x : Int, y : Int, s : Int, c : @scene.Rgba, bg : @scene.Rgba, ops : Array[@scene.DrawOp]) -> Unit { let bw = s * 5 / 8 let bh = s / 2 let bx = x + (s - bw) / 2 let by = y + s - bh - s / 10 let sw = bw * 5 / 8 let shx = x + (s - sw) / 2 ops.push(@scene.DrawOp::StrokeRect(@scene.Rect::new(shx, by - bh * 3 / 4, sw, bh), c, s / 12 + 1, sw / 2)) ops.push(@scene.DrawOp::FillRect(@scene.Rect::new(bx, by, bw, bh), c, s / 10)) ops.push(@scene.DrawOp::Circle(x + s / 2, by + bh * 2 / 5, s / 14 + 1, bg, true)) ops.push(@scene.DrawOp::FillRect(@scene.Rect::new(x + s / 2 - 1, by + bh * 2 / 5, 3, bh / 3), bg, 1)) } ///| A button: filled (the default action) or outlined; with a focus ring. fn auth_button( r : @scene.Rect, label : String, primary : Bool, focused : Bool, hover : Bool, enabled : Bool, p : @scene.ThemePalette, fs : Int, rad : Int, ops : Array[@scene.DrawOp], ) -> Unit { if primary { let a = p.accent let alpha = if enabled { if hover { 230 } else { 255 } } else { 120 } ops.push(@scene.DrawOp::FillRect(r, @scene.Rgba::new(a.r.to_int(), a.g.to_int(), a.b.to_int(), alpha), rad)) ops.push(@scene.DrawOp::Text(r.x + r.w / 2, r.y + r.h / 2, label, fs, p.accent_foreground, @scene.TextAlign::Center, true)) } else { if hover { ops.push(@scene.DrawOp::FillRect(r, p.surface_hover, rad)) } ops.push(@scene.DrawOp::StrokeRect(r, p.border, 1, rad)) ops.push(@scene.DrawOp::Text(r.x + r.w / 2, r.y + r.h / 2, label, fs, p.foreground, @scene.TextAlign::Center, false)) } if focused { ops.push(@scene.DrawOp::StrokeRect(@scene.Rect::new(r.x - 3, r.y - 3, r.w + 6, r.h + 6), p.accent, 2, rad + 3)) } } ///| A face outline (head, eyes, smile) centred at (cx, cy), `r` the head's radius. fn face_glyph(cx : Int, cy : Int, r : Int, c : @scene.Rgba, ops : Array[@scene.DrawOp]) -> Unit { ops.push(@scene.DrawOp::Circle(cx, cy, r, c, false)) ops.push(@scene.DrawOp::Circle(cx - r * 2 / 5, cy - r / 4, r / 8 + 1, c, true)) ops.push(@scene.DrawOp::Circle(cx + r * 2 / 5, cy - r / 4, r / 8 + 1, c, true)) ops.push(@scene.DrawOp::Line(cx - r / 2, cy + r / 4, cx - r / 5, cy + r / 2, c, 2)) ops.push(@scene.DrawOp::Line(cx - r / 5, cy + r / 2, cx + r / 5, cy + r / 2, c, 2)) ops.push(@scene.DrawOp::Line(cx + r / 5, cy + r / 2, cx + r / 2, cy + r / 4, c, 2)) } ///| Point `k` of 12 on a circle of radius `r` (clockwise from the top). fn ring_point(k : Int, r : Int) -> (Int, Int) { // sin and cos of k * 30 degrees, times 1000. let s = [0, 500, 866, 1000, 866, 500, 0, -500, -866, -1000, -866, -500] let c = [1000, 866, 500, 0, -500, -866, -1000, -866, -500, 0, 500, 866] (s[k % 12] * r / 1000, -c[k % 12] * r / 1000) } ///| A right-pointing (`down`: down-pointing) chevron centred at (cx, cy). fn chevron(cx : Int, cy : Int, s : Int, down : Bool, left : Bool, c : @scene.Rgba, ops : Array[@scene.DrawOp]) -> Unit { if down { ops.push(@scene.DrawOp::Line(cx - s, cy - s / 2, cx, cy + s / 2, c, 2)) ops.push(@scene.DrawOp::Line(cx, cy + s / 2, cx + s, cy - s / 2, c, 2)) } else if left { ops.push(@scene.DrawOp::Line(cx + s / 2, cy - s, cx - s / 2, cy, c, 2)) ops.push(@scene.DrawOp::Line(cx - s / 2, cy, cx + s / 2, cy + s, c, 2)) } else { ops.push(@scene.DrawOp::Line(cx - s / 2, cy - s, cx + s / 2, cy, c, 2)) ops.push(@scene.DrawOp::Line(cx + s / 2, cy, cx - s / 2, cy + s, c, 2)) } } ///| Draw the dialog (everything below it dimmed) and note where its controls are. fn ChandraCompositor::auth_ops(self : ChandraCompositor) -> Array[@scene.DrawOp] { let ops : Array[@scene.DrawOp] = [] let ui = match self.auth { Some(u) => u None => return ops } let d = ui.view let now = @sys.monotonic_ms() let p = self.theme.palette let (err_c, warn_c) = auth_colors(p) let fs = self.theme.font_size let rad = self.theme.radius + 2 let sw = self.output_w let sh = self.output_h ops.push( @scene.DrawOp::FillRect( @scene.Rect::new(0, 0, sw, sh), if d.face == Scanning { @scene.Rgba::new(255, 250, 242, 235) } else { @scene.Rgba::new(0, 0, 0, 150) }, 0, ), ) let w = (sw - 32).min(460) let pad = 24 let inner = w - pad * 2 let hover = self.auth_hit(ui) // Lay out top to bottom into `body` (card-relative y), then place the card. let body : Array[@scene.DrawOp] = [] let hits : Array[(@scene.Rect, @polkit.Focus)] = [] let mut y = pad // Header: icon, overline, title, subtitle. let icon_s = 48 let tx = pad + icon_s + 16 let tw = w - tx - pad let header_top = y let mut hy = y body.push(@scene.DrawOp::Text(tx, hy + 7, "AUTHENTICATION REQUIRED", fs - 3, p.accent, @scene.TextAlign::Left, true)) hy = hy + 18 let title_lines = wrap_text(d.title, fs + 3, true, false, tw) for l in title_lines { body.push(@scene.DrawOp::Text(tx, hy + (fs + 8) / 2, l, fs + 3, p.foreground, @scene.TextAlign::Left, true)) hy = hy + fs + 8 } hy = hy + 2 for l in wrap_text(d.subtitle, fs - 1, false, false, tw) { body.push(@scene.DrawOp::Text(tx, hy + (fs + 4) / 2, l, fs - 1, p.foreground_muted, @scene.TextAlign::Left, false)) hy = hy + fs + 4 } // Icon tile. let ix = pad let iy = header_top + 2 body.push(@scene.DrawOp::FillRect(@scene.Rect::new(ix, iy, icon_s, icon_s), p.surface_hover, 12)) if ui.icon != 0U { body.push(@scene.DrawOp::Image(@scene.Rect::new(ix + 6, iy + 6, icon_s - 12, icon_s - 12), ui.icon)) } else { lock_glyph(ix + 8, iy + 8, icon_s - 16, p.accent, p.surface_hover, body) } y = hy.max(iy + icon_s) + 14 // The command, as a shell would read it. if d.command != "" { let mfs = fs - 1 let lines = wrap_text(d.command, mfs, false, true, inner - 24) let shown = if lines.length() > 4 { lines[:4].to_array() } else { lines } if lines.length() > 4 { shown[3] = shown[3] + " …" } let lh = mfs + 6 let bh = shown.length() * lh + 16 body.push(@scene.DrawOp::FillRect(@scene.Rect::new(pad, y, inner, bh), p.surface_hover, rad)) body.push(@scene.DrawOp::FillRect(@scene.Rect::new(pad, y, 3, bh), p.accent, 1)) for i, l in shown { body.push(@scene.DrawOp::MonoText(pad + 14, y + 8 + i * lh + lh / 2, l, mfs, p.foreground, @scene.TextAlign::Left, false)) } y = y + bh + 14 } // Who authenticates. match d.user() { Some(u) => { let rh = 40 let r = @scene.Rect::new(pad, y, inner, rh) let many = d.users.length() > 1 if many { if hover == Some(User) { body.push(@scene.DrawOp::FillRect(r, p.surface_hover, rad)) } hits.push((r, User)) } let initial = if u.real_name != "" { u.real_name[:1].to_string() } else { u.name[:1].to_string() } body.push(@scene.DrawOp::Circle(pad + 20, y + rh / 2, 15, p.accent, true)) body.push(@scene.DrawOp::Text(pad + 20, y + rh / 2, initial.to_upper(), fs, p.accent_foreground, @scene.TextAlign::Center, true)) let name = if u.real_name != "" && u.real_name != u.name { u.real_name } else { u.name } body.push(@scene.DrawOp::Text(pad + 44, y + rh / 2 - 8, name, fs, p.foreground, @scene.TextAlign::Left, true)) let login = if u.uid == 0 { "root" } else { u.name } let sub = if many { login + " · account " + (d.user_sel + 1).to_string() + " of " + d.users.length().to_string() } else { login } body.push(@scene.DrawOp::Text(pad + 44, y + rh / 2 + 9, sub, fs - 2, p.foreground_muted, @scene.TextAlign::Left, false)) if many { chevron(pad + inner - 34, y + rh / 2, 5, false, true, p.foreground_muted, body) chevron(pad + inner - 14, y + rh / 2, 5, false, false, p.foreground_muted, body) if d.focus == User { body.push(@scene.DrawOp::StrokeRect(r, p.accent, 2, rad)) } } y = y + rh + 12 } None => () } // Face unlock: what the face module in the PAM stack is doing (docs/face-unlock.md). if d.face != NoFace { let rh = 48 let cx = pad + 25 let cy = y + rh / 2 let tint = match d.face { FaceFailed(_) => warn_c _ => p.accent } body.push(@scene.DrawOp::FillRect(@scene.Rect::new(pad, y, inner, rh), p.surface_hover, rad)) face_glyph(cx, cy, 13, if d.face is FaceFailed(_) { p.foreground_muted } else { p.foreground }, body) match d.face { Scanning => { // A ring of dots sweeping round the face. let t = ((now - d.face_at) / 70UL).to_int() for k = 0; k < 12; k = k + 1 { let a = (k + t) % 12 let (dx, dy) = ring_point(a, 19) let alpha = 40 + k * 18 body.push(@scene.DrawOp::Circle(cx + dx, cy + dy, 2, @scene.Rgba::new(p.accent.r.to_int(), p.accent.g.to_int(), p.accent.b.to_int(), alpha), true)) } } Matched => { body.push(@scene.DrawOp::Circle(cx + 13, cy + 11, 8, p.accent, true)) body.push(@scene.DrawOp::Line(cx + 9, cy + 11, cx + 12, cy + 14, p.accent_foreground, 2)) body.push(@scene.DrawOp::Line(cx + 12, cy + 14, cx + 17, cy + 8, p.accent_foreground, 2)) } FaceFailed(_) => { body.push(@scene.DrawOp::Circle(cx + 13, cy + 11, 8, warn_c, true)) body.push(@scene.DrawOp::Line(cx + 10, cy + 8, cx + 16, cy + 14, p.surface_popup, 2)) body.push(@scene.DrawOp::Line(cx + 16, cy + 8, cx + 10, cy + 14, p.surface_popup, 2)) } NoFace => () } let (title, sub) = match d.face { Scanning => ("Looking for your face…", "Or type your password") Matched => ("Face recognized", "") FaceFailed(why) => (why, "Type your password instead") NoFace => ("", "") } let tx = pad + 54 if sub == "" { body.push(@scene.DrawOp::Text(tx, cy, title, fs, tint, @scene.TextAlign::Left, true)) } else { body.push(@scene.DrawOp::Text(tx, cy - 8, title, fs, tint, @scene.TextAlign::Left, true)) body.push(@scene.DrawOp::Text(tx, cy + 10, sub, fs - 2, p.foreground_muted, @scene.TextAlign::Left, false)) } y = y + rh + 12 } // The prompt and the field. body.push(@scene.DrawOp::Text(pad, y + 7, d.prompt, fs - 1, p.foreground_muted, @scene.TextAlign::Left, true)) y = y + 20 let fh = 40 let field = @scene.Rect::new(pad, y, inner, fh) let enabled = d.editable() body.push(@scene.DrawOp::FillRect(field, p.surface, rad)) let edge = if d.error != "" && d.typed() == 0 { err_c } else if d.focus == Field { p.accent } else { p.border } body.push(@scene.DrawOp::StrokeRect(field, edge, if d.focus == Field || d.error != "" { 2 } else { 1 }, rad)) hits.push((@scene.Rect::new(pad, y, inner - 70, fh), Field)) // Show / Hide (not for prompts that show the answer anyway). let text_right = if d.echo { pad + inner - 12 } else { pad + inner - 76 } if !d.echo { let rr = @scene.Rect::new(pad + inner - 68, y + 6, 60, fh - 12) if hover == Some(Reveal) || d.focus == Reveal { body.push(@scene.DrawOp::FillRect(rr, p.surface_hover, rad - 2)) } if d.focus == Reveal { body.push(@scene.DrawOp::StrokeRect(rr, p.accent, 2, rad - 2)) } body.push(@scene.DrawOp::Text(rr.x + rr.w / 2, rr.y + rr.h / 2, if d.reveal { "Hide" } else { "Show" }, fs - 1, p.accent, @scene.TextAlign::Center, true)) hits.push((rr, Reveal)) } body.push(@scene.DrawOp::PushClip(@scene.Rect::new(pad + 8, y, text_right - pad - 8, fh))) let cy = y + fh / 2 let mut caret_x = pad + 13 if d.typed() == 0 { let hint = match d.phase { Starting => if d.face == Scanning { "Type your password" } else { "Preparing…" } Failed => "Type your password, or press Enter to try again" _ => if d.echo { "Type your answer" } else { "Type your password" } } body.push(@scene.DrawOp::Text(pad + 18, cy, hint, fs, @scene.Rgba::new(p.foreground_muted.r.to_int(), p.foreground_muted.g.to_int(), p.foreground_muted.b.to_int(), 150), @scene.TextAlign::Left, false)) } else if d.echo || d.reveal { // Keep the end of long text in view. let t = d.field_text() let tw2 = @renderer.text_width(t, fs + 1, false, false) let avail = text_right - pad - 22 let x0 = if tw2 > avail { pad + 14 - (tw2 - avail) } else { pad + 14 } body.push(@scene.DrawOp::Text(x0, cy, t, fs + 1, if enabled { p.foreground } else { p.foreground_muted }, @scene.TextAlign::Left, false)) caret_x = x0 + tw2 + 2 } else { let n = d.typed() let step = 14 let avail = text_right - pad - 22 let total = n * step let x0 = if total > avail { pad + 14 - (total - avail) } else { pad + 14 } for i = 0; i < n; i = i + 1 { body.push(@scene.DrawOp::Circle(x0 + i * step + 5, cy, 4, if enabled { p.foreground } else { p.foreground_muted }, true)) } caret_x = x0 + total + 2 } if d.focus == Field && enabled { body.push(@scene.DrawOp::FillRect(@scene.Rect::new(caret_x, cy - fs / 2 - 2, 2, fs + 4), p.accent, 0)) } body.push(@scene.DrawOp::PopClip) y = y + fh + 10 // Status: busy, Caps Lock, error, PAM's information. let status : Array[(String, @scene.Rgba, Bool)] = [] if d.phase == Checking { status.push(("Checking…", p.foreground_muted, true)) } if d.caps && !d.echo { status.push(("Caps Lock is on", warn_c, false)) } if d.error != "" { status.push((d.error, err_c, false)) } if d.phase == Failed { status.push(("Nothing was checked. Press Enter or Try again to start over.", p.foreground_muted, false)) } if d.info != "" { status.push((d.info, p.foreground, false)) } for s in status { let lines = wrap_text(s.0, fs - 1, false, false, inner - 22) // A marker: a spinner while busy, else a dot in the line's colour. if s.2 { let t = ((now - ui.opened) / 90UL).to_int() for k = 0; k < 8; k = k + 1 { let ang = (k + t) % 8 let (dx, dy) = match ang { 0 => (0, -6) 1 => (4, -4) 2 => (6, 0) 3 => (4, 4) 4 => (0, 6) 5 => (-4, 4) 6 => (-6, 0) _ => (-4, -4) } let a = 50 + k * 29 body.push(@scene.DrawOp::Circle(pad + 6 + dx, y + 9 + dy, 2, @scene.Rgba::new(p.accent.r.to_int(), p.accent.g.to_int(), p.accent.b.to_int(), a), true)) } } else { body.push(@scene.DrawOp::Circle(pad + 6, y + 9, 3, s.1, true)) } for l in lines { body.push(@scene.DrawOp::Text(pad + 18, y + 9, l, fs - 1, s.1, @scene.TextAlign::Left, false)) y = y + fs + 5 } y = y + 3 } y = y + 6 // Details. if d.details_open { let rows : Array[(String, String)] = d.details.copy() if d.message != "" && d.title != d.message { rows.push(("polkit says", d.message)) } let lw = 104 let dh0 = y y = y + 10 let rows_ops : Array[@scene.DrawOp] = [] for r in rows { let vl = wrap_text(r.1, fs - 2, false, r.0 == "Action" || r.0 == "Unit", inner - lw - 24) rows_ops.push(@scene.DrawOp::Text(pad + 12, y + 8, r.0, fs - 2, p.foreground_muted, @scene.TextAlign::Left, true)) for l in vl { if r.0 == "Action" || r.0 == "Unit" { rows_ops.push(@scene.DrawOp::MonoText(pad + 12 + lw, y + 8, l, fs - 2, p.foreground, @scene.TextAlign::Left, false)) } else { rows_ops.push(@scene.DrawOp::Text(pad + 12 + lw, y + 8, l, fs - 2, p.foreground, @scene.TextAlign::Left, false)) } y = y + fs + 3 } y = y + 4 } y = y + 6 body.push(@scene.DrawOp::FillRect(@scene.Rect::new(pad, dh0, inner, y - dh0), p.surface_hover, rad)) body.append(rows_ops) y = y + 12 } // Bottom row: Details toggle on the left, Cancel and Authenticate on the right. let bh = 36 let dl = if d.details_open { "Hide details" } else { "Details" } let dw = @renderer.text_width(dl, fs - 1, false, false) + 30 let dr = @scene.Rect::new(pad - 6, y, dw, bh) if hover == Some(Details) { body.push(@scene.DrawOp::FillRect(dr, p.surface_hover, rad)) } chevron(pad + 6, y + bh / 2, 4, d.details_open, false, p.foreground_muted, body) body.push(@scene.DrawOp::Text(pad + 18, y + bh / 2, dl, fs - 1, p.foreground_muted, @scene.TextAlign::Left, false)) if d.focus == Details { body.push(@scene.DrawOp::StrokeRect(dr, p.accent, 2, rad)) } hits.push((dr, Details)) let main = d.main_label() let allow_w = @renderer.text_width(main, fs, true, false) + 32 let cancel_w = @renderer.text_width("Cancel", fs, false, false) + 32 let ar = @scene.Rect::new(pad + inner - allow_w, y, allow_w, bh) let cr = @scene.Rect::new(ar.x - 10 - cancel_w, y, cancel_w, bh) auth_button(cr, "Cancel", false, d.focus == Cancel, hover == Some(Cancel), true, p, fs, rad, body) auth_button(ar, main, true, d.focus == Allow, hover == Some(Allow), d.main_enabled(), p, fs, rad, body) hits.push((cr, Cancel)) hits.push((ar, Allow)) y = y + bh + pad // Place the card in the middle (shaking after a failure) with a soft shadow. let h = y let cx = (sw - w) / 2 + d.shake_offset(now) let avail_h = if self.osk_visible { sh - self.osk_height() } else { sh } let cyy = ((avail_h - h) / 2).max(8) for k = 1; k <= 4; k = k + 1 { ops.push(@scene.DrawOp::FillRect(@scene.Rect::new(cx - k * 2, cyy - k * 2 + 6, w + k * 4, h + k * 4), @scene.Rgba::new(0, 0, 0, 22), rad + 6 + k * 2)) } let opaque = @scene.Rgba::new(p.surface_popup.r.to_int(), p.surface_popup.g.to_int(), p.surface_popup.b.to_int(), 255) ops.push(@scene.DrawOp::FillRect(@scene.Rect::new(cx, cyy, w, h), opaque, rad + 6)) ops.push(@scene.DrawOp::StrokeRect(@scene.Rect::new(cx, cyy, w, h), p.border, 1, rad + 6)) ops.append(offset_ops_all(body, cx, cyy)) ui.hits.clear() for hit in hits { let r = hit.0 ui.hits.push((@scene.Rect::new(r.x + cx, r.y + cyy, r.w, r.h), hit.1)) } ops } ///| Move every op by (dx, dy). fn offset_ops_all(ops : Array[@scene.DrawOp], dx : Int, dy : Int) -> Array[@scene.DrawOp] { let mv = fn(r : @scene.Rect) { @scene.Rect::new(r.x + dx, r.y + dy, r.w, r.h) } ops.map(op => match op { FillRect(r, c, rad) => @scene.DrawOp::FillRect(mv(r), c, rad) StrokeRect(r, c, w, rad) => @scene.DrawOp::StrokeRect(mv(r), c, w, rad) Line(x0, y0, x1, y1, c, w) => @scene.DrawOp::Line(x0 + dx, y0 + dy, x1 + dx, y1 + dy, c, w) Circle(x, y, r, c, f) => @scene.DrawOp::Circle(x + dx, y + dy, r, c, f) Text(x, y, t, s, c, a, b) => @scene.DrawOp::Text(x + dx, y + dy, t, s, c, a, b) MonoText(x, y, t, s, c, a, b) => @scene.DrawOp::MonoText(x + dx, y + dy, t, s, c, a, b) PushClip(r) => @scene.DrawOp::PushClip(mv(r)) PopClip => PopClip Image(r, h) => @scene.DrawOp::Image(mv(r), h) }) } ///| The notice about the dialog itself (it couldn't start, it stopped), at the top of the screen. fn ChandraCompositor::auth_notice_ops(self : ChandraCompositor) -> Array[@scene.DrawOp] { let ops : Array[@scene.DrawOp] = [] let n = match self.auth_notice { Some(n) => n None => return ops } let p = self.theme.palette let (err_c, _) = auth_colors(p) let fs = self.theme.font_size let rad = self.theme.radius + 4 let w = (self.output_w - 32).min(560) let pad = 16 let lines = wrap_text(n.text, fs, false, false, w - pad * 2 - 28) let lh = fs + 6 let h = pad * 2 + 20 + lines.length() * lh + 6 + fs let x = (self.output_w - w) / 2 let y = 16 for k = 1; k <= 3; k = k + 1 { ops.push(@scene.DrawOp::FillRect(@scene.Rect::new(x - k * 2, y - k * 2 + 4, w + k * 4, h + k * 4), @scene.Rgba::new(0, 0, 0, 22), rad + k * 2)) } let opaque = @scene.Rgba::new(p.surface_popup.r.to_int(), p.surface_popup.g.to_int(), p.surface_popup.b.to_int(), 255) ops.push(@scene.DrawOp::FillRect(@scene.Rect::new(x, y, w, h), opaque, rad)) ops.push(@scene.DrawOp::StrokeRect(@scene.Rect::new(x, y, w, h), err_c, 2, rad)) ops.push(@scene.DrawOp::FillRect(@scene.Rect::new(x, y, 4, h), err_c, 2)) lock_glyph(x + pad, y + pad - 2, 20, err_c, opaque, ops) ops.push(@scene.DrawOp::Text(x + pad + 28, y + pad + 8, "PASSWORD DIALOG", fs - 3, err_c, @scene.TextAlign::Left, true)) let mut ty = y + pad + 20 for l in lines { ops.push(@scene.DrawOp::Text(x + pad + 28, ty + lh / 2, l, fs, p.foreground, @scene.TextAlign::Left, false)) ty = ty + lh } ops.push(@scene.DrawOp::Text(x + pad + 28, ty + 6 + fs / 2, "Click to dismiss", fs - 2, p.foreground_muted, @scene.TextAlign::Left, false)) n.rect = @scene.Rect::new(x, y, w, h) ops }