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,112 @@
|
||||
using Titano.Core.Advice;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Core.Project;
|
||||
using Titano.Ui.Visuals;
|
||||
|
||||
namespace Titano.App.Editor;
|
||||
|
||||
/// <summary>
|
||||
/// Exposure (BRIEF §12.3): deflicker, regions, holy-grail transitions and white balance; the chart shows the measured
|
||||
/// luminance (Sun) against the target curve the corrections produce (Accent), the sky region (dashed) and the exposure
|
||||
/// steps as received.
|
||||
/// </summary>
|
||||
public sealed class ExposureTab : EditorTab
|
||||
{
|
||||
private IReadOnlyList<ChartSeries> _series = [];
|
||||
private IReadOnlyList<ChartLegendItem> _legend = [];
|
||||
private IReadOnlyList<TimelineMarker> _markers = [];
|
||||
private string? _summary;
|
||||
|
||||
public ExposureTab(EditorViewModel editor)
|
||||
: base(editor, "Exposure", AdvisorSection.Exposure)
|
||||
{
|
||||
var s = editor.Session;
|
||||
string? NoDeflicker(ProjectSettings p) => EditorSettings.Deflicker.Effective(p, s.Content.Deep) ? null : Loc.L("Tooltips.Editor.NotApplicable.DeflickerOff");
|
||||
string? NoHolyGrail(ProjectSettings p) => EditorSettings.HolyGrail.Effective(p, s.Content.Deep) ? null : Loc.L("Tooltips.Editor.NotApplicable.HolyGrailOff");
|
||||
Rows =
|
||||
[
|
||||
new AutoSwitchRow(s, EditorSettings.Deflicker, "Editor.Exposure.Deflicker", "Tooltips.Editor.Exposure.Deflicker"),
|
||||
new AutoNumberRow<int>(s, EditorSettings.DeflickerWindow, "Editor.Exposure.Window", "Tooltips.Editor.Exposure.Window", 5, 151, 2, "0", NoDeflicker),
|
||||
new AutoNumberRow<double>(s, EditorSettings.DeflickerStrength, "Editor.Exposure.Strength", "Tooltips.Editor.Exposure.Strength", 0, 1, 0.05, "0.00", NoDeflicker),
|
||||
new AutoChoiceRow<RegionMode>(s, EditorSettings.Regions, "Editor.Exposure.Regions", "Tooltips.Editor.Exposure.Regions",
|
||||
[
|
||||
new Choice(RegionMode.Off, "Editor.Value.Off"), new Choice(RegionMode.Auto, "Editor.Regions.Auto"),
|
||||
new Choice(RegionMode.Horizon, "Editor.Regions.Horizon"), new Choice(RegionMode.Luminance, "Editor.Regions.Luminance"),
|
||||
], NoDeflicker),
|
||||
new AutoSwitchRow(s, EditorSettings.HolyGrail, "Editor.Exposure.HolyGrail", "Tooltips.Editor.Exposure.HolyGrail"),
|
||||
new AutoNumberRow<int>(s, EditorSettings.TransitionLength, "Editor.Exposure.Transitions", "Tooltips.Editor.Exposure.Transitions", 0, 120, 1, "0", NoHolyGrail),
|
||||
new AutoSwitchRow(s, EditorSettings.WhiteBalance, "Editor.Exposure.WhiteBalance", "Tooltips.Editor.Exposure.WhiteBalance"),
|
||||
new InfoRow("Editor.Exposure.Temperature", "Tooltips.Editor.Exposure.Temperature", Temperature),
|
||||
new NumberRow(s, "Editor.Exposure.Offset", "Tooltips.Editor.Exposure.Offset", -3, 3, 0.1, p => p.Exposure.ExposureOffsetEv,
|
||||
(p, v) => p with { Exposure = p.Exposure with { ExposureOffsetEv = v } }, v => Loc.L("Editor.Value.Ev", v.ToString("+0.0;−0.0;0.0", Loc.Culture))),
|
||||
];
|
||||
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); }
|
||||
|
||||
public IReadOnlyList<TimelineMarker> Markers { get => _markers; private set => Set(ref _markers, value); }
|
||||
|
||||
/// <summary>"flicker −67 % · max step 0.21 EV".</summary>
|
||||
public string? Summary { get => _summary; private set => Set(ref _summary, value); }
|
||||
|
||||
public Func<double, string> YFormatter { get; } = v => v.ToString("0.0", Loc.Culture);
|
||||
|
||||
public override void OnContentChanged()
|
||||
{
|
||||
base.OnContentChanged();
|
||||
BuildChart();
|
||||
}
|
||||
|
||||
public override void OnCorrectionsChanged() => BuildChart();
|
||||
|
||||
private (string?, string?) Temperature()
|
||||
{
|
||||
if (Editor.Session.Content.Deep is not { } deep) return (null, Loc.L("Tooltips.Editor.NotApplicable.NeedsAnalysis"));
|
||||
if (deep.WhiteBalance is { KelvinLow: { } low, KelvinHigh: { } high })
|
||||
return (Loc.L("Editor.Value.Kelvin", double.Round(low, -1).ToString("N0", Loc.Culture), double.Round(high, -1).ToString("N0", Loc.Culture)), null);
|
||||
return (null, Loc.L("Tooltips.Editor.NotApplicable.Kelvin"));
|
||||
}
|
||||
|
||||
private void BuildChart()
|
||||
{
|
||||
var content = Editor.Session.Content;
|
||||
var n = content.Count;
|
||||
var corrections = Editor.Corrections is { } c && c.FrameCount == n ? c : null;
|
||||
double[] measured = corrections?.MeasuredLogLuminance is { } m && m.Any(double.IsFinite)
|
||||
? m
|
||||
: content.Deep is { } deep ? [.. deep.Frames.LogLuminance.Select(v => v ?? double.NaN)] : [.. content.Frames.Select(f => f.MeanLogLuminance ?? double.NaN)];
|
||||
var series = new List<ChartSeries> { new(Loc.L("Editor.Chart.Measured"), measured, "Brush.Sun") };
|
||||
var legend = new List<ChartLegendItem> { new(Loc.L("Editor.Chart.Measured"), "Brush.Sun") };
|
||||
if (corrections is not null && measured.Any(double.IsFinite))
|
||||
{
|
||||
series.Add(new ChartSeries(Loc.L("Editor.Chart.Target"), corrections.TargetLogLuminance(), "Brush.Accent") { Thickness = 2 });
|
||||
legend.Add(new ChartLegendItem(Loc.L("Editor.Chart.Target"), "Brush.Accent"));
|
||||
}
|
||||
if (content.Deep is { Regions: not null } withSky && withSky.Frames.SkyLogLuminance.Any(v => v is not null))
|
||||
{
|
||||
series.Add(new ChartSeries(Loc.L("Editor.Chart.Sky"), withSky.Frames.SkyLogLuminance.Select(v => v ?? double.NaN).ToArray(), "Brush.Region")
|
||||
{ Dash = LineDash.Dashed });
|
||||
legend.Add(new ChartLegendItem(Loc.L("Editor.Chart.Sky"), "Brush.Region", LegendSwatch.DashedLine));
|
||||
}
|
||||
var markers = EditorViewModel.StepMarkers(content);
|
||||
if (markers.Count > 0) legend.Add(new ChartLegendItem(Loc.L("Editor.Chart.Steps"), "Brush.Sun", LegendSwatch.Triangle));
|
||||
Series = series;
|
||||
Legend = legend;
|
||||
Markers = markers;
|
||||
Summary = SummaryOf(corrections);
|
||||
}
|
||||
|
||||
private static string? SummaryOf(Core.Render.RenderCorrections? corrections)
|
||||
{
|
||||
if (corrections is null) return null;
|
||||
var parts = new List<string>();
|
||||
if (corrections.Report.Deflicker is { FlickerBefore: > 0 } d)
|
||||
parts.Add(Loc.L("Editor.Exposure.FlickerChange", double.Round((d.FlickerAfter / d.FlickerBefore - 1) * 100).ToString("+0;−0;0", Loc.Culture)));
|
||||
if (corrections.Report.MaxTargetStepEv is { } step) parts.Add(Loc.L("Editor.Exposure.MaxStep", step.ToString("0.00", Loc.Culture)));
|
||||
return parts.Count == 0 ? null : string.Join(" · ", parts);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user