feat(app): editor view models for every section, preset cards and render actions
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
15 files changed
+2666
-6
No files matched your search
@@ -0,0 +1,159 @@
|
||||
using Titano.Core.Advice;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Core.Project;
|
||||
using Titano.Ui.Visuals;
|
||||
|
||||
namespace Titano.App.Editor;
|
||||
|
||||
/// <summary>Motion (BRIEF §12.3): motion blur, flow quality and stabilisation, with the measured camera path (shake) chart.</summary>
|
||||
public sealed class MotionTab : EditorTab
|
||||
{
|
||||
private IReadOnlyList<ChartSeries> _series = [];
|
||||
private IReadOnlyList<ChartLegendItem> _legend = [];
|
||||
private string? _summary;
|
||||
|
||||
public MotionTab(EditorViewModel editor)
|
||||
: base(editor, "Motion", AdvisorSection.Motion)
|
||||
{
|
||||
var s = editor.Session;
|
||||
string? NoBlur(ProjectSettings p) => EditorSettings.MotionBlur.Effective(p, null) ? null : Loc.L("Tooltips.Editor.NotApplicable.BlurOff");
|
||||
string? NoFlow(ProjectSettings p) =>
|
||||
EditorSettings.MotionBlur.Effective(p, null) || EditorSettings.TimingMode.Effective(p, null) == TimingMode.Interpolated
|
||||
? null
|
||||
: Loc.L("Tooltips.Editor.NotApplicable.NoFlow");
|
||||
string? NoStabilize(ProjectSettings p) => EditorSettings.Stabilize.Effective(p, null) ? null : Loc.L("Tooltips.Editor.NotApplicable.StabilizeOff");
|
||||
Rows =
|
||||
[
|
||||
new AutoSwitchRow(s, EditorSettings.MotionBlur, "Editor.Motion.Blur", "Tooltips.Editor.Motion.Blur"),
|
||||
new AutoNumberRow<double>(s, EditorSettings.ShutterAngle, "Editor.Motion.Shutter", "Tooltips.Editor.Motion.Shutter", 0, 360, 15, "0", NoBlur),
|
||||
new AutoChoiceRow<FlowQualitySetting>(s, EditorSettings.FlowQuality, "Editor.Motion.Flow", "Tooltips.Editor.Motion.Flow",
|
||||
[
|
||||
new Choice(FlowQualitySetting.Draft, "Editor.Flow.Draft"), new Choice(FlowQualitySetting.Balanced, "Editor.Flow.Balanced"),
|
||||
new Choice(FlowQualitySetting.Best, "Editor.Flow.Best"),
|
||||
], NoFlow),
|
||||
new AutoSwitchRow(s, EditorSettings.Stabilize, "Editor.Motion.Stabilize", "Tooltips.Editor.Motion.Stabilize"),
|
||||
new AutoNumberRow<double>(s, EditorSettings.StabilizeSmoothing, "Editor.Motion.Smoothing", "Tooltips.Editor.Motion.Smoothing", 2, 60, 1, "0", NoStabilize),
|
||||
];
|
||||
Refresh();
|
||||
BuildChart();
|
||||
}
|
||||
|
||||
public IReadOnlyList<ChartSeries> Series { get => _series; private set => Set(ref _series, value); }
|
||||
|
||||
public IReadOnlyList<ChartLegendItem> Legend { get => _legend; private set => Set(ref _legend, value); }
|
||||
|
||||
/// <summary>"shake 0.42 px · crop 1.8 %".</summary>
|
||||
public string? Summary { get => _summary; private set => Set(ref _summary, value); }
|
||||
|
||||
public Func<double, string> YFormatter { get; } = v => Loc.L("Editor.Value.Pixels", v.ToString("0.#", Loc.Culture));
|
||||
|
||||
public override void OnContentChanged()
|
||||
{
|
||||
base.OnContentChanged();
|
||||
BuildChart();
|
||||
}
|
||||
|
||||
/// <summary>The camera path: per-frame content shifts accumulated from the first frame (gaps hold the last position).</summary>
|
||||
private void BuildChart()
|
||||
{
|
||||
if (Editor.Session.Content.Deep is not { } deep)
|
||||
{
|
||||
Series = [];
|
||||
Legend = [];
|
||||
Summary = Loc.L("Editor.Chart.NotAnalysed");
|
||||
return;
|
||||
}
|
||||
var x = Accumulate(deep.Frames.ShiftX);
|
||||
var y = Accumulate(deep.Frames.ShiftY);
|
||||
Series =
|
||||
[
|
||||
new ChartSeries(Loc.L("Editor.Chart.PathX"), x, "Brush.Accent"),
|
||||
new ChartSeries(Loc.L("Editor.Chart.PathY"), y, "Brush.TextMuted") { Dash = LineDash.Dashed },
|
||||
];
|
||||
Legend = [new ChartLegendItem(Loc.L("Editor.Chart.PathX"), "Brush.Accent"), new ChartLegendItem(Loc.L("Editor.Chart.PathY"), "Brush.TextMuted", LegendSwatch.DashedLine)];
|
||||
var shake = deep.Shake;
|
||||
var parts = new List<string>
|
||||
{
|
||||
Loc.L("Editor.Motion.ShakeValue", shake.RmsPx.ToString("0.00", Loc.Culture)),
|
||||
Loc.L("Editor.Motion.CropValue", (shake.CropCost * 100).ToString("0.0", Loc.Culture)),
|
||||
};
|
||||
if (shake.PanDetected) parts.Add(Loc.L("Editor.Motion.PanValue", shake.PanPxPerFrame.ToString("0.0", Loc.Culture)));
|
||||
Summary = string.Join(" · ", parts);
|
||||
}
|
||||
|
||||
private static double[] Accumulate(double?[] shifts)
|
||||
{
|
||||
var path = new double[shifts.Length];
|
||||
double position = 0;
|
||||
for (var i = 0; i < shifts.Length; i++)
|
||||
{
|
||||
position += shifts[i] ?? 0;
|
||||
path[i] = position;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Stack (BRIEF §12.3): median, mean or star-trail stacking; the chart shows the star field and cloud measurements.</summary>
|
||||
public sealed class StackTab : EditorTab
|
||||
{
|
||||
private IReadOnlyList<ChartSeries> _series = [];
|
||||
private IReadOnlyList<ChartLegendItem> _legend = [];
|
||||
private string? _summary;
|
||||
|
||||
public StackTab(EditorViewModel editor)
|
||||
: base(editor, "Stack", AdvisorSection.Stack)
|
||||
{
|
||||
var s = editor.Session;
|
||||
Rows =
|
||||
[
|
||||
new ChoiceRow(s, "Editor.Stack.Mode", "Tooltips.Editor.Stack.Mode",
|
||||
[
|
||||
new Choice(StackSetting.None, "Editor.Value.Off"), new Choice(StackSetting.Median, "Editor.Stack.Median"),
|
||||
new Choice(StackSetting.Mean, "Editor.Stack.Mean"), new Choice(StackSetting.StarTrails, "Editor.Stack.StarTrails"),
|
||||
],
|
||||
p => p.Stack.Mode, (p, v) => p with { Stack = p.Stack with { Mode = (StackSetting)v } }),
|
||||
new NumberRow(s, "Editor.Stack.Length", "Tooltips.Editor.Stack.Length", 3, 199, 2, p => p.Stack.Length,
|
||||
(p, v) => p with { Stack = p.Stack with { Length = (int)v } }, v => Loc.Plural("Editor.Value.Frames", (long)v),
|
||||
p => p.Stack.Mode == StackSetting.None ? Loc.L("Tooltips.Editor.NotApplicable.StackOff") : null),
|
||||
];
|
||||
Refresh();
|
||||
BuildChart();
|
||||
}
|
||||
|
||||
/// <summary>The advisor never stacks on its own (a temporal median erases moving stars).</summary>
|
||||
public override bool CanOptimise => false;
|
||||
|
||||
public IReadOnlyList<ChartSeries> Series { get => _series; private set => Set(ref _series, value); }
|
||||
|
||||
public IReadOnlyList<ChartLegendItem> Legend { get => _legend; private set => Set(ref _legend, value); }
|
||||
|
||||
public string? Summary { get => _summary; private set => Set(ref _summary, value); }
|
||||
|
||||
public Func<double, string> YFormatter { get; } = v => v.ToString("0.#", Loc.Culture);
|
||||
|
||||
public override void OnContentChanged()
|
||||
{
|
||||
base.OnContentChanged();
|
||||
BuildChart();
|
||||
}
|
||||
|
||||
private void BuildChart()
|
||||
{
|
||||
if (Editor.Session.Content.Deep is not { } deep)
|
||||
{
|
||||
Series = [];
|
||||
Legend = [];
|
||||
Summary = Loc.L("Editor.Chart.NotAnalysed");
|
||||
return;
|
||||
}
|
||||
Series =
|
||||
[
|
||||
new ChartSeries(Loc.L("Editor.Chart.Stars"), deep.Frames.StarDensity.Select(v => v ?? double.NaN).ToArray(), "Brush.Accent"),
|
||||
new ChartSeries(Loc.L("Editor.Chart.Clouds"), deep.Frames.CloudCoverage.Select(v => v is { } c ? c * 100 : double.NaN).ToArray(), "Brush.TextMuted")
|
||||
{ Dash = LineDash.Dashed },
|
||||
];
|
||||
Legend = [new ChartLegendItem(Loc.L("Editor.Chart.Stars"), "Brush.Accent"), new ChartLegendItem(Loc.L("Editor.Chart.Clouds"), "Brush.TextMuted", LegendSwatch.DashedLine)];
|
||||
Summary = Loc.L(deep.Sky.StarField ? "Editor.Stack.StarField" : "Editor.Stack.NoStarField");
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user