Files
Chronos/src/Chronos.App/Editor/MotionTab.cs
T
Alby96andClaude Opus 5.5 f2b58522b9
CI / Build and test (push) Successful in 8m14s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 13m19s
CI / PostgreSQL 16 integration (push) Successful in 4m49s
CI / PostgreSQL 17 integration (push) Successful in 5m28s
CI / Docker image (push) Successful in 53s
Release / Server image (push) Failing after 10s
refactor!: rename Titano to Chronos and move CI and releases to Gitea (#6)
The owner renamed the product and moved the repository to the self-hosted
Gitea (https://gitea.encke-hake.ts.net/BalboSoft/Chronos) for more control,
and asked for Actions and a first automatic release with the server package
and the Windows exe (docs/requests/2026-10-23-chronos-gitea.md).

- Chronos everywhere: a byte-exact rename of contents and paths, then a
  per-language review of the forms the old name's ending had dictated.
- Gitea instead of GitHub: the update check, licence, issue and support
  links read ChronosReleasesUrl; the update check takes the highest stable
  version, offers a pre-release build its final release and reports a
  repository it cannot see as a failed check. EULA, security policy and
  Gitea issue forms live at the repository root.
- Gitea Actions for the Linux act_runner (.gitea/workflows): CI, release,
  nightly image and performance gates in the .NET SDK container with git
  checkout and the system SQLite. The release cross-compiles the Windows
  programs, checks their icon, version and DPI manifest, packs installers
  and zips, publishes the Gitea release and pushes the server image
  (REGISTRY_TOKEN). Windows-only tests run in an opt-in job on a Windows
  runner (WINDOWS_RUNNER).
- New Chronos.Tools commands: zip, gitea-release, postgres-ci (replaces the
  docker-exec script, which Gitea's service containers do not allow; the
  throw-away server runs without durability) and pe-check.
- Timed tests take their budget from TestTiming (CHRONOS_TEST_TIME_FACTOR,
  3 on the shared runner; the weekly performance gates keep theirs).

BREAKING CHANGE: programs, settings, data folders, file types, environment
variables and the Docker image use the new name; nothing is migrated from
Titano, which never had a release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
2026-10-23 12:45:18 +02:00

159 lines
7.3 KiB
C#

using Chronos.Core.Advice;
using Chronos.Core.Localization;
using Chronos.Core.Project;
using Chronos.Ui.Visuals;
namespace Chronos.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;
// The same rule as the Edit path's (EditorSettings.Applies): a row shown n/a is never asked for.
string? NoBlur(ProjectSettings p) => EditorSettings.Applies(EditorSettings.ShutterAngle, p, s.Content.Deep) ? null : Loc.L("Tooltips.Editor.NotApplicable.BlurOff");
string? NoFlow(ProjectSettings p) => EditorSettings.Applies(EditorSettings.FlowQuality, p, s.Content.Deep) ? null : Loc.L("Tooltips.Editor.NotApplicable.NoFlow");
string? NoStabilize(ProjectSettings p) =>
EditorSettings.Applies(EditorSettings.StabilizeSmoothing, p, s.Content.Deep) ? 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(Loc.Separator, 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");
}
}