diff --git a/crates/voelin-ui/ui/screens/mobile.slint b/crates/voelin-ui/ui/screens/mobile.slint index 277c2eb..1ec2bb1 100644 --- a/crates/voelin-ui/ui/screens/mobile.slint +++ b/crates/voelin-ui/ui/screens/mobile.slint @@ -9,6 +9,8 @@ import { Icon, Button, ButtonKind, IconButton, Avatar, Status, CountBadge, LiveB import { ServerHeader, ConnectActions, ChannelTree } from "channels.slint"; import { StreamsPanel } from "streams.slint"; import { VoiceCard, VoiceButtons } from "../shells/common.slint"; +import { StudioBridge } from "../studio-bridge.slint"; +import { ShareMenu } from "../share-menu.slint"; // Servers as a horizontal strip, the current server, its channels. export component MobileServers inherits VerticalLayout { @@ -166,11 +168,15 @@ export component YouPage inherits ScrollView { enabled: Bridge.voice-connected; clicked => { Bridge.set-output-muted(!Bridge.output-muted); } } - if Bridge.streams-available && Bridge.can-share: ActionButton { - icon: Icons.radio; - text: Bridge.share-state == "live" ? @tr("Live") : @tr("Go Live"); - checked: Bridge.share-state == "live"; - clicked => { Nav.open-share(); } + // A screen or the Stream Studio (ShareMenu). + if Bridge.streams-available && Bridge.can-share: VerticalLayout { + live := ActionButton { + icon: Icons.radio; + text: Bridge.share-state == "live" || StudioBridge.status.live ? @tr("Live") : @tr("Go Live"); + checked: Bridge.share-state == "live" || StudioBridge.status.live; + clicked => { share-menu.open(0, - live.height - share-menu.menu-height - 4px); } + } + share-menu := ShareMenu { } } ActionButton { icon: Icons.phone-off; diff --git a/crates/voelin-ui/ui/share-menu.slint b/crates/voelin-ui/ui/share-menu.slint new file mode 100644 index 0000000..df491e5 --- /dev/null +++ b/crates/voelin-ui/ui/share-menu.slint @@ -0,0 +1,42 @@ +// What a Share button opens: a quick share of a screen or a window (the +// share dialog) or the Stream Studio. While a share runs it opens the share +// dialog right away, to manage it. + +import { Theme } from "theme.slint"; +import { Icons } from "icons.slint"; +import { PopupMenu } from "components/index.slint"; +import { Bridge } from "bridge.slint"; +import { StudioBridge } from "studio-bridge.slint"; +import { Nav } from "nav.slint"; + +export component ShareMenu inherits Rectangle { + // The menu's height, to open it above a button. + out property menu-height: 2 * Theme.control-height + 2 * Theme.space-2 + 2px; + width: 0; + height: 0; + + // Open at (x, y), relative to this element. + public function open(x: length, y: length) { + if Bridge.share-state == "live" || Bridge.share-state == "starting" { + Nav.open-share(); + } else { + menu.show(x, y); + } + } + + menu := PopupMenu { + menu-width: 220px; + entries: [ + // The studio's stream takes the place of a simple share. + { text: @tr("Share screen"), icon: Icons.monitor-up, enabled: !StudioBridge.status.live }, + { text: @tr("Stream Studio"), icon: Icons.radio, enabled: true }, + ]; + activated(i) => { + if i == 0 { + Nav.open-share(); + } else { + Nav.open-studio(); + } + } + } +} diff --git a/crates/voelin-ui/ui/shells/common.slint b/crates/voelin-ui/ui/shells/common.slint index cf66e86..63134ea 100644 --- a/crates/voelin-ui/ui/shells/common.slint +++ b/crates/voelin-ui/ui/shells/common.slint @@ -4,6 +4,8 @@ import { Theme } from "../theme.slint"; import { Icons } from "../icons.slint"; import { Bridge } from "../bridge.slint"; import { Nav, SettingsSection } from "../nav.slint"; +import { StudioBridge } from "../studio-bridge.slint"; +import { ShareMenu } from "../share-menu.slint"; import { Icon, IconButton, Avatar, Status } from "../components/index.slint"; // A rounded panel of the frame (sidebar, main area, right panel). @@ -131,12 +133,16 @@ export component VoiceButtons inherits HorizontalLayout { enabled: Bridge.voice-connected; clicked => { Bridge.set-output-muted(!Bridge.output-muted); } } - if Bridge.streams-available && Bridge.can-share: IconButton { - icon: Icons.monitor-up; - label: Bridge.share-state == "live" ? @tr("Sharing") : @tr("Share screen"); - checked: Bridge.share-state == "live"; - size: root.size; - clicked => { Nav.open-share(); } + // A screen or window, or the Stream Studio (ShareMenu). + if Bridge.streams-available && Bridge.can-share: VerticalLayout { + IconButton { + icon: Icons.monitor-up; + label: Bridge.share-state == "live" ? @tr("Sharing") : StudioBridge.status.live ? @tr("Live in the Stream Studio") : @tr("Share or go live"); + checked: Bridge.share-state == "live" || StudioBridge.status.live; + size: root.size; + clicked => { share-menu.open(0, - root.size - share-menu.menu-height - 4px); } + } + share-menu := ShareMenu { } } IconButton { icon: Icons.settings; diff --git a/crates/voelin-ui/ui/shells/desktop.slint b/crates/voelin-ui/ui/shells/desktop.slint index dc1ea85..a5fcfcc 100644 --- a/crates/voelin-ui/ui/shells/desktop.slint +++ b/crates/voelin-ui/ui/shells/desktop.slint @@ -218,13 +218,6 @@ export component TopBar inherits Rectangle { } } } - IconButton { - icon: Icons.radio; - label: @tr("Stream Studio"); - checked: Nav.page == Page.studio; - y: (parent.height - self.height) / 2; - clicked => { Nav.open-studio(); } - } IconButton { icon: Icons.users; label: @tr("Members"); diff --git a/crates/voelin-ui/ui/shells/mobile.slint b/crates/voelin-ui/ui/shells/mobile.slint index 25bd331..c75a72d 100644 --- a/crates/voelin-ui/ui/shells/mobile.slint +++ b/crates/voelin-ui/ui/shells/mobile.slint @@ -117,15 +117,6 @@ export component MobileShell inherits Rectangle { overflow: elide; } } - IconButton { - icon: Icons.radio; - label: @tr("Stream Studio"); - round: true; - filled: true; - checked: Nav.page == Page.studio; - y: (parent.height - self.height) / 2; - clicked => { Nav.open-studio(); } - } IconButton { icon: Icons.bell; label: @tr("Notifications"); diff --git a/docs/ui.md b/docs/ui.md index 719f174..4a6decf 100644 --- a/docs/ui.md +++ b/docs/ui.md @@ -149,7 +149,9 @@ Activity tab. ![Stream Studio](screenshots/desktop-studio-live.png) The studio (mockups 09, 10 and the phone's 04) is a page of the main window -(the radio button in the top bar), a window of its own (the button in its +(the Share button's menu: "Share screen" for a quick share of a screen or +window, "Stream Studio" for the studio; while a share runs the button opens +its dialog), a window of its own (the button in its header; closing that window brings it back) and a phone page. Its controller is `src/studio.rs` on the engine's studio ([studio.md](studio.md)): the studio runs while it is shown, live or recording, and a `Streamer` started