Split the development switches: the sample data into voelin-ui-vm

dev/logic.rs now has the sample of VOELIN_DEMO_UI as plain values and as
the events a server would send: the servers and their presence, the
pictures (PNG bytes the front end saves), the chats with their pins and
topics, the contacts, the private chats, the poke, the offline messages,
the gateway's events, the notices and the recordings, and the older pages
that answer scrolling up. The helpers that only look at the state (the
divider of VOELIN_OPEN=unread, the first locked channel) moved with it. The
Slint side (dev/bind.rs) keeps the switches, the window and the screenshot,
and feeds the sample through the app's own events; a test replays the
whole sample through events::handle and checks the state it leaves.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
faumarayandClaude Sonnet 5.5 committed 2026-10-21 13:57:42 +03:00
1 parent 2d6cbf66af
commit bf72d85a22
11 files changed
+1447 -1036

No files matched your search

+2 -3
View File
@@ -29,14 +29,13 @@ roxmltree = { version = "0.21", default-features = false, features = ["std"] }
miniz_oxide = "0.8"
# Grapheme clusters for emoji in chat text.
unicode-segmentation = "1.13"
# The sample pictures of the demo data (VOELIN_DEMO_UI) and the tests.
png = "0.18"
voelin-audio = { path = "../voelin-audio", default-features = false }
voelin-core = { path = "../voelin-core", default-features = false, features = ["media"] }
voelin-gateway-proto = { path = "../voelin-gateway-proto" }
voelin-model = { path = "../voelin-model" }
voelin-store = { path = "../voelin-store" }
[dev-dependencies]
png = "0.18"
[lints]
workspace = true
File diff suppressed because it is too large. Load diff
+6
View File
@@ -0,0 +1,6 @@
//! The sample data of `VOELIN_DEMO_UI` and the helpers of the development
//! switches that only look at the state. [`logic`] has the sample servers,
//! people, chats, contacts, notices and pictures as plain values and as the
//! events a server would send.
pub mod logic;
+1
View File
@@ -15,6 +15,7 @@ pub mod bbcode;
pub mod bridge;
pub mod chat;
pub mod color;
pub mod dev;
pub mod emoji;
pub mod events;
pub mod home;
+8 -7
View File
@@ -2,11 +2,12 @@
//! event loop glue and the state the screens share.
//!
//! The screens' logic is elsewhere: servers and the channel tree in
//! `servers.rs`, chat in `chat.rs`, streams in `streams.rs`, the settings
//! page in `settings_page.rs` and `appearance.rs`, the settings pages in
//! `settings_pages/`, the Stream Studio in `studio/`, the view models in the
//! `voelin-ui-vm` crate (`vm`), callbacks in `bind/`, development switches in
//! `dev.rs`.
//! `servers/`, chat in `chat/`, streams in `streams/`, the people, the bell
//! and the search in `social/`, the settings page in `settings_page/` and
//! `appearance.rs`, the settings pages in `settings_pages/`, the Stream
//! Studio in `studio/`, what the screens show and what a move or an event
//! does in the `voelin-ui-vm` crate (`vm`), callbacks in `bind/`,
//! development switches in `dev/`.
use std::cell::RefCell;
use std::path::{Path, PathBuf};
@@ -234,7 +235,7 @@ pub(crate) struct App {
pub decoder: Option<Decoder>,
/// `VOELIN_DEMO_STREAM`: the viewer shows a local test stream.
pub demo: bool,
/// `VOELIN_DEMO_UI`: sample servers, channels and chat (dev.rs).
/// `VOELIN_DEMO_UI`: sample servers, channels and chat (dev/).
pub demo_ui: bool,
/// `VOELIN_AUTOSHARE=test-pattern`: share the test pattern once streams work.
pub autoshare: bool,
@@ -350,7 +351,7 @@ pub fn run(options: RunOptions) -> Result<()> {
let HostedEngine { engine, runtime, mut events } = hosted;
// VOELIN_DATA_DIR isolates the database; the other development
// switches are in dev.rs.
// switches are in dev/.
// A host that names the data directory (Android) has no platform cache
// directory either: avatars and icons go next to the database.
if let Some(dir) = &options.data_dir {
+506
View File
@@ -0,0 +1,506 @@
//! The Slint side of the development switches: the window's size, the
//! screenshot, the screens opened at start (`VOELIN_OPEN`), and the sample
//! data fed through the app's own events. The sample data itself is in
//! `voelin_ui_vm::dev::logic`.
use std::sync::Arc;
use std::time::Duration;
use anyhow::Result;
use slint::{ComponentHandle, Rgba8Pixel, SharedPixelBuffer};
use voelin_core::{Event, HistoryMessage, HistorySource, JoinFailure};
use voelin_model::ChatTarget;
use crate::app::{App, Bridge, MainWindow, MobileTab, Nav, Page, SettingsSection, with_app};
use crate::social::now_ms;
use crate::vm::dev::logic::{self, DEMO};
/// The switches read at start.
#[derive(Clone, Debug, Default)]
pub(crate) struct Switches {
pub demo_stream: bool,
pub demo_ui: bool,
pub autoshare: bool,
pub open_client: bool,
open: Vec<String>,
autoconnect: Option<String>,
screenshot: Option<std::path::PathBuf>,
screenshot_delay: u64,
window_size: Option<(f32, f32)>,
}
fn flag(name: &str) -> bool {
std::env::var(name).is_ok_and(|v| v == "1")
}
/// `390x844` → (390, 844).
fn parse_size(text: &str) -> Option<(f32, f32)> {
let (w, h) = text.split_once(['x', 'X'])?;
Some((w.trim().parse().ok()?, h.trim().parse().ok()?))
}
impl Switches {
pub fn from_env() -> Self {
let open: Vec<String> = std::env::var("VOELIN_OPEN")
.unwrap_or_default()
.split(',')
.map(|s| s.trim().to_owned())
.filter(|s| !s.is_empty())
.collect();
Self {
demo_stream: flag("VOELIN_DEMO_STREAM"),
demo_ui: flag("VOELIN_DEMO_UI"),
autoshare: std::env::var("VOELIN_AUTOSHARE").is_ok_and(|v| v == "test-pattern"),
open_client: open.iter().any(|o| o == "client"),
open,
autoconnect: std::env::var("VOELIN_AUTOCONNECT").ok(),
screenshot: std::env::var_os("VOELIN_SCREENSHOT").map(Into::into),
screenshot_delay: std::env::var("VOELIN_SCREENSHOT_DELAY")
.ok()
.and_then(|d| d.parse().ok())
.unwrap_or(4),
window_size: std::env::var("VOELIN_WINDOW_SIZE").ok().as_deref().and_then(parse_size),
}
}
}
fn section(name: &str) -> SettingsSection {
match name {
"1" | "keybinds" | "ptt" => SettingsSection::Keybinds,
"2" | "streaming" => SettingsSection::Streaming,
"3" | "privacy" => SettingsSection::Privacy,
"4" | "appearance" => SettingsSection::Appearance,
"5" | "account" => SettingsSection::Account,
"6" | "profiles" | "identities" => SettingsSection::Profiles,
"7" | "devices" => SettingsSection::Devices,
"8" | "notifications" => SettingsSection::Notifications,
"9" | "integrations" => SettingsSection::Integrations,
"10" | "advanced" => SettingsSection::Advanced,
_ => SettingsSection::Voice,
}
}
fn mobile_tab(name: &str) -> MobileTab {
match name {
"home" => MobileTab::Home,
"servers" => MobileTab::Servers,
"activity" => MobileTab::Activity,
"you" => MobileTab::You,
_ => MobileTab::Chat,
}
}
/// Timers that must live while the window runs.
pub(crate) struct Running {
_screenshot: Option<slint::Timer>,
_resize: Option<slint::Timer>,
_scroll: Option<slint::Timer>,
_more: Option<slint::Timer>,
}
/// Apply the switches once the app is set up.
pub(crate) fn start(ui: &MainWindow, switches: &Switches) -> Running {
if let Some((w, h)) = switches.window_size {
ui.window().set_size(slint::LogicalSize::new(w, h));
}
if switches.demo_ui {
with_app(demo_ui);
}
match switches.autoconnect.as_deref() {
Some("voice") => {
with_app(|app| app.connect_voice());
}
Some("observe") => {
with_app(|app| {
if let Some(id) = app.state.current {
app.observe(id);
}
});
}
_ => {}
}
let nav = ui.global::<Nav>();
for open in &switches.open {
let (what, arg) = open.split_once(':').unwrap_or((open.as_str(), ""));
match what {
"home" => nav.invoke_show(Page::Home),
"server" => {
nav.invoke_show(Page::Server);
// The server chat, which starts with the welcome message.
if arg == "chat" {
with_app(|app| app.select_tab(0));
}
}
"settings" => nav.invoke_open_settings(section(arg)),
"about" => nav.invoke_open_about(),
"share" => {
nav.invoke_open_share();
// The sample share of the test pattern, live at once.
if arg == "live" && switches.demo_ui {
with_app(|app| app.demo_share());
}
}
// The current server's dialog, Advanced open.
"bookmark" if arg == "edit" => {
if let Some(id) = with_app(|app| app.state.current).flatten() {
nav.invoke_edit_server(id as i32);
}
}
// `join`: the same dialog (Join a server was one of its own).
"bookmark" | "join" => nav.invoke_add_server(),
"emoji" => nav.set_emoji_open(true),
"panel" => nav.set_right_panel_open(true),
"no-panel" => nav.set_right_panel_open(false),
"tab" => nav.set_mobile_tab(mobile_tab(arg)),
"voice" => {
nav.invoke_show_voice(true);
// The smaller stage, for this run only.
if arg == "compact" {
nav.set_voice_compact(true);
}
}
"pins" => nav.invoke_show_pins(true),
// Opened once laid out (below).
"more" => {}
// The phone's members page.
"members" => nav.set_members_open(true),
// What Android hands over: a tapped voice notification, text
// shared to the app.
"notification" => crate::inbox::request(crate::inbox::Request::ShowVoice),
"shared" => crate::inbox::request(crate::inbox::Request::Share {
text: Some(arg.to_owned()),
files: Vec::new(),
}),
"topics" => nav.invoke_show_topics(true),
"topic" => {
with_app(|app| {
app.open_topic(arg.parse().unwrap_or(1));
// No gateway answers in demo mode.
if switches.demo_ui {
app.handle_event(logic::topic_history(now_ms()));
}
});
}
"member" => {
with_app(|app| app.open_first_member());
}
// After `friends` the contact path (Kairo without a contact
// chosen), else the member card's.
"poke" => {
let friends = nav.get_page() == Page::Friends;
with_app(|app| {
if friends {
let uid = app.social.selected.clone().unwrap_or_else(|| "demo-3".into());
app.contact_action(&uid, "poke");
} else {
app.open_first_member();
app.member_action("poke");
}
});
}
"channel-password" => {
with_app(|app| open_channel_password(app, arg == "wrong"));
}
// A screenshot cannot hover.
"actions" => nav.set_show_actions(true),
// Home as before the first server, over the sample data.
"first-run" => nav.set_first_run(true),
// `end`: further back, so the divider is above the view.
"unread" => {
with_app(|app| open_unread(app, if arg == "end" { 10 } else { 5 }));
}
"link-confirm" => {
let url = if arg.is_empty() { logic::DEMO_RAID_BOARD } else { arg };
with_app(|app| app.open_link_text(url, true));
}
// As a link from the platform comes.
"link" => crate::inbox::request(crate::inbox::Request::OpenLink(arg.to_owned())),
"watch" | "popout" => {
with_app(|app| {
if switches.demo_ui {
app.demo_watch();
} else {
app.watch_first_stream();
}
if what == "popout" {
app.viewer_pop_out();
}
});
}
"theatre" => nav.set_theatre(true),
// Home, friends, messages, events, the bell, the search.
"friends" => {
with_app(|app| app.select_contact(arg.to_owned()));
nav.invoke_show(Page::Friends);
}
"messages" | "dm" => {
let uid = if arg.is_empty() { "demo-3" } else { arg };
with_app(|app| app.open_dm_with(Some(logic::DEMO), uid));
nav.invoke_show(Page::Messages);
}
"inbox" => {
nav.set_dm_tab(2);
with_app(|app| app.dm_tab(2));
nav.invoke_show(Page::Messages);
}
"library" => nav.invoke_show(Page::Library),
"events" => nav.invoke_show(Page::Events),
"event-form" => nav.invoke_create_event(),
"search" => nav.invoke_open_search(arg.into()),
"notifications" => nav.set_notifications_open(true),
"offline" => nav.invoke_write_offline("demo-ari".into(), "Ari".into()),
"picture" => {
let picture = logic::demo_picture(1280, 720, 16);
let image = crate::images::picture("demo:lightbox", &picture);
nav.set_lightbox(image);
nav.set_lightbox_open(true);
}
// The camera preview of the settings (the test pattern).
"camera" => {
with_app(|app| {
app.start_camera();
app.refresh_pages();
});
}
"studio" => {
if arg != "window" {
nav.invoke_open_studio();
}
with_app(|app| app.studio_dev(arg));
}
// Opened once connected (settings_page.rs).
"client" => {}
other => eprintln!("VOELIN_OPEN: unknown screen {other:?}"),
}
}
// A window manager can refuse the size set before the window opened,
// so ask again once it is up. (Under `xvfb-run` in a Wayland session,
// remove WAYLAND_DISPLAY, or winit opens the window on the desktop.)
let resize = switches.window_size.map(|(w, h)| {
let weak = ui.as_weak();
let timer = slint::Timer::default();
timer.start(
slint::TimerMode::SingleShot,
Duration::from_millis(switches.screenshot_delay * 1000 / 2),
move || {
if let Some(ui) = weak.upgrade() {
ui.window().set_size(slint::LogicalSize::new(w, h));
}
},
);
timer
});
// `unread`: up to the divider once the list is laid out (after the
// resize above).
let scroll = switches.open.iter().any(|o| o == "unread").then(|| {
late(ui, switches, |ui| {
let bridge = ui.global::<Bridge>();
bridge.set_jump_index(bridge.get_unread_index());
bridge.set_jump_requests(bridge.get_jump_requests().wrapping_add(1));
})
});
// `more`: the phone voice screen's More menu (a screenshot cannot tap).
let more = switches.open.iter().any(|o| o == "more").then(|| {
late(ui, switches, |ui| {
let nav = ui.global::<Nav>();
nav.set_more_requests(nav.get_more_requests().wrapping_add(1));
})
});
let screenshot = switches.screenshot.clone().map(|path| {
let weak = ui.as_weak();
let timer = slint::Timer::default();
timer.start(
slint::TimerMode::SingleShot,
Duration::from_secs(switches.screenshot_delay),
move || {
if let Some(ui) = weak.upgrade() {
if let Err(e) = save_screenshot(&ui, &path) {
eprintln!("screenshot failed: {e}");
}
let _ = ui.hide();
// Also when the studio's or the stream's own window is
// open.
let _ = slint::quit_event_loop();
}
},
);
timer
});
Running { _screenshot: screenshot, _resize: resize, _scroll: scroll, _more: more }
}
/// A timer that runs `action` at three quarters of the screenshot delay, once
/// the window has its size and the screens are laid out.
fn late(
ui: &MainWindow,
switches: &Switches,
action: impl Fn(&MainWindow) + 'static,
) -> slint::Timer {
let weak = ui.as_weak();
let timer = slint::Timer::default();
timer.start(
slint::TimerMode::SingleShot,
Duration::from_millis(switches.screenshot_delay * 1000 * 3 / 4),
move || {
if let Some(ui) = weak.upgrade() {
action(&ui);
}
},
);
timer
}
fn save_screenshot(ui: &MainWindow, path: &std::path::Path) -> Result<()> {
let mut image = ui.window().take_snapshot()?;
let window = with_app(|app| app.studio_snapshot().or_else(|| app.viewer_snapshot())).flatten();
if let Some(window) = window {
let stem = path.file_stem().unwrap_or_default().to_string_lossy();
save_png(&window, &path.with_file_name(format!("{stem}-window.png")))?;
paste(&mut image, &window);
}
save_png(&image, path)
}
/// Draw `top` over the bottom right of `image` with a border, as a second
/// window sits on a desktop.
fn paste(image: &mut SharedPixelBuffer<Rgba8Pixel>, top: &SharedPixelBuffer<Rgba8Pixel>) {
let (w, h) = (image.width() as usize, image.height() as usize);
let (tw, th) = (top.width() as usize, top.height() as usize);
let (x0, y0) = (w.saturating_sub(tw + 24), h.saturating_sub(th + 24));
let border = Rgba8Pixel { r: 0x3f, g: 0x7b, b: 0xff, a: 0xff };
let pixels = image.make_mut_slice();
for y in y0.saturating_sub(1)..(y0 + th + 1).min(h) {
for x in x0.saturating_sub(1)..(x0 + tw + 1).min(w) {
let (ty, tx) = (y.wrapping_sub(y0), x.wrapping_sub(x0));
pixels[y * w + x] =
if ty < th && tx < tw { top.as_slice()[ty * tw + tx] } else { border };
}
}
}
fn save_png(image: &SharedPixelBuffer<Rgba8Pixel>, path: &std::path::Path) -> Result<()> {
let file = std::io::BufWriter::new(std::fs::File::create(path)?);
let mut encoder = png::Encoder::new(file, image.width(), image.height());
encoder.set_color(png::ColorType::Rgba);
encoder.set_depth(png::BitDepth::Eight);
encoder.write_header()?.write_image_data(image.as_bytes())?;
Ok(())
}
/// The current chat's read marker `back` messages before its end
/// ([`logic::unread_from`]), its "New" divider shown (`VOELIN_OPEN=unread`).
fn open_unread(app: &mut App, back: usize) {
if logic::unread_from(&mut app.state, back) {
app.refresh_chat();
app.refresh_servers();
}
}
/// `VOELIN_OPEN=channel-password`: join the current server's first locked
/// channel, which asks for its password; `wrong` as if the server had
/// refused one.
fn open_channel_password(app: &mut App, wrong: bool) {
let Some((session, channel)) = logic::first_locked_channel(&app.state) else { return };
if wrong {
if let Some(view) = app.view_mut() {
view.channel_passwords.insert(channel, "guess".into());
}
app.join_failed(session, channel, JoinFailure::Password);
} else {
app.join_channel(session, channel);
}
}
/// Sample data through the same events a server would send.
fn demo_ui(app: &mut App) {
app.state.bookmarks = logic::bookmarks();
app.state.settings.last_voice = Some(logic::last_voice());
app.state.current = Some(DEMO);
for event in logic::server_events() {
app.handle_event(event);
}
demo_pictures(app);
for event in logic::chat_events(now_ms()) {
app.handle_event(event);
}
demo_social(app);
// No toast over the screenshots.
app.set_status("");
app.refresh_all();
}
/// Avatars, icons, banners and badges as the engine reports them once they
/// are in its cache (here a folder of synthetic pictures in the temporary
/// directory).
fn demo_pictures(app: &mut App) {
let dir = std::env::temp_dir().join("voelin-demo-pictures");
let _ = std::fs::create_dir_all(&dir);
let address = app.bookmark(DEMO).map(|b| b.address.clone()).unwrap_or_default();
let events = logic::pictures(&address, |name, png| {
let path = dir.join(name);
let _ = std::fs::write(&path, png);
path
});
for event in events {
app.handle_event(event);
}
}
/// Sample people, private chats, pokes, notifications, events, a picture
/// and recordings for the home, friends, messages, events and settings
/// screens (`VOELIN_DEMO_UI`).
fn demo_social(app: &mut App) {
let now = now_ms();
// The second sample server is observed: a few people there.
for event in logic::lounge_events() {
app.handle_event(event);
}
app.handle_event(Event::ContactsChanged { contacts: Arc::new(logic::contacts(now)) });
for (uid, since) in logic::online_since(now) {
app.social.online_since.insert(uid.into(), since);
}
for event in logic::private_chat_events(now) {
app.handle_event(event);
}
let (server_uid, chat, bookmark) = logic::stored_chat(now);
app.social.dm.stored.push((server_uid.into(), chat));
app.social.dm.bookmark_of.insert(server_uid.into(), bookmark);
logic::read_samples(&mut app.state);
let (poke, ts_ms) = logic::poke(now);
app.handle_event(poke);
if let Some(p) = app.social.pokes.last_mut() {
p.ts_ms = ts_ms;
}
app.handle_event(logic::offline_messages(now));
logic::link_previews(&mut app.state);
for event in logic::gateway_events(now) {
app.handle_event(event);
}
for n in logic::notices() {
app.notify(n.kind, n.title, n.body, n.target, n.name, n.uid);
}
logic::age_notices(&mut app.social, now);
app.refresh_notices();
app.models.social.recordings.sync(&logic::recordings());
app.refresh_chats();
app.refresh_people();
app.refresh_home();
}
/// Answer [`App::load_older`] in demo mode (no engine runs) with
/// [`logic::demo_older`], a moment later as a server would.
pub(crate) fn answer_older(session: i64, target: ChatTarget, oldest: Option<HistoryMessage>) {
slint::Timer::single_shot(Duration::from_millis(600), move || {
let now = now_ms();
let (messages, complete) = logic::demo_older(&target, oldest.as_ref(), now);
with_app(|app| {
app.handle_event(Event::ChatHistory {
session: session as u64,
target,
messages,
source: HistorySource::Gateway,
complete,
});
});
});
}
+67
View File
@@ -0,0 +1,67 @@
//! Development switches (environment variables), for trying screens and
//! taking screenshots without a server:
//!
//! - `VOELIN_DATA_DIR=<dir>`: the database (app.rs).
//! - `VOELIN_AUTOCONNECT=voice|observe`: connect the first bookmark on start.
//! - `VOELIN_SCREENSHOT=<png>`: save the window after
//! `VOELIN_SCREENSHOT_DELAY` seconds (default 4) and exit.
//! - `VOELIN_WINDOW_SIZE=<w>x<h>`: the window's size (e.g. `390x844` for the
//! phone layout).
//! - `VOELIN_DEMO_UI=1`: sample servers, channels, chat (two pages of older
//! messages answer scrolling up) and streams, no server needed (nothing is
//! stored).
//! - `VOELIN_DEMO_STREAM=1`: a local test stream in the viewer.
//! - `VOELIN_OPEN=<what>[,<what>...]`: open screens on start: `home`,
//! `server` (`server:chat`: its server chat), `settings[:<section>]`
//! (voice, keybinds, streaming, privacy, appearance, or 0-4), `about`,
//! `share`, `bookmark` (add a server, also `join`;
//! `bookmark:edit` the current one, Advanced open),
//! `emoji` (the picker), `client` (the volume dialog of the first other
//! client once connected), `panel` / `no-panel` (the members panel),
//! `voice` (the voice channel view; on the phone its own screen;
//! `voice:compact` with the smaller stage, not stored),
//! `more` (after `voice` on the phone: the voice screen's More menu,
//! opened once the screen is laid out),
//! `members` (the phone's members page), `notification` (a tapped voice
//! notification), `shared:<text>` (text shared to the app on Android),
//! `pins`, `topics` (the drawers),
//! `topic:<id>` (a topic's messages), `member` (the member card of the
//! first other client), `poke` (the poke dialog: for the contact shown
//! after `friends`, else for the first other client, its card open),
//! `channel-password` (the password dialog of the first locked channel,
//! the sample's Officers; `channel-password:wrong` as after a refused
//! one), `actions` (the last message's actions, as if hovered),
//! `first-run` (home's banner as before the first server, over the
//! sample data),
//! `unread` (the current chat read up to five messages before its end:
//! the "New" divider, scrolled up to; `unread:end` ten messages before,
//! at the list's end, under the bar that counts the new messages),
//! `link-confirm[:<url>]` (the question before a masked link opens, by
//! default the sample's raid board), `link:<url>` (a TeamSpeak link
//! opened: the server dialog filled in from it, or in voice on its
//! server a move into its channel), `watch` (the first stream; with
//! sample data the local test pattern in its place), `theatre` (after
//! `watch`: in theatre mode), `popout` (`watch` in a window of its own),
//! `tab:<home|servers|chat|activity|you>` (phone layout); `friends[:<uid>]`,
//! `messages[:<uid>]` (a private chat), `inbox` (offline messages),
//! `library`, `events`, `event-form`, `search[:<text>]`,
//! `notifications` (the bell), `offline` (an offline message), `picture`
//! (a chat picture opened large), `camera` (the settings' camera
//! preview); settings sections also `account`,
//! `profiles` (also `identities`), `devices`, `notifications`,
//! `integrations`, `advanced` (5-10);
//! `studio[:<what>]`: the Stream Studio (with `VOELIN_DEMO_UI` a demo
//! studio from synthetic sources), `studio:window` in a window of its own,
//! `studio:live` going live (also with a screen opened after it:
//! `studio:live,server,voice` shows our stream's card with the studio's
//! picture), `studio:record`, or a dialog: `studio:source`,
//! `studio:audio`, `studio:camera`, `studio:scene`, `studio:settings`.
//! A screenshot also saves the studio's window, or the stream's
//! (`<name>-window.png`), and draws it over the main window.
//! - `VOELIN_AUTOWATCH=1`: watch the first stream that shows up.
//! - `VOELIN_AUTOSHARE=test-pattern`: share the test pattern (accepting
//! everyone) once connected to a TeamSpeak 6 server.
mod bind;
pub(crate) use bind::{Switches, answer_older, start};
+1 -1
View File
@@ -129,7 +129,7 @@ impl App {
self.with_player(|_, window| crate::streams::show_cursor(window, shown));
}
/// A picture of the viewer's window (screenshots, dev.rs).
/// A picture of the viewer's window (screenshots, dev/).
pub(crate) fn viewer_snapshot(&self) -> Option<SharedPixelBuffer<Rgba8Pixel>> {
self.popout.window.as_ref()?.window().take_snapshot().ok()
}
+2 -2
View File
@@ -1253,12 +1253,12 @@ impl App {
});
}
/// A picture of the studio window (screenshots, dev.rs).
/// A picture of the studio window (screenshots, dev/).
pub(crate) fn studio_snapshot(&self) -> Option<SharedPixelBuffer<Rgba8Pixel>> {
self.studio.window.as_ref()?.window().take_snapshot().ok()
}
// Development switches and sample data (dev.rs).
// Development switches and sample data (dev/).
/// `VOELIN_OPEN=studio:<what>`: `window` (the window of its own), `live`,
/// `record`, or a dialog: `source`, `audio`, `camera`, `scene`, `settings`.
+1 -1
View File
@@ -1,6 +1,6 @@
// Where the user is: the page, open dialogs, panel sizes. Any screen can
// navigate through these functions; Rust sets the same properties for the
// development switch VOELIN_OPEN (src/dev.rs).
// development switch VOELIN_OPEN (src/dev/mod.rs).
import { Bridge, BookmarkForm, ShareForm, EventForm, OfflineForm } from "bridge.slint";
import { StudioBridge } from "studio-bridge.slint";
+7 -5
View File
@@ -39,6 +39,7 @@ crates/voelin-ui-vm/ view models and state, no UI toolkit
settings.rs the UI's settings keys, the audio form
settings_pages/logic.rs, studio/logic.rs
the decisions of the settings pages and of the Stream Studio
dev/logic.rs the sample data of `VOELIN_DEMO_UI` as plain values and events
social/logic.rs the friends, the bell and the search as rows, what the user's moves on
them do, and what an event does to the friends, pokes and notices
settings_page/logic.rs
@@ -93,7 +94,9 @@ crates/voelin-ui/ the Slint front end
(plain values → Slint values), rows.rs (a Slint model kept in step
with a plain list)
images.rs the image cache (LRU, bounded by `ui.image_cache_mb`)
dev.rs development switches (screenshots, sample data)
dev/ mod.rs (the switches, listed), bind.rs: the window's size, the
screenshot, the screens opened at start, the sample data fed through
the app's own events
```
Models are created once (`app::Models`) and updated row by row with
@@ -164,7 +167,7 @@ this file is `voelin_ui_vm::chat`. The boundary:
settings service, the `AppState` and plain rows; they return rows,
commands or messages for the status line, and write no Bridge) and
`<area>/bind.rs` in `voelin-ui` (the Bridge and model writes, windows,
timers, threads, engine commands). Done: `settings_pages`, `studio`, `streams`, `chat`, `servers`, `settings_page` and `social`.
timers, threads, engine commands). Done: `settings_pages`, `studio`, `streams`, `chat`, `servers`, `settings_page`, `social` and `dev`.
The pure code is tested in `voelin-ui-vm` (`cargo test -p voelin-ui-vm`,
no display); the Slint crate's tests are what needs the window types.
@@ -186,7 +189,6 @@ the same shape as `settings_pages` and `studio`: move the decisions into
| File | `.set_` calls | What it mixes |
|---|---|---|
| `app.rs` | 31 | setup, the status line, the toolbar and tree refreshes (the event dispatch is `vm::events::apply`) |
| `dev.rs` | 23 | development switches and the sample data (the switches stay with the window; the sample rows can move) |
| `images.rs` | 13 | the decoded-picture cache |
| `messages.rs` | 12 | direct messages |
| `appearance.rs` | 11 | theme, font scale and breakpoints |
@@ -583,7 +585,7 @@ for importing the official clients' identities on start
the Slint side as `impl App` in `voelin-ui/src/<name>.rs`, with the
decisions in the view-model crate (`<name>/logic.rs`, [Two
crates](#two-crates)).
5. A development switch to open it (`dev.rs`, `VOELIN_OPEN=<name>`), a
5. A development switch to open it (`dev/bind.rs`, `VOELIN_OPEN=<name>`), a
screenshot (below) and a line in this file.
## Settings
@@ -669,7 +671,7 @@ notifications and the home's news show the text on one line
## Development switches and screenshots
Environment variables (see `src/dev.rs`):
Environment variables (see `src/dev/mod.rs`):
- `VOELIN_DEMO_UI=1`: sample servers, channels, members, chat with
formatting and emoji (and two pages of older messages, which load when