Add Store support and unsigned app releases

This commit is contained in:
Tamas Csikel
2026-10-25 14:11:49 +01:00
parent 1694cc4858
commit bcc7bc64c0
38 changed files with 12394 additions and 5 deletions

101
sf-ui/gallery/src/main.rs Normal file
View File

@@ -0,0 +1,101 @@
//! sf-ui gallery: every component on one screen.
//!
//! cargo run -p sf-ui-gallery
//! SF_UI_SIZE=1920x1080 SF_UI_KEYS="down right" SF_UI_SNAPSHOT=shot.png cargo run -p sf-ui-gallery
use std::time::Duration;
use slint::{ComponentHandle, Model, Rgba8Pixel, SharedPixelBuffer, VecModel};
slint::include_modules!();
sf_ui::glue!(Gallery);
/// Stand-in artwork: a soft two-colour gradient with a light blob.
fn artwork(a: [u8; 3], b: [u8; 3], w: u32, h: u32) -> SharedPixelBuffer<Rgba8Pixel> {
let mut px = SharedPixelBuffer::<Rgba8Pixel>::new(w, h);
let (cw, ch) = (w as f32, h as f32);
for (i, p) in px.make_mut_slice().iter_mut().enumerate() {
let (x, y) = ((i as u32 % w) as f32 / cw, (i as u32 / w) as f32 / ch);
let t = (x * 0.6 + y * 0.4).clamp(0.0, 1.0);
let d = ((x - 0.7).powi(2) + (y - 0.3).powi(2)).sqrt();
let glow = (1.0 - d * 2.2).max(0.0).powi(2) * 0.55;
let c = |k: usize| ((a[k] as f32 * (1.0 - t) + b[k] as f32 * t) * (1.0 - glow) + 255.0 * glow) as u8;
*p = Rgba8Pixel { r: c(0), g: c(1), b: c(2), a: 255 };
}
px
}
fn main() -> anyhow::Result<()> {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("info")).init();
sf_ui::init()?;
let ui = Gallery::new()?;
ui.sf_ui_setup();
let colours = [
([190, 70, 40], [30, 10, 40]),
([30, 110, 160], [10, 20, 40]),
([60, 140, 80], [10, 30, 20]),
([170, 140, 40], [40, 20, 10]),
([120, 60, 170], [20, 10, 40]),
];
let pictures: Vec<SharedPixelBuffer<Rgba8Pixel>> = colours.iter().map(|(a, b)| artwork(*a, *b, 640, 360)).collect();
let images: Vec<slint::Image> = pictures.iter().map(|p| slint::Image::from_rgba8(p.clone())).collect();
ui.set_art(slint::ModelRc::new(VecModel::from(images)));
let weak = ui.as_weak();
ui.on_search(move |text| {
if let Some(ui) = weak.upgrade() {
ui.set_typed(text);
}
});
let glass = sf_ui::Glass::install(&ui, |ui, panels| {
panels.extend(ui.get_glass().iter());
panels.extend(ui.get_glass_menu().iter());
panels.extend(ui.get_glass_modal().iter());
panels.extend(ui.get_glass_keyboard().iter());
})?;
glass.set_palette(sf_ui::Palette::from_hex(["#ffb27a", "#8a3d12", "#120805"]));
// SF_UI_VIDEO=<uri> (feature "video"): the film plays under the glass.
#[cfg(feature = "video")]
let _video = match std::env::var("SF_UI_VIDEO") {
Ok(uri) => {
sf_ui::video::init()?;
log::info!("hardware decoding: {}", sf_ui::video::hardware_decoding());
let player = std::rc::Rc::new(std::cell::RefCell::new(sf_ui::video::Player::new(&uri, Default::default())?));
glass.set_video(Some(player.borrow().video()));
let p = player.clone();
let poll = slint::Timer::default();
poll.start(slint::TimerMode::Repeated, Duration::from_millis(100), move || {
let mut p = p.borrow_mut();
for ev in p.poll() {
log::info!("video: {ev:?}");
if let sf_ui::video::Event::Ready { .. } = ev {
log::info!("audio: {:?}", p.audio_tracks());
log::info!("text: {:?}", p.text_tracks());
}
}
});
Some((player, poll))
}
Err(_) => None,
};
// The focused card's artwork becomes the backdrop (crossfades), and the
// light follows the focus.
let weak = ui.as_weak();
let mut shown: Option<usize> = None;
let timer = slint::Timer::default();
timer.start(slint::TimerMode::Repeated, Duration::from_millis(100), move || {
let Some(ui) = weak.upgrade() else { return };
let want = (ui.get_area() == 2).then(|| ui.get_card() as usize);
if want != shown {
shown = want;
glass.set_backdrop(want.map(|i| sf_ui::Backdrop::new(pictures[i].clone()).dim(0.2)));
}
glass.set_light((ui.get_card() as f32 - 2.0) * 0.08);
});
ui.run()?;
Ok(())
}