fixing linux stuff
This commit is contained in:
@@ -110,7 +110,6 @@ impl App {
|
||||
show_scope: self.audio.config.show_scope,
|
||||
show_spectrum: self.audio.config.show_spectrum,
|
||||
show_completion: self.ui.show_completion,
|
||||
flash_brightness: self.ui.flash_brightness,
|
||||
color_scheme: self.ui.color_scheme,
|
||||
layout: self.audio.config.layout,
|
||||
hue_rotation: self.ui.hue_rotation,
|
||||
@@ -1384,10 +1383,6 @@ impl App {
|
||||
.editor
|
||||
.set_completion_enabled(self.ui.show_completion);
|
||||
}
|
||||
AppCommand::AdjustFlashBrightness(delta) => {
|
||||
self.ui.flash_brightness = (self.ui.flash_brightness + delta).clamp(0.0, 1.0);
|
||||
}
|
||||
|
||||
// Live keys
|
||||
AppCommand::ToggleLiveKeysFill => {
|
||||
self.live_keys.flip_fill();
|
||||
|
||||
@@ -187,7 +187,6 @@ impl CagireDesktop {
|
||||
app.audio.config.show_scope = settings.display.show_scope;
|
||||
app.audio.config.show_spectrum = settings.display.show_spectrum;
|
||||
app.ui.show_completion = settings.display.show_completion;
|
||||
app.ui.flash_brightness = settings.display.flash_brightness;
|
||||
|
||||
let metrics = Arc::new(EngineMetrics::default());
|
||||
let scope_buffer = Arc::new(ScopeBuffer::new());
|
||||
@@ -419,17 +418,6 @@ impl eframe::App for CagireDesktop {
|
||||
self.app.metrics.event_count = seq_snapshot.event_count;
|
||||
self.app.metrics.dropped_events = seq_snapshot.dropped_events;
|
||||
|
||||
self.app.ui.event_flash = (self.app.ui.event_flash - 0.1).max(0.0);
|
||||
let new_events = self
|
||||
.app
|
||||
.metrics
|
||||
.event_count
|
||||
.saturating_sub(self.app.ui.last_event_count);
|
||||
if new_events > 0 {
|
||||
self.app.ui.event_flash = (new_events as f32 * 0.4).min(1.0);
|
||||
}
|
||||
self.app.ui.last_event_count = self.app.metrics.event_count;
|
||||
|
||||
self.app.flush_queued_changes(&sequencer.cmd_tx);
|
||||
self.app.flush_dirty_patterns(&sequencer.cmd_tx);
|
||||
|
||||
|
||||
@@ -169,7 +169,6 @@ pub enum AppCommand {
|
||||
SetHueRotation(f32),
|
||||
ToggleRuntimeHighlight,
|
||||
ToggleCompletion,
|
||||
AdjustFlashBrightness(f32),
|
||||
|
||||
// Live keys
|
||||
ToggleLiveKeysFill,
|
||||
|
||||
@@ -7,7 +7,9 @@ use std::sync::atomic::{AtomicI64, AtomicU64};
|
||||
use std::sync::Arc;
|
||||
use std::thread::{self, JoinHandle};
|
||||
use std::time::Duration;
|
||||
use thread_priority::{set_current_thread_priority, ThreadPriority};
|
||||
use thread_priority::ThreadPriority;
|
||||
#[cfg(not(unix))]
|
||||
use thread_priority::set_current_thread_priority;
|
||||
|
||||
use super::LinkState;
|
||||
use crate::model::{
|
||||
@@ -1286,7 +1288,25 @@ fn sequencer_loop(
|
||||
) {
|
||||
use std::sync::atomic::Ordering;
|
||||
|
||||
let _ = set_current_thread_priority(ThreadPriority::Max);
|
||||
#[cfg(unix)]
|
||||
{
|
||||
use thread_priority::unix::{
|
||||
set_thread_priority_and_policy, thread_native_id, RealtimeThreadSchedulePolicy,
|
||||
ThreadSchedulePolicy,
|
||||
};
|
||||
|
||||
let policy = ThreadSchedulePolicy::Realtime(RealtimeThreadSchedulePolicy::Fifo);
|
||||
if let Err(e) =
|
||||
set_thread_priority_and_policy(thread_native_id(), ThreadPriority::Max, policy)
|
||||
{
|
||||
eprintln!("Warning: Could not set SCHED_FIFO: {e:?}");
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(not(unix))]
|
||||
{
|
||||
let _ = set_current_thread_priority(ThreadPriority::Max);
|
||||
}
|
||||
|
||||
let mut seq_state = SequencerState::new(variables, dict, rng, cc_access);
|
||||
|
||||
|
||||
@@ -1443,10 +1443,6 @@ fn handle_options_page(ctx: &mut InputContext, key: KeyEvent) -> InputResult {
|
||||
OptionsFocus::ShowCompletion => {
|
||||
ctx.dispatch(AppCommand::ToggleCompletion);
|
||||
}
|
||||
OptionsFocus::FlashBrightness => {
|
||||
let delta = if key.code == KeyCode::Left { -0.1 } else { 0.1 };
|
||||
ctx.dispatch(AppCommand::AdjustFlashBrightness(delta));
|
||||
}
|
||||
OptionsFocus::LinkEnabled => ctx.link.set_enabled(!ctx.link.is_enabled()),
|
||||
OptionsFocus::StartStopSync => ctx
|
||||
.link
|
||||
|
||||
11
src/main.rs
11
src/main.rs
@@ -98,7 +98,6 @@ fn main() -> io::Result<()> {
|
||||
app.audio.config.show_scope = settings.display.show_scope;
|
||||
app.audio.config.show_spectrum = settings.display.show_spectrum;
|
||||
app.ui.show_completion = settings.display.show_completion;
|
||||
app.ui.flash_brightness = settings.display.flash_brightness;
|
||||
app.ui.color_scheme = settings.display.color_scheme;
|
||||
app.ui.hue_rotation = settings.display.hue_rotation;
|
||||
app.audio.config.layout = settings.display.layout;
|
||||
@@ -327,16 +326,6 @@ fn main() -> io::Result<()> {
|
||||
app.metrics.event_count = seq_snapshot.event_count;
|
||||
app.metrics.dropped_events = seq_snapshot.dropped_events;
|
||||
|
||||
app.ui.event_flash = (app.ui.event_flash - 0.1).max(0.0);
|
||||
let new_events = app
|
||||
.metrics
|
||||
.event_count
|
||||
.saturating_sub(app.ui.last_event_count);
|
||||
if new_events > 0 {
|
||||
app.ui.event_flash = (new_events as f32 * 0.4).min(1.0);
|
||||
}
|
||||
app.ui.last_event_count = app.metrics.event_count;
|
||||
|
||||
app.flush_queued_changes(&sequencer.cmd_tx);
|
||||
app.flush_dirty_patterns(&sequencer.cmd_tx);
|
||||
|
||||
|
||||
@@ -44,8 +44,6 @@ pub struct DisplaySettings {
|
||||
pub show_spectrum: bool,
|
||||
#[serde(default = "default_true")]
|
||||
pub show_completion: bool,
|
||||
#[serde(default = "default_flash_brightness")]
|
||||
pub flash_brightness: f32,
|
||||
#[serde(default = "default_font")]
|
||||
pub font: String,
|
||||
#[serde(default)]
|
||||
@@ -60,8 +58,6 @@ fn default_font() -> String {
|
||||
"8x13".to_string()
|
||||
}
|
||||
|
||||
fn default_flash_brightness() -> f32 { 1.0 }
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
pub struct LinkSettings {
|
||||
pub enabled: bool,
|
||||
@@ -92,7 +88,6 @@ impl Default for DisplaySettings {
|
||||
show_scope: true,
|
||||
show_spectrum: true,
|
||||
show_completion: true,
|
||||
flash_brightness: 1.0,
|
||||
font: default_font(),
|
||||
color_scheme: ColorScheme::default(),
|
||||
layout: MainLayout::default(),
|
||||
|
||||
@@ -10,7 +10,6 @@ pub enum OptionsFocus {
|
||||
ShowScope,
|
||||
ShowSpectrum,
|
||||
ShowCompletion,
|
||||
FlashBrightness,
|
||||
LinkEnabled,
|
||||
StartStopSync,
|
||||
Quantum,
|
||||
@@ -33,7 +32,6 @@ impl CyclicEnum for OptionsFocus {
|
||||
Self::ShowScope,
|
||||
Self::ShowSpectrum,
|
||||
Self::ShowCompletion,
|
||||
Self::FlashBrightness,
|
||||
Self::LinkEnabled,
|
||||
Self::StartStopSync,
|
||||
Self::Quantum,
|
||||
|
||||
@@ -46,9 +46,6 @@ pub struct UiState {
|
||||
pub runtime_highlight: bool,
|
||||
pub show_completion: bool,
|
||||
pub minimap_until: Option<Instant>,
|
||||
pub last_event_count: usize,
|
||||
pub event_flash: f32,
|
||||
pub flash_brightness: f32,
|
||||
pub color_scheme: ColorScheme,
|
||||
pub hue_rotation: f32,
|
||||
}
|
||||
@@ -75,9 +72,6 @@ impl Default for UiState {
|
||||
runtime_highlight: false,
|
||||
show_completion: true,
|
||||
minimap_until: None,
|
||||
last_event_count: 0,
|
||||
event_flash: 0.0,
|
||||
flash_brightness: 1.0,
|
||||
color_scheme: ColorScheme::default(),
|
||||
hue_rotation: 0.0,
|
||||
}
|
||||
|
||||
@@ -63,7 +63,6 @@ pub fn render(frame: &mut Frame, app: &App, link: &LinkState, area: Rect) {
|
||||
Span::styled(peer_text, Style::new().fg(theme.ui.text_muted)),
|
||||
]);
|
||||
|
||||
let flash_str = format!("{:.0}%", app.ui.flash_brightness * 100.0);
|
||||
let quantum_str = format!("{:.0}", link.quantum());
|
||||
let tempo_str = format!("{:.1} BPM", link.tempo());
|
||||
let beat_str = format!("{:.2}", link.beat());
|
||||
@@ -161,7 +160,6 @@ pub fn render(frame: &mut Frame, app: &App, link: &LinkState, area: Rect) {
|
||||
focus == OptionsFocus::ShowCompletion,
|
||||
&theme,
|
||||
),
|
||||
render_option_line("Flash brightness", &flash_str, focus == OptionsFocus::FlashBrightness, &theme),
|
||||
Line::from(""),
|
||||
link_header,
|
||||
render_divider(content_width, &theme),
|
||||
@@ -215,18 +213,17 @@ pub fn render(frame: &mut Frame, app: &App, link: &LinkState, area: Rect) {
|
||||
OptionsFocus::ShowScope => 6,
|
||||
OptionsFocus::ShowSpectrum => 7,
|
||||
OptionsFocus::ShowCompletion => 8,
|
||||
OptionsFocus::FlashBrightness => 9,
|
||||
OptionsFocus::LinkEnabled => 13,
|
||||
OptionsFocus::StartStopSync => 14,
|
||||
OptionsFocus::Quantum => 15,
|
||||
OptionsFocus::MidiOutput0 => 26,
|
||||
OptionsFocus::MidiOutput1 => 27,
|
||||
OptionsFocus::MidiOutput2 => 28,
|
||||
OptionsFocus::MidiOutput3 => 29,
|
||||
OptionsFocus::MidiInput0 => 33,
|
||||
OptionsFocus::MidiInput1 => 34,
|
||||
OptionsFocus::MidiInput2 => 35,
|
||||
OptionsFocus::MidiInput3 => 36,
|
||||
OptionsFocus::LinkEnabled => 12,
|
||||
OptionsFocus::StartStopSync => 13,
|
||||
OptionsFocus::Quantum => 14,
|
||||
OptionsFocus::MidiOutput0 => 25,
|
||||
OptionsFocus::MidiOutput1 => 26,
|
||||
OptionsFocus::MidiOutput2 => 27,
|
||||
OptionsFocus::MidiOutput3 => 28,
|
||||
OptionsFocus::MidiInput0 => 32,
|
||||
OptionsFocus::MidiInput1 => 33,
|
||||
OptionsFocus::MidiInput2 => 34,
|
||||
OptionsFocus::MidiInput3 => 35,
|
||||
};
|
||||
|
||||
let scroll_offset = if total_lines <= max_visible {
|
||||
|
||||
@@ -7,7 +7,7 @@ use std::time::Instant;
|
||||
use rand::rngs::StdRng;
|
||||
use rand::SeedableRng;
|
||||
use ratatui::layout::{Alignment, Constraint, Layout, Rect};
|
||||
use ratatui::style::{Color, Modifier, Style};
|
||||
use ratatui::style::{Modifier, Style};
|
||||
use ratatui::text::{Line, Span};
|
||||
use ratatui::widgets::{Block, Borders, Cell, Clear, Paragraph, Row, Table};
|
||||
use ratatui::Frame;
|
||||
@@ -150,17 +150,7 @@ pub fn render(frame: &mut Frame, app: &App, link: &LinkState, snapshot: &Sequenc
|
||||
let term = frame.area();
|
||||
|
||||
let theme = theme::get();
|
||||
let bg_color = if app.ui.event_flash > 0.0 {
|
||||
let t = (app.ui.event_flash * app.ui.flash_brightness).min(1.0);
|
||||
let (base_r, base_g, base_b) = theme.ui.bg_rgb;
|
||||
let (tgt_r, tgt_g, tgt_b) = theme.flash.event_rgb;
|
||||
let r = base_r + ((tgt_r as f32 - base_r as f32) * t) as u8;
|
||||
let g = base_g + ((tgt_g as f32 - base_g as f32) * t) as u8;
|
||||
let b = base_b + ((tgt_b as f32 - base_b as f32) * t) as u8;
|
||||
Color::Rgb(r, g, b)
|
||||
} else {
|
||||
theme.ui.bg
|
||||
};
|
||||
let bg_color = theme.ui.bg;
|
||||
|
||||
let blank = " ".repeat(term.width as usize);
|
||||
let lines: Vec<Line> = (0..term.height).map(|_| Line::raw(&blank)).collect();
|
||||
|
||||
Reference in New Issue
Block a user