fix: edit separator names in a modal
Render separator add and rename input in a centered dialog with explicit save and cancel guidance, while retaining revisioned configuration edits. Tests: cargo fmt --all -- --check; cargo check --workspace --all-targets --all-features; cargo test --workspace --all-targets --all-features; cargo test --workspace --doc --all-features; cargo clippy --workspace --all-targets --all-features -- -D warnings; cargo build --workspace --release --all-features; cargo check --workspace; cargo check --workspace --no-default-features; cargo check -p midi --no-default-features --features midir; cargo check -p volume_lib --no-default-features --features pulse
This commit is contained in:
parent
a6d9dc558f
commit
16e724b7c8
|
|
@ -54,7 +54,8 @@ volume and mute. Learning opens a waiting popup and captures the next supported
|
|||
fader movement or button press from the selected controller. The editor also
|
||||
provides per-fader Size (`Slim`, `Standard`, or `Thick`) and visibility. Slim
|
||||
faders occupy one terminal row; Standard remains the compatible default. The
|
||||
Config tab is a settings/status page: change the session theme, switch the
|
||||
separator name is entered in a centered popup for both add and rename actions.
|
||||
The Config tab is a settings/status page: change the session theme, switch the
|
||||
persisted mixer layout between Vertical and Horizontal, restore individual
|
||||
hidden faders, inspect backend and MIDI-device state, and apply or save the
|
||||
server-owned draft. Horizontal mode packs fader cards side by side and keeps
|
||||
|
|
|
|||
|
|
@ -415,8 +415,9 @@ default for compatibility. `horizontal` packs fader cards into display-width
|
|||
rows while separators remain full-width boundaries.
|
||||
|
||||
The selected main-list entry can be moved directly, and separators can be
|
||||
added, renamed, moved, or removed. Editing a fader presents domain fields
|
||||
rather than a serialized command:
|
||||
added, renamed, moved, or removed. Adding or renaming a separator uses a
|
||||
centered naming dialog, keeping transient text entry out of the mixer status
|
||||
line. Editing a fader presents domain fields rather than a serialized command:
|
||||
|
||||
- **Capture:** application selector field, exact/regex mode, and pattern; group
|
||||
faders instead present member faders and the currently available group mode.
|
||||
|
|
|
|||
2
task.md
2
task.md
|
|
@ -368,6 +368,8 @@ Dependencies: M8, M2, M1.
|
|||
declaration-order synthesis for existing files. The mixer renders that
|
||||
layout and provides direct move, separator add/rename/remove, hide, and
|
||||
hidden-fader restore actions through revisioned comment-preserving drafts.
|
||||
Separator add and rename collect their label in a centered modal rather than
|
||||
reusing the mixer status line.
|
||||
Hidden restoration now lives in the Config settings page rather than a
|
||||
second mixer mode. Config also persists a Vertical or Horizontal mixer
|
||||
orientation; horizontal mode packs faders side by side while separators span
|
||||
|
|
|
|||
108
tui/src/lib.rs
108
tui/src/lib.rs
|
|
@ -1916,22 +1916,16 @@ impl<C: MixerClient> Widget for &LiveTui<C> {
|
|||
)
|
||||
.render(header, buf);
|
||||
|
||||
let status_error = self.editor.is_none()
|
||||
&& (self.client_error.is_some()
|
||||
|| self
|
||||
.snapshot
|
||||
.devices
|
||||
.iter()
|
||||
.any(|device| device.error.is_some() || device.status == "error"));
|
||||
let status = self.editor.as_ref().map_or_else(
|
||||
|| {
|
||||
self.client_error.clone().unwrap_or_else(|| {
|
||||
device_summary(&self.snapshot.devices)
|
||||
.unwrap_or_else(|| "confirmed server state".to_owned())
|
||||
})
|
||||
},
|
||||
|editor| format!("separator name: {}", editor.value),
|
||||
);
|
||||
let status_error = self.client_error.is_some()
|
||||
|| self
|
||||
.snapshot
|
||||
.devices
|
||||
.iter()
|
||||
.any(|device| device.error.is_some() || device.status == "error");
|
||||
let status = self.client_error.clone().unwrap_or_else(|| {
|
||||
device_summary(&self.snapshot.devices)
|
||||
.unwrap_or_else(|| "confirmed server state".to_owned())
|
||||
});
|
||||
let mixer = Block::bordered()
|
||||
.title(
|
||||
match self.tab {
|
||||
|
|
@ -2002,6 +1996,9 @@ impl<C: MixerClient> Widget for &LiveTui<C> {
|
|||
)
|
||||
.render(footer, buf);
|
||||
|
||||
if self.editor.is_some() {
|
||||
self.render_separator_editor(area, buf);
|
||||
}
|
||||
if self.fader_editor.is_some() {
|
||||
self.render_fader_editor(area, buf);
|
||||
}
|
||||
|
|
@ -2148,6 +2145,48 @@ fn selector_field_index(field: &str) -> usize {
|
|||
}
|
||||
|
||||
impl<C: MixerClient> LiveTui<C> {
|
||||
fn render_separator_editor(&self, area: Rect, buf: &mut Buffer) {
|
||||
let Some(editor) = &self.editor else {
|
||||
return;
|
||||
};
|
||||
let theme = self.theme.palette();
|
||||
let popup = centered_rect(area, 56, 7);
|
||||
let title = if editor.target.is_some() {
|
||||
" Rename separator "
|
||||
} else {
|
||||
" Add separator "
|
||||
};
|
||||
let validation = self
|
||||
.client_error
|
||||
.as_deref()
|
||||
.filter(|error| *error == "separator name must not be empty");
|
||||
let guidance = validation.unwrap_or("Choose a short, recognizable section name.");
|
||||
let guidance_style = if validation.is_some() {
|
||||
Style::default().fg(theme.error).bold()
|
||||
} else {
|
||||
Style::default().fg(theme.muted)
|
||||
};
|
||||
|
||||
Clear.render(popup, buf);
|
||||
Paragraph::new(Text::from(vec![
|
||||
Line::from(""),
|
||||
Line::from(format!("Name {}▏", editor.value))
|
||||
.fg(theme.foreground)
|
||||
.bold(),
|
||||
Line::from(guidance).style(guidance_style),
|
||||
]))
|
||||
.alignment(Alignment::Center)
|
||||
.block(
|
||||
Block::bordered()
|
||||
.title(title.fg(theme.accent).bold())
|
||||
.title_bottom(" Enter save · Esc cancel ".fg(theme.muted))
|
||||
.border_set(border::DOUBLE)
|
||||
.border_style(Style::default().fg(theme.accent))
|
||||
.style(Style::default().bg(theme.background)),
|
||||
)
|
||||
.render(popup, buf);
|
||||
}
|
||||
|
||||
fn render_fader_editor(&self, area: Rect, buf: &mut Buffer) {
|
||||
let Some(editor) = &self.fader_editor else {
|
||||
return;
|
||||
|
|
@ -3068,6 +3107,43 @@ mod tests {
|
|||
assert!(app.exit);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn separator_name_is_edited_in_a_centered_popup() {
|
||||
let mut app = LiveTui::new(DemoClient::default()).unwrap();
|
||||
app.handle_key_event(press(KeyCode::Char('a')));
|
||||
for character in "Music".chars() {
|
||||
app.handle_key_event(press(KeyCode::Char(character)));
|
||||
}
|
||||
|
||||
let area = Rect::new(0, 0, 80, 20);
|
||||
let mut buffer = Buffer::empty(area);
|
||||
(&app).render(area, &mut buffer);
|
||||
let rows = buffer
|
||||
.content
|
||||
.chunks(usize::from(area.width))
|
||||
.map(|row| row.iter().map(|cell| cell.symbol()).collect::<String>())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert!(rows[6..14].iter().any(|row| row.contains("Add separator")));
|
||||
assert!(rows[6..14].iter().any(|row| row.contains("Name Music")));
|
||||
assert!(rows[6..14].iter().any(|row| row.contains("Enter save")));
|
||||
assert!(!rows.iter().any(|row| row.contains("separator name:")));
|
||||
|
||||
app.editor = Some(EditorInput {
|
||||
value: "Players".to_owned(),
|
||||
target: Some("players".to_owned()),
|
||||
});
|
||||
let mut rename_buffer = Buffer::empty(area);
|
||||
(&app).render(area, &mut rename_buffer);
|
||||
let renamed = rename_buffer
|
||||
.content
|
||||
.iter()
|
||||
.map(|cell| cell.symbol())
|
||||
.collect::<String>();
|
||||
assert!(renamed.contains("Rename separator"));
|
||||
assert!(renamed.contains("Name Players"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn terminal_restore_runs_when_client_initialization_fails() {
|
||||
struct FailingClient;
|
||||
|
|
|
|||
Loading…
Reference in New Issue