A new style desktop shell for Windows 11: menu bar, Dock, Finder, Spotlight, Control Center and Liquid Glass, in native C++.
Rust
//! seletor.cpp: o seletor de apps (Cmd+Tab do Mac) no Alt+Tab: um ícone por app, na ordem de uso, num painel de vidro
//! no meio da tela; o escolhido num quadrado com o nome embaixo. Segurando o Alt: Tab avança, Shift+Tab volta, setas
//! andam, Q encerra o escolhido, H oculta, Esc cancela; soltar o Alt troca. Sequoia (medidas das capturas), Tahoe (guia
//! seção 37 a ~78%), Leopard (painel preto translúcido do 10.5, ícones grandes).
#![allow(dead_code)]
use std::collections::HashMap;
use comum::windows::core::*;
use comum::windows::Win32::Foundation::*;
use comum::windows::Win32::Graphics::Direct2D::*;
use comum::windows::Win32::Graphics::DirectWrite::*;
use comum::windows::Win32::Graphics::Dwm::*;
use comum::windows::Win32::Graphics::Gdi::{BeginPaint, EndPaint, GetMonitorInfoW, MonitorFromPoint, MONITORINFO, MONITOR_DEFAULTTOPRIMARY, PAINTSTRUCT};
use comum::windows::Win32::UI::Input::KeyboardAndMouse::*;
use comum::windows::Win32::UI::WindowsAndMessaging::*;
use comum::*;
use crate::{anim, apps, backdrop, liquid, log, shell, ui};
const RADIUS: f32 = 15.0;
const T_SHOW: usize = 1;
const T_SHOWNOW: usize = 2;
const WM_SHOWNOW: u32 = WM_APP + 31; // o vidro já está na tela: mostra as janelas
#[derive(Clone, Copy)]
struct M {
icon: f32,
pitch: f32,
tile: f32,
pad_x: f32,
pad_top: f32,
panel_h: f32,
label_cy: f32,
}
fn metricas() -> M {
if liquid::on() {
// o usuário achou grande (16/11/2026): o guia em ~78%
M { icon: 100.0 * 0.805, pitch: 105.0, tile: 100.0, pad_x: 19.0, pad_top: 19.0, panel_h: 138.0, label_cy: 129.0 }
} else if liquid::leopard() {
M { icon: 96.0, pitch: 118.0, tile: 114.0, pad_x: 16.0, pad_top: 14.0, panel_h: 160.0, label_cy: 143.0 }
} else {
M { icon: 78.0, pitch: 101.5, tile: 103.0, pad_x: 13.5, pad_top: 18.5, panel_h: 141.0, label_cy: 132.5 }
}
}
struct Entry {
id: String,
name: String,
bmp: Option<ID2D1Bitmap>,
mac: bool,
}
struct S {
wnd: HWND,
back: HWND,
glass: bool,
s: ui::GpuSurface,
list: Vec<Entry>,
sel: usize,
frente_na_lista: bool,
active: bool,
visible: bool,
k: f32,
m: M,
/// ícone de cada app, guardado entre uma abertura e outra
cache: HashMap<String, Option<ID2D1Bitmap>>,
cache_rt: usize,
foto: Option<(f32, f32)>,
}
static SS: Global<Option<S>> = Global::new(None);
fn s() -> &'static mut S {
SS.get().get_or_insert_with(|| S { wnd: HWND::default(), back: HWND::default(), glass: false, s: ui::GpuSurface::default(), list: Vec::new(), sel: 0, frente_na_lista: false, active: false, visible: false, k: 1.0, m: metricas(), cache: HashMap::new(), cache_rt: 0, foto: None })
}
fn sc() -> f32 {
if s().foto.is_some() {
ui::foto_scale()
} else {
ui::scale(s().wnd)
}
}
fn panel_r() -> f32 {
if liquid::on() {
s().m.panel_h * 0.4 // Tahoe: cantos de ~40% da altura
} else {
RADIUS
}
}
fn panel_w() -> f32 {
let m = &s().m;
m.pad_x * 2.0 + s().list.len() as f32 * m.pitch + (m.tile - m.pitch)
}
/// ordem de uso: a ordem das janelas na tela (a de cima é a mais recente), depois os minimizados
fn collect() {
let st = s();
st.list.clear();
apps::refresh();
let mut order: Vec<String> = Vec::new();
let mut add = |id: &str| {
if !order.iter().any(|x| x == id) {
order.push(id.to_string());
}
};
unsafe {
let me = comum::windows::Win32::System::Threading::GetCurrentProcessId();
let mut h = GetTopWindow(None).unwrap_or_default();
while !h.0.is_null() {
let mut pid = 0;
GetWindowThreadProcessId(h, Some(&mut pid));
if IsWindowVisible(h).as_bool() && !IsIconic(h).as_bool() && pid != me {
if let Some(a) = apps::of_window(h) {
if !a.wins.is_empty() {
add(&a.id);
}
}
}
h = GetWindow(h, GW_HWNDNEXT).unwrap_or_default();
}
}
for a in apps::list().iter().filter(|a| !a.wins.is_empty()) {
add(&a.id); // minimizados
}
// o Finder está sempre na lista, como no Mac; seletor_finder=0: só com janela aberta (issue #4)
if shell::setting("seletor_finder", "1") != "0" {
for a in apps::list().iter().filter(|a| a.finder) {
add(&a.id);
}
}
// fechou a janela da frente: ninguém está "na frente" e o 1º da lista já é o app anterior (issue #4)
let fg = unsafe { GetForegroundWindow() };
st.frente_na_lista = !order.is_empty() && apps::of_window(fg).is_some_and(|a| a.id == order[0]);
fill(order);
}
fn fill(order: Vec<String>) {
let st = s();
for id in order {
let Some(a) = apps::find_by_id(&id) else { continue };
apps::ensure_icon(a, 128);
st.list.push(Entry { id: a.id.clone(), name: a.name.clone(), bmp: None, mac: a.mac });
}
}
fn bmp_of(rt: &ID2D1RenderTarget, i: usize) -> Option<ID2D1Bitmap> {
let st = s();
let k = rt.as_raw() as usize;
if st.cache_rt != k {
st.cache.clear();
st.cache_rt = k;
}
let id = st.list[i].id.clone();
if let Some(b) = st.cache.get(&id) {
return b.clone();
}
let a = apps::find_by_id(&id)?;
let b = if a.icon.is_empty() { None } else { ui::bitmap(rt, a.iw, a.ih, &a.icon) };
st.cache.insert(id, b.clone());
b
}
unsafe fn draw_icon(dc: &ID2D1DeviceContext, i: usize, tile: RectF, div: f32) {
let rt: ID2D1RenderTarget = dc.cast().unwrap();
let Some(b) = bmp_of(&rt, i) else { return };
let m = s().m;
let k_ = if s().list[i].mac { m.icon / div } else { m.icon };
let (cx, cy) = ((tile.left + tile.right) / 2.0, (tile.top + tile.bottom) / 2.0);
let sz = b.GetSize();
let k = (k_ / sz.width).min(k_ / sz.height);
dc.DrawBitmap(&b, Some(&rf(cx - sz.width * k / 2.0, cy - sz.height * k / 2.0, cx + sz.width * k / 2.0, cy + sz.height * k / 2.0)), 1.0, D2D1_INTERPOLATION_MODE_HIGH_QUALITY_CUBIC, None, None);
}
fn begin() -> Option<(ID2D1DeviceContext, f32, f32, i32, i32)> {
let st = s();
let (w, h) = (panel_w(), st.m.panel_h);
let k = sc();
let (wpx, hpx) = ((w * st.k * k).round() as i32, (h * st.k * k).round() as i32);
if let Some(fp) = st.foto {
st.s.foto_pos = fp;
}
let dc = ui::gpu_begin(&mut st.s, wpx, hpx, k * st.k)?;
Some((dc, w, h, wpx, hpx))
}
/// Leopard: o seletor do 10.5 — painel preto translúcido de cantos 18 com o fio claro, o escolhido num quadrado cinza
fn paint_leopard() {
let st = s();
unsafe {
if !st.back.0.is_null() && IsWindowVisible(st.back).as_bool() {
let _ = ShowWindow(st.back, SW_HIDE); // sem o vidro desfocado: o 10.5 não desfocava
}
}
let Some((dc, pw, ph, _, _)) = begin() else { return };
let m = st.m;
unsafe {
let Ok(br) = dc.CreateSolidColorBrush(&col(0.0, 0.0, 0.0, 1.0), None) else {
ui::gpu_end(&mut st.s);
return;
};
let r = 18.0;
if st.foto.is_some() {
backdrop::foto_vidro(&dc, rf(0.0, 0.0, pw, ph), r, col(0.06, 0.06, 0.07, 0.0));
}
br.SetColor(&col(0.06, 0.06, 0.07, 0.66));
dc.FillRoundedRectangle(&comum::rr(rf(0.0, 0.0, pw, ph), r, r), &br);
br.SetColor(&col(1.0, 1.0, 1.0, 0.22));
dc.DrawRoundedRectangle(&comum::rr(rf(0.5, 0.5, pw - 0.5, ph - 0.5), r - 0.5, r - 0.5), &br, 1.0, None);
for i in 0..st.list.len() {
let x = m.pad_x + i as f32 * m.pitch;
let tile = rf(x, m.pad_top, x + m.tile, m.pad_top + m.tile);
if i == st.sel {
br.SetColor(&col(1.0, 1.0, 1.0, 0.20));
dc.FillRoundedRectangle(&comum::rr(tile, 10.0, 10.0), &br);
br.SetColor(&col(1.0, 1.0, 1.0, 0.30));
dc.DrawRoundedRectangle(&comum::rr(rf(tile.left + 0.5, tile.top + 0.5, tile.right - 0.5, tile.bottom - 0.5), 9.5, 9.5), &br, 1.0, None);
}
draw_icon(&dc, i, tile, 0.8);
}
if let Some(e) = st.list.get(st.sel) {
thread_local!(static TF: IDWriteTextFormat = {
let f = ui::format_face("Lucida Sans Unicode", 13.0, DWRITE_FONT_WEIGHT_BOLD);
unsafe { let _ = f.SetTextAlignment(DWRITE_TEXT_ALIGNMENT_CENTER); }
f
});
let cx = m.pad_x + st.sel as f32 * m.pitch + m.tile / 2.0;
br.SetColor(&col(1.0, 1.0, 1.0, 0.97));
dc.DrawText(&w(&e.name), &TF.with(|t| t.clone()), &rf(cx - 140.0, m.label_cy - 10.0, cx + 140.0, m.label_cy + 10.0), &br, D2D1_DRAW_TEXT_OPTIONS_NONE, DWRITE_MEASURING_MODE_NATURAL);
}
}
ui::gpu_end(&mut st.s);
}
fn paint() {
let st = s();
if !st.visible {
return;
}
if liquid::leopard() {
paint_leopard();
return;
}
let Some((dc, pw, ph, wpx, hpx)) = begin() else { return };
let m = st.m;
let dark = ui::dark();
let tahoe = liquid::on();
let r = panel_r();
let tint = if dark { col(0.15, 0.15, 0.16, if tahoe { 0.45 } else { 0.62 }) } else { col(0.96, 0.96, 0.95, if tahoe { 0.30 } else { 0.42 }) };
unsafe {
let Ok(br) = dc.CreateSolidColorBrush(&col(0.0, 0.0, 0.0, 1.0), None) else {
ui::gpu_end(&mut st.s);
return;
};
let rt: ID2D1RenderTarget = dc.cast().unwrap();
if st.foto.is_some() {
backdrop::foto_vidro(&dc, rf(0.0, 0.0, pw, ph), r, tint);
} else if !st.glass {
br.SetColor(&if dark { col(0.17, 0.17, 0.18, 0.96) } else { col(0.93, 0.93, 0.93, 0.96) });
dc.FillRoundedRectangle(&comum::rr(rf(0.0, 0.0, pw, ph), r, r), &br);
}
if tahoe {
if !backdrop::liquid() || st.foto.is_some() {
liquid::rim0(&rt, rf(0.0, 0.0, pw, ph), r, dark); // com o Liquid Glass o vidro já tem o contorno
}
} else {
br.SetColor(&if dark { col(1.0, 1.0, 1.0, 0.14) } else { col(1.0, 1.0, 1.0, 0.35) });
dc.DrawRoundedRectangle(&comum::rr(rf(0.5, 0.5, pw - 0.5, ph - 0.5), r - 0.5, r - 0.5), &br, 1.0, None);
}
for i in 0..st.list.len() {
let x = m.pad_x + i as f32 * m.pitch;
let tile = rf(x, m.pad_top, x + m.tile, m.pad_top + m.tile);
if i == st.sel && tahoe {
// Tahoe: o escolhido num quadrado MAIS ESCURO e translúcido, cantos de ~26% e um fio claro
let tr_ = (tile.right - tile.left) * 0.26;
br.SetColor(&if dark { col(0.0, 0.0, 0.0, 0.34) } else { col(0.0, 0.0, 0.0, 0.14) });
dc.FillRoundedRectangle(&comum::rr(tile, tr_, tr_), &br);
br.SetColor(&col(1.0, 1.0, 1.0, if dark { 0.18 } else { 0.40 }));
dc.DrawRoundedRectangle(&comum::rr(rf(tile.left + 0.5, tile.top + 0.5, tile.right - 0.5, tile.bottom - 0.5), tr_, tr_), &br, 1.0, None);
} else if i == st.sel {
br.SetColor(&if dark { col(1.0, 1.0, 1.0, 0.14) } else { col(0.0, 0.0, 0.0, 0.22) });
dc.FillRoundedRectangle(&comum::rr(tile, 5.0, 5.0), &br);
}
// o desenho visível do ícone tem 78: os do Mac têm margem transparente (corpo = 80,5% da imagem)
draw_icon(&dc, i, tile, 0.805);
}
if let Some(e) = st.list.get(st.sel) {
let tf = ui::format(12.0, DWRITE_FONT_WEIGHT_NORMAL, false, DWRITE_TEXT_ALIGNMENT_CENTER);
let _ = tf.SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
let _ = tf.SetWordWrapping(DWRITE_WORD_WRAPPING_NO_WRAP);
let cx = m.pad_x + st.sel as f32 * m.pitch + m.tile / 2.0;
br.SetColor(&if dark { col(1.0, 1.0, 1.0, 0.80) } else { col(0.0, 0.0, 0.0, 0.70) });
dc.DrawText(&w(&e.name), &tf, &rf(cx - 120.0, m.label_cy - 10.0, cx + 120.0, m.label_cy + 10.0), &br, D2D1_DRAW_TEXT_OPTIONS_NONE, DWRITE_MEASURING_MODE_NATURAL);
}
}
ui::gpu_end(&mut st.s);
if st.glass && st.foto.is_none() {
backdrop::set(st.back, wpx as f32, hpx as f32, r * st.k * sc(), tint);
}
}
fn show_now() {
let st = s();
unsafe {
let _ = KillTimer(st.wnd, T_SHOWNOW);
if !st.visible || IsWindowVisible(st.wnd).as_bool() {
return;
}
if !liquid::leopard() {
let _ = SetWindowPos(st.back, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_SHOWWINDOW);
}
let _ = SetWindowPos(st.wnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_SHOWWINDOW);
}
}
static CURSOR_REF: Global<POINT> = Global::new(POINT { x: 0, y: 0 });
fn show() {
let st = s();
if st.visible || !st.active {
return;
}
st.m = metricas();
unsafe {
let mut c = POINT::default();
let _ = GetCursorPos(&mut c);
*CURSOR_REF.get() = c; // issue #324: só mexer o mouse muda a seleção
let mut mi = MONITORINFO { cbSize: std::mem::size_of::<MONITORINFO>() as u32, ..Default::default() };
let _ = GetMonitorInfoW(MonitorFromPoint(c, MONITOR_DEFAULTTOPRIMARY), &mut mi);
let mon = mi.rcMonitor;
let k = sc();
st.k = 1f32.min((mon.right - mon.left) as f32 * 0.94 / k / panel_w()); // encolhe quando não cabe
let (wpx, hpx) = ((panel_w() * st.k * k).round() as i32, (st.m.panel_h * st.k * k).round() as i32);
let (x, y) = ((mon.left + mon.right - wpx) / 2, (mon.top + mon.bottom - hpx) / 2);
// desenha antes de aparecer: o primeiro quadro já vem com os ícones
let _ = SetWindowPos(st.wnd, HWND_TOPMOST, x, y, wpx, hpx, SWP_NOACTIVATE);
st.visible = true;
paint();
let _ = SetWindowPos(st.back, HWND_TOPMOST, x, y, wpx, hpx, SWP_NOACTIVATE);
// mostra só depois que o vidro redesenhado chegou à tela (senão a janela antiga aparecia por um quadro)
if st.glass {
backdrop::after_commit(st.wnd, WM_SHOWNOW);
SetTimer(st.wnd, T_SHOWNOW, 50, None);
} else {
show_now();
}
}
}
fn hide() {
let st = s();
unsafe {
let _ = KillTimer(st.wnd, T_SHOW);
let _ = KillTimer(st.wnd, T_SHOWNOW);
let _ = ShowWindow(st.wnd, SW_HIDE);
let _ = ShowWindow(st.back, SW_HIDE);
}
st.visible = false;
st.active = false;
}
fn selected_id() -> Option<String> {
s().list.get(s().sel).map(|e| e.id.clone())
}
fn hit_icon(l: LPARAM) -> Option<usize> {
let st = s();
let k = sc() * st.k;
let (x, y) = (get_x_lparam(l) as f32 / k, get_y_lparam(l) as f32 / k);
if y < st.m.pad_top || y > st.m.pad_top + st.m.tile {
return None;
}
let i = ((x - st.m.pad_x) / st.m.pitch).floor();
(i >= 0.0 && (i as usize) < st.list.len()).then_some(i as usize)
}
fn commit() {
let id = selected_id();
hide();
let Some(a) = id.and_then(|i| apps::find_by_id(&i)) else { return };
log!("seletor: {}", a.name);
if a.wins.is_empty() {
apps::launch(a, ""); // o Finder sem janela: abre uma
} else {
apps::activate(a);
}
}
unsafe extern "system" fn proc_(h: HWND, m: u32, w_: WPARAM, l: LPARAM) -> LRESULT {
let st = s();
match m {
WM_PAINT => {
let mut ps = PAINTSTRUCT::default();
BeginPaint(h, &mut ps);
let _ = EndPaint(h, &ps);
paint();
return LRESULT(0);
}
WM_TIMER => {
if w_.0 == T_SHOW {
let _ = KillTimer(h, T_SHOW);
show();
} else if w_.0 == T_SHOWNOW {
show_now(); // segurança: o aviso não veio
}
return LRESULT(0);
}
WM_SHOWNOW => {
show_now();
return LRESULT(0);
}
WM_MOUSEACTIVATE => return LRESULT(MA_NOACTIVATE as isize), // o app de baixo continua com o teclado
WM_CLOSE => {
if st.active {
hide(); // nunca destrói
}
return LRESULT(0);
}
WM_MOUSEMOVE => {
// issue #324: o Windows manda WM_MOUSEMOVE para a janela que aparece debaixo de um cursor parado (jogo que
// prende o mouse no centro): sem mexer o mouse, a seleção do teclado não é trocada pelo ícone embaixo dele
let mut p = POINT::default();
let _ = GetCursorPos(&mut p);
let r = CURSOR_REF.get();
if p.x == r.x && p.y == r.y {
return LRESULT(0);
}
*r = p;
if let Some(i) = hit_icon(l) {
if i != st.sel {
st.sel = i;
paint();
}
}
return LRESULT(0);
}
WM_LBUTTONUP => {
if let Some(i) = hit_icon(l) {
st.sel = i;
commit();
}
return LRESULT(0);
}
_ => {}
}
DefWindowProcW(h, m, w_, l)
}
unsafe extern "system" fn back_proc(h: HWND, m: u32, w_: WPARAM, l: LPARAM) -> LRESULT {
if m == WM_MOUSEACTIVATE {
return LRESULT(MA_NOACTIVATE as isize);
}
DefWindowProcW(h, m, w_, l)
}
pub fn icons_changed() {
let st = s();
st.cache.clear();
for e in st.list.iter_mut() {
e.bmp = None;
}
}
pub fn create(hi: HINSTANCE) -> bool {
let st = s();
unsafe {
RegisterClassW(&WNDCLASSW { lpfnWndProc: Some(back_proc), hInstance: hi, lpszClassName: w!("ShellSeletorFundo"), ..Default::default() });
RegisterClassW(&WNDCLASSW { lpfnWndProc: Some(proc_), hInstance: hi, lpszClassName: w!("ShellSeletor"), hCursor: LoadCursorW(None, IDC_ARROW).unwrap_or_default(), ..Default::default() });
let ex = WS_EX_TOPMOST | WS_EX_TOOLWINDOW | WS_EX_NOACTIVATE;
st.back = CreateWindowExW(ex | WS_EX_NOREDIRECTIONBITMAP, w!("ShellSeletorFundo"), w!(""), WS_POPUP, 0, 0, 10, 10, None, None, hi, None).unwrap_or_default();
st.wnd = CreateWindowExW(ex | WS_EX_NOREDIRECTIONBITMAP, w!("ShellSeletor"), w!("Seletor de Apps"), WS_POPUP, 0, 0, 10, 10, None, None, hi, None).unwrap_or_default();
if st.wnd.0.is_null() || st.back.0.is_null() {
return false;
}
st.glass = backdrop::attach(st.back);
let corner: u32 = if st.glass { 1 } else { 2 };
if !st.glass {
let _ = DestroyWindow(st.back);
st.back = CreateWindowExW(ex, w!("ShellSeletorFundo"), w!(""), WS_POPUP, 0, 0, 10, 10, None, None, hi, None).unwrap_or_default();
ui::acrylic(st.back, if ui::dark() { 0xC020_1E1E } else { 0xC0F6_F6F6 });
}
let _ = DwmSetWindowAttribute(st.back, DWMWINDOWATTRIBUTE(33), &corner as *const _ as *const _, 4);
let none: u32 = 0xFFFF_FFFE;
let _ = DwmSetWindowAttribute(st.back, DWMWINDOWATTRIBUTE(34), &none as *const _ as *const _, 4);
}
apps::ours().push(st.wnd);
apps::ours().push(st.back);
st.s.hwnd = st.wnd;
true
}
pub fn is_active() -> bool {
s().active
}
/// Tab/Shift+Tab com o Alt seguro (vem do gancho de teclado)
pub fn step(dir: i32) {
let st = s();
if !st.active {
let t0 = anim::now();
collect();
log!("seletor: lista em {:.1} ms", anim::now() - t0);
if st.list.is_empty() {
return;
}
st.active = true;
let n = st.list.len();
st.sel = if n > 1 {
if dir > 0 {
st.frente_na_lista as usize // o app anterior
} else {
n - 1
}
} else {
0
};
show(); // aparece junto com o Tab, como o Cmd+Tab do Mac
return;
}
let n = st.list.len() as i32;
st.sel = (((st.sel as i32 + dir) % n + n) % n) as usize;
if !st.visible {
unsafe {
let _ = KillTimer(st.wnd, T_SHOW);
}
show();
} else {
paint();
}
}
pub fn key(vk: u32) {
let st = s();
if !st.active {
return;
}
match vk {
x if x == VK_ESCAPE.0 as u32 => hide(),
x if x == VK_LEFT.0 as u32 => step(-1),
x if x == VK_RIGHT.0 as u32 => step(1),
x if x == 'Q' as u32 => {
// encerra o escolhido e continua no seletor (como no Mac)
let Some(a) = selected_id().and_then(|i| apps::find_by_id(&i)) else { return };
apps::quit(a);
st.list.remove(st.sel);
if st.list.is_empty() {
hide();
return;
}
st.sel = st.sel.min(st.list.len() - 1);
st.visible = false; // o painel encolhe: mostra de novo, recentrado
show();
}
x if x == 'H' as u32 => {
if let Some(a) = selected_id().and_then(|i| apps::find_by_id(&i)) {
apps::hide(a);
}
}
_ => {}
}
}
pub fn release() {
if s().active {
commit();
}
}
/// modo foto: o seletor no meio da tela com os apps fixos do Dock (o 2º escolhido, como num Alt+Tab)
pub fn foto(tela_w: f32, tela_h: f32) {
let st = s();
st.m = metricas();
let order: Vec<String> = apps::list().iter().filter(|a| a.pinned || a.finder).take(8).map(|a| a.id.clone()).collect();
fill(order);
st.sel = 1.min(st.list.len().saturating_sub(1));
st.active = true;
st.visible = true;
st.k = 1f32.min(tela_w * 0.94 / panel_w());
let k = ui::foto_scale();
st.foto = Some(((tela_w - panel_w() * st.k) / 2.0 * k, (tela_h - st.m.panel_h * st.k) / 2.0 * k));
paint();
}