using System.Windows.Input; using Titano.Core.Advice; using Titano.Core.Localization; using Titano.Ui.Mvvm; namespace Titano.App.Editor; /// /// One section of the editor (BRIEF §12.3): a tab with its measuring tool below the filmstrip and its settings column on /// the right, with "Optimise section" and "Reset". runs after every project change. /// public abstract class EditorTab : LocalizedViewModel { protected EditorTab(EditorViewModel editor, string key, AdvisorSection section) { Editor = editor; Key = key; Section = section; OptimiseCommand = new RelayCommand(() => Editor.Optimise(Section), () => CanOptimise && !Editor.IsBusy); ResetCommand = new RelayCommand(() => Editor.Session.ResetSection(Section), () => CanReset && !Editor.IsBusy); } public EditorViewModel Editor { get; } /// "Frames", "Exposure"… (resource key suffix). public string Key { get; } public AdvisorSection Section { get; } public string Header => Loc.L("Editor.Tab." + Key); public string ToolTip => Loc.L("Tooltips.Editor.Tab." + Key); /// Settings rows of the right column (empty for tabs with their own panel). public IReadOnlyList Rows { get; protected init; } = []; /// The advisor has heavier decisions for this section (stacking has none). public virtual bool CanOptimise => true; public virtual bool CanReset => true; /// What Optimise section does, or why it cannot run now. public string OptimiseToolTip => Loc.L(!CanOptimise ? "Tooltips.Editor.OptimiseNone" : Editor.IsBusy ? "Tooltips.Editor.Busy" : "Tooltips.Editor.OptimiseSection"); public string ResetToolTip => Loc.L(Editor.IsBusy ? "Tooltips.Editor.Busy" : "Tooltips.Editor.ResetSection"); public ICommand OptimiseCommand { get; } public ICommand ResetCommand { get; } /// Re-reads the project (any change). public virtual void Refresh() { foreach (var row in Rows) row.Refresh(); } /// The sequence was read again: new analyses (charts, findings). public virtual void OnContentChanged() => Refresh(); /// The preview's corrections were prepared for the current settings (target curves). public virtual void OnCorrectionsChanged() { } /// The export plan of the project changed (durations, sizes). public virtual void OnPlanChanged() { } /// The frame on screen changed (playheads, the frame table, keyframe commands). public virtual void OnCurrentFrameChanged() { } /// A job of this sequence started or ended: commands and their tooltips follow. public virtual void OnBusyChanged() { OnPropertyChanged(nameof(OptimiseToolTip)); OnPropertyChanged(nameof(ResetToolTip)); } /// Raises the enabled state of the tab's asynchronous commands (the others follow the command manager). public virtual void RefreshCommands() { } /// Whether this sequence can send its renders to the server changed (). public virtual void OnSyncGateChanged() { } public override void Dispose() { foreach (var row in Rows) row.Dispose(); base.Dispose(); } }