Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 67 additions & 18 deletions apps/desktop-gpui/src/controls_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ impl ControlsWindow {
let theme = self.theme;
div()
.id(id)
.size(px(32.))
.w(px(28.))
.h(px(32.))
.flex_shrink_0()
.flex()
.items_center()
.justify_center()
Expand All @@ -128,7 +130,6 @@ impl ControlsWindow {
let stopping = session.phase == Phase::Stopping;
let countdown = session.countdown_remaining();
let can_stop = (!starting && !stopping) || countdown.is_some();
let error = session.error.clone();
let label: SharedString = if let Some(countdown) = countdown {
countdown.to_string().into()
} else if starting {
Expand All @@ -142,23 +143,25 @@ impl ControlsWindow {
"Pausing…"
}
.into()
} else if error.is_some() {
"Error".into()
} else if session.is_paused() {
"Paused".into()
} else if session.error.is_some() {
"Error".into()
} else {
Self::format_elapsed(session.elapsed()).into()
};

div()
.id("stop")
.min_w_0()
.flex_1()
.flex()
.flex_row()
.items_center()
.gap(px(4.))
.rounded(px(8.))
.py(px(4.))
.px(px(8.))
.px(px(6.))
.text_color(theme.red_300)
.when(can_stop, |this| {
this.hover(|style| style.bg(Theme::with_alpha(theme.red_300, 0.08)))
Expand All @@ -168,17 +171,17 @@ impl ControlsWindow {
}))
})
.when(!can_stop, |this| this.opacity(0.6))
.when_some(error, |this, error| {
this.tooltip(move |_, cx| ui::Tooltip::new(&theme, error.clone()).view(cx))
})
.child(
svg()
.path("icons/stop-circle.svg")
.size(px(16.))
.size(px(20.))
.flex_shrink_0()
.text_color(theme.red_300),
)
.child(
div()
.min_w_0()
.truncate()
.text_size(px(14.))
.font_weight(gpui::FontWeight::MEDIUM)
.child(label),
Expand Down Expand Up @@ -215,7 +218,9 @@ impl ControlsWindow {

div()
.id("microphone")
.size(px(32.))
.w(px(28.))
.h(px(32.))
.flex_shrink_0()
.relative()
.flex()
.items_center()
Expand Down Expand Up @@ -352,6 +357,7 @@ impl ControlsWindow {

div()
.h(px(40.))
.flex_shrink_0()
.w_full()
.flex()
.flex_row()
Expand All @@ -373,17 +379,20 @@ impl ControlsWindow {
div()
.flex()
.flex_1()
.min_w_0()
.flex_row()
.items_center()
.justify_between()
.gap(px(4.))
.p(px(4.))
.child(self.render_stop(cx))
.child(
div()
.flex()
.flex_row()
.items_center()
.gap(px(4.))
.gap(px(2.))
.flex_shrink_0()
.child(self.render_microphone(cx))
.child(
self.action_button(
Expand Down Expand Up @@ -440,6 +449,8 @@ impl ControlsWindow {
.child(
div()
.id("drag")
.w(px(24.))
.flex_shrink_0()
.cursor_move()
.flex()
.items_center()
Expand All @@ -465,29 +476,67 @@ impl ControlsWindow {
impl Render for ControlsWindow {
fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {
self.theme.refresh(window, cx, false);
let session = self.session.read(cx);
let issue = session.error.clone().or_else(|| {
session
.storage_warning
.then(|| "Low storage. Cap will stop soon to save your recording.".to_owned())
});

div()
.size_full()
.flex()
.flex_col()
.justify_end()
.px(px(12.))
.pb(px(12.))
.p(px(12.))
.font_family("Geist")
// `body { font-weight: 500 }` (`ui-solid/src/main.css:189-192`).
.font_weight(FontWeight::MEDIUM)
.when(self.session.read(cx).storage_warning, |this| {
.when_some(issue, |this, issue| {
this.child(
div()
.min_h_0()
.w_full()
.flex()
.items_start()
.gap(px(8.))
.mb(px(8.))
.rounded(px(8.))
.bg(self.theme.red_2)
.rounded(px(12.))
.border_1()
.border_color(Theme::with_alpha(self.theme.red_9, 0.4))
.bg(self.theme.gray_1)
.p(px(8.))
.text_size(px(11.))
.text_size(px(12.))
.text_color(self.theme.red_11)
.child("Low storage. Cap will stop soon to save your recording."),
.child(
svg()
.path("icons/triangle-alert.svg")
.size(px(20.))
.flex_shrink_0()
.text_color(self.theme.red_9),
)
.child(recording_issue_text(issue)),
)
})
.child(self.render_bar(cx))
}
}

fn recording_issue_text(error: String) -> impl IntoElement + Styled {
div()
.id("recording-issue-text")
.min_w_0()
.min_h_0()
.flex_1()
.max_h(px(56.))
.overflow_x_scroll()
.overflow_y_scroll()
.child(if error.contains("Insufficient disk space")
&& error.contains("Your recording is still paused")
{
"Not enough disk space to resume. Free up space and try again, or press Stop to save."
.to_owned()
} else {
error
})
}
Loading
Loading