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
14 changes: 11 additions & 3 deletions rustortion-plugin/src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ struct PluginAppFlags {

struct PluginApp {
shared: SharedApp<PluginBackend>,
params: Arc<RustortionParams>,
}

impl iced_baseview::Application for PluginApp {
Expand Down Expand Up @@ -201,7 +202,10 @@ impl iced_baseview::Application for PluginApp {
stages: Vec::new(),
collapsed_stages: Vec::new(),
dirty_params: HashMap::new(),
active_tab: Tab::Amp,
active_tab: params
.active_tab
.lock()
.map_or_else(|_| Tab::default(), |t| *t),
selected_stage_type: StageType::ALL.first().copied().unwrap_or(StageType::Preamp),
ir_cabinet_control: ir_cabinet,
pitch_shift_control: PitchShiftControl::new(params.pitch_shift.value()),
Expand All @@ -227,18 +231,22 @@ impl iced_baseview::Application for PluginApp {
|stages| iced_baseview::Task::done(Message::SetStages(stages)),
);

(Self { shared }, init_task)
(Self { shared, params }, init_task)
}

fn update(&mut self, message: Self::Message) -> iced_baseview::Task<Self::Message> {
match self.shared.update(message) {
let task = match self.shared.update(message) {
UpdateResult::Handled(task) => task,
UpdateResult::Unhandled(_msg) => {
// Standalone-only messages (Settings, Midi, Tuner, Recording)
// are silently dropped in plugin mode.
iced_baseview::Task::none()
}
};
if let Ok(mut tab) = self.params.active_tab.lock() {
*tab = self.shared.active_tab;
}
task
}

fn view(
Expand Down
6 changes: 6 additions & 0 deletions rustortion-plugin/src/params.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use nih_plug::prelude::*;
use rustortion_core::preset::InputFilterConfig;
use rustortion_core::preset::stage_config::StageConfig;
use rustortion_ui::tabs::Tab;
use std::sync::Arc;
use std::sync::Mutex;
use std::sync::atomic::AtomicU32;
Expand Down Expand Up @@ -56,6 +57,10 @@ pub struct RustortionParams {
/// modifications (add/remove/reorder stages) survive save/restore.
#[persist = "chain_state"]
pub chain_state: Arc<Mutex<Option<Vec<StageConfig>>>>,

/// Editor tab, so reopening the editor (or the project) lands where it closed.
#[persist = "active_tab"]
pub active_tab: Arc<Mutex<Tab>>,
}

impl RustortionParams {
Expand Down Expand Up @@ -145,6 +150,7 @@ impl Default for RustortionParams {
oversampling_factor: Arc::new(AtomicU32::new(1)), // 1 = 1x (no oversampling)
ir_name: Arc::new(Mutex::new(None)),
chain_state: Arc::new(Mutex::new(None)),
active_tab: Arc::new(Mutex::new(Tab::default())),
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions rustortion-standalone/src/gui/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use rustortion_ui::messages::{
HotkeyMessage, Message, MidiMessage, NamTabMessage, PresetMessage, TunerMessage,
};
use rustortion_ui::stages::StageType;
use rustortion_ui::tabs::Tab;

const TUNER_POLL_INTERVAL: Duration = Duration::from_millis(20);
const MIDI_POLL_INTERVAL: Duration = Duration::from_millis(10);
Expand Down Expand Up @@ -142,7 +141,7 @@ impl AmplifierApp {
stages: preset.stages,
collapsed_stages,
dirty_params: HashMap::new(),
active_tab: Tab::default(),
active_tab: settings.active_tab,
selected_stage_type: StageType::default(),
ir_cabinet_control,
pitch_shift_control,
Expand Down Expand Up @@ -274,6 +273,11 @@ impl AmplifierApp {
self.save_settings();
}

if self.shared.active_tab != self.settings.active_tab {
self.settings.active_tab = self.shared.active_tab;
self.save_settings();
}

// Persist oversampling changes from the shared IO tab
if self.shared.oversampling_factor != self.settings.audio.oversampling_factor {
self.settings.audio.oversampling_factor = self.shared.oversampling_factor;
Expand Down
5 changes: 5 additions & 0 deletions rustortion-standalone/src/settings/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use std::path::PathBuf;
use crate::i18n::Language;
use crate::midi::MidiMapping;
use rustortion_ui::hotkey::HotkeySettings;
use rustortion_ui::tabs::Tab;

impl std::fmt::Display for AudioSettings {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand Down Expand Up @@ -93,6 +94,9 @@ pub struct Settings {
pub hotkeys: HotkeySettings,
#[serde(default)]
pub collapsed_stages: HashMap<String, Vec<bool>>,
/// Tab the window was last on, reopened on next launch.
#[serde(default)]
pub active_tab: Tab,
}

impl std::fmt::Display for Settings {
Expand Down Expand Up @@ -138,6 +142,7 @@ impl Default for Settings {
language: Language::default(),
hotkeys: HotkeySettings::default(),
collapsed_stages: HashMap::new(),
active_tab: Tab::default(),
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion rustortion-ui/src/tabs.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use serde::{Deserialize, Serialize};

use crate::stages::{StageCategory, StageConfig};

#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Default, Serialize, Deserialize)]
pub enum Tab {
#[default]
Amp,
Expand Down
Loading