Merge the development branch: Wave 5B's phone screens and quick-share sound

Both sides kept. From the development branch: the phone's voice channel
screen, the pages over it (pins, topics, members), the voice button in
the phone's top bar, the quick share's mixer and picker, invite links,
viewer counts, the studio's cameras and RTMP output, and the Android
pieces.

The phone's top bar keeps this wave's search button next to the voice
button and the bell (the bell opens the notifications panel); its tabs
mark Home also on the friends, messages and Library pages and Servers on
a server's events page. The phone shell shows both sides' pages: this
wave's friends, messages, events and Library pages with their back
button, and the development branch's voice channel screen, which hides
the bottom navigation as before.

Home keeps this wave's page, which maps the design onto TeamSpeak as
decided for it (friends' presence across servers, the latest chats of
every server, live streams of all servers); the development branch's
interim home (people on the current server, its chats, its streams)
gives way to it. Its server cards still switch the phone to the Servers
tab through Nav.show. A server item keeps this wave's detail and flavor
with the development branch's wording of `live` (streams on the server).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
selikhovandClaude Opus 5.5 committed 2026-10-04 03:20:20 +03:00
commit cd5ac614ef
104 files changed
+8174 -574

No files matched your search

+8
View File
@@ -438,6 +438,9 @@ pub(crate) struct App {
}
thread_local! {
// It is `const`; clippy for Android targets does not see that through
// the macro's expansion there.
#[allow(clippy::missing_const_for_thread_local)]
static APP: RefCell<Option<App>> = const { RefCell::new(None) };
}
@@ -669,6 +672,8 @@ pub fn run(options: RunOptions) -> Result<()> {
});
let _dev = crate::dev::start(&ui, &switches);
// What the platform asked for before the window ran.
crate::inbox::take();
ui.run()?;
// With our own engine, leave servers properly, so no ghost client stays
@@ -768,6 +773,9 @@ impl App {
self.playback = self.prefs.get(&CLIENT_PLAYBACK);
} else if appearance_keys().iter().any(|k| k.name() == key) {
self.apply_appearance();
} else if key == voelin_core::settings::STREAM_AUDIO_SOURCES.name() {
// A running share mixes the new sources (streams.rs).
self.share_audio_changed();
}
self.page_setting_changed(key);
}
+1
View File
@@ -58,4 +58,5 @@ pub(super) fn wire(ui: &MainWindow) {
bridge.on_client_audio_changed(|form| {
with_app(|app| app.client_playback_changed(&form));
});
bridge.on_invite(|| with_app(|app| app.invite_link()).unwrap_or_default().into());
}
+2 -2
View File
@@ -73,8 +73,8 @@ pub(crate) fn wire(bridge: &StudioBridge) {
bridge.on_list_audio(|| {
with_app(|app| app.studio_list_audio());
});
bridge.on_add_audio(|i| {
with_app(|app| app.studio_add_audio(index(i)));
bridge.on_toggle_audio(|i| {
with_app(|app| app.studio_toggle_audio(index(i)));
});
bridge.on_set_gain(|i, db, done| {
with_app(|app| app.studio_set_gain(index(i), db, done));
+12 -2
View File
@@ -367,7 +367,17 @@ impl App {
let tabs: Vec<ChatTab> = view
.tabs
.iter()
.map(|t| ChatTab {
.map(|t| {
let (last, time) = t
.messages
.last()
.map(|m| vm::chat::preview(&m.message.message))
.unwrap_or_default();
(t, last, time)
})
.map(|(t, last, time)| ChatTab {
last: last.into(),
time: time.into(),
title: t.title.clone().into(),
name: t.title.trim_start_matches(['#', '@']).into(),
kind: match t.target {
@@ -775,7 +785,7 @@ impl App {
}
/// Upload a file into a channel and link it in the chat once it is up.
fn upload(&mut self, id: i64, channel: u64, from: PathBuf) {
pub(crate) fn upload(&mut self, id: i64, channel: u64, from: PathBuf) {
let Some(name) = from.file_name().map(|n| n.to_string_lossy().to_string()) else { return };
let view = self.sessions.entry(id).or_default();
let transfer = view.next_transfer;
+21 -2
View File
@@ -15,7 +15,10 @@
//! appearance, or 0-4), `about`, `share`, `bookmark` (add a server),
//! `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), `pins`, `topics` (the drawers),
//! `voice` (the voice channel view; on the phone its own screen),
//! `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), `watch` (the first stream; with sample data the
//! local test pattern in its place), `popout` (the same, popped out),
@@ -167,7 +170,13 @@ pub(crate) fn start(ui: &MainWindow, switches: &Switches) -> Running {
"server" => nav.invoke_show(Page::Server),
"settings" => nav.invoke_open_settings(section(arg)),
"about" => nav.invoke_open_about(),
"share" => nav.invoke_open_share(),
"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());
}
}
"bookmark" => nav.invoke_add_server(),
"emoji" => nav.set_emoji_open(true),
"panel" => nav.set_right_panel_open(true),
@@ -175,6 +184,15 @@ pub(crate) fn start(ui: &MainWindow, switches: &Switches) -> Running {
"tab" => nav.set_mobile_tab(mobile_tab(arg)),
"voice" => nav.invoke_show_voice(true),
"pins" => nav.invoke_show_pins(true),
// 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| {
@@ -480,6 +498,7 @@ fn demo_ui(app: &mut App) {
bitrate: 8000,
viewer_limit: 0,
audio: true,
viewers: Some(12),
}],
},
Event::State {
+101
View File
@@ -0,0 +1,101 @@
//! Requests from the platform around the window: on Android a tapped
//! notification or something shared to the app ("Share to Voelin"). They
//! can come from any thread and before the window runs; [`request`] keeps
//! them until the window takes them on its thread.
use std::path::PathBuf;
use std::sync::{Mutex, PoisonError};
use slint::ComponentHandle;
use voelin_model::ChatTarget;
use crate::app::{App, MobileTab, Nav, Page, with_app};
/// What the platform asks the window to do.
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum Request {
/// Show the voice channel we are in (the phone's voice screen).
ShowVoice,
/// Shared to the app: the text goes into the current chat's composer
/// (to send with one tap, or edit, as a mis-tap in the share sheet
/// should not post into a chat), the files are uploaded to the current
/// channel and linked there, as the composer's attach button does.
Share { text: Option<String>, files: Vec<PathBuf> },
}
static PENDING: Mutex<Vec<Request>> = Mutex::new(Vec::new());
/// Hand `request` to the window: at once if it runs, else when it starts.
pub fn request(request: Request) {
PENDING.lock().unwrap_or_else(PoisonError::into_inner).push(request);
// Fails without an event loop yet; `run` takes them then.
let _ = slint::invoke_from_event_loop(take);
}
/// Handle what is pending, on the window's thread; kept while there is no
/// window.
pub(crate) fn take() {
let Some(ui) = with_app(|app| app.ui.upgrade()).flatten() else { return };
let requests = std::mem::take(&mut *PENDING.lock().unwrap_or_else(PoisonError::into_inner));
// Not inside `with_app`: navigating calls back into Rust, which borrows
// the app again.
let nav = ui.global::<Nav>();
for request in requests {
match request {
Request::ShowVoice => {
nav.invoke_show(Page::Server);
nav.invoke_show_voice(true);
}
Request::Share { text, files } => {
// The phone shows the chat it went to.
nav.set_mobile_tab(MobileTab::Chat);
nav.invoke_show(Page::Server);
with_app(|app| app.share(&nav, text, files));
}
}
}
}
impl App {
fn share(&mut self, nav: &Nav<'_>, text: Option<String>, files: Vec<PathBuf>) {
let current = self.current.and_then(|id| {
let view = self.sessions.get(&id)?;
let tab = &view.tabs[view.current_tab];
// Files go to the channel of the chat, else to ours.
let channel = match tab.target {
ChatTarget::Channel(channel) => Some(channel),
_ => view.state.own_channel,
}
.map(|c| {
let name = view.presence.channels.get(&c).map(|c| c.name.as_str());
(c, name.map_or_else(|| "the channel".to_owned(), |n| format!("#{n}")))
});
Some((id, tab.title.clone(), channel))
});
if let Some(text) = text.filter(|t| !t.trim().is_empty()) {
nav.set_draft(text.into());
self.set_status(match &current {
Some((_, title, _)) => format!("Shared text is ready to send to {title}"),
None => "Shared text is in the composer".to_owned(),
});
}
if files.is_empty() {
return;
}
match current {
Some((id, _, Some((channel, name)))) if !self.demo_ui => {
let count = files.len();
for file in files {
self.upload(id, channel, file);
}
let what = if count == 1 {
"the shared file".to_owned()
} else {
format!("{count} files")
};
self.set_status(format!("Uploading {what} to {name}"));
}
_ => self.set_status("Open a channel's chat (or join a channel) to share files there"),
}
}
}
+2
View File
@@ -11,6 +11,7 @@ mod events;
mod home;
mod hotkey;
mod images;
mod inbox;
mod members;
mod messages;
mod previews;
@@ -25,3 +26,4 @@ mod video;
mod vm;
pub use app::{HostedEngine, RunOptions, run};
pub use inbox::{Request, request};
+27
View File
@@ -332,6 +332,33 @@ impl App {
self.refresh_tree();
}
/// A link to the voice channel we are in, for the Invite button (which
/// copies it); empty, with a note, without one.
pub(crate) fn invite_link(&mut self) -> String {
let bookmark = self.current.and_then(|id| self.bookmark(id)).map(|b| b.address.clone());
let path = self.view().and_then(|v| {
let mut names = Vec::new();
let mut channel = v.presence.channels.get(&v.state.own_channel?)?;
loop {
names.push(channel.name.clone());
match v.presence.channels.get(&channel.parent) {
Some(parent) if channel.parent != 0 && names.len() < 64 => channel = parent,
_ => break,
}
}
names.reverse();
Some(names)
});
let (Some(address), Some(path)) = (bookmark, path) else {
self.set_status("Join a voice channel to invite others to it");
return String::new();
};
let path: Vec<&str> = path.iter().map(String::as_str).collect();
let link = vm::servers::invite_link(&address, &path);
self.set_status(format!("Copied an invite to {}: {link}", path.last().unwrap_or(&"")));
link
}
pub(crate) fn toggle_collapse(&mut self, channel: u64) {
if let Some(view) = self.view_mut()
&& !view.collapsed.remove(&channel)
+185 -37
View File
@@ -2,16 +2,22 @@
//! viewer. The engine runs the stream sessions; `video.rs` captures,
//! encodes and decodes.
use std::time::Duration;
use slint::{ComponentHandle, Model};
use tracing::warn;
use voelin_core::media::audio_source_specs;
use voelin_core::settings::{STREAM_AUDIO_SOURCES, STREAM_BITRATE_KBPS, STREAM_FPS};
use voelin_core::media::{Streamer, audio_source_specs};
use voelin_core::settings::{
AudioSourceSetting, STREAM_AUDIO_SOURCES, STREAM_BITRATE_KBPS, STREAM_FPS,
};
use voelin_core::stream::{
EndReason, LayerId, LayerSpec, LeaveReason, StreamKind, StreamSetup, ViewerInfo, ViewerState,
};
use voelin_core::{Command, Event, StreamState, WatchState};
use crate::app::{App, Bridge, ShareForm, SourceItem, StreamItem, ViewerItem, later, model};
use crate::app::{
App, Bridge, ShareForm, SourceItem, StreamItem, ViewerItem, later, model, with_app,
};
use crate::settings::{
BITRATE_CHOICES, FPS_CHOICES, ShareDefaults, nearest_choice, parse_positive,
};
@@ -27,6 +33,46 @@ pub(crate) struct Share {
viewers: Vec<ViewerInfo>,
/// The capture ended by itself and the stream is being stopped.
stopping: bool,
/// The audio mixer's meters (the studio's rows), about 15 times a second.
_meters: slint::Timer,
}
/// What the share dialog asks of the capture: the audio mixer's `sources`
/// (`stream.audio_sources`) while "Share system audio" is on; off, or with
/// no sources, no audio at all.
fn capture_request(
fps: u32,
bitrate_kbps: u32,
audio: bool,
sources: &[AudioSourceSetting],
restore_token: Option<String>,
) -> CaptureRequest {
let audio_sources = if audio { audio_source_specs(sources) } else { Vec::new() };
CaptureRequest {
fps,
bitrate_kbps,
audio: !audio_sources.is_empty(),
audio_sources,
restore_token,
}
}
/// The viewers of the sample share (VOELIN_DEMO_UI): two watch, one asks.
fn demo_viewers() -> Vec<ViewerInfo> {
let viewer = |id, state, message: &str| ViewerInfo {
client: tsclientlib::ClientId(id),
state,
message: message.into(),
layer: None,
estimate: None,
srtp_profile: None,
codec: None,
};
vec![
viewer(3, ViewerState::Connected, ""),
viewer(5, ViewerState::Connected, ""),
viewer(4, ViewerState::Requested, "Can I watch?"),
]
}
/// The stream in the viewer.
@@ -103,6 +149,13 @@ fn share_end_text(reason: &EndReason) -> String {
}
}
/// How many watch stream `id`: the server's count (TeamSpeak 6 tells it),
/// else the gateway directory's.
fn viewer_count(view: &crate::app::SessionView, id: &str) -> Option<u32> {
let native = view.streams.iter().find(|s| s.id == id).and_then(|s| s.viewers);
native.or_else(|| view.stream_viewers.get(id).copied())
}
/// "8 Mbit/s", "640 kbit/s" (the stream's announced bitrate, kbit/s); "" for 0.
fn bitrate_text(kbps: u32) -> String {
match kbps {
@@ -147,6 +200,17 @@ impl App {
Event::WatchState { session, stream_id, state } => {
self.watch_state(session as i64, &stream_id, state);
}
Event::WatchLayers { session, stream_id, layers, layer } => {
if let Some(watch) = self
.watch
.as_mut()
.filter(|w| w.session == Some(session as i64) && w.stream_id == stream_id)
{
watch.layers = layers;
watch.layer = layer;
self.refresh_viewer();
}
}
// Also flagged on the sink, which the encoder reads.
Event::StreamKeyframeRequest { .. } => {}
_ => {}
@@ -171,6 +235,7 @@ impl App {
} else {
share_end_text(&reason)
});
self.mixer_refresh();
}
}
self.refresh_streams();
@@ -231,7 +296,7 @@ impl App {
streamer: view.nickname(s.streamer.0).into(),
channel: view.other_channel_name(s.streamer.0).into(),
streamer_id: i32::from(s.streamer.0),
viewers: view.stream_viewers.get(&s.id).map_or(0, |v| *v as i32),
viewers: viewer_count(view, &s.id).unwrap_or(0) as i32,
audio: s.audio,
watching,
own: view.state.own_client == Some(s.streamer.0),
@@ -287,6 +352,7 @@ impl App {
bridge.set_share_state(state.into());
bridge.set_share_busy(self.share_busy);
bridge.set_share_error(self.share_error.clone().into());
bridge.set_share_audio(share.is_some_and(|s| s.capture.has_audio()));
let viewers: Vec<ViewerItem> = share
.map(|s| {
s.viewers
@@ -349,13 +415,19 @@ impl App {
.and_then(|v| v.streams.iter().find(|s| s.id == watch.stream_id))
.map_or(-1, |s| i32::from(s.streamer.0));
bridge.set_viewer_streamer_id(streamer);
let members = &self.models.members;
bridge.set_viewer_streamer_admin(
(0..members.row_count())
.filter_map(|i| members.row_data(i))
.any(|m| m.id == streamer && m.admin),
);
let channel = u16::try_from(streamer).ok().and_then(|id| {
let view = self.view()?;
view.presence.channels.get(&view.channel_of(id)?).map(|c| c.name.clone())
});
bridge.set_viewer_channel(channel.unwrap_or_default().into());
bridge.set_viewer_elapsed(watch.elapsed().into());
let viewers = self.view().and_then(|v| v.stream_viewers.get(&watch.stream_id)).copied();
let viewers = self.view().and_then(|v| viewer_count(v, &watch.stream_id));
bridge.set_viewer_count(viewers.unwrap_or(0) as i32);
let qualities = watch.qualities();
let chosen = watch
@@ -370,17 +442,17 @@ impl App {
}
/// A simulcast layer of the watched stream (0: follow the bandwidth
/// estimate). The streamer picks the layer from each viewer's estimate,
/// so this asks for the picture again; a viewer-side choice needs an
/// engine API that does not exist yet.
/// estimate), asked of the streamer; the engine confirms with
/// `WatchLayers`.
pub(crate) fn set_stream_quality(&mut self, index: i32) {
let Some(watch) = &mut self.watch else { return };
watch.layer =
usize::try_from(index - 1).ok().and_then(|i| watch.layers.get(i)).map(|l| l.id);
if let Some(session) = watch.session {
self.engine.send(Command::RequestStreamKeyframe {
self.engine.send(Command::SetWatchLayer {
session: session as u64,
stream_id: watch.stream_id.clone(),
layer: watch.layer,
});
}
self.refresh_viewer();
@@ -410,6 +482,8 @@ impl App {
if self.share.is_some() {
self.refresh_streams();
}
// The share dialog's audio mixer (studio.rs).
self.mixer_tick();
if self.watch.is_some() {
self.refresh_viewer();
}
@@ -443,6 +517,8 @@ impl App {
ui.global::<Bridge>().set_share_sources(model(items));
}
self.refresh_streams();
// Its audio: the Stream Studio's mixer rows and picker.
self.mixer_show();
let defaults = &self.settings.share;
let nickname = self.current.and_then(|id| self.bookmark(id)).map(|b| b.nickname.clone());
let (fps, bitrate) = (self.prefs.get(&STREAM_FPS), self.prefs.get(&STREAM_BITRATE_KBPS));
@@ -461,21 +537,34 @@ impl App {
}
}
/// The share dialog's form with the test pattern chosen.
fn test_pattern_form(&mut self) -> Option<ShareForm> {
let mut form = self.open_share();
let ui = self.ui.upgrade()?;
let sources = ui.global::<Bridge>().get_share_sources();
let pattern = (0..sources.row_count())
.find(|&i| sources.row_data(i).is_some_and(|s| s.name == "Test pattern"))?;
form.source = pattern as i32;
Some(form)
}
/// Development switch `VOELIN_AUTOSHARE`: share the test pattern once.
pub(crate) fn autoshare(&mut self) {
if !self.autoshare || !self.view().is_some_and(|v| v.streams_available()) {
return;
}
self.autoshare = false;
let mut form = self.open_share();
let Some(ui) = self.ui.upgrade() else { return };
let sources = ui.global::<Bridge>().get_share_sources();
let pattern = (0..sources.row_count())
.find(|&i| sources.row_data(i).is_some_and(|s| s.name == "Test pattern"));
let Some(index) = pattern else { return };
form.source = index as i32;
form.auto_accept = true;
self.start_share(form);
if let Some(form) = self.test_pattern_form() {
self.start_share(ShareForm { auto_accept: true, ..form });
}
}
/// `VOELIN_OPEN=share:live` with sample data: the test pattern shared
/// with the sample mixer's sources (live at once, `capture_ready`).
pub(crate) fn demo_share(&mut self) {
if let Some(form) = self.test_pattern_form() {
self.start_share(ShareForm { audio: true, ..form });
}
}
pub(crate) fn start_share(&mut self, form: ShareForm) {
@@ -509,15 +598,10 @@ impl App {
audio: form.audio,
auto_accept: form.auto_accept,
};
// No sources configured: no audio.
let audio_sources = audio_source_specs(&self.prefs.get(&STREAM_AUDIO_SOURCES));
let request = CaptureRequest {
fps,
bitrate_kbps: bitrate,
audio: form.audio && !audio_sources.is_empty(),
audio_sources,
restore_token: self.settings.portal_restore_token.clone(),
};
// The mixer's sources (the sample studio's with VOELIN_DEMO_UI).
let sources = self.studio_settings().get(&STREAM_AUDIO_SOURCES);
let token = self.settings.portal_restore_token.clone();
let request = capture_request(fps, bitrate, form.audio, &sources, token);
self.settings.share = defaults;
self.store_settings();
self.share_busy = true;
@@ -526,7 +610,7 @@ impl App {
let setup = StreamSetup {
name: form.name.trim().to_owned(),
bitrate,
audio: form.audio,
audio: request.audio,
..StreamSetup::default()
};
let auto_accept = form.auto_accept;
@@ -562,30 +646,64 @@ impl App {
let reason = capture.audio_error().unwrap_or_default();
self.set_status(format!("Sharing without sound: {reason}"));
}
self.engine.send(Command::StartStream {
session: session as u64,
setup,
auto_accept,
// Sample data has no server: live at once, with viewers.
let (live, viewers) = if self.demo_ui {
(true, demo_viewers())
} else {
let session = session as u64;
self.engine.send(Command::StartStream { session, setup, auto_accept });
(false, Vec::new())
};
let meters = slint::Timer::default();
meters.start(slint::TimerMode::Repeated, Duration::from_millis(66), || {
with_app(|app| app.studio_meters());
});
self.share = Some(Share {
session,
capture,
live: false,
viewers: Vec::new(),
live,
viewers,
stopping: false,
_meters: meters,
});
// The mixer's rows follow this capture's sources.
self.mixer_refresh();
}
}
self.refresh_streams();
}
pub(crate) fn stop_share(&mut self) {
if let Some(share) = &mut self.share {
share.stopping = true;
self.engine.send(Command::StopStream { session: share.session as u64 });
let Some(share) = &mut self.share else { return };
share.stopping = true;
let session = share.session;
if self.demo_ui {
self.share_state(session, StreamState::Ended(EndReason::Local));
} else {
self.engine.send(Command::StopStream { session: session as u64 });
}
}
/// The running share's streamer (the mixer's rows, studio.rs).
pub(crate) fn share_streamer(&self) -> Option<&Streamer> {
self.share.as_ref().map(|s| s.capture.streamer())
}
/// `stream.audio_sources` changed (the mixer, the settings, another
/// window): a running share mixes the new sources.
pub(crate) fn share_audio_changed(&mut self) {
if self.share.is_none() {
return;
}
let sources = audio_source_specs(&self.studio_settings().get(&STREAM_AUDIO_SOURCES));
let codecs = self.video.codecs();
let Some(share) = &self.share else { return };
if let Err(e) = share.capture.follow_audio(&codecs, sources) {
self.set_status(format!("Stream audio: {e}"));
}
self.mixer_refresh();
}
pub(crate) fn respond_viewer(&mut self, viewer: u16, accept: bool) {
if let Some(share) = &self.share {
let session = share.session as u64;
@@ -796,4 +914,34 @@ mod tests {
assert_eq!(super::bitrate_text(8000), "8 Mbit/s");
assert_eq!(super::bitrate_text(4608), "4.6 Mbit/s");
}
/// What the share dialog's mixer holds goes to the capture, with each
/// source's gain and mute; "Share system audio" off (or nothing picked)
/// shares no audio at all.
#[test]
fn the_share_carries_the_picked_audio() {
use voelin_core::media::{AppMatch, AudioSourceKind};
use voelin_core::settings::{AudioSourceKindSetting, AudioSourceSetting};
let app = AudioSourceKindSetting::App { name: Some("firefox".into()), pid: None };
let picked = [
AudioSourceSetting { gain: 0.5, ..AudioSourceSetting::new(app) },
AudioSourceSetting {
muted: true,
..AudioSourceSetting::new(AudioSourceKindSetting::Microphone)
},
];
let request = super::capture_request(30, 4608, true, &picked, None);
assert!(request.audio);
let kinds: Vec<_> = request.audio_sources.iter().map(|s| s.kind.clone()).collect();
let firefox = AudioSourceKind::App(AppMatch::Name("firefox".into()));
assert_eq!(kinds, [firefox, AudioSourceKind::Microphone]);
let mix: Vec<_> = request.audio_sources.iter().map(|s| (s.gain, s.muted)).collect();
assert_eq!(mix, [(0.5, false), (1.0, true)]);
assert_eq!((request.fps, request.bitrate_kbps), (30, 4608));
let off = super::capture_request(30, 4608, false, &picked, None);
assert!(!off.audio && off.audio_sources.is_empty());
let none = super::capture_request(30, 4608, true, &[], None);
assert!(!none.audio && none.audio_sources.is_empty());
}
}
+149 -38
View File
@@ -12,7 +12,7 @@
//! VecModels) and get the same values; their callbacks come here
//! (bind/studio.rs). Commands go to the studio through one task, in order.
use std::path::PathBuf;
use std::path::{Path, PathBuf};
use std::rc::Rc;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Weak};
@@ -28,8 +28,8 @@ use voelin_core::media::voelin_media::handoff::Handoff;
use voelin_core::media::voelin_media::mix::SourceHandle;
use voelin_core::media::voelin_media::{VideoFrame, convert};
use voelin_core::media::{
AudioApps, AudioSourceSpec, Latest, Streamer, StreamerConfigUpdate, StreamerStats, audio_apps,
audio_source_specs, screen_sources,
AudioApps, AudioSourceSpec, AudioSourceStats, Latest, Streamer, StreamerConfigUpdate,
StreamerStats, audio_apps, audio_source_specs, screen_sources,
};
use voelin_core::settings::{
AudioSourceKindSetting, AudioSourceSetting, Key, Kind, STREAM_AUDIO_SOURCES,
@@ -38,7 +38,7 @@ use voelin_core::settings::{
};
use voelin_core::stream::{EndReason, StreamSetup, ViewerInfo, ViewerState};
use voelin_core::studio::scene::{
Align, Background, Colour, Fit, Scene, Scenes, Source, SourceKind, Transform,
Align, Background, Colour, Crop, Fit, Scene, Scenes, Source, SourceKind, Transform,
};
use voelin_core::studio::{self, SourceChange, Stats, Status, Studio, camera};
use voelin_core::{Command, HistoryMessage, HistorySource, StreamState};
@@ -329,15 +329,16 @@ fn demo_settings() -> Settings {
let mut cam = source(2, "Camera", camera.clone(), Transform::default());
cam.transform = vm::studio::placement(&camera, (1920, 1080));
cam.background = Background::Blur { strength: 0.04 };
main.sources = vec![
source(
1,
"Game Capture",
SourceKind::Pattern { size: (1280, 720) },
Transform { fit: Fit::Cover, ..Transform::full(1920, 1080) },
),
cam,
];
let mut game = source(
1,
"Game Capture",
SourceKind::Pattern { size: (1280, 720) },
Transform { fit: Fit::Cover, ..Transform::full(1920, 1080) },
);
// The pattern's frame counter sits in its top-left corner, under the
// preview's LIVE badge and timer: cropped away.
game.crop = Crop { top: 120, ..Crop::default() };
main.sources = vec![game, cam];
let mut chatting = Scene::new(2, "Just Chatting");
chatting.sources = vec![source(
1,
@@ -420,8 +421,9 @@ fn file_name(what: &str) -> String {
}
impl App {
/// The studio's settings (made once).
fn studio_settings(&mut self) -> Settings {
/// The studio's settings (made once): its mixer's `stream.audio_sources`
/// are the share dialog's too.
pub(crate) fn studio_settings(&mut self) -> Settings {
let demo = self.demo_ui;
let prefs = &self.prefs;
self.studio
@@ -477,14 +479,19 @@ impl App {
|| self.ui.upgrade().is_some_and(|ui| ui.global::<Nav>().get_page() == Page::Studio)
}
/// The studio page or window appeared: show it and start the studio.
pub(crate) fn studio_open(&mut self) {
/// The models in the main window's StudioBridge (once).
fn studio_attach_main(&mut self) {
if !self.studio.attached
&& let Some(ui) = self.ui.upgrade()
{
self.studio_attach(&ui.global::<StudioBridge>());
self.studio.attached = true;
}
}
/// The studio page or window appeared: show it and start the studio.
pub(crate) fn studio_open(&mut self) {
self.studio_attach_main();
if let Some(window) = &self.studio.window
&& let Err(e) = window.show()
{
@@ -725,12 +732,23 @@ impl App {
vm::list::sync(&m.sources, &vm::studio::sources(self.studio.scenes.active(), stats));
}
/// The streamer whose mixer the audio rows show: a quick share's while
/// one runs (what goes out; both mix `stream.audio_sources`), else the
/// studio's encoder.
fn mixer_streamer(&self) -> Option<&Streamer> {
self.share_streamer().or_else(|| self.studio_streamer())
}
/// What the mixer says about each of its sources now.
fn mixer_stats(&self) -> Vec<AudioSourceStats> {
self.mixer_streamer().map(|s| s.stats().audio_sources).unwrap_or_default()
}
/// The mixer source of each audio row, and why one captures nothing.
fn studio_map_meters(&mut self) {
let sources = self.studio.settings.as_ref().map(|s| s.get(&STREAM_AUDIO_SOURCES));
let streamer = self.studio_streamer();
let mixer = streamer.and_then(Streamer::audio_mixer);
let stats = self.studio.encoder.as_ref().map(|s| &s.audio_sources[..]).unwrap_or_default();
let mixer = self.mixer_streamer().and_then(Streamer::audio_mixer);
let stats = self.mixer_stats();
self.studio.meters = sources
.unwrap_or_default()
.iter()
@@ -745,7 +763,7 @@ impl App {
fn studio_refresh_audio(&self) {
let Some(settings) = &self.studio.settings else { return };
let sources = settings.get(&STREAM_AUDIO_SOURCES);
let stats = self.studio.encoder.as_ref().map(|s| &s.audio_sources[..]).unwrap_or_default();
let stats = self.mixer_stats();
let live: Vec<Option<vm::studio::AudioLive>> = sources
.iter()
.enumerate()
@@ -760,8 +778,38 @@ impl App {
vm::list::sync(&self.studio.models.audio, &vm::studio::audio(&sources, &live));
}
/// The share dialog's audio: the studio's mixer rows and picker in the
/// main window, without starting the studio.
pub(crate) fn mixer_show(&mut self) {
self.studio_attach_main();
self.studio_settings();
self.mixer_refresh();
}
/// The audio rows again: which mixer source each meter reads, levels
/// and errors.
pub(crate) fn mixer_refresh(&mut self) {
self.studio_map_meters();
self.studio_refresh_audio();
}
/// Once a second while the studio does not run (it has its own tick):
/// the share's rows, and the picker's application list let go once the
/// share dialog is closed.
pub(crate) fn mixer_tick(&mut self) {
if self.studio.run.is_some() {
return;
}
if self.share.is_some() {
self.mixer_refresh();
}
if !self.ui.upgrade().is_some_and(|ui| ui.global::<Nav>().get_share_open()) {
self.studio.apps = None;
}
}
/// The meters, about 15 times a second (only rows that moved redraw).
fn studio_meters(&mut self) {
pub(crate) fn studio_meters(&mut self) {
let model = &self.studio.models.audio;
for (i, meter) in self.studio.meters.iter().enumerate() {
let level = meter.as_ref().map_or(-100.0, |m| m.level().peak_db().max(-100.0));
@@ -830,7 +878,12 @@ impl App {
.iter()
.map(|(id, _)| {
let (channel, server) = self.studio_destination_parts(*id);
StudioPick { name: channel.into(), detail: server.into(), kind: "server".into() }
StudioPick {
name: channel.into(),
detail: server.into(),
kind: "server".into(),
..Default::default()
}
})
.collect();
vm::list::sync(&self.studio.models.destinations, &rows);
@@ -1363,6 +1416,35 @@ impl App {
"remove" => {
self.studio_op(Op::Apply(studio::Command::RemoveSource { scene, source: id }));
}
// The next camera (a phone's front and back), mirrored as that
// camera is by default.
"next-camera" => {
let SourceKind::Camera { device, size, fps, .. } = source.kind.clone() else {
return;
};
let name = source.name.clone();
let cameras = if self.demo_ui { Vec::new() } else { camera::list() };
let real: Vec<_> = cameras.iter().filter(|c| c.backend != "synthetic").collect();
let at = real.iter().position(|c| c.id == device);
let next = at.map_or(real.first(), |i| real.get((i + 1) % real.len()));
let Some(next) = next.filter(|c| c.id != device) else {
self.set_status("There is no other camera.");
return;
};
let kind = SourceKind::Camera {
device: next.id.clone(),
size,
fps,
mirror: next.mirrored,
};
// A source named after its camera is named after the next.
let renamed = name.is_empty() || at.is_some_and(|i| real[i].name == name);
let name = renamed.then(|| next.name.clone());
self.studio_update(
id,
SourceChange { kind: Some(kind), name, ..Default::default() },
);
}
"bg-keep" | "bg-blur" => {
let background = if action == "bg-blur" {
Background::Blur { strength: 0.04 }
@@ -1423,6 +1505,7 @@ impl App {
name: name.into(),
detail: detail.into(),
kind: icon.into(),
..Default::default()
};
let mut picks: Vec<(Pick, StudioPick)> = Vec::new();
let source = |name: &str, kind: SourceKind| Pick::Source { name: name.into(), kind };
@@ -1434,6 +1517,7 @@ impl App {
camera::SYNTHETIC.to_owned(),
"Test pattern".to_owned(),
"1280×720".to_owned(),
true,
)]
} else {
camera::list()
@@ -1443,12 +1527,12 @@ impl App {
c.formats.iter().flat_map(|f| &f.sizes).max_by_key(|(w, h)| w * h);
let detail =
biggest.map_or(String::new(), |(w, h)| format!("up to {w}×{h}"));
(c.id, c.name, detail)
(c.id, c.name, detail, c.mirrored)
})
.collect()
};
for (device, name, detail) in cameras {
let kind = SourceKind::Camera { device, size: None, fps: None, mirror: true };
for (device, name, detail, mirror) in cameras {
let kind = SourceKind::Camera { device, size: None, fps: None, mirror };
picks.push((source(&name, kind), row(&name, detail, "camera")));
}
}
@@ -1580,11 +1664,24 @@ impl App {
let settings = self.studio_settings();
let current = settings.get(&STREAM_AUDIO_SOURCES);
let mut picks: Vec<(Pick, StudioPick)> = Vec::new();
let mut add = |setting: AudioSourceSetting, name: String, detail: String| {
let (_, _, kind) = vm::studio::audio_label(&setting.kind);
let row = StudioPick { name: name.into(), detail: detail.into(), kind: kind.into() };
picks.push((Pick::Audio(setting), row));
};
let mut add =
|setting: AudioSourceSetting, name: String, detail: String, icon: Option<&str>| {
let (_, _, kind) = vm::studio::audio_label(&setting.kind);
let row = StudioPick {
name: name.into(),
detail: detail.into(),
kind: kind.into(),
// An application's own icon, when it gave a file (Android
// does; a desktop icon theme name is left out).
icon: icon
.map(Path::new)
.filter(|p| p.is_absolute())
.map(crate::images::file)
.unwrap_or_default(),
selected: current.iter().any(|s| s.kind == setting.kind),
};
picks.push((Pick::Audio(setting), row));
};
let fixed = [
(AudioSourceKindSetting::Microphone, "Microphone", "What you say in voice, cleaned up"),
(
@@ -1599,14 +1696,17 @@ impl App {
),
];
for (kind, name, detail) in fixed {
if !current.iter().any(|s| s.kind == kind) {
add(AudioSourceSetting::new(kind), name.into(), detail.into());
// A phone shares the whole screen: there is no window's app.
if cfg!(target_os = "android") && kind == AudioSourceKindSetting::Window {
continue;
}
add(AudioSourceSetting::new(kind), name.into(), detail.into(), None);
}
if self.demo_ui {
for frequency in [330, 550] {
for frequency in [440, 660, 330] {
let kind = AudioSourceKindSetting::Synthetic { frequency };
add(AudioSourceSetting::new(kind), "Test tone".into(), format!("{frequency} Hz"));
let detail = format!("{frequency} Hz");
add(AudioSourceSetting::new(kind), "Test tone".into(), detail, None);
}
} else {
if self.studio.apps.is_none() {
@@ -1623,7 +1723,7 @@ impl App {
.media
.clone()
.unwrap_or_else(|| if app.playing { "playing".into() } else { String::new() });
add(AudioSourceSetting::new(kind), app.name, detail);
add(AudioSourceSetting::new(kind), app.name, detail, app.icon.as_deref());
}
}
self.studio_set_picks(picks);
@@ -1636,13 +1736,24 @@ impl App {
if let Err(e) = settings.set(&STREAM_AUDIO_SOURCES, sources) {
self.set_status(e.to_string());
}
// A quick share follows at once (the studio through its watch).
self.share_audio_changed();
self.studio_refresh_audio();
}
pub(crate) fn studio_add_audio(&mut self, index: usize) {
/// Mix a picked source in, or take it out if it is (the picker
/// chooses several at once), and mark the picks again.
pub(crate) fn studio_toggle_audio(&mut self, index: usize) {
let Some(Pick::Audio(setting)) = self.studio.picks.get(index) else { return };
let setting = setting.clone();
self.studio_audio_sources(|sources| sources.push(setting));
self.studio_audio_sources(|sources| {
if sources.iter().any(|s| s.kind == setting.kind) {
sources.retain(|s| s.kind != setting.kind);
} else {
sources.push(setting);
}
});
self.studio_list_audio();
}
/// While dragging the gain goes to the mixer directly; at the end it is
+66 -2
View File
@@ -14,7 +14,7 @@ use voelin_core::media::voelin_media::capture::{CaptureSource, SourceId};
use voelin_core::media::voelin_media::{Codec, Codecs, VideoFrame, convert};
use voelin_core::media::{
self, AudioSourceSpec, EncoderPreference, Latest, LocalPreview, Streamer, StreamerConfig,
Viewer, peer_config, preferred_codec, stream_codec,
StreamerConfigUpdate, Viewer, peer_config, preferred_codec, stream_codec,
};
use voelin_core::stream::{LayerSpec, PeerConfig};
use voelin_core::studio::Studio;
@@ -419,6 +419,28 @@ impl Capture {
self.streamer.audio_error()
}
/// For the audio mixer's rows: its levels and errors.
pub fn streamer(&self) -> &Streamer {
&self.streamer
}
/// Mix `sources` from now on (`stream.audio_sources` changed while
/// sharing): a source whose kind stays keeps capturing with the new
/// gain and mute, new ones start, removed ones stop. True if anything
/// changed. A capture without sound stays so: its stream has no audio
/// track to carry them.
pub fn follow_audio(
&self,
codecs: &Codecs,
sources: Vec<AudioSourceSpec>,
) -> Result<bool, String> {
if !self.has_audio() || self.streamer.audio_sources() == sources {
return Ok(false);
}
let update = StreamerConfigUpdate { audio_sources: Some(sources), ..Default::default() };
self.streamer.reconfigure(codecs, update).map(|()| true).map_err(|e| e.to_string())
}
/// The portal's token for this choice, to keep.
pub fn restore_token(&self) -> Option<String> {
self.streamer.restore_token().map(str::to_owned)
@@ -468,7 +490,8 @@ impl Decoder {
}
}
/// One line about the video: codec, size, problems.
/// One line about the video: codec, size, decoded frame rate, received
/// bitrate, problems.
pub fn info(&self) -> String {
let stats = self.stats();
let mut parts = Vec::new();
@@ -478,6 +501,10 @@ impl Decoder {
if stats.width > 0 {
parts.push(size_text(stats.width, stats.height));
}
if stats.decoded > 0 {
parts.push(format!("{} fps", stats.fps));
parts.push(format!("{:.1} Mbit/s", stats.bitrate as f64 / 1_000_000.0));
}
if let Some(e) = stats.error {
parts.push(e);
}
@@ -516,4 +543,41 @@ mod tests {
let restore: Vec<_> = entries.iter().map(|e| e.2).collect();
assert_eq!(restore, [false, true]);
}
/// A running share mixes what `stream.audio_sources` says now; one
/// started without sound has no audio track to change.
#[tokio::test(flavor = "multi_thread")]
async fn a_share_follows_its_audio_sources() {
use voelin_core::media::AudioSourceKind;
let codecs = Codecs::new();
let tone = |hz| AudioSourceSpec::new(AudioSourceKind::Synthetic { hz });
let start = async |audio| {
let config = StreamerConfig {
source: SourceId::Synthetic,
synthetic_size: (64, 48),
audio,
audio_sources: vec![tone(440)],
..StreamerConfig::default()
};
let streamer = Streamer::start(&codecs, config).await.unwrap();
Capture { streamer, name: "Test pattern".into() }
};
let share = start(true).await;
let mixed = vec![
AudioSourceSpec { muted: true, ..tone(440) },
AudioSourceSpec { gain: 0.5, ..tone(660) },
];
assert_eq!(share.follow_audio(&codecs, mixed.clone()), Ok(true));
assert_eq!(share.streamer().audio_sources(), mixed);
assert_eq!(share.follow_audio(&codecs, mixed), Ok(false), "nothing changed");
// Every source taken out: silence, the track stays for new ones.
assert_eq!(share.follow_audio(&codecs, Vec::new()), Ok(true));
assert!(share.has_audio() && share.streamer().audio_sources().is_empty());
assert_eq!(share.follow_audio(&codecs, vec![tone(330)]), Ok(true));
assert_eq!(share.streamer().audio_sources(), [tone(330)]);
let silent = start(false).await;
assert_eq!(silent.follow_audio(&codecs, vec![tone(660)]), Ok(false));
assert!(!silent.has_audio());
}
}
+40
View File
@@ -101,6 +101,29 @@ fn without_links(text: &str, files: &[FileRef]) -> String {
out.replace("[/URL]", "").replace("[/url]", "").trim().to_owned()
}
/// A chat's last message for a list of chats, on one line ("Mira: the
/// banner I promised: guild-banner.png"), and when it came.
pub fn preview(message: &ChatMessage) -> (String, String) {
let text = if message.blocked {
"Message from a blocked contact.".to_owned()
} else {
let files = message.file_refs();
let names = files.iter().map(|f| f.name.as_str());
let text = without_links(&message.text, &files);
std::iter::once(text.as_str()).chain(names).collect::<Vec<_>>().join(" ")
};
// A one-line text cannot show emoji (they are pictures): left out.
let plain = match emoji::runs(&text) {
Some(runs) => runs.into_iter().filter(|r| r.emoji.is_none()).map(|r| r.text).collect(),
None => text,
};
let mut text = plain.split_whitespace().collect::<Vec<_>>().join(" ");
if text.is_empty() {
text = "sent an emoji".into();
}
(format!("{}: {text}", message.author_name), time_of(message.ts_ms))
}
fn runs_model(runs: &[emoji::Run]) -> ModelRc<TextRun> {
ModelRc::from(Rc::new(VecModel::from(
runs.iter()
@@ -294,6 +317,23 @@ mod tests {
assert!(line.text.starts_with("here you go"));
}
#[test]
fn previews_are_one_line() {
let url = "ts3file://plan.pdf?channel=2&path=/&filename=plan.pdf&isDir=0&size=2048";
let text = format!("route\nfor tonight: [URL={url}]plan.pdf[/URL]");
let (last, time) = preview(&message("Mira", &text, 0));
assert_eq!(last, "Mira: route for tonight: plan.pdf");
assert!(!time.is_empty());
assert_eq!(
preview(&message("Ari", "co-op later? 👀 Posting", 0)).0,
"Ari: co-op later? Posting"
);
assert_eq!(preview(&message("dex", "🎉🎉", 0)).0, "dex: sent an emoji");
let mut blocked = message("X", "secret", 0);
blocked.blocked = true;
assert_eq!(preview(&blocked).0, "X: Message from a blocked contact.");
}
#[test]
fn stamps() {
let at = |d: &str| chrono::NaiveDateTime::parse_from_str(d, "%Y-%m-%d %H:%M").unwrap();
+62 -3
View File
@@ -17,9 +17,9 @@ pub fn status(state: &SessionState) -> &'static str {
}
/// A server of the rail and the home page. `unread`: messages in its
/// chats; `live`: streams in our channel there; `detail`: who is there
/// ("9 online · 7 channels"), empty for its address; `flavor`:
/// "TeamSpeak 6" once reached.
/// chats; `live`: streams on it; `detail`: who is there ("9 online · 7
/// channels"), empty for its address; `flavor`: "TeamSpeak 6" once
/// reached.
pub fn item(
bookmark: &Bookmark,
state: &SessionState,
@@ -43,10 +43,69 @@ pub fn item(
}
}
/// A `ts3server://` link that joins the channel at `path` (its names from
/// the top) on the server at `address` (`host`, `host:port` or
/// `[v6]:port`), as TeamSpeak clients open them.
pub fn invite_link(address: &str, path: &[&str]) -> String {
fn encode(text: &str) -> String {
text.bytes()
.map(|b| match b {
b'A'..=b'Z' | b'a'..=b'z' | b'0'..=b'9' | b'-' | b'.' | b'_' | b'~' => {
char::from(b).to_string()
}
_ => format!("%{b:02X}"),
})
.collect()
}
let address = address.trim();
// A port follows the last colon, unless that colon is inside an IPv6
// address without brackets.
let (host, port) = match address.rsplit_once(':') {
Some((host, port))
if !port.is_empty()
&& port.bytes().all(|b| b.is_ascii_digit())
&& (!host.contains(':') || host.ends_with(']')) =>
{
(host, Some(port))
}
_ => (address, None),
};
let mut link = format!("ts3server://{host}");
let mut query = Vec::new();
if let Some(port) = port {
query.push(format!("port={port}"));
}
if !path.is_empty() {
let names: Vec<String> = path.iter().map(|n| encode(n)).collect();
query.push(format!("channel={}", names.join("/")));
}
if !query.is_empty() {
link.push('?');
link.push_str(&query.join("&"));
}
link
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn invite_links() {
assert_eq!(
invite_link("ts.example.com:9988", &["Gaming", "Raid Night"]),
"ts3server://ts.example.com?port=9988&channel=Gaming/Raid%20Night"
);
assert_eq!(invite_link(" ts.example.com ", &[]), "ts3server://ts.example.com");
assert_eq!(
invite_link("[2001:db8::1]:9987", &["Chill & Co"]),
"ts3server://[2001:db8::1]?port=9987&channel=Chill%20%26%20Co"
);
// A bare IPv6 address has no port.
assert_eq!(invite_link("2001:db8::1", &[]), "ts3server://2001:db8::1");
assert_eq!(invite_link("h:x", &["Ä/b"]), "ts3server://h:x?channel=%C3%84%2Fb");
}
#[test]
fn states() {
let mut s = SessionState::default();
+19 -9
View File
@@ -29,7 +29,8 @@ import { FriendsPage, ContactPanel } from "screens/friends.slint";
import { MessagesPage, ConversationList, Conversation, DmProfile, OfflineDialog } from "screens/messages.slint";
import { ServerLinks, EventsPage, EventDialog } from "screens/events.slint";
import { NotificationsPanel, SearchPalette, Lightbox } from "screens/overlays.slint";
import { MobileServers, ActivityPage, YouPage } from "screens/mobile.slint";
import { MobileServers, ActivityPage, YouPage, PhoneSheet } from "screens/mobile.slint";
import { MobileVoice } from "screens/mobile-voice.slint";
import { BookmarkDialog, ShareDialog, ClientAudioDialog, AboutDialog } from "screens/dialogs.slint";
import { StudioBridge } from "studio-bridge.slint";
import { StudioPage, MobileStudio } from "screens/studio.slint";
@@ -218,16 +219,21 @@ export component MainWindow inherits Window {
: Nav.page == Page.messages ? @tr("Messages")
: Nav.page == Page.library ? @tr("Library")
: Nav.page == Page.events ? @tr("Events")
: Nav.phone-voice ? Bridge.app-name
: Nav.page == Page.home || Nav.mobile-tab == MobileTab.home ? Bridge.app-name
: Nav.mobile-tab == MobileTab.you ? @tr("You")
: Nav.mobile-tab == MobileTab.activity ? @tr("Activity")
: Bridge.server-title;
subtitle: Nav.page == Page.settings || Nav.page == Page.friends || Nav.page == Page.messages || Nav.page == Page.library ? ""
: Nav.page == Page.events || Nav.phone-voice ? Bridge.server-title
: Nav.page == Page.home || Nav.mobile-tab == MobileTab.home ? @tr("Find your people. Talk beyond.")
: Nav.page == Page.events ? Bridge.server-title
: Nav.mobile-tab == MobileTab.chat && Bridge.current-tab >= 0 && Bridge.current-tab < Bridge.tabs.length ? Bridge.tabs[Bridge.current-tab].title : Nav.mobile-tab == MobileTab.servers ? Bridge.server-stats : "";
: Nav.mobile-tab == MobileTab.chat && Bridge.current-tab >= 0 && Bridge.current-tab < Bridge.tabs.length ? Bridge.tabs[Bridge.current-tab].title
: Nav.mobile-tab == MobileTab.servers ? Bridge.server-stats : "";
back: Nav.page == Page.settings || Nav.page == Page.friends || Nav.page == Page.messages || Nav.page == Page.library || Nav.page == Page.events;
unread: Bridge.unread-total;
voice: Nav.phone-voice;
// The voice channel and the studio bring their own controls.
navigation: !Nav.phone-voice && Nav.page != Page.studio;
go-back => {
if Nav.page == Page.messages && Bridge.dm.open {
Bridge.open-conversation(-1);
@@ -241,7 +247,7 @@ export component MainWindow inherits Window {
if Nav.page == Page.settings: SettingsPage {
compact: true;
}
if Nav.page == Page.home || (Nav.page == Page.server && Nav.mobile-tab == MobileTab.home): HomePage {
if !Nav.phone-voice && (Nav.page == Page.home || (Nav.page == Page.server && Nav.mobile-tab == MobileTab.home)): HomePage {
compact: true;
}
if Nav.page == Page.friends: FriendsPage {
@@ -257,14 +263,18 @@ export component MainWindow inherits Window {
if Nav.page == Page.events: EventsPage {
compact: true;
}
if Nav.page == Page.server && Nav.mobile-tab == MobileTab.servers: MobileServers { }
if Nav.page == Page.server && Nav.mobile-tab == MobileTab.chat && Bridge.viewer-open: StreamViewer { }
if Nav.page == Page.server && Nav.mobile-tab == MobileTab.chat && !Bridge.viewer-open: ChatView {
if Nav.phone-voice: MobileVoice { }
if Nav.page == Page.server && !Nav.phone-voice && Nav.mobile-tab == MobileTab.servers: MobileServers { }
// Watching without voice (the local test stream): the player.
if Nav.page == Page.server && !Nav.phone-voice && Nav.mobile-tab == MobileTab.chat && Bridge.viewer-open: StreamViewer { }
if Nav.page == Page.server && !Nav.phone-voice && Nav.mobile-tab == MobileTab.chat && !Bridge.viewer-open: ChatView {
header: false;
}
if Nav.page == Page.server && Nav.mobile-tab == MobileTab.activity: ActivityPage { }
if Nav.page == Page.server && Nav.mobile-tab == MobileTab.you: YouPage { }
if Nav.page == Page.server && !Nav.phone-voice && Nav.mobile-tab == MobileTab.activity: ActivityPage { }
if Nav.page == Page.server && !Nav.phone-voice && Nav.mobile-tab == MobileTab.you: YouPage { }
if Nav.page == Page.studio && !StudioBridge.status.detached: MobileStudio { }
// Pins, topics or the members, over the page.
if Nav.page == Page.server && (Nav.pins-open || Nav.topics-open || Nav.members-open): PhoneSheet { }
}
}
}
+10
View File
@@ -124,6 +124,9 @@ export struct ChatTab {
unread: int,
// The channel's topic (channel chats).
topic: string,
// The last message ("Mira: the banner I promised") and its time.
last: string,
time: string,
}
// A piece of a chat line: text, or an emoji shown as an image (`emoji` is
@@ -810,6 +813,8 @@ export global Bridge {
in property <[SourceItem]> share-sources;
in property <string> share-error;
in property <bool> share-busy;
// Our share carries sound: its audio mixer can change it.
in property <bool> share-audio;
// Whether capture and encoding are built in.
in property <bool> can-share: true;
@@ -839,6 +844,8 @@ export global Bridge {
in-out property <int> viewer-quality: 0;
// What "Auto" picked ("720p · 2.4 Mbit/s").
in property <string> viewer-quality-detail;
// The streamer is in an admin group (the crown beside their name).
in property <bool> viewer-streamer-admin;
// Settings.
in property <[string]> input-devices;
@@ -946,6 +953,9 @@ export global Bridge {
callback delete-crash-reports();
callback dismiss-crash-notice();
callback open-about();
// A link to our voice channel (`ts3server://`) to hand to others; the
// caller copies it.
callback invite() -> string;
// Home, friends, direct messages, notifications, search, events and
// the settings pages.
+27
View File
@@ -102,6 +102,14 @@ export global Nav {
in-out property <int> dm-tab;
in-out property <bool> join-open;
// The phone layout (narrow windows).
// The server's members as a page of their own (the desktop shows them
// beside the chat).
in-out property <bool> members-open;
// The voice channel screen (design mockup 02) instead of a tab: the
// voice channel view, or a stream we watch.
out property <bool> phone-voice: narrow && page == Page.server && Bridge.voice-connected && (voice-view || Bridge.viewer-open);
// Settings were opened (so leaving them tells Rust).
property <bool> settings-active;
@@ -110,6 +118,15 @@ export global Nav {
settings-active = false;
Bridge.close-settings();
}
// The phone shows Home on its own tab: a server goes to Servers,
// and Home from anywhere (the desktop's logo, a switch) is that tab.
// Also while wide, so the tab is right when the window narrows.
if p == Page.server && mobile-tab == MobileTab.home {
mobile-tab = MobileTab.servers;
}
if p == Page.home {
mobile-tab = MobileTab.home;
}
page = p;
notifications-open = false;
if p == Page.events {
@@ -123,6 +140,16 @@ export global Nav {
}
}
// A tab of the phone's bottom navigation, without the pages that were
// over the last one (pins, topics, members).
public function show-tab(tab: MobileTab) {
pins-open = false;
topics-open = false;
members-open = false;
show(tab == MobileTab.home ? Page.home : Page.server);
mobile-tab = tab;
}
public function open-settings(section: SettingsSection) {
if !settings-active {
settings-active = true;
+87 -4
View File
@@ -6,6 +6,8 @@ import { Bridge, BookmarkForm, ShareForm } from "../bridge.slint";
import { Nav, Page } from "../nav.slint";
import { Icon, Button, ButtonKind, IconButton, TextField, Field, Select, Toggle, ToggleRow, Slider, Modal, Card, Chip, Banner, Avatar, Status, ListView, ScrollView } from "../components/index.slint";
import { AboutSlint } from "std-widgets.slint";
import { StudioBridge } from "../studio-bridge.slint";
import { MixerRow, PickDialog } from "studio-parts.slint";
// Buttons at the bottom right of a dialog.
component Footer inherits HorizontalLayout {
@@ -182,15 +184,57 @@ component SourceCard inherits Rectangle {
}
}
export component ShareDialog inherits Modal {
// The stream's audio: the Stream Studio's mixer rows (`stream.audio_sources`,
// levels while live) and Add, which opens its picker.
component ShareAudio inherits VerticalLayout {
callback add();
spacing: Theme.space-1;
HorizontalLayout {
spacing: Theme.space-2;
Text {
text: @tr("Audio sources");
color: Theme.text-secondary;
font-size: Theme.font-sm;
font-weight: Theme.weight-semibold;
vertical-alignment: center;
horizontal-stretch: 1;
}
Button {
small: true;
icon: Icons.plus;
text: @tr("Add");
clicked => { root.add(); }
}
}
if StudioBridge.audio.length == 0: Text {
text: @tr("No audio: add your microphone, the desktop or an application.");
color: Theme.text-muted;
font-size: Theme.font-sm;
wrap: word-wrap;
}
// Three rows at a time.
if StudioBridge.audio.length > 0: ListView {
height: min(StudioBridge.audio.length, 3) * 56px;
accessible-label: @tr("Audio sources");
for audio[i] in StudioBridge.audio: MixerRow {
audio: audio;
index: i;
compact: true;
phone: Nav.narrow;
}
}
}
component ShareCard inherits Modal {
in-out property <ShareForm> form;
callback done();
callback pick-audio();
property <bool> live: Bridge.share-state == "live" || Bridge.share-state == "starting";
title: Bridge.share-state == "live" ? @tr("You are sharing your screen") : Bridge.share-state == "starting" ? @tr("Starting…") : @tr("Share screen");
subtitle: live ? Bridge.share-status : @tr("Stream to the people in your channel.");
icon: Icons.radio;
card-width: 600px;
card-height: 660px;
card-height: 860px;
dismissed => { done(); }
if live: VerticalLayout {
@@ -264,6 +308,15 @@ export component ShareDialog inherits Modal {
}
}
}
// Changes apply to the stream at once.
if Bridge.share-audio: ShareAudio {
add => { root.pick-audio(); }
}
if !Bridge.share-audio: Text {
text: @tr("This stream has no sound.");
color: Theme.text-muted;
font-size: Theme.font-sm;
}
Footer {
Button {
text: @tr("Close");
@@ -320,7 +373,8 @@ export component ShareDialog inherits Modal {
input-type: number;
placeholder: @tr("fps");
label: @tr("Frames per second");
width: 80px;
// On a phone both pairs fit side by side.
width: Nav.narrow ? 60px : 80px;
horizontal-stretch: 0;
}
}
@@ -340,17 +394,22 @@ export component ShareDialog inherits Modal {
input-type: number;
placeholder: @tr("kbit/s");
label: @tr("Bitrate in kbit/s");
width: 80px;
// On a phone both pairs fit side by side.
width: Nav.narrow ? 60px : 80px;
horizontal-stretch: 0;
}
}
}
}
// Off: no audio at all.
ToggleRow {
text: @tr("Share system audio");
icon: Icons.volume-2;
checked <=> form.audio;
}
if form.audio: ShareAudio {
add => { root.pick-audio(); }
}
ToggleRow {
text: @tr("Let everyone in the channel watch without asking");
icon: Icons.users;
@@ -377,6 +436,30 @@ export component ShareDialog inherits Modal {
}
}
// Share the screen or a window, with the stream's audio; the studio's
// audio picker opens over it.
export component ShareDialog inherits Rectangle {
in-out property <ShareForm> form;
callback done();
property <bool> picking;
ShareCard {
width: parent.width;
height: parent.height;
form <=> root.form;
done => { root.done(); }
pick-audio => {
StudioBridge.list-audio();
root.picking = true;
}
}
if root.picking: PickDialog {
width: parent.width;
height: parent.height;
kind: "audio";
done => { root.picking = false; }
}
}
// Local volume and mute of one client.
export component ClientAudioDialog inherits Modal {
callback done();
@@ -0,0 +1,713 @@
// The voice channel on the phone (design mockup 02): the channel's name
// and Leave, the stream we watch (or a card to watch one), the people in
// the channel, the channel's chat, and the voice controls at the bottom in
// place of the navigation.
import { Theme } from "../theme.slint";
import { Icons } from "../icons.slint";
import { Bridge, MemberItem, StreamItem } from "../bridge.slint";
import { Nav, MobileTab } from "../nav.slint";
import { Icon, IconButton, Button, ButtonKind, Avatar, LiveBadge, Select, Slider, SpeakingBars, ScrollView } from "../components/index.slint";
import { MessageList, Composer } from "chat.slint";
import { StudioBridge } from "../studio-bridge.slint";
// Back to the navigation; a stream we watch goes on behind it.
export global PhoneVoice {
public function close() {
if Bridge.viewer-open {
Bridge.hide-viewer();
}
Nav.show-voice(false);
}
}
// The channel's name and topic, back, and Leave.
component ChannelBar inherits HorizontalLayout {
padding-left: Theme.space-3;
padding-right: Theme.space-3;
spacing: Theme.space-3;
height: 56px;
IconButton {
icon: Icons.arrow-left;
label: @tr("Back");
round: true;
filled: true;
size: 40px;
y: (parent.height - self.height) / 2;
clicked => { PhoneVoice.close(); }
}
Icon {
source: Icons.volume-2;
size: 28px;
tint: Theme.text-secondary;
y: (parent.height - self.height) / 2;
}
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
Text {
text: Bridge.own-channel;
color: Theme.text;
font-size: Theme.font-lg;
font-weight: Theme.weight-semibold;
overflow: elide;
}
if Bridge.own-channel-topic != "": Text {
text: Bridge.own-channel-topic;
color: Theme.text-secondary;
font-size: Theme.font-sm;
overflow: elide;
}
}
Button {
kind: ButtonKind.danger;
icon: Icons.log-out;
text: @tr("Leave");
y: (parent.height - self.height) / 2;
clicked => {
PhoneVoice.close();
Bridge.disconnect-voice();
}
}
}
// A translucent pill over the picture.
component OverlayChip inherits Rectangle {
in property <string> text;
in property <image> icon;
height: 26px;
width: row.preferred-width;
border-radius: Theme.radius-pill;
background: #060a18b0;
border-width: 1px;
border-color: #ffffff24;
row := HorizontalLayout {
padding-left: Theme.space-3;
padding-right: Theme.space-3;
spacing: Theme.space-2;
if root.icon.width > 0: Icon {
source: root.icon;
size: 14px;
tint: #ffffff;
y: (parent.height - self.height) / 2;
}
Text {
text: root.text;
color: #ffffff;
font-size: Theme.font-sm;
font-weight: Theme.weight-medium;
vertical-alignment: center;
}
}
}
// The stream we watch: the picture with LIVE, the viewers and the quality
// over its top, the title and who streams it over its bottom, and volume
// and full screen below them.
component PhonePlayer inherits Rectangle {
border-radius: Theme.radius-lg;
clip: true;
background: #000000;
border-width: 1px;
border-color: Theme.accent.transparentize(0.45);
accessible-role: AccessibleRole.groupbox;
accessible-label: Bridge.viewer-title;
Image {
width: parent.width;
height: parent.height;
source: Bridge.viewer-frame;
image-fit: contain;
visible: Bridge.viewer-has-frame;
accessible-role: AccessibleRole.image;
accessible-label: @tr("Stream picture");
}
if Bridge.viewer-status != "": Text {
width: parent.width - 48px;
text: Bridge.viewer-status;
color: #ffffff;
font-size: Theme.font-sm;
horizontal-alignment: center;
vertical-alignment: center;
wrap: word-wrap;
accessible-live-region: polite;
}
// Shades for what is drawn over the picture.
Rectangle {
y: 0;
height: 64px;
background: @linear-gradient(180deg, #000000b0 0%, #00000000 100%);
}
Rectangle {
y: parent.height - self.height;
height: 104px;
background: @linear-gradient(180deg, #00000000 0%, #000000d0 100%);
}
// LIVE, viewers; the quality and full screen.
HorizontalLayout {
y: Theme.space-3;
height: 30px;
padding-left: Theme.space-3;
padding-right: Theme.space-3;
spacing: Theme.space-2;
if !Bridge.viewer-ended: LiveBadge {
large: true;
y: (parent.height - self.height) / 2;
}
if Bridge.viewer-count > 0: OverlayChip {
icon: Icons.eye;
text: Bridge.viewer-count;
y: (parent.height - self.height) / 2;
}
Rectangle { horizontal-stretch: 1; }
// Simulcast layers the streamer offers ("Auto" follows the
// bandwidth estimate); otherwise the height of what arrives.
if Bridge.viewer-qualities.length > 1: Select {
width: 116px;
horizontal-stretch: 0;
label: @tr("Quality");
model: Bridge.viewer-qualities;
current-index <=> Bridge.viewer-quality;
selected(_) => { Bridge.set-stream-quality(Bridge.viewer-quality); }
}
if Bridge.viewer-qualities.length <= 1 && Bridge.viewer-has-frame: OverlayChip {
text: @tr("{}p", Bridge.viewer-frame.height);
y: (parent.height - self.height) / 2;
}
IconButton {
icon: Icons.maximize;
label: @tr("Full screen");
size: 30px;
icon-size: 16px;
tint: #ffffff;
y: (parent.height - self.height) / 2;
clicked => { Bridge.toggle-fullscreen(); }
}
}
// The title, who streams it, and the controls.
VerticalLayout {
height: self.preferred-height;
y: parent.height - self.height;
padding-left: Theme.space-4;
padding-right: Theme.space-3;
padding-bottom: Theme.space-1;
spacing: 1px;
Text {
text: Bridge.viewer-title;
color: #ffffff;
font-size: Theme.font-md;
font-weight: Theme.weight-semibold;
overflow: elide;
}
HorizontalLayout {
spacing: Theme.space-2;
alignment: start;
Text {
text: Bridge.viewer-streamer;
color: #ffffffd0;
font-size: Theme.font-sm;
vertical-alignment: center;
overflow: elide;
}
if Bridge.viewer-streamer-admin: Icon {
source: Icons.crown;
size: 14px;
tint: Theme.gold;
y: (parent.height - self.height) / 2;
}
if !Bridge.viewer-ended: Text {
text: "• " + Bridge.viewer-elapsed;
color: #ffffffa0;
font-size: Theme.font-sm;
vertical-alignment: center;
}
}
HorizontalLayout {
height: 40px;
spacing: Theme.space-2;
IconButton {
icon: Bridge.viewer-volume > 0 ? Icons.volume-2 : Icons.volume-x;
label: Bridge.viewer-volume > 0 ? @tr("Mute") : @tr("Unmute");
size: 34px;
tint: #ffffff;
y: (parent.height - self.height) / 2;
clicked => { Bridge.set-stream-volume(Bridge.viewer-volume > 0 ? 0 : 100); }
}
Slider {
y: (parent.height - self.height) / 2;
minimum: 0;
maximum: 200;
step: 5;
value <=> Bridge.viewer-volume;
enabled: !Bridge.viewer-ended;
label: @tr("Stream volume");
changed(v) => { Bridge.set-stream-volume(v); }
}
IconButton {
icon: Bridge.viewer-ended ? Icons.x : Icons.log-out;
label: Bridge.viewer-ended ? @tr("Close") : @tr("Stop watching");
size: 34px;
tint: #ffffff;
y: (parent.height - self.height) / 2;
clicked => { Bridge.leave-stream(); }
}
}
}
}
// A stream in the channel that we do not show: LIVE, the title, who, and
// Watch (or Show, if we watch it already).
component StreamPrompt inherits Rectangle {
in property <StreamItem> stream;
height: 76px;
border-radius: Theme.radius-lg;
clip: true;
background: @linear-gradient(160deg, #26237a 0%, #0c1430 100%);
border-width: 1px;
border-color: stream.watching ? Theme.accent : Theme.border-strong;
accessible-role: AccessibleRole.groupbox;
accessible-label: stream.name;
HorizontalLayout {
padding: Theme.space-3;
padding-left: Theme.space-4;
spacing: Theme.space-3;
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
spacing: Theme.space-1;
HorizontalLayout {
spacing: Theme.space-2;
alignment: start;
if stream.id != "": LiveBadge {
y: (parent.height - self.height) / 2;
}
Text {
text: stream.id == "" ? @tr("{} is streaming", stream.streamer) : stream.name != "" ? stream.name : @tr("Untitled stream");
color: #ffffff;
font-weight: Theme.weight-semibold;
vertical-alignment: center;
overflow: elide;
}
}
Text {
text: stream.id == "" ? (stream.channel == "" ? @tr("Looking it up…") : @tr("In {}; looking it up…", stream.channel))
: stream.own ? @tr("Your stream")
: stream.channel != "" ? @tr("{} · in {}", stream.streamer, stream.channel)
: stream.viewers > 0 ? @tr("{} · {} watching", stream.streamer, stream.viewers)
: stream.streamer;
color: #ffffffb0;
font-size: Theme.font-sm;
overflow: elide;
}
}
if stream.id != "" && !stream.own: Button {
kind: ButtonKind.primary;
small: true;
icon: stream.watching ? Icons.monitor : Icons.eye;
text: stream.watching ? @tr("Show") : @tr("Watch");
y: (parent.height - self.height) / 2;
clicked => {
if stream.watching {
Bridge.show-viewer();
} else {
Bridge.watch-stream(stream.id);
}
}
}
}
}
// One person: an avatar ringed green while talking (blue while
// streaming), the muted mark, the name with the crown, LIVE below.
component VoiceMember inherits VerticalLayout {
in property <MemberItem> member;
property <length> size: 54px;
width: 68px;
spacing: Theme.space-1;
accessible-role: AccessibleRole.list-item;
accessible-label: member.name;
accessible-description: member.status;
accessible-action-default => { Bridge.open-member(member.id); }
HorizontalLayout {
alignment: center;
Rectangle {
width: root.size + 8px;
height: root.size + 8px;
border-radius: self.width / 2;
border-width: member.talking || member.streaming ? 2px : 0px;
border-color: member.talking ? Theme.success : Theme.accent;
Avatar {
size: root.size;
initials: member.initials;
tint: member.tint;
image: member.avatar;
label: member.name;
}
if member.talking || member.muted || member.sound-off: Rectangle {
x: parent.width - self.width;
y: parent.height - self.height;
width: 22px;
height: 22px;
border-radius: 11px;
background: member.talking ? Theme.accent : Theme.surface;
border-width: 2px;
border-color: Theme.surface;
if member.talking: SpeakingBars {
width: 12px;
height: 12px;
tint: #ffffff;
}
if !member.talking: Icon {
source: member.sound-off ? Icons.headphone-off : Icons.mic-off;
size: 12px;
tint: Theme.danger;
}
}
TouchArea {
clicked => { Bridge.open-member(member.id); }
}
}
}
HorizontalLayout {
alignment: center;
spacing: Theme.space-1;
Text {
text: member.name;
color: member.myself ? Theme.accent-text : Theme.text;
font-size: Theme.font-sm;
overflow: elide;
max-width: root.width - (member.admin ? 16px : 0px);
}
if member.admin: Icon {
source: Icons.crown;
size: 13px;
tint: Theme.gold;
y: (parent.height - self.height) / 2;
}
}
if member.streaming: HorizontalLayout {
alignment: center;
LiveBadge { }
}
}
// "# Chill Zone Chat · Linked to this voice channel", with the pins, the
// topics and the members.
component ChatHeader inherits Rectangle {
height: 56px;
border-radius: Theme.radius-lg;
background: Theme.surface-2;
border-width: 1px;
border-color: Theme.border;
HorizontalLayout {
padding-left: Theme.space-4;
padding-right: Theme.space-3;
spacing: Theme.space-3;
Icon {
source: Icons.hash;
size: 24px;
tint: Theme.text-secondary;
y: (parent.height - self.height) / 2;
}
VerticalLayout {
alignment: center;
horizontal-stretch: 1;
Text {
text: @tr("{} Chat", Bridge.own-channel);
color: Theme.text;
font-size: Theme.font-md;
font-weight: Theme.weight-semibold;
overflow: elide;
}
Text {
text: @tr("Linked to this voice channel");
color: Theme.text-secondary;
font-size: Theme.font-xs;
overflow: elide;
}
}
if Bridge.has-pins: IconButton {
icon: Icons.pin;
label: @tr("Pinned Messages");
filled: true;
size: 36px;
icon-size: 18px;
tint: Theme.accent-text;
y: (parent.height - self.height) / 2;
clicked => { Nav.show-pins(true); }
}
if Bridge.has-topics: IconButton {
icon: Icons.book-open;
label: @tr("Topics");
filled: true;
size: 36px;
icon-size: 18px;
y: (parent.height - self.height) / 2;
clicked => { Nav.show-topics(true); }
}
IconButton {
icon: Icons.users;
label: @tr("Members");
filled: true;
size: 36px;
icon-size: 18px;
y: (parent.height - self.height) / 2;
clicked => { Nav.members-open = true; }
}
}
}
// A round control with its caption, for the voice bar.
component VoiceControl inherits VerticalLayout {
in property <image> icon;
in property <string> text;
in property <bool> checked;
in property <bool> danger;
in property <bool> enabled: true;
// Filled red (Leave).
in property <bool> alarm;
callback clicked();
horizontal-stretch: 1;
spacing: Theme.space-1;
alignment: center;
accessible-role: AccessibleRole.button;
accessible-label: text;
accessible-enabled: enabled;
accessible-checkable: !alarm;
accessible-checked: checked;
accessible-action-default => { if enabled { clicked(); } }
HorizontalLayout {
alignment: center;
Rectangle {
width: 48px;
height: 48px;
border-radius: 24px;
background: root.alarm ? (touch.pressed ? Theme.danger.darker(0.2) : Theme.danger)
: root.checked ? (root.danger ? Theme.danger-soft : Theme.accent-soft)
: touch.pressed ? Theme.surface-4 : Theme.surface-2;
border-width: root.alarm ? 0px : 1px;
border-color: root.checked ? (root.danger ? Theme.danger.transparentize(0.5) : Theme.accent) : Theme.border-strong;
opacity: root.enabled ? 1.0 : 0.45;
Icon {
source: root.icon;
size: 22px;
tint: root.alarm ? #ffffff : root.checked ? (root.danger ? Theme.danger : Theme.accent-text) : Theme.icon;
}
touch := TouchArea {
enabled: root.enabled;
clicked => { root.clicked(); }
}
}
}
Text {
text: root.text;
color: root.checked && root.danger ? Theme.danger : Theme.text-secondary;
font-size: Theme.font-xs;
horizontal-alignment: center;
accessible-role: AccessibleRole.none;
}
}
// Mute, Deafen, Go Live (the Stream Studio; "Live" while it or a share
// is), Share (the screen, at once) and Leave.
component VoiceBar inherits Rectangle {
height: 84px;
background: Theme.surface;
border-width: 1px;
border-color: Theme.border;
accessible-role: AccessibleRole.groupbox;
accessible-label: @tr("Voice");
HorizontalLayout {
padding-left: Theme.space-2;
padding-right: Theme.space-2;
padding-top: Theme.space-3;
padding-bottom: Theme.space-3;
VoiceControl {
icon: Bridge.input-muted ? Icons.mic-off : Icons.mic;
text: Bridge.input-muted ? @tr("Unmute") : @tr("Mute");
checked: Bridge.input-muted;
danger: true;
clicked => { Bridge.set-input-muted(!Bridge.input-muted); }
}
VoiceControl {
icon: Bridge.output-muted ? Icons.headphone-off : Icons.headphones;
text: Bridge.output-muted ? @tr("Undeafen") : @tr("Deafen");
checked: Bridge.output-muted;
danger: true;
clicked => { Bridge.set-output-muted(!Bridge.output-muted); }
}
// The big one: the Stream Studio, or live there.
if Bridge.streams-available && Bridge.can-share: VerticalLayout {
horizontal-stretch: 1.6;
spacing: Theme.space-1;
alignment: center;
accessible-role: AccessibleRole.button;
accessible-label: @tr("Go Live");
accessible-action-default => { Nav.open-studio(); }
Rectangle {
height: 48px;
border-radius: 24px;
background: live.pressed ? Theme.accent-pressed : Theme.accent;
border-width: 2px;
border-color: Theme.glow;
Icon {
source: Icons.radio;
size: 26px;
tint: Theme.on-accent;
}
live := TouchArea {
clicked => { Nav.open-studio(); }
}
}
Text {
text: Bridge.share-state == "live" || StudioBridge.status.live ? @tr("Live") : @tr("Go Live");
color: Theme.text;
font-size: Theme.font-xs;
font-weight: Theme.weight-semibold;
horizontal-alignment: center;
}
}
if Bridge.streams-available && Bridge.can-share: VoiceControl {
icon: Icons.screen-share;
text: Bridge.share-state == "live" ? @tr("Sharing") : @tr("Share");
checked: Bridge.share-state == "live";
clicked => { Nav.open-share(); }
}
VoiceControl {
icon: Icons.phone-off;
text: @tr("Leave");
alarm: true;
clicked => {
PhoneVoice.close();
Bridge.disconnect-voice();
}
}
}
}
// Push-to-talk at the end of the composer: talks while held.
component TalkButton inherits Rectangle {
width: 48px;
height: 48px;
border-radius: 24px;
background: Bridge.transmitting ? Theme.success : touch.pressed ? Theme.accent-pressed : Theme.accent;
border-width: 2px;
border-color: Bridge.transmitting ? Theme.success.transparentize(0.4) : Theme.glow;
accessible-role: AccessibleRole.button;
accessible-label: @tr("Hold to talk");
accessible-checkable: true;
accessible-checked: Bridge.transmitting;
accessible-action-default => { Bridge.push-to-talk(!Bridge.transmitting); }
Icon {
source: Icons.mic;
size: 22px;
tint: Theme.on-accent;
}
touch := TouchArea {
pointer-event(e) => {
if e.kind == PointerEventKind.down {
Bridge.push-to-talk(true);
} else if e.kind == PointerEventKind.up || e.kind == PointerEventKind.cancel {
Bridge.push-to-talk(false);
}
}
}
}
// The whole screen.
export component MobileVoice inherits VerticalLayout {
// A topic opened from the drawer shows in the chat page.
property <int> topic: Bridge.current-topic;
changed topic => {
if topic >= 0 {
PhoneVoice.close();
Nav.mobile-tab = MobileTab.chat;
}
}
clip := TextInput {
visible: false;
width: 0;
height: 0;
}
ChannelBar { }
sv := ScrollView {
// The stream, the people and the chat header scroll away together
// when the window is short; the messages always keep some room.
vertical-stretch: 0;
height: min(content.preferred-height, root.height * 0.55);
content := VerticalLayout {
width: sv.visible-width;
padding-left: Theme.space-3;
padding-right: Theme.space-3;
spacing: Theme.space-3;
if Bridge.viewer-open: PhonePlayer {
height: (sv.visible-width - 2 * Theme.space-3) * 9 / 16;
}
if !Bridge.viewer-open: VerticalLayout {
spacing: Theme.space-2;
for stream in Bridge.streams: StreamPrompt {
stream: stream;
}
}
people := ScrollView {
height: 112px;
HorizontalLayout {
padding-top: Theme.space-2;
spacing: Theme.space-2;
alignment: start;
for member in Bridge.members: VoiceMember {
member: member;
}
VerticalLayout {
width: 68px;
spacing: Theme.space-1;
alignment: start;
HorizontalLayout {
alignment: center;
IconButton {
icon: Icons.user-plus;
label: @tr("Invite: copy a link to this channel");
round: true;
filled: true;
size: 62px;
icon-size: 24px;
// Through a text field: Slint copies only
// what is selected in one.
clicked => {
clip.text = Bridge.invite();
clip.select-all();
clip.copy();
}
}
}
Text {
text: @tr("Invite");
color: Theme.text-secondary;
font-size: Theme.font-sm;
horizontal-alignment: center;
}
}
}
}
ChatHeader { }
}
}
MessageList {
vertical-stretch: 1;
min-height: 96px;
model: Bridge.messages;
older: true;
}
HorizontalLayout {
padding-right: Bridge.audio.transmit == 0 ? Theme.space-4 : 0px;
Composer {
placeholder: @tr("Message #{}…", Bridge.own-channel);
padding: Theme.space-3;
padding-right: Bridge.audio.transmit == 0 ? Theme.space-3 : Theme.space-5;
}
// Push-to-talk is the transmit mode: talking is at hand.
if Bridge.audio.transmit == 0: TalkButton {
y: (parent.height - self.height) / 2;
}
}
VoiceBar { }
}
+33 -1
View File
@@ -1,5 +1,6 @@
// Pages of the narrow (phone) layout that the desktop shows elsewhere:
// the server list with the channels, activity, and the "You" page.
// the server list with the channels, activity, the "You" page, and the
// pins, topics and members over the page.
import { Theme } from "../theme.slint";
import { Icons } from "../icons.slint";
@@ -8,6 +9,8 @@ import { Nav, Page, SettingsSection } from "../nav.slint";
import { Icon, Button, ButtonKind, IconButton, Avatar, Status, CountBadge, LiveBadge, NavItem, ListItem, SectionHeader, Card, Banner, ScrollView, ActionButton } from "../components/index.slint";
import { ServerHeader, ConnectActions, ChannelTree } from "channels.slint";
import { StreamsPanel } from "streams.slint";
import { PinsDrawer, TopicsDrawer } from "drawers.slint";
import { MembersPanel } from "members.slint";
import { VoiceCard, VoiceButtons } from "../shells/common.slint";
import { StudioBridge } from "../studio-bridge.slint";
import { ShareMenu } from "../share-menu.slint";
@@ -230,3 +233,32 @@ export component YouPage inherits ScrollView {
}
}
}
// The pins, the topics or the server's members as a page over the current
// one (the desktop shows them beside the chat).
export component PhoneSheet inherits Rectangle {
background: Theme.bg-app;
// Nothing below takes clicks while it is shown.
TouchArea { }
if Nav.pins-open: PinsDrawer { }
if Nav.topics-open && !Nav.pins-open: TopicsDrawer { }
if Nav.members-open && !Nav.pins-open && !Nav.topics-open: VerticalLayout {
HorizontalLayout {
padding-left: Theme.space-3;
padding-top: Theme.space-3;
spacing: Theme.space-2;
alignment: start;
IconButton {
icon: Icons.arrow-left;
label: @tr("Back");
round: true;
filled: true;
size: 36px;
clicked => { Nav.members-open = false; }
}
}
MembersPanel {
vertical-stretch: 1;
}
}
}
+15 -5
View File
@@ -108,12 +108,13 @@ export component StreamsPanel inherits VerticalLayout {
overflow: elide;
vertical-alignment: center;
}
IconButton {
icon: Icons.x;
label: @tr("Close the panel");
// The phone's voice channel screen.
if Bridge.voice-connected: IconButton {
icon: Icons.chevron-right;
label: @tr("Open the voice channel");
size: 28px;
icon-size: Theme.icon-sm;
clicked => { Nav.right-panel-open = false; }
clicked => { Nav.show-voice(true); }
}
}
if Bridge.members.length == 0: Text {
@@ -367,7 +368,16 @@ component StreamPlayer inherits Rectangle {
vertical-alignment: center;
}
}
Rectangle { horizontal-stretch: 1; }
// What arrives: codec, size, frame rate, bitrate.
Text {
horizontal-stretch: 1;
text: Bridge.viewer-quality-detail;
color: #ffffff80;
font-size: Theme.font-xs;
horizontal-alignment: right;
vertical-alignment: center;
overflow: elide;
}
if !Bridge.viewer-fullscreen && !Nav.narrow: IconButton {
icon: Icons.minimize-2;
label: @tr("Back to the chat (keeps watching)");
+50 -20
View File
@@ -317,21 +317,25 @@ component SourceRow inherits Rectangle {
{ text: source.locked ? @tr("Unlock") : @tr("Lock"), icon: Icons.lock, enabled: true },
{ text: source.background == "keep" ? @tr("Blur background") : @tr("Background effect off"), icon: Icons.sparkles, enabled: source.kind == "camera", separator: true },
{ text: @tr("Background effect…"), icon: Icons.sliders-horizontal, enabled: source.kind == "camera" },
// A phone's front and back camera, or the next webcam.
{ text: @tr("Switch camera"), icon: Icons.video, enabled: source.kind == "camera" },
{ text: @tr("Bring forward"), icon: Icons.chevron-up, enabled: !source.front, separator: true },
{ text: @tr("Send backward"), icon: Icons.chevron-down, enabled: !source.back },
{ text: @tr("Rename…"), icon: Icons.pencil, enabled: true, separator: true },
{ text: @tr("Remove"), icon: Icons.trash-2, enabled: true, danger: true },
];
activated(i) => {
if i == 0 || i == 1 || i == 2 || i == 5 || i == 8 {
if i == 0 || i == 1 || i == 2 || i == 5 || i == 9 {
StudioNav.edit-source(source.id);
} else if i == 3 {
StudioBridge.source-action(source.id, "lock");
} else if i == 4 {
StudioBridge.source-action(source.id, source.background == "keep" ? "bg-blur" : "bg-keep");
} else if i == 6 {
StudioBridge.source-action(source.id, "up");
StudioBridge.source-action(source.id, "next-camera");
} else if i == 7 {
StudioBridge.source-action(source.id, "up");
} else if i == 8 {
StudioBridge.source-action(source.id, "down");
} else {
StudioBridge.source-action(source.id, "remove");
@@ -731,8 +735,8 @@ export component StudioHeader inherits HorizontalLayout {
}
}
// One audio source: meter, gain, mute, a menu.
component MixerRow inherits Rectangle {
// One audio source: meter, gain, mute, a menu (also the share dialog's).
export component MixerRow inherits Rectangle {
in property <StudioAudio> audio;
in property <int> index;
in property <bool> compact;
@@ -1918,12 +1922,13 @@ component SourceDialog inherits Modal {
}
}
// Pick a screen, window, camera or audio source.
component PickDialog inherits Modal {
// Pick a screen, window, camera or audio source (audio: also over the
// share dialog).
export component PickDialog inherits Modal {
in property <string> kind;
callback done();
title: kind == "screen" ? @tr("Share a screen") : kind == "window" ? @tr("Share a window") : kind == "camera" ? @tr("Add a camera") : @tr("Add an audio source");
subtitle: kind == "audio" ? @tr("Mixed into the stream's audio.") : @tr("Added to the live scene.");
title: kind == "screen" ? @tr("Share a screen") : kind == "window" ? @tr("Share a window") : kind == "camera" ? @tr("Add a camera") : @tr("Audio sources");
subtitle: kind == "audio" ? @tr("Mixed into the stream's audio. Pick as many as you like.") : @tr("Added to the live scene.");
icon: StudioKinds.icon(kind == "audio" ? "microphone" : kind);
card-width: 520px;
card-height: 540px;
@@ -1944,24 +1949,22 @@ component PickDialog inherits Modal {
accessible-role: AccessibleRole.button;
accessible-label: pick.name;
accessible-description: pick.detail;
accessible-action-default => {
if root.kind == "audio" {
StudioBridge.add-audio(i);
} else {
StudioBridge.add-picked(root.kind, i);
}
root.done();
}
accessible-checkable: root.kind == "audio";
accessible-checked: pick.selected;
accessible-action-default => { pick-touch.pick(); }
pick-touch := TouchArea {
mouse-cursor: MouseCursor.pointer;
clicked => {
// Audio sources are switched on and off (several at once);
// the rest is added and the picker closes.
function pick() {
if root.kind == "audio" {
StudioBridge.add-audio(i);
StudioBridge.toggle-audio(i);
} else {
StudioBridge.add-picked(root.kind, i);
root.done();
}
root.done();
}
clicked => { self.pick(); }
}
HorizontalLayout {
padding-left: Theme.space-3;
@@ -1973,10 +1976,15 @@ component PickDialog inherits Modal {
y: (parent.height - self.height) / 2;
border-radius: Theme.radius-md;
background: Theme.surface-3;
Icon {
if pick.icon.width == 0: Icon {
source: StudioKinds.icon(pick.kind);
size: 18px;
}
if pick.icon.width > 0: Image {
width: 28px;
height: 28px;
source: pick.icon;
}
}
VerticalLayout {
alignment: center;
@@ -1993,9 +2001,31 @@ component PickDialog inherits Modal {
overflow: elide;
}
}
if root.kind == "audio": Rectangle {
width: 24px;
height: 24px;
y: (parent.height - self.height) / 2;
border-radius: 12px;
background: pick.selected ? Theme.accent : transparent;
border-width: pick.selected ? 0 : 1.5px;
border-color: Theme.border-strong;
if pick.selected: Icon {
source: Icons.check;
size: 16px;
tint: Theme.on-accent;
}
}
}
}
}
if root.kind == "audio": HorizontalLayout {
alignment: end;
Button {
kind: ButtonKind.primary;
text: @tr("Done");
clicked => { root.done(); }
}
}
}
// Rename a scene.
+12
View File
@@ -69,6 +69,10 @@ export component VoiceCard inherits Rectangle {
border-color: Theme.border;
accessible-role: AccessibleRole.groupbox;
accessible-label: @tr("Voice");
// The phone: a tap opens the voice channel screen.
if Nav.narrow && Bridge.voice-connected: TouchArea {
clicked => { Nav.show-voice(true); }
}
VerticalLayout {
padding: Theme.space-3;
spacing: Theme.space-3;
@@ -97,6 +101,14 @@ export component VoiceCard inherits Rectangle {
overflow: elide;
}
}
if Nav.narrow && Bridge.voice-connected: IconButton {
icon: Icons.chevron-right;
label: @tr("Open the voice channel");
size: 32px;
icon-size: Theme.icon-sm;
y: (parent.height - self.height) / 2;
clicked => { Nav.show-voice(true); }
}
IconButton {
icon: Icons.phone-off;
label: @tr("Disconnect");
+121 -12
View File
@@ -1,12 +1,13 @@
// The narrow (phone) frame: a top bar, one page at a time (@children), and
// the bottom navigation (Home, Servers, Chat, Activity, You). Used while
// the bottom navigation (Home, Servers, Chats, Activity, You). Used while
// the window is narrower than `Nav.narrow-breakpoint`.
import { Theme } from "../theme.slint";
import { Icons } from "../icons.slint";
import { Bridge } from "../bridge.slint";
import { Nav, Page, MobileTab, SettingsSection } from "../nav.slint";
import { Icon, IconButton, CountBadge } from "../components/index.slint";
import { Icon, IconButton, CountBadge, PopupMenu, MenuEntry } from "../components/index.slint";
import { PhoneVoice } from "../screens/mobile-voice.slint";
// One entry of the bottom navigation.
component NavTab inherits Rectangle {
@@ -68,6 +69,40 @@ component NavTab inherits Rectangle {
}
}
// The people in our channel, as a pill (the voice channel screen's top bar).
component PeoplePill inherits Rectangle {
callback clicked();
width: row.preferred-width;
height: 40px;
border-radius: 20px;
background: touch.pressed ? Theme.surface-4 : Theme.surface-2;
border-width: 1px;
border-color: Theme.border;
accessible-role: AccessibleRole.button;
accessible-label: @tr("{} in voice", Bridge.members.length);
accessible-action-default => { root.clicked(); }
touch := TouchArea {
clicked => { root.clicked(); }
}
row := HorizontalLayout {
padding-left: Theme.space-4;
padding-right: Theme.space-4;
spacing: Theme.space-2;
Icon {
source: Icons.users;
size: 18px;
tint: Theme.icon;
y: (parent.height - self.height) / 2;
}
Text {
text: Bridge.members.length;
color: Theme.text;
font-size: Theme.font-md;
vertical-alignment: center;
}
}
}
export component MobileShell inherits Rectangle {
in property <string> title;
in property <string> subtitle;
@@ -75,6 +110,12 @@ export component MobileShell inherits Rectangle {
in property <int> unread;
// Show a back arrow (sub-pages such as the settings).
in property <bool> back;
// The bottom navigation; pages with their own controls there (the
// voice channel, the Stream Studio) go without.
in property <bool> navigation: true;
// The voice channel screen's buttons in the top bar: the people, the
// chats and a menu.
in property <bool> voice;
callback go-back();
background: Theme.backdrop;
VerticalLayout {
@@ -117,7 +158,7 @@ export component MobileShell inherits Rectangle {
overflow: elide;
}
}
IconButton {
if !root.voice: IconButton {
icon: Icons.search;
label: @tr("Search");
round: true;
@@ -125,7 +166,21 @@ export component MobileShell inherits Rectangle {
y: (parent.height - self.height) / 2;
clicked => { Nav.open-search(""); }
}
IconButton {
// The voice channel we are in, from any page.
if !root.voice && Bridge.voice-connected: IconButton {
icon: Icons.volume-2;
label: @tr("Voice channel");
round: true;
filled: true;
dot: true;
dot-color: Theme.success;
y: (parent.height - self.height) / 2;
clicked => {
Nav.show(Page.server);
Nav.show-voice(true);
}
}
if !root.voice: IconButton {
icon: Icons.bell;
label: @tr("Notifications");
round: true;
@@ -135,6 +190,60 @@ export component MobileShell inherits Rectangle {
y: (parent.height - self.height) / 2;
clicked => { Nav.notifications-open = !Nav.notifications-open; }
}
if root.voice: PeoplePill {
y: (parent.height - self.height) / 2;
clicked => { Nav.members-open = true; }
}
if root.voice: Rectangle {
width: 40px;
height: 40px;
y: (parent.height - self.height) / 2;
IconButton {
icon: Icons.message-square;
label: @tr("Chats");
round: true;
filled: true;
size: 40px;
clicked => {
PhoneVoice.close();
Nav.mobile-tab = MobileTab.chat;
}
}
if root.unread > 0: CountBadge {
x: parent.width - self.width / 2 - 4px;
y: -4px;
count: root.unread;
}
}
if root.voice: IconButton {
icon: Icons.more-horizontal;
label: @tr("More");
round: true;
filled: true;
y: (parent.height - self.height) / 2;
clicked => { more.show(self.x + self.width - 220px, self.y + self.height + 4px); }
}
}
more := PopupMenu {
entries: [
{ text: @tr("Stream Studio"), icon: Icons.radio, enabled: Bridge.streams-available },
{ text: @tr("Voice Settings"), icon: Icons.settings, enabled: true },
{ text: @tr("Activity"), icon: Icons.activity, enabled: true },
{ text: @tr("Leave Voice"), icon: Icons.phone-off, danger: true, enabled: true, separator: true },
];
activated(i) => {
if i == 0 {
Nav.open-studio();
} else if i == 1 {
Nav.open-settings(SettingsSection.voice);
} else if i == 2 {
PhoneVoice.close();
Nav.mobile-tab = MobileTab.activity;
} else {
PhoneVoice.close();
Bridge.disconnect-voice();
}
}
}
}
Rectangle {
@@ -142,7 +251,7 @@ export component MobileShell inherits Rectangle {
@children
}
// Bottom navigation.
Rectangle {
if root.navigation: Rectangle {
height: 64px;
background: Theme.surface;
border-width: 1px;
@@ -156,34 +265,34 @@ export component MobileShell inherits Rectangle {
icon: Icons.home;
text: @tr("Home");
selected: Nav.page == Page.home || Nav.page == Page.friends || Nav.page == Page.messages || Nav.page == Page.library || (Nav.mobile-tab == MobileTab.home && Nav.page == Page.server);
clicked => { Nav.show(Page.home); Nav.mobile-tab = MobileTab.home; }
clicked => { Nav.show-tab(MobileTab.home); }
}
NavTab {
icon: Icons.server;
text: @tr("Servers");
selected: (Nav.mobile-tab == MobileTab.servers && Nav.page == Page.server) || Nav.page == Page.events;
dot: Bridge.voice-connected;
clicked => { Nav.show(Page.server); Nav.mobile-tab = MobileTab.servers; }
clicked => { Nav.show-tab(MobileTab.servers); }
}
NavTab {
icon: Bridge.viewer-open ? Icons.monitor : Icons.message-circle;
text: Bridge.viewer-open ? @tr("Stream") : @tr("Chat");
icon: Icons.message-circle;
text: @tr("Chats");
selected: Nav.mobile-tab == MobileTab.chat && Nav.page == Page.server;
badge: root.unread;
clicked => { Nav.show(Page.server); Nav.mobile-tab = MobileTab.chat; }
clicked => { Nav.show-tab(MobileTab.chat); }
}
NavTab {
icon: Icons.activity;
text: @tr("Activity");
selected: Nav.mobile-tab == MobileTab.activity && Nav.page == Page.server;
badge: Bridge.share-requests;
clicked => { Nav.show(Page.server); Nav.mobile-tab = MobileTab.activity; }
clicked => { Nav.show-tab(MobileTab.activity); }
}
NavTab {
icon: Icons.user;
text: @tr("You");
selected: (Nav.mobile-tab == MobileTab.you && Nav.page == Page.server) || Nav.page == Page.settings;
clicked => { Nav.show(Page.server); Nav.mobile-tab = MobileTab.you; }
clicked => { Nav.show-tab(MobileTab.you); }
}
}
}
+7 -2
View File
@@ -78,6 +78,10 @@ export struct StudioPick {
detail: string,
// For the icon: monitor, window, portal, camera, microphone, desktop, app, tone
kind: string,
// The application's own icon (audio), if it has one.
icon: image,
// Already mixed in (audio): picking it again takes it out.
selected: bool,
}
// The header, the preview's badges and the bottom bar.
@@ -223,9 +227,10 @@ export global StudioBridge {
// The phone layout's source cards: screen, camera, window.
callback main-source(string);
// Audio: fill `picks` with what can be added; add, change, remove.
// Audio: fill `picks` with what can be mixed in (marking what is);
// mix one in or take it out, change, remove.
callback list-audio();
callback add-audio(int);
callback toggle-audio(int);
// While dragging (`done` false) and at the end.
callback set-gain(int, float, bool);
callback toggle-mute(int);