cleaning
This commit is contained in:
@@ -156,7 +156,7 @@ fn render_devices(frame: &mut Frame, app: &App, area: Rect) {
|
||||
let input_focused = section_focused && app.audio.device_kind == DeviceKind::Input;
|
||||
|
||||
render_device_column(
|
||||
frame, app, output_col,
|
||||
frame, output_col,
|
||||
"Output", &app.audio.output_devices,
|
||||
app.audio.current_output_device_index(),
|
||||
app.audio.output_list.cursor,
|
||||
@@ -172,7 +172,7 @@ fn render_devices(frame: &mut Frame, app: &App, area: Rect) {
|
||||
frame.render_widget(Paragraph::new(sep_lines), separator);
|
||||
|
||||
render_device_column(
|
||||
frame, app, input_col,
|
||||
frame, input_col,
|
||||
"Input", &app.audio.input_devices,
|
||||
app.audio.current_input_device_index(),
|
||||
app.audio.input_list.cursor,
|
||||
@@ -184,7 +184,6 @@ fn render_devices(frame: &mut Frame, app: &App, area: Rect) {
|
||||
|
||||
fn render_device_column(
|
||||
frame: &mut Frame,
|
||||
_app: &App,
|
||||
area: Rect,
|
||||
label: &str,
|
||||
devices: &[doux::audio::AudioDeviceInfo],
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::app::App;
|
||||
use crate::engine::SequencerSnapshot;
|
||||
use crate::widgets::{Orientation, Scope, Spectrum, VuMeter};
|
||||
|
||||
pub fn render(frame: &mut Frame, app: &mut App, snapshot: &SequencerSnapshot, area: Rect) {
|
||||
pub fn render(frame: &mut Frame, app: &App, snapshot: &SequencerSnapshot, area: Rect) {
|
||||
let [left_area, _spacer, vu_area] = Layout::horizontal([
|
||||
Constraint::Fill(1),
|
||||
Constraint::Length(2),
|
||||
|
||||
@@ -28,14 +28,14 @@ fn adjust_spans_for_line(spans: &[SourceSpan], line_start: usize, line_len: usiz
|
||||
}).collect()
|
||||
}
|
||||
|
||||
pub fn render(frame: &mut Frame, app: &mut App, link: &LinkState, snapshot: &SequencerSnapshot) {
|
||||
pub fn render(frame: &mut Frame, app: &App, link: &LinkState, snapshot: &SequencerSnapshot) {
|
||||
let term = frame.area();
|
||||
let blank = " ".repeat(term.width as usize);
|
||||
let lines: Vec<Line> = (0..term.height).map(|_| Line::raw(&blank)).collect();
|
||||
frame.render_widget(Paragraph::new(lines), term);
|
||||
|
||||
if app.ui.show_title {
|
||||
title_view::render(frame, term, &mut app.ui);
|
||||
title_view::render(frame, term, &app.ui);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
use rand::Rng;
|
||||
use ratatui::layout::{Alignment, Constraint, Layout, Rect};
|
||||
use ratatui::style::{Color, Style, Stylize};
|
||||
use ratatui::text::{Line, Span};
|
||||
@@ -6,56 +5,11 @@ use ratatui::widgets::Paragraph;
|
||||
use ratatui::Frame;
|
||||
use tui_big_text::{BigText, PixelSize};
|
||||
|
||||
use crate::state::ui::{Sparkle, UiState};
|
||||
use crate::state::ui::UiState;
|
||||
|
||||
const SPARKLE_CHARS: &[char] = &['·', '✦', '✧', '°', '•', '+', '⋆', '*'];
|
||||
const SPARKLE_COLORS: &[(u8, u8, u8)] = &[
|
||||
(200, 220, 255),
|
||||
(255, 200, 150),
|
||||
(150, 255, 200),
|
||||
(255, 150, 200),
|
||||
(200, 150, 255),
|
||||
];
|
||||
pub fn render(frame: &mut Frame, area: Rect, ui: &UiState) {
|
||||
frame.render_widget(&ui.sparkles, area);
|
||||
|
||||
pub fn render(frame: &mut Frame, area: Rect, ui: &mut UiState) {
|
||||
let mut rng = rand::thread_rng();
|
||||
|
||||
// Spawn new sparkles
|
||||
for _ in 0..3 {
|
||||
if rng.gen_bool(0.6) {
|
||||
let x = rng.gen_range(0..area.width);
|
||||
let y = rng.gen_range(0..area.height);
|
||||
ui.sparkles.push(Sparkle {
|
||||
x,
|
||||
y,
|
||||
char_idx: rng.gen_range(0..SPARKLE_CHARS.len()),
|
||||
life: rng.gen_range(15..40),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Age and remove dead sparkles
|
||||
ui.sparkles.iter_mut().for_each(|s| s.life = s.life.saturating_sub(1));
|
||||
ui.sparkles.retain(|s| s.life > 0);
|
||||
|
||||
// Render sparkles
|
||||
for sparkle in &ui.sparkles {
|
||||
let color = SPARKLE_COLORS[sparkle.char_idx % SPARKLE_COLORS.len()];
|
||||
let intensity = (sparkle.life as f32 / 30.0).min(1.0);
|
||||
let r = (color.0 as f32 * intensity) as u8;
|
||||
let g = (color.1 as f32 * intensity) as u8;
|
||||
let b = (color.2 as f32 * intensity) as u8;
|
||||
|
||||
let ch = SPARKLE_CHARS[sparkle.char_idx];
|
||||
let span = Span::styled(ch.to_string(), Style::new().fg(Color::Rgb(r, g, b)));
|
||||
let para = Paragraph::new(Line::from(span));
|
||||
let sparkle_area = Rect::new(sparkle.x, sparkle.y, 1, 1);
|
||||
if sparkle_area.x < area.width && sparkle_area.y < area.height {
|
||||
frame.render_widget(para, sparkle_area);
|
||||
}
|
||||
}
|
||||
|
||||
// Main content
|
||||
let author_style = Style::new().fg(Color::Rgb(180, 140, 200));
|
||||
let link_style = Style::new().fg(Color::Rgb(120, 200, 180));
|
||||
let license_style = Style::new().fg(Color::Rgb(200, 160, 100));
|
||||
|
||||
Reference in New Issue
Block a user