Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix(desktop-gpui): focus ring on text fields, name settings switches for screen readers, trim the menu doc comment

Richie McIlroy19014c8a7d07
diff --git a/apps/desktop-gpui/src/menus.rs b/apps/desktop-gpui/src/menus.rs
index dc165622d..9624eca26 100644
--- a/apps/desktop-gpui/src/menus.rs
+++ b/apps/desktop-gpui/src/menus.rs
@@ -152,8 +152,7 @@ fn settings_shortcut_allowed(idle: bool, onboarding_open: bool, hotkeys_paused:
/// The menu bar model.
///
/// One-to-one with `build_macos_app_menu`, including the empty Help submenu
-/// (`Submenu::with_id_and_items(.., HELP_SUBMENU_ID, "Help", true, &[])`),
-/// plus the standard Settings… item the Tauri menu never had.
+/// (`Submenu::with_id_and_items(.., HELP_SUBMENU_ID, "Help", true, &[])`).
pub fn build_menus() -> Vec<Menu> {
vec![
Menu {
diff --git a/apps/desktop-gpui/src/settings_pages.rs b/apps/desktop-gpui/src/settings_pages.rs
index dde8b7f54..530a8df63 100644
--- a/apps/desktop-gpui/src/settings_pages.rs
+++ b/apps/desktop-gpui/src/settings_pages.rs
@@ -2624,6 +2624,7 @@ impl SettingsWindow {
),
self.toggle(
"out-of-process-muxer",
+ "Out-of-process muxer",
self.settings.out_of_process_muxer,
cx,
|this, cx| {
@@ -2666,14 +2667,20 @@ impl SettingsWindow {
"Turn off to close this app and reopen the classic Tauri app in the dev harness. \
Recordings and settings are shared.",
),
- self.toggle("enable-gpui-app", checked, cx, |this, cx| {
- match this.pages.switch_back {
- Some(SwitchBack::Running(_)) => this.cancel_switch_back(cx),
- // Committed: the classic app is already being brought up.
- Some(SwitchBack::WaitingForClassic) => {}
- _ => this.start_switch_back(cx),
- }
- })
+ self.toggle(
+ "enable-gpui-app",
+ "Use native app",
+ checked,
+ cx,
+ |this, cx| {
+ match this.pages.switch_back {
+ Some(SwitchBack::Running(_)) => this.cancel_switch_back(cx),
+ // Committed: the classic app is already being brought up.
+ Some(SwitchBack::WaitingForClassic) => {}
+ _ => this.start_switch_back(cx),
+ }
+ },
+ )
.into_any_element(),
)
}
@@ -3399,6 +3406,7 @@ impl SettingsWindow {
),
self.toggle(
"diagnostic-mic",
+ "Test microphone",
self.pages.diagnostic_mic,
cx,
|this, cx| {
@@ -6996,15 +7004,19 @@ impl SettingsWindow {
(false, true) => "Disabled · Not saved",
}),
)
- .child(
- self.toggle(("rule-enabled", index), enabled, cx, move |this, cx| {
+ .child(self.toggle(
+ ("rule-enabled", index),
+ "Enabled",
+ enabled,
+ cx,
+ move |this, cx| {
if let Some(rule) = this.pages.automations.rules.get_mut(index) {
rule.enabled = !rule.enabled;
this.automations_persist();
cx.notify();
}
- }),
- ),
+ },
+ )),
)
.child(
div()
@@ -7693,6 +7705,7 @@ impl SettingsWindow {
SharedString::from(format!(
"action-copy-link-{rule}-{index}"
)),
+ "Copy link to clipboard",
copy_link,
cx,
move |this, cx| {
@@ -7725,6 +7738,7 @@ impl SettingsWindow {
SharedString::from(format!(
"action-open-browser-{rule}-{index}"
)),
+ "Open in browser",
open_in_browser,
cx,
move |this, cx| {
@@ -7779,6 +7793,7 @@ impl SettingsWindow {
.gap(px(8.))
.child(self.toggle(
SharedString::from(format!("action-shell-{rule}-{index}")),
+ "Run through shell",
use_shell,
cx,
move |this, cx| {
diff --git a/apps/desktop-gpui/src/settings_window.rs b/apps/desktop-gpui/src/settings_window.rs
index cf59287fe..df60d2ead 100644
--- a/apps/desktop-gpui/src/settings_window.rs
+++ b/apps/desktop-gpui/src/settings_window.rs
@@ -3068,6 +3068,7 @@ impl SettingsWindow {
// The row is the *inverse* of the stored key.
self.toggle(
"hide-dock-icon",
+ "Always show dock icon",
!self.settings.hide_dock_icon,
cx,
|this, cx| {
@@ -3091,6 +3092,7 @@ impl SettingsWindow {
),
self.toggle(
"enable-notifications",
+ "System notifications",
self.settings.enable_notifications,
cx,
|this, cx| {
@@ -3150,6 +3152,7 @@ impl SettingsWindow {
Some("Open the link in your browser when an upload finishes."),
self.toggle(
"auto-open-links",
+ "Open share links automatically",
!self.settings.disable_auto_open_links,
cx,
|this, cx| {
@@ -3432,6 +3435,7 @@ impl SettingsWindow {
),
self.toggle(
"confirm-without-mic",
+ "Confirm before recording without a microphone",
settings.confirm_without_microphone,
cx,
|this, cx| {
@@ -3458,6 +3462,7 @@ impl SettingsWindow {
),
self.toggle(
"studio-sound-default",
+ "Studio Sound on new recordings",
settings.studio_sound_by_default,
cx,
|this, cx| {
@@ -3502,6 +3507,7 @@ impl SettingsWindow {
Some("Cap removes the local file once it has uploaded successfully."),
self.toggle(
"delete-after-upload",
+ "Delete Instant recordings after upload",
settings.delete_instant_recordings_after_upload,
cx,
|this, cx| {
@@ -3521,6 +3527,7 @@ impl SettingsWindow {
),
self.toggle(
"crash-recovery",
+ "Crash-recoverable recording",
settings.crash_recovery_recording,
cx,
|this, cx| {
@@ -3540,6 +3547,7 @@ impl SettingsWindow {
),
self.toggle(
"custom-cursor",
+ "Custom cursor capture (Studio)",
settings.custom_cursor_capture,
cx,
|this, cx| {
@@ -3557,11 +3565,18 @@ impl SettingsWindow {
"Automatically add zoom segments around mouse clicks in Studio \
recordings.",
),
- self.toggle("auto-zoom", settings.auto_zoom_on_clicks, cx, |this, cx| {
- this.settings.auto_zoom_on_clicks = !this.settings.auto_zoom_on_clicks;
- let value = this.settings.auto_zoom_on_clicks;
- this.write_bool("autoZoomOnClicks", value, cx);
- })
+ self.toggle(
+ "auto-zoom",
+ "Auto zoom on clicks",
+ settings.auto_zoom_on_clicks,
+ cx,
+ |this, cx| {
+ this.settings.auto_zoom_on_clicks =
+ !this.settings.auto_zoom_on_clicks;
+ let value = this.settings.auto_zoom_on_clicks;
+ this.write_bool("autoZoomOnClicks", value, cx);
+ },
+ )
.into_any_element(),
),
self.setting_row(
@@ -3590,6 +3605,7 @@ impl SettingsWindow {
Some("Record key presses so you can add keyboard overlays in the editor."),
self.toggle(
"capture-keyboard",
+ "Capture keyboard presses",
settings.capture_keyboard_events,
cx,
|this, cx| {
@@ -3611,6 +3627,7 @@ impl SettingsWindow {
),
self.toggle(
"notch-overlay",
+ "Draw the MacBook notch on screen recordings",
settings.macbook_notch_overlay,
cx,
|this, cx| {
@@ -4290,6 +4307,7 @@ impl SettingsWindow {
),
self.toggle(
"telemetry",
+ "Share anonymous telemetry",
self.settings.enable_telemetry,
cx,
|this, cx| {
@@ -4358,11 +4376,13 @@ impl SettingsWindow {
pub(crate) fn toggle(
&self,
id: impl Into<gpui::ElementId>,
+ label: impl Into<SharedString>,
checked: bool,
cx: &mut Context<Self>,
on_change: impl Fn(&mut Self, &mut Context<Self>) + 'static,
) -> ui::Toggle {
ui::Toggle::settings(&self.theme, id, checked)
+ .label(label)
.on_click(cx.listener(move |this, _, _window, cx| on_change(this, cx)))
}
diff --git a/apps/desktop-gpui/src/ui/text_input.rs b/apps/desktop-gpui/src/ui/text_input.rs
index 940feff89..4bbf4b3b2 100644
--- a/apps/desktop-gpui/src/ui/text_input.rs
+++ b/apps/desktop-gpui/src/ui/text_input.rs
@@ -75,6 +75,7 @@ use gpui::{
use smallvec::SmallVec;
use unicode_segmentation::UnicodeSegmentation;
+use super::keyboard_nav;
use crate::theme::Theme;
// -- Actions and key bindings -------------------------------------------------
@@ -1882,6 +1883,7 @@ impl RenderOnce for TextInput {
.id(self.id.clone())
.key_context(KEY_CONTEXT)
.track_focus(&focus)
+ .when(keyboard_nav::active(window, cx), keyboard_nav::ring)
.relative()
.flex()
.flex_row()
diff --git a/apps/desktop-gpui/src/ui/toggle.rs b/apps/desktop-gpui/src/ui/toggle.rs
index 8e483e03a..4a6bf7fdf 100644
--- a/apps/desktop-gpui/src/ui/toggle.rs
+++ b/apps/desktop-gpui/src/ui/toggle.rs
@@ -6,7 +6,8 @@
use gpui::{
App, ClickEvent, ElementId, Hsla, InteractiveElement, IntoElement, ParentElement, Pixels,
- RenderOnce, StatefulInteractiveElement, Styled, Window, div, prelude::FluentBuilder, px,
+ RenderOnce, SharedString, StatefulInteractiveElement, Styled, Window, div,
+ prelude::FluentBuilder, px,
};
use super::keyboard_nav;
@@ -55,6 +56,7 @@ pub struct Toggle {
/// `bg-white` -- the thumb is white on every surface.
thumb: Hsla,
disabled: bool,
+ label: Option<SharedString>,
on_click: Option<crate::ui::button::ClickHandler>,
}
@@ -69,6 +71,7 @@ impl Toggle {
on_fill: Hsla::from(theme.editor.accent),
thumb: gpui::white(),
disabled: false,
+ label: None,
on_click: None,
}
}
@@ -116,6 +119,11 @@ impl Toggle {
self
}
+ pub fn label(mut self, label: impl Into<SharedString>) -> Self {
+ self.label = Some(label.into());
+ self
+ }
+
pub fn on_click(
mut self,
handler: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
@@ -135,6 +143,7 @@ impl RenderOnce for Toggle {
on_fill,
thumb,
disabled,
+ label,
on_click,
} = self;
let (width, height, padding) = size.track();
@@ -151,6 +160,7 @@ impl RenderOnce for Toggle {
} else {
gpui::Toggled::False
})
+ .when_some(label, |this, label| this.aria_label(label))
.w(width)
.h(height)
.p(padding)