A new style desktop shell for Windows 11: menu bar, Dock, Finder, Spotlight, Control Center and Liquid Glass, in native C++.
Rust
//! Clima (src\clima\main.cpp): cidades à esquerda, o tempo da escolhida sobre a cor do céu (Open-Meteo, sem chave).
//! Cidades em %APPDATA%\Shell\clima.txt; o "Meu Local" vem dos Ajustes (tempoCidade/Lat/Lon).
#![windows_subsystem = "windows"]
use std::f64::consts::PI;
use comum::app2d::{self, *};
use comum::windows::Win32::Foundation::*;
use comum::windows::Win32::Graphics::Direct2D::Common::*;
use comum::windows::Win32::Graphics::Direct2D::*;
use comum::windows::Win32::Graphics::DirectWrite::*;
use comum::windows::Win32::Graphics::Gdi::HDC;
use comum::windows::Win32::System::Time::*;
use comum::windows::Win32::UI::Input::KeyboardAndMouse::*;
use comum::windows::Win32::UI::WindowsAndMessaging::*;
use comum::*;
const SB_W: f32 = 230.0;
const WM_DATA: u32 = WM_APP + 5;
const WM_FIELDLOST: u32 = WM_APP + 77;
#[derive(Clone, Default)]
struct HourW {
t: f64,
temp: f32,
code: i32,
day: bool,
}
#[derive(Clone, Default)]
struct DayW {
t: f64,
hi: f32,
lo: f32,
code: i32,
rise: f64,
set: f64,
}
#[derive(Clone, Default)]
struct Wx {
ok: bool,
temp: f32,
feels: f32,
hum: f32,
wind: f32,
code: i32,
day: bool,
off: i64,
hours: Vec<HourW>,
days: Vec<DayW>,
}
#[derive(Clone, Default)]
struct Place {
name: String,
lat: String,
lon: String,
wx: Wx,
loading: bool,
}
#[derive(Clone, Copy)]
struct Hit {
kind: i32,
arg: i32,
r: RectF,
}
#[derive(Default)]
struct App {
side: bool,
places: Vec<Place>,
sel: i32,
file: std::path::PathBuf,
status: String,
meu_local: bool,
hits: Vec<Hit>,
g_scroll: f32,
g_total: f32,
tf: std::collections::HashMap<&'static str, IDWriteTextFormat>,
}
static A: Global<Option<App>> = Global::new(None);
fn a() -> &'static mut App {
A.get().as_mut().unwrap()
}
fn tf(n: &str) -> &'static IDWriteTextFormat {
&a().tf[n]
}
fn hit(kind: i32, arg: i32, r: RectF) {
a().hits.push(Hit { kind, arg, r });
}
// ---- JSON simples (como o C++)
fn section(j: &str, key: &str) -> String {
let Some(p) = j.find(&format!("\"{key}\":{{")) else { return String::new() };
let p = p + j[p..].find('{').unwrap();
let mut depth = 0;
for (i, c) in j[p..].char_indices() {
if c == '{' {
depth += 1;
} else if c == '}' {
depth -= 1;
if depth == 0 {
return j[p..p + i + 1].to_string();
}
}
}
String::new()
}
fn number(s: &str, key: &str) -> f64 {
let k = format!("\"{key}\":");
let Some(p) = s.find(&k) else { return f64::NAN };
let r = s[p + k.len()..].trim_start();
if r.starts_with("null") {
return f64::NAN;
}
let fim = r.find(|c: char| !(c.is_ascii_digit() || c == '.' || c == '-' || c == 'e' || c == 'E' || c == '+')).unwrap_or(r.len());
r[..fim].parse().unwrap_or(f64::NAN)
}
fn array(s: &str, key: &str) -> Vec<f64> {
let k = format!("\"{key}\":[");
let Some(p) = s.find(&k) else { return Vec::new() };
let ini = p + k.len();
let fim = s[ini..].find(']').map(|f| ini + f).unwrap_or(s.len());
s[ini..fim].split(',').map(|x| x.trim()).filter(|x| !x.is_empty()).map(|x| if x == "null" { f64::NAN } else { x.parse().unwrap_or(f64::NAN) }).collect()
}
fn parse(j: &str) -> Wx {
let mut w = Wx::default();
let (cur, hr, dl) = (section(j, "current"), section(j, "hourly"), section(j, "daily"));
if cur.is_empty() || hr.is_empty() || dl.is_empty() {
return w;
}
let off = number(j, "utc_offset_seconds");
if !off.is_nan() {
w.off = off as i64;
}
w.temp = number(&cur, "temperature_2m") as f32;
w.feels = number(&cur, "apparent_temperature") as f32;
w.hum = number(&cur, "relative_humidity_2m") as f32;
w.wind = number(&cur, "wind_speed_10m") as f32;
w.code = number(&cur, "weather_code") as i32;
w.day = number(&cur, "is_day") > 0.5;
let (t, tp, c, d) = (array(&hr, "time"), array(&hr, "temperature_2m"), array(&hr, "weather_code"), array(&hr, "is_day"));
for i in 0..t.len().min(tp.len()).min(c.len()).min(d.len()) {
w.hours.push(HourW { t: t[i], temp: tp[i] as f32, code: c[i] as i32, day: d[i] > 0.5 });
}
let (dt, mx, mn, dc, sr, ss) = (array(&dl, "time"), array(&dl, "temperature_2m_max"), array(&dl, "temperature_2m_min"), array(&dl, "weather_code"), array(&dl, "sunrise"), array(&dl, "sunset"));
for i in 0..dt.len().min(mx.len()).min(mn.len()).min(dc.len()) {
w.days.push(DayW { t: dt[i], hi: mx[i] as f32, lo: mn[i] as f32, code: dc[i] as i32, rise: *sr.get(i).unwrap_or(&0.0), set: *ss.get(i).unwrap_or(&0.0) });
}
w.ok = !w.temp.is_nan() && !w.days.is_empty();
w
}
fn fetch(i: usize) {
let p = &mut a().places[i];
if p.loading {
return;
}
p.loading = true;
let (lat, lon) = (p.lat.clone(), p.lon.clone());
let h = wnd().0 as usize;
std::thread::spawn(move || {
let path = format!(
"/v1/forecast?latitude={lat}&longitude={lon}¤t=temperature_2m,apparent_temperature,relative_humidity_2m,wind_speed_10m,weather_code,is_day&hourly=temperature_2m,weather_code,is_day&daily=weather_code,temperature_2m_max,temperature_2m_min,sunrise,sunset&timezone=auto&forecast_days=10&timeformat=unixtime"
);
let body = rede::get("api.open-meteo.com", &path, "SequoiaClima/1.0", 512 * 1024).unwrap_or_default();
let w = parse(&String::from_utf8_lossy(&body));
let p = Box::into_raw(Box::new(w));
unsafe {
if PostMessageW(HWND(h as *mut _), WM_DATA, WPARAM(i), LPARAM(p as isize)).is_err() {
drop(Box::from_raw(p));
}
}
});
}
fn save() {
let mut out = vec!["# Cidades do Clima (nome, latitude, longitude); a primeira vem dos Ajustes".to_string()];
for p in a().places.iter().skip(1) {
out.push(format!("C\t{}\t{}\t{}", esc(&p.name), p.lat, p.lon));
}
write_lines(&a().file, &out);
}
fn set_my_place(i: usize) {
let p = a().places[i].clone();
set_app_setting("tempoCidade", &p.name);
set_app_setting("tempoLat", &p.lat);
set_app_setting("tempoLon", &p.lon);
}
/// cidade::Padrao: a do fuso do Windows
fn cidade_padrao() -> (String, String, String) {
const T: [(&str, &str, &str, &str); 52] = [
("E. South America Standard Time", "Campinas", "-22.9056", "-47.0608"),
("SA Eastern Standard Time", "Fortaleza", "-3.7319", "-38.5267"),
("Bahia Standard Time", "Salvador", "-12.9777", "-38.5016"),
("Tocantins Standard Time", "Palmas", "-10.1844", "-48.3336"),
("SA Western Standard Time", "Manaus", "-3.1190", "-60.0217"),
("Central Brazilian Standard Time", "Cuiabá", "-15.6014", "-56.0979"),
("Argentina Standard Time", "Buenos Aires", "-34.6037", "-58.3816"),
("Pacific SA Standard Time", "Santiago", "-33.4489", "-70.6693"),
("SA Pacific Standard Time", "Bogotá", "4.7110", "-74.0721"),
("Venezuela Standard Time", "Caracas", "10.4806", "-66.9036"),
("Central Standard Time (Mexico)", "Ciudad de México", "19.4326", "-99.1332"),
("Eastern Standard Time", "New York", "40.7128", "-74.0060"),
("Central Standard Time", "Chicago", "41.8781", "-87.6298"),
("Mountain Standard Time", "Denver", "39.7392", "-104.9903"),
("US Mountain Standard Time", "Phoenix", "33.4484", "-112.0740"),
("Pacific Standard Time", "Los Angeles", "34.0522", "-118.2437"),
("Alaskan Standard Time", "Anchorage", "61.2181", "-149.9003"),
("Hawaiian Standard Time", "Honolulu", "21.3069", "-157.8583"),
("Atlantic Standard Time", "Halifax", "44.6488", "-63.5752"),
("GMT Standard Time", "London", "51.5072", "-0.1276"),
("Greenwich Standard Time", "Reykjavík", "64.1466", "-21.9426"),
("W. Europe Standard Time", "Berlin", "52.5200", "13.4050"),
("Romance Standard Time", "Paris", "48.8566", "2.3522"),
("Central Europe Standard Time", "Budapest", "47.4979", "19.0402"),
("Central European Standard Time", "Warszawa", "52.2297", "21.0122"),
("GTB Standard Time", "Athens", "37.9838", "23.7275"),
("FLE Standard Time", "Kyiv", "50.4501", "30.5234"),
("E. Europe Standard Time", "Chișinău", "47.0105", "28.8638"),
("Turkey Standard Time", "İstanbul", "41.0082", "28.9784"),
("Russian Standard Time", "Moscow", "55.7558", "37.6173"),
("Israel Standard Time", "Jerusalem", "31.7683", "35.2137"),
("Egypt Standard Time", "Cairo", "30.0444", "31.2357"),
("South Africa Standard Time", "Johannesburg", "-26.2041", "28.0473"),
("W. Central Africa Standard Time", "Lagos", "6.5244", "3.3792"),
("E. Africa Standard Time", "Nairobi", "-1.2921", "36.8219"),
("Arab Standard Time", "Riyadh", "24.7136", "46.6753"),
("Arabian Standard Time", "Dubai", "25.2048", "55.2708"),
("Iran Standard Time", "Tehran", "35.6892", "51.3890"),
("Pakistan Standard Time", "Karachi", "24.8607", "67.0011"),
("India Standard Time", "Mumbai", "19.0760", "72.8777"),
("Bangladesh Standard Time", "Dhaka", "23.8103", "90.4125"),
("SE Asia Standard Time", "Bangkok", "13.7563", "100.5018"),
("Singapore Standard Time", "Singapore", "1.3521", "103.8198"),
("China Standard Time", "Beijing", "39.9042", "116.4074"),
("Taipei Standard Time", "Taipei", "25.0330", "121.5654"),
("Korea Standard Time", "Seoul", "37.5665", "126.9780"),
("Tokyo Standard Time", "Tokyo", "35.6762", "139.6503"),
("W. Australia Standard Time", "Perth", "-31.9505", "115.8605"),
("AUS Eastern Standard Time", "Sydney", "-33.8688", "151.2093"),
("E. Australia Standard Time", "Brisbane", "-27.4698", "153.0251"),
("New Zealand Standard Time", "Auckland", "-36.8485", "174.7633"),
("UTC", "London", "51.5072", "-0.1276"),
];
let mut d = DYNAMIC_TIME_ZONE_INFORMATION::default();
let r = unsafe { GetDynamicTimeZoneInformation(&mut d) };
if r != u32::MAX {
let k = from_w(&d.TimeZoneKeyName);
if let Some(t) = T.iter().find(|t| t.0 == k) {
return (t.1.into(), t.2.into(), t.3.into());
}
}
("London".into(), "51.5072".into(), "-0.1276".into())
}
fn load() {
let a = a();
a.places.clear();
let (n, la, lo) = cidade_padrao();
let m = ajustes::ler_padrao();
let g = |k: &str, d: &str| m.get(k).cloned().unwrap_or_else(|| d.to_string());
a.places.push(Place { name: g("tempoCidade", &n), lat: g("tempoLat", &la), lon: g("tempoLon", &lo), ..Default::default() });
for l in read_lines(&a.file) {
let f = split(&l);
if f.len() >= 4 && f[0] == "C" {
a.places.push(Place { name: unesc(&f[1]), lat: f[2].clone(), lon: f[3].clone(), ..Default::default() });
}
}
}
fn search(q: String) {
if q.is_empty() {
return;
}
a().status = tr("Procurando…");
invalidate();
let h = wnd().0 as usize;
std::thread::spawn(move || {
let path = format!("/v1/search?count=1&language={}&name={}", idioma::code(), rede::url_encode(&q));
let body = String::from_utf8_lossy(&rede::get("geocoding-api.open-meteo.com", &path, "SequoiaClima/1.0", 512 * 1024).unwrap_or_default()).into_owned();
let mut p = Place::default();
if body.contains("\"results\"") {
let (la, lo) = (number(&body, "latitude"), number(&body, "longitude"));
if !la.is_nan() {
p.name = rede::json_field(&body, "name");
p.lat = format!("{la:.4}");
p.lon = format!("{lo:.4}");
}
}
let ptr = Box::into_raw(Box::new(p));
unsafe {
if PostMessageW(HWND(h as *mut _), WM_DATA, WPARAM(usize::MAX), LPARAM(ptr as isize)).is_err() {
drop(Box::from_raw(ptr));
}
}
});
}
fn cond_text(c: i32) -> String {
tr(match c {
0 => "Céu Limpo",
1 | 2 => "Parcialmente Nublado",
3 => "Nublado",
45 | 48 => "Neblina",
51..=57 => "Garoa",
61..=67 | 80..=82 => "Chuva",
71..=77 | 85 | 86 => "Neve",
x if x >= 95 => "Tempestade",
_ => return String::new(),
})
}
fn cond_emoji(c: i32, day: bool) -> &'static str {
match c {
0 => {
if day {
"☀️"
} else {
"\u{1F319}"
}
}
1 | 2 => {
if day {
"⛅"
} else {
"☁️"
}
}
3 => "☁️",
45 | 48 => "\u{1F32B}\u{FE0F}",
51..=57 => "\u{1F326}\u{FE0F}",
61..=67 | 80..=82 => "\u{1F327}\u{FE0F}",
71..=77 | 85 | 86 => "❄️",
x if x >= 95 => "⛈️",
_ => "☁️",
}
}
fn sky(w: &Wx) -> (Cor, Cor) {
let (cloudy, rain) = (w.code >= 3, w.code >= 51);
if !w.day {
(rgb(16, 24, 48, 1.0), rgb(38, 48, 80, 1.0))
} else if rain {
(rgb(70, 84, 104, 1.0), rgb(110, 124, 140, 1.0))
} else if cloudy {
(rgb(92, 120, 150, 1.0), rgb(140, 160, 182, 1.0))
} else {
(rgb(40, 110, 200, 1.0), rgb(110, 170, 230, 1.0))
}
}
fn gm(unix: f64, off: i64) -> (i64, i64, i64) {
let t = unix as i64 + off;
let s = t.rem_euclid(86400);
let wd = (t.div_euclid(86400) + 4).rem_euclid(7); // 1970-01-01 foi quinta-feira
(s / 3600, s / 60 % 60, wd)
}
fn hour_of(u: f64, off: i64) -> String {
gm(u, off).0.to_string()
}
fn hm_of(u: f64, off: i64) -> String {
let (h, m, _) = gm(u, off);
format!("{h}:{m:02}")
}
fn wday_of(u: f64, off: i64) -> i32 {
gm(u, off).2 as i32
}
/// a temperatura na unidade escolhida (lida uma vez: trocar nos Ajustes vale ao abrir o Tempo de novo; issues #247 e #264)
fn unidade_f() -> bool {
static F: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
*F.get_or_init(|| comum::temperatura::fahrenheit(ajustes::ler_padrao().get("temperatura").map(String::as_str).unwrap_or("auto")))
}
fn tf_(c: f32) -> f32 {
comum::temperatura::mostra(c, unidade_f())
}
fn graus(v: f32) -> String {
format!("{}°", tf_(v).round() as i32)
}
fn grad_fill(r: RectF, a_: Cor, b: Cor, p0: Ponto, p1: Ponto, rad: f32) {
unsafe {
if let Some(lg) = linear(app2d::rt(), &[(0.0, a_), (1.0, b)], p0, p1) {
if rad > 0.0 {
app2d::rt().FillRoundedRectangle(&rr(r, rad, rad), &lg);
} else {
app2d::rt().FillRectangle(&r, &lg);
}
}
}
}
fn sky_fill(r: RectF, w: &Wx, h: f32) {
let (c0, c1) = sky(w);
grad_fill(r, c0, c1, pt(0.0, 0.0), pt(0.0, h), 0.0);
}
fn glass_card(r: RectF) {
fill(r, rgb(255, 255, 255, 0.15), 18.0);
stroke_rect(rf(r.left + 0.25, r.top + 0.25, r.right - 0.25, r.bottom - 0.25), rgb(255, 255, 255, 0.20), 17.75, 0.5);
}
fn card_head(r: RectF, t: &str) {
text(t, tf("hdr"), rf(r.left + 14.0, r.top + 8.0, r.right - 10.0, r.top + 24.0), rgb(255, 255, 255, 0.62));
}
fn sensacao(w: &Wx) -> String {
if w.feels < w.temp - 1.0 {
tr("O vento deixa mais frio do que a temperatura real.")
} else if w.feels > w.temp + 1.0 {
tr("A umidade deixa mais quente do que a temperatura real.")
} else {
tr("Parecida com a temperatura real.")
}
}
fn now_unix() -> f64 {
std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH).map(|d| d.as_secs_f64()).unwrap_or(0.0)
}
fn city_card(i: usize, r: RectF, golden: bool, dark: bool, text_c: Cor, gray: Cor) {
let p = a().places[i].clone();
let white = rgb(255, 255, 255, 1.0);
let dim = rgb(255, 255, 255, if golden { 0.72 } else { 0.7 });
let rad = if golden { 14.0 } else { 12.0 };
if p.wx.ok {
let (c0, c1) = sky(&p.wx);
grad_fill(r, c0, c1, pt(r.left, r.top), pt(r.right, r.bottom), rad);
} else if golden {
fill(r, if dark { rgb(255, 255, 255, 0.08) } else { rgb(0, 0, 0, 0.05) }, rad);
} else {
fill(r, if dark { rgb(58, 58, 60, 1.0) } else { white }, rad);
}
if i as i32 == a().sel {
let c = if golden && semaforo::aqua() { rgb(0, 136, 255, 1.0) } else { rgb(10, 132, 255, 1.0) };
if golden {
stroke_rect(rf(r.left + 1.0, r.top + 1.0, r.right - 1.0, r.bottom - 1.0), c, 13.0, 2.0);
} else {
stroke_rect(r, c, 12.0, 2.5);
}
}
let tc = if p.wx.ok { white } else { text_c };
let tdim = if p.wx.ok { dim } else { gray };
text(&if i == 0 { tr("Meu Local") } else { p.name.clone() }, tf("side"), rf(r.left + 12.0, r.top + 8.0, r.right - 60.0, r.top + 30.0), tc);
if i == 0 {
text(&p.name, tf("small"), rf(r.left + 12.0, r.top + 28.0, r.right - 60.0, r.top + 46.0), tdim);
}
if p.wx.ok {
text(&cond_text(p.wx.code), tf("small"), rf(r.left + 12.0, r.bottom - 24.0, r.right - 60.0, r.bottom - 6.0), dim);
let x0 = if golden { 80.0 } else { 70.0 };
text(&graus(p.wx.temp), tf("sidetemp"), rf(r.right - x0, r.top + 4.0, r.right - if golden { 12.0 } else { 10.0 }, r.top + 44.0), white);
}
hit(1, i as i32, r);
}
fn paint_golden() {
a().hits.clear();
let sz = size();
let white = rgb(255, 255, 255, 1.0);
let dim = rgb(255, 255, 255, 0.72);
let side = a().side;
let sbg = if side { 270.0 } else { 0.0 };
let sel = a().sel;
let have = sel >= 0 && (sel as usize) < a().places.len();
let pl = if have { a().places[sel as usize].clone() } else { Place::default() };
let mut sk = if have && pl.wx.ok { pl.wx.clone() } else { Wx::default() };
if !have || !pl.wx.ok {
sk.day = true;
sk.code = 1;
}
sky_fill(rf(0.0, 0.0, sz.width, sz.height), &sk, sz.height);
if !side {
let tb = rf(84.0, 8.0, 120.0, 44.0);
fill(tb, rgb(255, 255, 255, 0.16), 18.0);
icon_sidebar(pt(102.0, 26.0), white);
bar_button(tb);
hit(3, 0, tb);
} else {
let dark = dark();
let text_c = if dark { rgb(245, 245, 247, 1.0) } else { rgb(29, 29, 31, 1.0) };
let gray = if dark { rgb(152, 152, 157, 1.0) } else { rgb(134, 134, 139, 1.0) };
fill(rf(0.0, 0.0, sbg, sz.height), sidebar_color(), 0.0);
fill(rf(sbg - 0.5, 0.0, sbg, sz.height), if dark { rgb(0, 0, 0, 0.5) } else { rgb(0, 0, 0, 0.12) }, 0.0);
let tb = rf(226.0, 8.0, 262.0, 44.0);
glass_button(tb, dark, false);
icon_sidebar(pt(244.0, 26.0), text_c);
bar_button(tb);
hit(3, 0, tb);
let sr = rf(9.0, 63.0, 262.0, 97.0);
glass_field(sr, dark);
icon_search(pt(27.0, 80.0), gray, 0.9);
if app2d::s().field.h.0.is_null() {
text(&tr("Buscar"), tf("searchg"), rf(40.0, sr.top, sr.right - 10.0, sr.bottom), gray);
}
hit(2, 0, sr);
let mut y = 108.0;
push_clip(rf(0.0, 100.0, sbg, sz.height));
for i in 0..a().places.len() {
city_card(i, rf(9.0, y, 262.0, y + 70.0), true, dark, text_c, gray);
y += 76.0;
}
pop_clip();
if !a().status.is_empty() {
text(&a().status.clone(), tf("small"), rf(12.0, sz.height - 30.0, sbg - 10.0, sz.height - 8.0), gray);
}
}
let add_x = if side { 297.0 } else { 146.0 };
let add = rf(add_x - 18.0, 8.0, add_x + 18.0, 44.0);
fill(add, rgb(255, 255, 255, 0.16), 18.0);
icon_plus(pt(add_x, 26.0), white, 7.0);
hit(2, 0, add);
bar_button(add);
if !have {
return;
}
let x0c = sbg;
let cx = (sbg + sz.width) / 2.0;
if !pl.wx.ok {
text(&if pl.loading { tr("Carregando…") } else { tr("Sem conexão com o serviço do tempo.") }, tf("condg"), rf(x0c, 0.0, sz.width, sz.height), white);
return;
}
let w = &pl.wx;
push_clip(rf(x0c, 52.0, sz.width, sz.height));
let oy = -a().g_scroll;
text(&if sel == 0 { tr("Meu Local") } else { pl.name.clone() }, tf("cityg"), rf(x0c, oy + 94.0, sz.width, oy + 120.0), white);
text(&format!(" {}", graus(w.temp)), tf("tempg"), rf(x0c, oy + 118.0, sz.width, oy + 182.0), white);
text(&cond_text(w.code), tf("condg"), rf(x0c, oy + 177.0, sz.width, oy + 195.0), white);
if let Some(d0) = w.days.first() {
text(&cf!(tr("Máx.: %d° Mín.: %d°"), tf_(d0.hi).round() as i32, tf_(d0.lo).round() as i32), tf("condg"), rf(x0c, oy + 194.0, sz.width, oy + 212.0), white);
}
let mut gw = 622.0;
let mut x0 = cx - gw / 2.0;
let y0 = oy + 266.0;
if x0 < x0c + 12.0 {
x0 = x0c + 12.0;
gw = sz.width - x0c - 24.0;
}
let sm = if (gw - 32.0 - 304.0) / 2.0 > 100.0 { 143.0 } else { (gw - 16.0) / 2.0 };
let wide_x = x0 + 2.0 * sm + 32.0;
let wide_w = x0 + gw - wide_x;
let c1 = rf(x0, y0, x0 + sm, y0 + 141.0);
let c2 = rf(x0 + sm + 16.0, y0, x0 + 2.0 * sm + 16.0, y0 + 141.0);
let c3 = rf(wide_x, y0, wide_x + wide_w, y0 + 141.0);
glass_card(c1);
card_head(c1, &tr("SENSAÇÃO"));
text(&graus(w.feels), tf("bigg"), rf(c1.left + 14.0, c1.top + 28.0, c1.right, c1.top + 62.0), white);
text_opt(&sensacao(w), tf("smallw"), rf(c1.left + 14.0, c1.top + 66.0, c1.right - 12.0, c1.bottom - 8.0), white, D2D1_DRAW_TEXT_OPTIONS_CLIP);
glass_card(c2);
card_head(c2, &tr("VENTO"));
{
let c = pt((c2.left + c2.right) / 2.0, c2.top + 82.0);
for k in 0..72 {
let an = k as f64 * PI / 36.0;
let r0 = if k % 18 == 0 { 36.0 } else { 40.0 };
let (s, co) = (an.sin() as f32, an.cos() as f32);
line(pt(c.x + s * r0, c.y - co * r0), pt(c.x + s * 44.0, c.y - co * 44.0), rgb(255, 255, 255, 0.35), 0.8);
}
for k in 0..4 {
let an = k as f64 * PI / 2.0;
let (s, co) = (an.sin() as f32 * 30.0, an.cos() as f32 * 30.0);
text(idioma::compass(k), tf("hdr"), rf(c.x + s - 8.0, c.y - co - 8.0, c.x + s + 8.0, c.y - co + 8.0), white);
}
text(&(w.wind.round() as i32).to_string(), tf("condtitle"), rf(c.x - 20.0, c.y - 12.0, c.x + 20.0, c.y + 6.0), white);
text("km/h", tf("hdr"), rf(c.x - 20.0, c.y + 3.0, c.x + 20.0, c.y + 15.0), white);
}
glass_card(c3);
text(&tr("Condições"), tf("condtitle"), rf(c3.left + 14.0, c3.top + 10.0, c3.right, c3.top + 28.0), white);
text(&if unidade_f() { tr("Temperatura (°C)").replace("°C", "°F") } else { tr("Temperatura (°C)") }, tf("hdr"), rf(c3.left + 14.0, c3.top + 26.0, c3.right, c3.top + 40.0), dim);
{
let now = now_unix();
let start = w.hours.iter().rposition(|h| h.t <= now).unwrap_or(0);
let n = 6.min(w.hours.len().saturating_sub(start));
let cw = (c3.right - c3.left - 16.0) / 6.0;
for k in 0..n {
let hh = &w.hours[start + k];
let x = c3.left + 8.0 + k as f32 * cw;
text(&if k == 0 { tr("Agora") } else { hour_of(hh.t, w.off) }, tf("hdrc"), rf(x, c3.top + 50.0, x + cw, c3.top + 66.0), white);
text(cond_emoji(hh.code, hh.day), tf("emojismall"), rf(x, c3.top + 70.0, x + cw, c3.top + 100.0), white);
text(&graus(hh.temp), tf("cardg"), rf(x, c3.top + 104.0, x + cw, c3.top + 126.0), white);
}
}
let y1 = y0 + 141.0 + 16.0;
let c4 = rf(x0, y1, x0 + 2.0 * sm + 16.0, y1 + 143.0);
glass_card(c4);
card_head(c4, &tr("UMIDADE"));
text(&format!("{}%", w.hum.round() as i32), tf("bigg"), rf(c4.left + 14.0, c4.top + 28.0, c4.right, c4.top + 62.0), white);
{
let bar = rf(c4.left + 14.0, c4.top + 86.0, c4.right - 14.0, c4.top + 91.0);
unsafe {
if let Some(lg) = linear(app2d::rt(), &[(0.0, rgb(255, 210, 120, 1.0)), (0.5, rgb(120, 220, 255, 1.0)), (1.0, rgb(40, 110, 255, 1.0))], pt(bar.left, 0.0), pt(bar.right, 0.0)) {
app2d::rt().FillRoundedRectangle(&rr(bar, 2.5, 2.5), &lg);
}
}
let px = bar.left + (bar.right - bar.left) * (w.hum / 100.0).clamp(0.0, 1.0);
circle(pt(px, (bar.top + bar.bottom) / 2.0), 4.5, white, true, 1.5);
let s = if w.hum >= 70.0 {
tr("O ar está úmido agora.")
} else if w.hum <= 35.0 {
tr("O ar está seco agora.")
} else {
tr("Umidade confortável agora.")
};
text(&s, tf("smallw"), rf(c4.left + 14.0, c4.top + 100.0, c4.right - 12.0, c4.bottom - 8.0), white);
}
let rows = w.days.len().min(10) as f32;
let c5 = rf(wide_x, y1, wide_x + wide_w, y1 + 30.0 + rows * 42.0 + 8.0);
glass_card(c5);
{
let lo = w.days.iter().map(|d| d.lo).fold(999.0f32, f32::min);
let hi = w.days.iter().map(|d| d.hi).fold(-999.0f32, f32::max);
for k in 0..rows as usize {
let d = &w.days[k];
let yy = c5.top + 8.0 + k as f32 * 42.0;
if k > 0 {
fill(rf(c5.left + 14.0, yy, c5.right - 14.0, yy + 0.5), rgb(255, 255, 255, 0.22), 0.0);
}
text(&if k == 0 { tr("Hoje") } else { weekday_short(wday_of(d.t + 12.0 * 3600.0, w.off)) }, tf("condtitle"), rf(c5.left + 14.0, yy, c5.left + 64.0, yy + 42.0), white);
text(cond_emoji(d.code, true), tf("emojismall"), rf(c5.left + 64.0, yy, c5.left + 100.0, yy + 42.0), white);
text(&graus(d.lo), tf("rowr"), rf(c5.left + 100.0, yy, c5.left + 138.0, yy + 42.0), dim);
let (bx0, bx1, by) = (c5.left + 146.0, c5.right - 52.0, yy + 21.0);
fill(rf(bx0, by - 2.5, bx1, by + 2.5), rgb(0, 0, 0, 0.16), 2.5);
let span = (hi - lo).max(1.0);
let a_ = bx0 + (d.lo - lo) / span * (bx1 - bx0);
let b_ = bx0 + (d.hi - lo) / span * (bx1 - bx0);
let e = (a_ + 6.0).max(b_);
grad_fill(rf(a_, by - 2.5, e, by + 2.5), rgb(255, 196, 64, 1.0), rgb(255, 120, 40, 1.0), pt(a_, 0.0), pt(e, 0.0), 2.5);
text(&graus(d.hi), tf("rowr"), rf(c5.right - 50.0, yy, c5.right - 14.0, yy + 42.0), white);
}
}
let y2 = y1 + 143.0 + 16.0;
if let Some(d0) = w.days.first() {
let c6 = rf(x0, y2, x0 + sm, y2 + 141.0);
let c7 = rf(x0 + sm + 16.0, y2, x0 + 2.0 * sm + 16.0, y2 + 141.0);
glass_card(c6);
card_head(c6, &tr("NASCER DO SOL"));
text(&hm_of(d0.rise, w.off), tf("bigg"), rf(c6.left + 14.0, c6.top + 28.0, c6.right, c6.top + 62.0), white);
glass_card(c7);
card_head(c7, &tr("PÔR DO SOL"));
text(&hm_of(d0.set, w.off), tf("bigg"), rf(c7.left + 14.0, c7.top + 28.0, c7.right, c7.top + 62.0), white);
for c in [c6, c7] {
unsafe {
if let Ok(g) = d2d().CreatePathGeometry() {
if let Ok(s) = g.Open() {
let (bx, bw, base) = (c.left + 12.0, c.right - c.left - 24.0, c.top + 112.0);
s.BeginFigure(pt(bx, base + 6.0), D2D1_FIGURE_BEGIN_HOLLOW);
for k in 1..=30 {
let u = k as f32 / 30.0;
s.AddLine(pt(bx + bw * u, base + 6.0 - (u as f64 * PI).sin() as f32 * 28.0));
}
s.EndFigure(D2D1_FIGURE_END_OPEN);
let _ = s.Close();
br().SetColor(&rgb(255, 255, 255, 0.45));
app2d::rt().DrawGeometry(&g, br(), 2.0, None);
}
}
}
fill(rf(c.left + 12.0, c.top + 112.0, c.right - 12.0, c.top + 112.6), rgb(255, 255, 255, 0.5), 0.0);
}
}
a().g_total = c5.bottom.max(y2 + 141.0) + a().g_scroll + 20.0;
pop_clip();
}
fn paint() {
if !begin_paint() {
return;
}
if bar() > 0.0 {
paint_golden();
end_paint();
return;
}
a().hits.clear();
let dark = dark();
let sz = size();
let text_c = if dark { rgb(245, 245, 247, 1.0) } else { rgb(29, 29, 31, 1.0) };
let gray = if dark { rgb(152, 152, 157, 1.0) } else { rgb(134, 134, 139, 1.0) };
let white = rgb(255, 255, 255, 1.0);
let dim = rgb(255, 255, 255, 0.7);
clear(if dark { rgb(30, 30, 30, 1.0) } else { rgb(242, 242, 245, 1.0) });
let side = a().side;
let sb = if side { SB_W } else { 0.0 };
let tog = rf(10.0, 10.0, 38.0, 38.0);
let toggle = |c: Cor| {
icon_sidebar(pt((tog.left + tog.right) / 2.0, (tog.top + tog.bottom) / 2.0), c);
hit(3, 0, tog);
};
if side {
fill(rf(0.0, 0.0, sb, sz.height), if dark { rgb(40, 40, 42, 1.0) } else { rgb(236, 236, 240, 1.0) }, 0.0);
toggle(text_c);
let add = rf(sb - 40.0, 10.0, sb - 10.0, 38.0);
text("\u{E710}", tf("icon"), add, text_c);
hit(2, 0, add);
let mut y = 48.0;
for i in 0..a().places.len() {
city_card(i, rf(8.0, y, sb - 8.0, y + 70.0), false, dark, text_c, gray);
y += 78.0;
}
if !a().status.is_empty() {
text(&a().status.clone(), tf("small"), rf(12.0, sz.height - 30.0, sb - 10.0, sz.height - 8.0), gray);
}
}
let sel = a().sel;
if sel < 0 || sel as usize >= a().places.len() {
if !side {
toggle(text_c);
}
end_paint();
return;
}
let pl = a().places[sel as usize].clone();
let main_r = rf(sb, 0.0, sz.width, sz.height);
if !pl.wx.ok {
text(&if pl.loading { tr("Carregando…") } else { tr("Sem conexão com o serviço do tempo.") }, tf("cond"), main_r, gray);
if !side {
toggle(text_c);
}
end_paint();
return;
}
let w = &pl.wx;
{
let (c0, c1) = sky(w);
grad_fill(main_r, c0, c1, pt(0.0, 0.0), pt(0.0, sz.height), 0.0);
}
if !side {
toggle(white);
}
let ww = sz.width - sb;
text(&if sel == 0 { tr("Meu Local") } else { pl.name.clone() }, tf("city"), rf(sb, 24.0, sz.width, 62.0), white);
if sel == 0 {
text(&pl.name, tf("smallc"), rf(sb, 58.0, sz.width, 76.0), dim);
}
text(&format!(" {}", graus(w.temp)), tf("temp"), rf(sb, 70.0, sz.width, 170.0), white);
text(&cond_text(w.code), tf("cond"), rf(sb, 168.0, sz.width, 194.0), white);
if let Some(d0) = w.days.first() {
text(&cf!(tr("Máx.: %d° Mín.: %d°"), tf_(d0.hi).round() as i32, tf_(d0.lo).round() as i32), tf("cond"), rf(sb, 192.0, sz.width, 218.0), white);
}
let (pad, y0) = (20.0, 236.0);
let hr = rf(sb + pad, y0, sz.width - pad, y0 + 124.0);
fill(hr, rgb(255, 255, 255, 0.14), 14.0);
text(&tr("PREVISÃO POR HORA"), tf("small"), rf(hr.left + 14.0, hr.top + 6.0, hr.right, hr.top + 26.0), dim);
let now = now_unix();
let start = w.hours.iter().rposition(|h| h.t <= now).unwrap_or(0);
let n = 24.min(w.hours.len().saturating_sub(start));
let largura = hr.right - hr.left - 20.0;
let cw = largura / (n.min((largura / 52.0) as usize).max(1)) as f32;
let vis = (largura / cw) as usize;
for k in 0..n.min(vis) {
let h = &w.hours[start + k];
let x = hr.left + 10.0 + k as f32 * cw;
text(&if k == 0 { tr("Agora") } else { hour_of(h.t, w.off) }, tf("card"), rf(x, hr.top + 30.0, x + cw, hr.top + 50.0), white);
text(cond_emoji(h.code, h.day), tf("emojismall"), rf(x, hr.top + 52.0, x + cw, hr.top + 84.0), white);
text(&graus(h.temp), tf("cardbig"), rf(x, hr.top + 88.0, x + cw, hr.top + 114.0), white);
}
let col_w = (ww - 3.0 * pad) / 2.0;
let dr = rf(sb + pad, hr.bottom + pad, sb + pad + col_w, sz.height - pad);
fill(dr, rgb(255, 255, 255, 0.14), 14.0);
text(&tr("PREVISÃO PARA 10 DIAS"), tf("small"), rf(dr.left + 14.0, dr.top + 6.0, dr.right, dr.top + 26.0), dim);
let lo = w.days.iter().map(|d| d.lo).fold(999.0f32, f32::min);
let hi = w.days.iter().map(|d| d.hi).fold(-999.0f32, f32::max);
let row_h = 44.0f32.min((dr.bottom - dr.top - 34.0) / w.days.len().max(1) as f32);
for (k, d) in w.days.iter().enumerate() {
let yy = dr.top + 30.0 + k as f32 * row_h;
if yy + row_h > dr.bottom {
break;
}
text(&if k == 0 { tr("Hoje") } else { weekday_short(wday_of(d.t + 12.0 * 3600.0, w.off)) }, tf("card"), rf(dr.left + 14.0, yy, dr.left + 70.0, yy + row_h), white);
text(cond_emoji(d.code, true), tf("emojismall"), rf(dr.left + 64.0, yy, dr.left + 100.0, yy + row_h), white);
text(&graus(d.lo), tf("rowr"), rf(dr.left + 96.0, yy, dr.left + 136.0, yy + row_h), dim);
let (bx0, bx1, by) = (dr.left + 146.0, dr.right - 56.0, yy + row_h / 2.0);
fill(rf(bx0, by - 2.5, bx1, by + 2.5), rgb(0, 0, 0, 0.18), 2.5);
let span = (hi - lo).max(1.0);
let a_ = bx0 + (d.lo - lo) / span * (bx1 - bx0);
let b_ = bx0 + (d.hi - lo) / span * (bx1 - bx0);
fill(rf(a_, by - 2.5, (a_ + 6.0).max(b_), by + 2.5), rgb(255, 196, 64, 1.0), 2.5);
text(&graus(d.hi), tf("rowr"), rf(dr.right - 52.0, yy, dr.right - 12.0, yy + row_h), white);
}
let qx = dr.right + pad;
let qw = (sz.width - pad - qx - pad) / 2.0;
let qh = 150.0f32.min((dr.bottom - dr.top - pad) / 2.0);
let quad = |i: i32, title: &str, big: &str, sub: &str| {
let x = qx + (i % 2) as f32 * (qw + pad);
let yy = dr.top + (i / 2) as f32 * (qh + pad);
let r = rf(x, yy, x + qw, yy + qh);
fill(r, rgb(255, 255, 255, 0.14), 14.0);
text(title, tf("small"), rf(r.left + 14.0, r.top + 6.0, r.right, r.top + 26.0), dim);
text(big, tf("cityl"), rf(r.left + 14.0, r.top + 30.0, r.right - 8.0, r.top + 70.0), white);
text(sub, tf("smallwrap"), rf(r.left + 14.0, r.top + 72.0, r.right - 10.0, r.bottom - 8.0), white);
};
quad(0, &tr("SENSAÇÃO"), &graus(w.feels), &sensacao(w));
quad(1, &tr("UMIDADE"), &format!("{}%", w.hum.round() as i32), "");
quad(2, &tr("VENTO"), &format!("{} km/h", w.wind.round() as i32), "");
if let Some(d0) = w.days.first() {
quad(3, &tr("NASCER DO SOL"), &hm_of(d0.rise, w.off), &format!("{}{}", tr("Pôr do sol: "), hm_of(d0.set, w.off)));
}
end_paint();
}
fn open_search() {
let g = bar() > 0.0;
let fr = if g { rf(40.0, 71.0, 252.0, 89.0) } else { rf(12.0, 12.0, SB_W - 46.0, 36.0) };
field_open(fr, "", if g { 14.0 } else { 13.0 }, false, |t, key| {
if key == VK_RETURN.0 as i32 {
search(t);
} else if key == VK_ESCAPE.0 as i32 {
a().meu_local = false;
}
});
}
extern "system" fn proc_(h: HWND, m: u32, w_: WPARAM, l: LPARAM) -> LRESULT {
unsafe {
match m {
WM_PAINT => return wm_paint(h, paint),
WM_ERASEBKGND => return LRESULT(1),
WM_SIZE => {
on_size(l);
return LRESULT(0);
}
WM_DPICHANGED => {
on_dpi(w_, l);
return LRESULT(0);
}
WM_SETTINGCHANGE => {
invalidate();
return LRESULT(0);
}
WM_CTLCOLOREDIT => {
let dc = HDC(w_.0 as *mut _);
if bar() > 0.0 {
if !dark() {
return field_colors(dc, colorref(249, 250, 251));
}
let c = sidebar_color();
let mx = |v: f32| ((v + (1.0 - v) * 0.08) * 255.0).round() as u8;
return field_colors(dc, colorref(mx(c.r), mx(c.g), mx(c.b)));
}
return field_colors(dc, if dark() { colorref(40, 40, 42) } else { colorref(236, 236, 240) });
}
WM_FIELDLOST => {
let fh = app2d::s().field.h;
if !fh.0.is_null() && GetFocus() != fh {
field_close();
}
return LRESULT(0);
}
WM_DATA => {
if w_.0 == usize::MAX {
let p = *Box::from_raw(l.0 as *mut Place);
if !p.name.is_empty() && a().meu_local {
a().meu_local = false;
a().places.push(p);
let last = a().places.len() - 1;
a().places.swap(0, last);
set_my_place(0);
a().sel = 0;
save();
fetch(0);
fetch(last);
a().status.clear();
} else if !p.name.is_empty() {
a().places.push(p);
a().sel = a().places.len() as i32 - 1;
save();
fetch(a().sel as usize);
a().status.clear();
} else {
a().status = tr("Cidade não encontrada.");
}
} else {
let wx = *Box::from_raw(l.0 as *mut Wx);
if let Some(p) = a().places.get_mut(w_.0) {
p.loading = false;
if wx.ok {
p.wx = wx;
}
}
}
invalidate();
return LRESULT(0);
}
WM_TIMER => {
for i in 0..a().places.len() {
fetch(i);
}
return LRESULT(0);
}
WM_MOUSEWHEEL => {
if bar() > 0.0 {
let mx = (a().g_total - size().height).max(0.0);
a().g_scroll = (a().g_scroll - wheel_delta(w_) / 120.0 * 60.0).clamp(0.0, mx);
invalidate();
}
return LRESULT(0);
}
WM_LBUTTONDOWN | WM_RBUTTONUP => {
if !app2d::s().field.h.0.is_null() {
field_close();
}
let s_ = sc();
let (x, y) = (get_x_lparam(l) as f32 / s_, get_y_lparam(l) as f32 / s_);
for ht in a().hits.clone() {
if !in_rect(&ht.r, x, y) {
continue;
}
match ht.kind {
3 => {
a().side = !a().side;
invalidate();
}
2 => {
if !a().side {
a().side = true;
paint();
}
open_search();
invalidate();
}
1 => {
if m == WM_RBUTTONUP {
let scr = to_screen(h, get_x_lparam(l), get_y_lparam(l));
if let Ok(mm) = CreatePopupMenu() {
if ht.arg > 0 {
append_menu(mm, MF_STRING, 2, &tr("Usar como Meu Local"));
}
append_menu(mm, MF_STRING | if a().places.len() > 1 { MF_ENABLED } else { MF_GRAYED }, 1, &tr("Apagar"));
let k = TrackPopupMenu(mm, TPM_RETURNCMD | TPM_RIGHTBUTTON, scr.x, scr.y, 0, h, None).0;
let _ = DestroyMenu(mm);
if k == 2 {
a().places.swap(0, ht.arg as usize);
set_my_place(0);
a().sel = 0;
save();
} else if k == 1 && a().places.len() > 1 {
a().places.remove(ht.arg as usize);
if ht.arg == 0 {
set_my_place(0);
}
a().sel = 0;
save();
}
}
} else {
a().sel = ht.arg;
}
invalidate();
}
_ => {}
}
return LRESULT(0);
}
return LRESULT(0);
}
WM_KEYDOWN => {
let ctrl = key_down(VK_CONTROL.0);
if ctrl && w_.0 == 'W' as usize {
let _ = DestroyWindow(h);
}
if ctrl && w_.0 == 'R' as usize {
for i in 0..a().places.len() {
fetch(i);
}
}
if w_.0 == VK_UP.0 as usize && a().sel > 0 {
a().sel -= 1;
invalidate();
}
if w_.0 == VK_DOWN.0 as usize && ((a().sel + 1) as usize) < a().places.len() {
a().sel += 1;
invalidate();
}
return LRESULT(0);
}
WM_DESTROY => {
PostQuitMessage(0);
return LRESULT(0);
}
_ => {}
}
DefWindowProcW(h, m, w_, l)
}
}
fn main() {
if !app2d::init() {
std::process::exit(1);
}
*A.get() = Some(App { side: true, file: data_path("clima.txt"), meu_local: tem_arg("--meu-local"), ..Default::default() });
load();
let disp = if has_font("SF Pro Display") { "SF Pro Display".to_string() } else { family() };
let ic = icon_family();
use DWRITE_TEXT_ALIGNMENT_CENTER as C;
use DWRITE_TEXT_ALIGNMENT_LEADING as L;
use DWRITE_TEXT_ALIGNMENT_TRAILING as T;
let f = |s: f32, w_: DWRITE_FONT_WEIGHT, al: DWRITE_TEXT_ALIGNMENT, wrap: bool, fam: Option<&str>| fmt_full(s, w_, al, wrap, fam);
let me = DWRITE_FONT_WEIGHT_MEDIUM;
let sb_ = DWRITE_FONT_WEIGHT_SEMI_BOLD;
let emoji = cjk::format(dw(), "Segoe UI Emoji", DWRITE_FONT_WEIGHT_NORMAL, DWRITE_FONT_STYLE_NORMAL, 20.0, "").unwrap();
unsafe {
let _ = emoji.SetTextAlignment(C);
let _ = emoji.SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_CENTER);
}
let small_w = f(11.5, me, L, true, None);
let small_wrap = f(12.0, me, L, true, None);
unsafe {
let _ = small_w.SetParagraphAlignment(DWRITE_PARAGRAPH_ALIGNMENT_NEAR);
}
let t = &mut a().tf;
for (k, v) in [
("city", f(30.0, me, C, false, Some(&disp))),
("cityl", f(30.0, me, L, false, Some(&disp))),
("temp", f(92.0, DWRITE_FONT_WEIGHT_THIN, C, false, Some(&disp))),
("cond", f(18.0, me, C, false, None)),
("small", f(12.0, me, L, false, None)),
("smallwrap", small_wrap),
("smallc", f(13.0, me, C, false, None)),
("card", f(14.0, me, C, false, None)),
("cardbig", f(18.0, me, C, false, None)),
("rowr", f(16.0, me, T, false, None)),
("emojismall", emoji),
("side", f(15.0, sb_, L, false, None)),
("sidetemp", f(30.0, DWRITE_FONT_WEIGHT_LIGHT, T, false, Some(&disp))),
("icon", f(16.0, DWRITE_FONT_WEIGHT_NORMAL, C, false, Some(&ic))),
("cityg", f(22.0, me, C, false, Some(&disp))),
("tempg", f(64.0, DWRITE_FONT_WEIGHT_THIN, C, false, Some(&disp))),
("condg", f(14.0, sb_, C, false, None)),
("hdr", f(11.0, sb_, L, false, None)),
("hdrc", f(12.0, sb_, C, false, None)),
("bigg", f(26.0, me, L, false, Some(&disp))),
("smallw", small_w),
("searchg", f(14.0, DWRITE_FONT_WEIGHT_NORMAL, L, false, None)),
("condtitle", f(14.0, sb_, L, false, None)),
("cardg", f(14.0, sb_, C, false, None)),
] {
t.insert(k, v);
}
set_bar_wanted(52.0);
let aq = semaforo::aqua();
let Some(h) = create_main("ClimaJanela", &tr("Clima"), proc_, if aq { 1070 } else { 1080 }, if aq { 768 } else { 760 }) else { std::process::exit(1) };
for i in 0..a().places.len() {
fetch(i);
}
unsafe {
SetTimer(h, 1, 15 * 60 * 1000, None);
}
show(h, SW_SHOWNORMAL);
if a().meu_local {
a().side = true;
paint();
open_search();
a().status = tr("Digite a cidade do Meu Local");
invalidate();
}
std::process::exit(run());
}