From ab353edc0b0620ff1ce4d3fd6c2de7ae9548d132 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Forment?= Date: Sat, 21 Feb 2026 13:23:43 +0100 Subject: [PATCH] Feat: make some stuff optional for the CLAP/VST version --- Cargo.toml | 4 ++-- plugins/cagire-plugins/Cargo.toml | 2 +- plugins/cagire-plugins/src/editor.rs | 20 ++++++++++++++++++-- src/app/mod.rs | 3 +++ src/bin/desktop/main.rs | 4 +--- src/{bin/desktop => }/block_renderer.rs | 0 src/lib.rs | 3 +++ src/state/options.rs | 1 + src/views/options_view.rs | 24 +++++++++++++----------- 9 files changed, 42 insertions(+), 19 deletions(-) rename src/{bin/desktop => }/block_renderer.rs (100%) diff --git a/Cargo.toml b/Cargo.toml index 057fe37..0480d71 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,13 +35,13 @@ required-features = ["desktop"] [features] default = [] +block-renderer = ["dep:soft_ratatui", "dep:rustc-hash"] desktop = [ + "block-renderer", "cagire-forth/desktop", "dep:egui", "dep:eframe", "dep:egui_ratatui", - "dep:soft_ratatui", - "dep:rustc-hash", "dep:image", ] diff --git a/plugins/cagire-plugins/Cargo.toml b/plugins/cagire-plugins/Cargo.toml index fd1649c..90276ee 100644 --- a/plugins/cagire-plugins/Cargo.toml +++ b/plugins/cagire-plugins/Cargo.toml @@ -10,7 +10,7 @@ description = "Cagire as a CLAP/VST3 audio plugin" crate-type = ["cdylib", "lib"] [dependencies] -cagire = { path = "../.." } +cagire = { path = "../..", features = ["block-renderer"] } cagire-forth = { path = "../../crates/forth" } cagire-project = { path = "../../crates/project" } cagire-ratatui = { path = "../../crates/ratatui" } diff --git a/plugins/cagire-plugins/src/editor.rs b/plugins/cagire-plugins/src/editor.rs index 831c4d1..708f79a 100644 --- a/plugins/cagire-plugins/src/editor.rs +++ b/plugins/cagire-plugins/src/editor.rs @@ -17,6 +17,7 @@ use soft_ratatui::embedded_graphics_unicodefonts::{ }; use soft_ratatui::{EmbeddedGraphics, SoftBackend}; +use cagire::block_renderer::BlockCharBackend; use cagire::app::App; use cagire::engine::{AudioCommand, LinkState, SequencerSnapshot}; use cagire::input::{handle_key, handle_mouse, InputContext}; @@ -28,7 +29,7 @@ use crate::input_egui::{convert_egui_events, convert_egui_mouse}; use crate::params::CagireParams; use crate::PluginBridge; -type TerminalType = Terminal>; +type TerminalType = Terminal>; #[derive(Clone, Copy, PartialEq)] enum FontChoice { @@ -106,7 +107,22 @@ fn create_terminal(font: FontChoice) -> TerminalType { FontChoice::Size10x20 => (mono_10x20_atlas(), None, None), }; - let soft = SoftBackend::::new(80, 24, regular, bold, italic); + let eg = SoftBackend::::new(80, 24, regular, bold, italic); + let soft = SoftBackend { + buffer: eg.buffer, + cursor: eg.cursor, + cursor_pos: eg.cursor_pos, + char_width: eg.char_width, + char_height: eg.char_height, + blink_counter: eg.blink_counter, + blinking_fast: eg.blinking_fast, + blinking_slow: eg.blinking_slow, + rgb_pixmap: eg.rgb_pixmap, + always_redraw_list: eg.always_redraw_list, + raster_backend: BlockCharBackend { + inner: eg.raster_backend, + }, + }; Terminal::new(RataguiBackend::new("cagire", soft)).expect("terminal") } diff --git a/src/app/mod.rs b/src/app/mod.rs index 4b7d9c8..6e190a6 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -200,6 +200,9 @@ impl App { } pub fn maybe_show_onboarding(&mut self) { + if self.plugin_mode { + return; + } if self.ui.modal != Modal::None { return; } diff --git a/src/bin/desktop/main.rs b/src/bin/desktop/main.rs index 2bcff71..df0c035 100644 --- a/src/bin/desktop/main.rs +++ b/src/bin/desktop/main.rs @@ -1,10 +1,8 @@ -mod block_renderer; - use std::sync::atomic::{AtomicBool, AtomicI64, AtomicU32, AtomicU64, Ordering}; use std::sync::Arc; use std::time::Duration; -use block_renderer::BlockCharBackend; +use cagire::block_renderer::BlockCharBackend; use clap::Parser; use doux::EngineMetrics; use eframe::NativeOptions; diff --git a/src/bin/desktop/block_renderer.rs b/src/block_renderer.rs similarity index 100% rename from src/bin/desktop/block_renderer.rs rename to src/block_renderer.rs diff --git a/src/lib.rs b/src/lib.rs index a620a3a..a4a1f55 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -15,5 +15,8 @@ pub mod theme; pub mod views; pub mod widgets; +#[cfg(feature = "block-renderer")] +pub mod block_renderer; + #[cfg(feature = "desktop")] pub mod input_egui; diff --git a/src/state/options.rs b/src/state/options.rs index 43e3142..d876f00 100644 --- a/src/state/options.rs +++ b/src/state/options.rs @@ -74,6 +74,7 @@ const STANDALONE_ONLY: &[OptionsFocus] = &[ OptionsFocus::MidiInput1, OptionsFocus::MidiInput2, OptionsFocus::MidiInput3, + OptionsFocus::ResetOnboarding, ]; /// Section layout: header line, divider line, then option lines. diff --git a/src/views/options_view.rs b/src/views/options_view.rs index 0db8af4..9479da7 100644 --- a/src/views/options_view.rs +++ b/src/views/options_view.rs @@ -232,17 +232,19 @@ pub fn render(frame: &mut Frame, app: &App, link: &LinkState, area: Rect) { render_option_line("Input 3", &midi_in_3, focus == OptionsFocus::MidiInput3, &theme), ]); } - lines.push(Line::from("")); - lines.extend([ - render_section_header("ONBOARDING", &theme), - render_divider(content_width, &theme), - render_option_line( - "Reset guides", - &onboarding_str, - focus == OptionsFocus::ResetOnboarding, - &theme, - ), - ]); + if !app.plugin_mode { + lines.push(Line::from("")); + lines.extend([ + render_section_header("ONBOARDING", &theme), + render_divider(content_width, &theme), + render_option_line( + "Reset guides", + &onboarding_str, + focus == OptionsFocus::ResetOnboarding, + &theme, + ), + ]); + } let total_lines = lines.len(); let max_visible = padded.height as usize;