Add comprehensive tests for EditSection functionality in the Windows application
- Implement tests for picker behavior, including loading sequences, searching, and handling empty libraries. - Validate sequence opening via Enter key and double-click actions. - Ensure proper handling of unsaved edits and sequence deletion scenarios. - Verify accessibility features for picker rows across different languages. - Introduce a dialog counting mechanism to manage unsaved edit confirmations.
This commit is contained in:
1 parent
4ea44bb917
commit
5aeb6aa787
214 files changed
+6547
-826
No files matched your search
@@ -36,13 +36,18 @@ public static class SequenceDeletion
|
||||
|
||||
/// <summary>
|
||||
/// The editor of a sequence about to move stores its last edit (so the trash keeps it) and closes; false when that
|
||||
/// edit could not be stored and the user kept it.
|
||||
/// edit could not be stored and the user kept it. A sequence Edit was asked for that goes is no longer asked for, so
|
||||
/// coming back to Edit shows the picker rather than a failed open.
|
||||
/// </summary>
|
||||
internal static async Task<bool> CloseEditorAsync(ShellViewModel shell, DeletePlan plan)
|
||||
{
|
||||
if (shell.Sequence.Editor is null || shell.CurrentSequenceId is not { } open || plan.Steps.All(s => s.Sequence.Id != open)) return true;
|
||||
if (!await shell.Sequence.ConfirmCloseAsync()) return false;
|
||||
await shell.Sequence.CloseAsync();
|
||||
bool Goes(Guid? id) => id is { } sequence && plan.Steps.Any(s => s.Sequence.Id == sequence);
|
||||
if (Goes(shell.Sequence.OpenSequenceId))
|
||||
{
|
||||
if (!await shell.Sequence.ConfirmCloseAsync()) return false;
|
||||
await shell.Sequence.CloseAsync();
|
||||
}
|
||||
if (Goes(shell.CurrentSequenceId)) shell.KeepSequence(shell.Sequence.OpenSequenceId);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,155 @@
|
||||
using Titano.Core.Analysis;
|
||||
using Titano.Core.Analysis.Deep;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Ui.Controls;
|
||||
|
||||
namespace Titano.App.Editor;
|
||||
|
||||
/// <summary>A finding of the analyses on the Analysis step: what it says, the frame it starts at and the step that deals with it.</summary>
|
||||
public sealed class AnalysisFinding
|
||||
{
|
||||
private readonly EditorViewModel _editor;
|
||||
|
||||
internal AnalysisFinding(EditorViewModel editor, FindingItem item, string? stepKey)
|
||||
{
|
||||
_editor = editor;
|
||||
Kind = item.Kind;
|
||||
Text = item.Text;
|
||||
Frame = item.Frame;
|
||||
StepKey = stepKey;
|
||||
}
|
||||
|
||||
public StatusKind Kind { get; }
|
||||
|
||||
public string Text { get; }
|
||||
|
||||
/// <summary>The first frame it concerns; null for a finding about the whole sequence.</summary>
|
||||
public int? Frame { get; }
|
||||
|
||||
/// <summary>The <see cref="EditPath"/> step that deals with it; null when no step does.</summary>
|
||||
public string? StepKey { get; }
|
||||
|
||||
/// <summary>The step that deals with it (looked up when shown: the steps exist once the editor does).</summary>
|
||||
public EditorTab? Step => StepKey is null ? null : _editor.Tabs.FirstOrDefault(t => t.Key == StepKey);
|
||||
|
||||
/// <summary>"Open Exposure, the step that deals with this · Alt+3".</summary>
|
||||
public string? GoToToolTip => Step is { } step ? Loc.L("Tooltips.Editor.Analysis.GoTo", step.Header, step.Number) : null;
|
||||
|
||||
/// <summary>The sentence (what UI Automation reads for a row the list has not realised).</summary>
|
||||
public override string ToString() => Text;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The first step of the Edit path (owner review 1, R7): every finding of the analyses with the step that deals with it,
|
||||
/// what the deep analysis measured (light, flicker, exposure steps received, shake, flagged frames) and where each later
|
||||
/// step stands. Analyse runs from here as from the header.
|
||||
/// </summary>
|
||||
public sealed class AnalysisTab : EditorTab
|
||||
{
|
||||
private IReadOnlyList<AnalysisFinding> _findings = [];
|
||||
private AnalysisFinding? _selected;
|
||||
|
||||
public AnalysisTab(EditorViewModel editor)
|
||||
: base(editor, EditPath.Analysis, null)
|
||||
{
|
||||
Rows =
|
||||
[
|
||||
new InfoRow("Editor.Analysis.Light", "Tooltips.Editor.Analysis.Light", () => Measured(d => LightText(d.Sky.Light))),
|
||||
// The finding's and the deflicker reason's measure (the deviation from the smooth course), rounded as they are.
|
||||
new InfoRow("Editor.Analysis.Flicker", "Tooltips.Editor.Analysis.Flicker",
|
||||
() => Measured(d => Loc.L("Editor.Value.Ev", double.Round(d.Flicker.AmplitudeEv, 3, MidpointRounding.AwayFromZero).ToString("0.###", Loc.Culture)))),
|
||||
new InfoRow("Editor.Analysis.Steps", "Tooltips.Editor.Analysis.Steps",
|
||||
() => Measured(d => Loc.L("Editor.Analysis.StepsValue", d.Exposure.ReceivedSteps, d.Exposure.MetadataSteps))),
|
||||
new InfoRow("Editor.Analysis.Shake", "Tooltips.Editor.Analysis.Shake", ShakeValue),
|
||||
new InfoRow("Editor.Analysis.Flagged", "Tooltips.Editor.Analysis.Flagged",
|
||||
() => Measured(d => Loc.Plural("Editor.Value.Frames", d.Issues.Excludable().Length))),
|
||||
];
|
||||
Load();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
/// <summary>The findings, the most severe first.</summary>
|
||||
public IReadOnlyList<AnalysisFinding> Findings
|
||||
{
|
||||
get => _findings;
|
||||
private set
|
||||
{
|
||||
if (Set(ref _findings, value)) OnPropertyChanged(nameof(HasFindings));
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasFindings => _findings.Count > 0;
|
||||
|
||||
/// <summary>The finding chosen in the list: the preview seeks its first frame.</summary>
|
||||
public AnalysisFinding? SelectedFinding
|
||||
{
|
||||
get => _selected;
|
||||
set
|
||||
{
|
||||
if (!Set(ref _selected, value) || value?.Frame is not { } frame) return;
|
||||
Editor.CurrentIndex = frame;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Instead of an empty list: the analysis running, not run yet, or nothing found.</summary>
|
||||
public string EmptyText => StateText.Length > 0 && Status == StepStatus.Running ? StateText
|
||||
: Editor.Session.Content.Deep is null ? Loc.L("Editor.Chart.NotAnalysed")
|
||||
: Loc.L("Editor.Frames.NoWarnings");
|
||||
|
||||
/// <summary>The glyph beside the step's state in its panel.</summary>
|
||||
public StatusKind StateKind => Status switch
|
||||
{
|
||||
StepStatus.Done => StatusKind.Analysed,
|
||||
StepStatus.Running => StatusKind.Analysing,
|
||||
StepStatus.Attention => StatusKind.Warning,
|
||||
_ => StatusKind.NotAnalysed,
|
||||
};
|
||||
|
||||
/// <summary>The path's other steps, each with where it stands.</summary>
|
||||
public IEnumerable<EditorTab> PathSteps => Editor.Tabs.Where(t => !ReferenceEquals(t, this));
|
||||
|
||||
public override bool PrefersTallMeasure => true;
|
||||
|
||||
public override void OnContentChanged()
|
||||
{
|
||||
Load();
|
||||
base.OnContentChanged();
|
||||
}
|
||||
|
||||
/// <summary>The step's state changed: the panel's glyph and the empty list's sentence follow.</summary>
|
||||
internal void OnStepChanged()
|
||||
{
|
||||
OnPropertyChanged(nameof(StateKind));
|
||||
OnPropertyChanged(nameof(EmptyText));
|
||||
}
|
||||
|
||||
private void Load()
|
||||
{
|
||||
Findings = [.. Editor.Session.Advice.Findings.OrderByDescending(f => f.Severity)
|
||||
.Select(f => new AnalysisFinding(Editor, FramesTab.ToItem(f), EditPath.StepOf(f.Key)))];
|
||||
_selected = null;
|
||||
OnPropertyChanged(nameof(SelectedFinding));
|
||||
OnPropertyChanged(nameof(EmptyText));
|
||||
}
|
||||
|
||||
/// <summary>The camera's wobble, or n/a when too few frame pairs could be measured (the Motion step asks for it then).</summary>
|
||||
private (string? Value, string? NotApplicableReason) ShakeValue()
|
||||
{
|
||||
if (Editor.Session.Content.Deep is { Shake: { MeasuredFraction: < ShakeSummary.MinMeasuredFraction } shake })
|
||||
return (null, Loc.L("Advisor.Missing.Shake", (100 * shake.MeasuredFraction).ToString("0", Loc.Culture)));
|
||||
return Measured(d => Loc.L("Editor.Value.Pixels", d.Shake.RmsPx.ToString("0.#", Loc.Culture)));
|
||||
}
|
||||
|
||||
/// <summary>A value of the deep analysis, or n/a saying it needs the analysis.</summary>
|
||||
private (string? Value, string? NotApplicableReason) Measured(Func<DeepAnalysisReport, string> value) =>
|
||||
Editor.Session.Content.Deep is { } deep ? (value(deep), null) : (null, Loc.L("Tooltips.Editor.NotApplicable.NeedsAnalysis"));
|
||||
|
||||
private static string LightText(DayNight light) => Loc.L(light switch
|
||||
{
|
||||
DayNight.Day => "Editor.Analysis.Light.Day",
|
||||
DayNight.Night => "Editor.Analysis.Light.Night",
|
||||
DayNight.DayToNight => "Editor.Analysis.Light.DayToNight",
|
||||
DayNight.NightToDay => "Editor.Analysis.Light.NightToDay",
|
||||
_ => "Editor.Analysis.Light.Unknown",
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using Titano.App.Jobs;
|
||||
using Titano.Core.Advice;
|
||||
using Titano.Core.Analysis;
|
||||
using Titano.Core.Analysis.Deep;
|
||||
using Titano.Core.Localization;
|
||||
using Titano.Core.Model;
|
||||
using Titano.Core.Project;
|
||||
|
||||
namespace Titano.App.Editor;
|
||||
|
||||
/// <summary>
|
||||
/// Where a step of the Edit path stands (owner review 1, R7). Each status has its own badge glyph, so colour never
|
||||
/// carries it alone. A status guides: it never keeps the user out of a step.
|
||||
/// </summary>
|
||||
public enum StepStatus
|
||||
{
|
||||
/// <summary>Not done yet: the step's number in a ring.</summary>
|
||||
Todo,
|
||||
|
||||
/// <summary>Nothing is missing: ✓.</summary>
|
||||
Done,
|
||||
|
||||
/// <summary>Something waits for the user: ▲.</summary>
|
||||
Attention,
|
||||
|
||||
/// <summary>The step's job runs, waits or is paused: ◐.</summary>
|
||||
Running,
|
||||
|
||||
/// <summary>The step needs the deep analysis first: ○.</summary>
|
||||
Waiting,
|
||||
}
|
||||
|
||||
/// <summary>A step's status, its text (three words at most) and, when there is more to say, a sentence for its tooltip.</summary>
|
||||
public sealed record StepState(StepStatus Status, string Text, string? Detail = null);
|
||||
|
||||
/// <summary>The step a sequence showed and the steps visited, which the Edit section keeps for the rest of the run.</summary>
|
||||
/// <param name="Analysis">The deep analysis the steps were seen with (<see cref="EditPath.AnalysisStamp"/>): another one since resets the visited marks.</param>
|
||||
public sealed record StepMemory(string Step, IReadOnlyCollection<string> Visited, string? Analysis = null);
|
||||
|
||||
/// <summary>What the statuses of the steps are worked out from.</summary>
|
||||
/// <param name="Analysis">The sequence's deep analysis that runs, else the paused one, else the queued one.</param>
|
||||
/// <param name="Render">The same for its renders.</param>
|
||||
/// <param name="RenderBlocked">Why the export cannot be rendered now, once its plan is known; null otherwise.</param>
|
||||
/// <param name="RenderMatches">A render was made from the current settings, or the newest says nothing about its settings.</param>
|
||||
public sealed record PathFacts(
|
||||
SequenceContent Content,
|
||||
AdvisorResult Advice,
|
||||
ProjectSettings Project,
|
||||
Job? Analysis,
|
||||
Job? Render,
|
||||
string? RenderBlocked,
|
||||
bool RenderMatches);
|
||||
|
||||
/// <summary>
|
||||
/// The Edit section's guided path (owner review 1, R7): each editor tab is one step, from the deep analysis to the
|
||||
/// export. This class says where each step stands, which step deals with each finding of the analyses, where the
|
||||
/// editor opens and whether the settings of a render are the current ones.
|
||||
/// </summary>
|
||||
public static class EditPath
|
||||
{
|
||||
public const string Analysis = "Analysis";
|
||||
public const string Frames = "Frames";
|
||||
public const string Exposure = "Exposure";
|
||||
public const string Motion = "Motion";
|
||||
public const string Camera = "Camera";
|
||||
public const string Time = "Time";
|
||||
public const string Stack = "Stack";
|
||||
public const string Export = "Export";
|
||||
|
||||
/// <summary>The step that deals with each finding of the light and the deep analysis.</summary>
|
||||
public static IReadOnlyDictionary<string, string> FindingSteps { get; } = new Dictionary<string, string>(StringComparer.Ordinal)
|
||||
{
|
||||
[FindingKeys.NoTimestamps] = Time,
|
||||
[FindingKeys.Gaps] = Time,
|
||||
[FindingKeys.Sessions] = Time,
|
||||
[FindingKeys.IrregularInterval] = Time,
|
||||
[FindingKeys.DuplicateTimestamps] = Time,
|
||||
[FindingKeys.NonMonotonicTimestamps] = Time,
|
||||
[FindingKeys.ClockJumps] = Time,
|
||||
[FindingKeys.TimeZoneEstimated] = Time,
|
||||
[FindingKeys.ExposureSteps] = Exposure,
|
||||
[FindingKeys.ExposureStep] = Exposure,
|
||||
[FindingKeys.MissingExposure] = Exposure,
|
||||
[FindingKeys.DayNightTransition] = Exposure,
|
||||
[DeepFindingKeys.Flicker] = Exposure,
|
||||
[DeepFindingKeys.WhiteBalanceJitter] = Exposure,
|
||||
[DeepFindingKeys.StepsNotReceived] = Exposure,
|
||||
[FindingKeys.CameraChanged] = Frames,
|
||||
[FindingKeys.LensChanged] = Frames,
|
||||
[DeepFindingKeys.UnreadableFrames] = Frames,
|
||||
[DeepFindingKeys.BlackFrames] = Frames,
|
||||
[DeepFindingKeys.WhiteFrames] = Frames,
|
||||
[DeepFindingKeys.DuplicateFrames] = Frames,
|
||||
[DeepFindingKeys.SceneChanges] = Frames,
|
||||
// Single frames of another size or orientation: Frames excludes them (no Camera setting acts on single frames).
|
||||
[FindingKeys.MixedResolution] = Frames,
|
||||
[FindingKeys.MixedOrientation] = Frames,
|
||||
[DeepFindingKeys.Shake] = Motion,
|
||||
[DeepFindingKeys.Panning] = Motion,
|
||||
[DeepFindingKeys.StarField] = Stack,
|
||||
[DeepFindingKeys.Clouds] = Stack,
|
||||
[FindingKeys.PreviewOnly] = Export,
|
||||
};
|
||||
|
||||
/// <summary>The step that deals with <paramref name="findingKey"/>; null for a finding no step names.</summary>
|
||||
public static string? StepOf(string findingKey) => FindingSteps.GetValueOrDefault(findingKey);
|
||||
|
||||
/// <summary>
|
||||
/// The step the editor opens on: the one last shown for this sequence in this run; else Analysis while the sequence
|
||||
/// has no current deep analysis or one waits, runs or is paused (<paramref name="analysis"/>, so the user sees it
|
||||
/// first); else Frames.
|
||||
/// </summary>
|
||||
public static string Start(string? remembered, SequenceContent content, Job? analysis = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(content);
|
||||
return remembered ?? (content.Deep is null || analysis is not null ? Analysis : Frames);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tells one deep analysis of the sequence from another (or from none), so that the step memory of a sequence closed
|
||||
/// while an analysis ran knows the steps changed meanwhile; null without a deep analysis.
|
||||
/// </summary>
|
||||
public static string? AnalysisStamp(SequenceContent content)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(content);
|
||||
return content.Deep is not { } d
|
||||
? null
|
||||
: string.Create(CultureInfo.InvariantCulture,
|
||||
$"{d.FrameCount}|{d.Findings.Count}|{d.Flicker.AmplitudeEv:R}|{d.Shake.RmsPx:R}|{d.Exposure.ReceivedSteps}|{d.Issues.Excludable().Length}|{d.HeroIndex}");
|
||||
}
|
||||
|
||||
/// <summary>Where <paramref name="step"/> stands.</summary>
|
||||
public static StepState Of(string step, PathFacts facts)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(facts);
|
||||
return step switch
|
||||
{
|
||||
Analysis => AnalysisState(facts),
|
||||
Frames => FramesState(facts),
|
||||
Exposure => SettingsState(facts, AdvisorSection.Exposure),
|
||||
Motion => SettingsState(facts, AdvisorSection.Motion),
|
||||
Camera => SettingsState(facts, AdvisorSection.Camera),
|
||||
Time => SettingsState(facts, AdvisorSection.Timing),
|
||||
Stack => StackState(facts.Project),
|
||||
Export => ExportState(facts),
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(step), step, null),
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The settings of <paramref name="project"/> that make its video, for comparing them with a render's: without the
|
||||
/// hero (the Library's picture), the frames still to place, the batch, the output folder, the output's name and the
|
||||
/// server copy, none of which changes the video.
|
||||
/// </summary>
|
||||
public static string Signature(ProjectSettings project)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(project);
|
||||
return (project with
|
||||
{
|
||||
HeroFrame = null,
|
||||
PendingFrames = null,
|
||||
Export = project.Export with { Batch = [], Folder = null, NameTemplate = string.Empty, SyncToServer = false },
|
||||
}).ToJson();
|
||||
}
|
||||
|
||||
private static StepState AnalysisState(PathFacts facts)
|
||||
{
|
||||
if (facts.Analysis is { } job) return new StepState(StepStatus.Running, JobLine(job));
|
||||
var content = facts.Content;
|
||||
if (content.Deep is null)
|
||||
{
|
||||
if ((content.Sequence.Status & SequenceStatus.AnalyzedDeep) == 0) return new StepState(StepStatus.Todo, Loc.L("Editor.Chart.NotAnalysed"));
|
||||
// Analysed, but the saved analysis describes frames the sequence no longer has, or cannot be read now (the
|
||||
// archive offline, the file moved or damaged, a server that sends none).
|
||||
return content.DeepOfOtherFrames
|
||||
? new StepState(StepStatus.Attention, Loc.L("Editor.Step.FramesChanged"), Loc.L("Tooltips.Editor.Step.FramesChanged"))
|
||||
: new StepState(StepStatus.Attention, Loc.L("Editor.Step.AnalysisUnavailable"), Loc.L("Tooltips.Editor.Step.AnalysisUnavailable"));
|
||||
}
|
||||
var warnings = facts.Advice.Findings.Count(f => f.Severity >= FindingSeverity.Warning);
|
||||
var text = warnings == 0
|
||||
? Loc.L("Editor.Step.Analysed")
|
||||
: string.Join(Loc.Separator, Loc.L("Editor.Step.Analysed"), Loc.Plural("Editor.Summary.Warnings", warnings));
|
||||
return new StepState(StepStatus.Done, text);
|
||||
}
|
||||
|
||||
private static StepState FramesState(PathFacts facts)
|
||||
{
|
||||
if (facts.Content.Deep is not { } deep) return Waiting();
|
||||
// Flagged frames the video still shows: neither excluded nor skipped by the render anyway.
|
||||
var flagged = deep.Issues.Excludable().Except(facts.Project.ExcludedFrames).Except(facts.Content.NotRenderable()).Count();
|
||||
return flagged > 0
|
||||
? new StepState(StepStatus.Attention, Loc.Plural("Editor.Step.Flagged", flagged), Loc.Plural("Tooltips.Editor.Step.Flagged", flagged))
|
||||
: new StepState(StepStatus.Done, Loc.L("Editor.Step.Excluded", facts.Project.ExcludedFrames.Count));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A settings step: waiting while an Auto setting of its section needs the deep analysis, needing attention while one
|
||||
/// lacks other data (no timestamps, no exposure data, an unknown source size), which taking the value over by hand
|
||||
/// settles; otherwise Auto, or Edited when a setting or a value of the section was set by hand.
|
||||
/// </summary>
|
||||
private static StepState SettingsState(PathFacts facts, AdvisorSection section)
|
||||
{
|
||||
var deep = facts.Content.Deep;
|
||||
var missing = facts.Advice.In(section).Where(r => r.IsMissingData && Counts(r, facts.Project, deep)).ToList();
|
||||
if (missing.Any(r => r.ReasonKey == AdvisorKeys.MissingDeep)) return Waiting();
|
||||
if (missing.FirstOrDefault() is { } reason) return new StepState(StepStatus.Attention, Loc.L("Editor.Step.MissingData"), Advisor.Explain(reason));
|
||||
var auto = EditorSettings.IsSectionAuto(facts.Project, section) && !HasHandValues(facts.Project, section);
|
||||
return new StepState(StepStatus.Done, Loc.L(auto ? "Common.Auto" : "Editor.Step.Edited"));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Advice without a value asks something of the user only for an Auto setting that applies now: a setting shown n/a
|
||||
/// (its switch is off) cannot be taken over by hand, and once a deep analysis exists, a value it could not measure
|
||||
/// (no usable region mask) stays at the engine's fallback rather than waiting for an analysis that has run.
|
||||
/// </summary>
|
||||
private static bool Counts(Recommendation recommendation, ProjectSettings project, DeepAnalysisReport? deep)
|
||||
{
|
||||
if (recommendation.ReasonKey == AdvisorKeys.MissingDeep && deep is not null) return false;
|
||||
return EditorSettings.All.FirstOrDefault(s => s.Id == recommendation.Parameter) is not { } setting
|
||||
|| (setting.IsAuto(project) && EditorSettings.Applies(setting, project, deep));
|
||||
}
|
||||
|
||||
/// <summary>Values of the section set by hand that are not Auto settings: crop, offsets and camera moves; fit to a duration; the exposure offset.</summary>
|
||||
private static bool HasHandValues(ProjectSettings project, AdvisorSection section) => section switch
|
||||
{
|
||||
AdvisorSection.Camera => CropMargins.Of(project.Camera.Crop).Any(m => m > 0) || project.Camera.OffsetX != 0 || project.Camera.OffsetY != 0
|
||||
|| project.Camera.Keyframes.Count > 0,
|
||||
AdvisorSection.Timing => project.Timing.FitToSeconds is > 0,
|
||||
AdvisorSection.Exposure => project.Exposure.ExposureOffsetEv != 0,
|
||||
_ => false,
|
||||
};
|
||||
|
||||
private static StepState StackState(ProjectSettings project) => project.Stack.Mode switch
|
||||
{
|
||||
StackSetting.None => new StepState(StepStatus.Todo, Loc.L("Editor.Step.Optional")),
|
||||
StackSetting.Median => new StepState(StepStatus.Done, Loc.L("Editor.Stack.Median")),
|
||||
StackSetting.Mean => new StepState(StepStatus.Done, Loc.L("Editor.Stack.Mean")),
|
||||
_ => new StepState(StepStatus.Done, Loc.L("Editor.Stack.StarTrails")),
|
||||
};
|
||||
|
||||
private static StepState ExportState(PathFacts facts)
|
||||
{
|
||||
if (facts.Render is { } job) return new StepState(StepStatus.Running, JobLine(job));
|
||||
if (facts.RenderBlocked is { } reason) return new StepState(StepStatus.Attention, Loc.L("Editor.Step.Blocked"), reason);
|
||||
if (facts.Content.Renders.Count == 0) return new StepState(StepStatus.Todo, Loc.L("Editor.Step.NotRendered"));
|
||||
return facts.RenderMatches
|
||||
? new StepState(StepStatus.Done, Loc.L("Editor.Step.Rendered"))
|
||||
: new StepState(StepStatus.Attention, Loc.L("Editor.Step.Outdated"), Loc.L("Tooltips.Editor.Step.Outdated"));
|
||||
}
|
||||
|
||||
private static StepState Waiting() => new(StepStatus.Waiting, Loc.L("Editor.Step.Waiting"), Loc.L("Tooltips.Editor.NotApplicable.NeedsAnalysis"));
|
||||
|
||||
/// <summary>"Deep analysis · running".</summary>
|
||||
private static string JobLine(Job job) => string.Join(Loc.Separator, JobText.Kind(job.Kind), Loc.L("Jobs.State." + job.State));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The settings the sequence's renders were made from, read once when the sequence loads, so each change of the project
|
||||
/// only works out its own <see cref="EditPath.Signature"/>.
|
||||
/// </summary>
|
||||
public sealed class RenderedSettings
|
||||
{
|
||||
private readonly HashSet<string> _signatures = new(StringComparer.Ordinal);
|
||||
|
||||
/// <param name="renders">Newest first, as <see cref="SequenceContent.Renders"/>.</param>
|
||||
public RenderedSettings(IReadOnlyList<Render> renders)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(renders);
|
||||
foreach (var render in renders)
|
||||
{
|
||||
if (render.SettingsJson is not { Length: > 0 } json) continue;
|
||||
try
|
||||
{
|
||||
_signatures.Add(EditPath.Signature(ProjectSettings.FromJson(json)));
|
||||
}
|
||||
catch (Exception ex) when (ex is JsonException or InvalidDataException)
|
||||
{
|
||||
// Settings no longer readable (or written by a newer Titano) say nothing either way, like none.
|
||||
}
|
||||
}
|
||||
// A render that keeps no settings (a server's, or one fetched from it) cannot be compared: it counts as current.
|
||||
NewestUnknown = renders.Count > 0 && (renders[0].SettingsJson is not { Length: > 0 } || _signatures.Count == 0);
|
||||
}
|
||||
|
||||
/// <summary>The newest render says nothing comparable about its settings.</summary>
|
||||
public bool NewestUnknown { get; }
|
||||
|
||||
/// <summary>A render was made from settings that make the same video as <paramref name="project"/>'s, or the newest cannot tell.</summary>
|
||||
public bool Matches(ProjectSettings project) => NewestUnknown || _signatures.Contains(EditPath.Signature(project));
|
||||
}
|
||||
@@ -5,9 +5,9 @@
|
||||
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
|
||||
xmlns:e="clr-namespace:Titano.App.Editor">
|
||||
<!--
|
||||
The measuring tool of each editor section, below the tab strip (BRIEF §12.3): luminance, flicker and waveform,
|
||||
camera path and sky charts, the frame table, the keyframe and time-remap curve editors with the plan chart, and the
|
||||
Export tab's preset cards. Clicking a chart seeks the preview.
|
||||
The measuring tool of each step, below the filmstrip (BRIEF §12.3): the Analysis step's findings, luminance, flicker
|
||||
and waveform, camera path and sky charts, the frame table, the keyframe and time-remap curve editors with the plan
|
||||
chart, and the Export step's preset cards. Clicking a chart seeks the preview.
|
||||
-->
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/Titano;component/Editor/EditorStyles.xaml" />
|
||||
@@ -83,6 +83,59 @@
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
|
||||
<!--
|
||||
Analysis (owner review 1, R7): every finding of the analyses, the most severe first, with the step that deals with
|
||||
it; choosing one seeks its first frame (a finding about the whole sequence has none, and no tooltip saying so). Each
|
||||
row reads as its sentence to screen readers.
|
||||
-->
|
||||
<DataTemplate DataType="{x:Type e:AnalysisTab}">
|
||||
<Grid Margin="0,10,0,0">
|
||||
<Border Style="{StaticResource Border.Panel}">
|
||||
<DockPanel>
|
||||
<TextBlock DockPanel.Dock="Top" Text="{l:Loc Editor.Analysis.Findings}" Style="{StaticResource Text.Section}" Margin="14,10,14,6" />
|
||||
<ListBox ItemsSource="{Binding Findings}" SelectedItem="{Binding SelectedFinding}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
AutomationProperties.Name="{l:Loc Editor.Analysis.Findings}" KeyboardNavigation.TabNavigation="Continue" BorderThickness="0" Background="Transparent">
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Row}">
|
||||
<Setter Property="AutomationProperties.Name" Value="{Binding Text}" />
|
||||
<Setter Property="ToolTip" Value="{l:Loc Tooltips.Editor.Frames.Finding}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding Frame}" Value="{x:Null}">
|
||||
<Setter Property="ToolTip" Value="{x:Null}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ListBox.ItemContainerStyle>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type e:AnalysisFinding}">
|
||||
<Grid MinHeight="36">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ui:StatusGlyph Kind="{Binding Kind}" VerticalAlignment="Center" Margin="0,0,8,0" />
|
||||
<TextBlock Grid.Column="1" Text="{Binding Text}" TextWrapping="Wrap" VerticalAlignment="Center" Margin="0,6" />
|
||||
<Button Grid.Column="2" Style="{StaticResource Button.Row}" Margin="8,0,0,0" VerticalAlignment="Center"
|
||||
Command="{Binding DataContext.Editor.GoToStepCommand, RelativeSource={RelativeSource AncestorType=ListBox}}" CommandParameter="{Binding Step}"
|
||||
ToolTip="{Binding GoToToolTip}" AutomationProperties.Name="{Binding Step.Header}"
|
||||
Visibility="{Binding Step, Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding Step.Header}" VerticalAlignment="Center" />
|
||||
<ui:Icon Glyph="{StaticResource Icon.ChevronRight}" Size="12" Margin="4,0,0,0" VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</DockPanel>
|
||||
</Border>
|
||||
<!-- No finding: the analysis runs, has not run yet, or found nothing. -->
|
||||
<ui:EmptyState Message="{Binding EmptyText}" Visibility="{Binding HasFindings, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="{x:Type e:MotionTab}">
|
||||
<ContentPresenter Content="{Binding}" ContentTemplate="{StaticResource Template.Chart}" />
|
||||
</DataTemplate>
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
xmlns:shell="clr-namespace:Titano.App.Shell"
|
||||
xmlns:e="clr-namespace:Titano.App.Editor">
|
||||
<!--
|
||||
The settings column of each editor section (BRIEF §12.3, Editor.html aside, Export.html Output panel): the setting
|
||||
rows by type, the common section frame (title, rows, Optimise section, Reset) and the panels with their own content.
|
||||
The column of each step (BRIEF §12.3, Editor.html aside, Export.html Output panel): the setting rows by type, the
|
||||
common section frame (title, rows, Optimise section, Reset) and the panels with their own content.
|
||||
-->
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/Titano;component/Editor/EditorStyles.xaml" />
|
||||
@@ -159,6 +159,42 @@
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
|
||||
<!--
|
||||
Analysis (owner review 1, R7): where the analysis stands, what it measured, the path's other steps with where each
|
||||
stands (a click opens one), and Analyse. Render stays the screen's one primary button.
|
||||
-->
|
||||
<DataTemplate DataType="{x:Type e:AnalysisTab}">
|
||||
<Border Style="{StaticResource Border.EditorPanel}">
|
||||
<DockPanel>
|
||||
<TextBlock DockPanel.Dock="Top" Text="{Binding Header}" Style="{StaticResource Text.Section}" Margin="0,0,0,10" />
|
||||
<ui:StatusGlyph DockPanel.Dock="Top" Kind="{Binding StateKind}" Text="{Binding StateText}" ToolTip="{Binding StepToolTip}" Margin="0,0,0,14" />
|
||||
<Button DockPanel.Dock="Bottom" Margin="0,12,0,0" HorizontalAlignment="Left" Content="{l:Loc Editor.Analyse}" Command="{Binding Editor.AnalyseCommand}"
|
||||
ToolTip="{Binding Editor.AnalyseToolTip}" ToolTipService.ShowOnDisabled="True" />
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Focusable="False">
|
||||
<StackPanel>
|
||||
<ItemsControl ItemsSource="{Binding Rows}" Focusable="False" />
|
||||
<TextBlock Text="{l:Loc Editor.Path}" Style="{StaticResource Text.Section}" Margin="0,8,0,8" />
|
||||
<ItemsControl ItemsSource="{Binding PathSteps}" Focusable="False">
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type e:EditorTab}">
|
||||
<Button Style="{StaticResource Button.Finding}" Command="{Binding Editor.GoToStepCommand}" CommandParameter="{Binding}" ToolTip="{Binding StepToolTip}"
|
||||
AutomationProperties.Name="{Binding Header}" AutomationProperties.ItemStatus="{Binding StateText}">
|
||||
<DockPanel>
|
||||
<Control DockPanel.Dock="Left" Template="{StaticResource Template.StepBadge}" Focusable="False" IsTabStop="False" VerticalAlignment="Center" />
|
||||
<TextBlock DockPanel.Dock="Left" Text="{Binding Header}" VerticalAlignment="Center" Margin="8,0" />
|
||||
<TextBlock Text="{Binding StateText}" Style="{StaticResource Text.Secondary}" VerticalAlignment="Center" TextAlignment="Right"
|
||||
TextTrimming="CharacterEllipsis" />
|
||||
</DockPanel>
|
||||
</Button>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</DockPanel>
|
||||
</Border>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="{x:Type e:ExposureTab}">
|
||||
<ContentControl Template="{StaticResource Template.SectionPanel}" Focusable="False" />
|
||||
</DataTemplate>
|
||||
@@ -243,8 +279,9 @@
|
||||
<Button Grid.Column="1" Content="{Binding CurrentExcludeText}" Command="{Binding ToggleExcludeCommand}" ToolTip="{Binding CurrentExcludeToolTip}"
|
||||
ToolTipService.ShowOnDisabled="True" Margin="8,0,0,0" />
|
||||
</Grid>
|
||||
<TextBlock Text="{l:Loc Editor.Frames.Warnings}" Style="{StaticResource Text.Section}" Margin="0,0,0,8" />
|
||||
<TextBlock Text="{l:Loc Editor.Frames.NoWarnings}" Style="{StaticResource Text.Secondary}"
|
||||
<!-- The findings about single frames (the Analysis step lists every finding). -->
|
||||
<TextBlock Text="{l:Loc Editor.Frames.FrameWarnings}" Style="{StaticResource Text.Section}" Margin="0,0,0,8" />
|
||||
<TextBlock Text="{l:Loc Editor.Frames.NoFrameWarnings}" Style="{StaticResource Text.Secondary}"
|
||||
Visibility="{Binding HasFindings, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
|
||||
<ItemsControl ItemsSource="{Binding Findings}" Focusable="False">
|
||||
<ItemsControl.ItemTemplate>
|
||||
|
||||
@@ -259,6 +259,19 @@ public sealed class EditorSession : IAsyncDisposable
|
||||
/// <summary>Stores pending changes now; false when the save failed (the change stays pending and is retried).</summary>
|
||||
public Task<bool> FlushAsync() => _saver.FlushAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Stops retrying a change that could not be stored while the user decides about it (<see cref="ProjectSaver.HoldAsync"/>);
|
||||
/// end it with <see cref="KeepPending"/> or <see cref="DiscardPending"/>.
|
||||
/// </summary>
|
||||
/// <returns>True when a change is still not stored; false when a retry stored it meanwhile (nothing to decide).</returns>
|
||||
public Task<bool> HoldPendingAsync() => _saver.HoldAsync();
|
||||
|
||||
/// <summary>The user kept the change: it is retried in the background as before.</summary>
|
||||
public void KeepPending() => _saver.Release();
|
||||
|
||||
/// <summary>The user discarded the change: it is dropped and never written, and nothing more is saved (the editor closes).</summary>
|
||||
public void DiscardPending() => _saver.Stop();
|
||||
|
||||
/// <summary>
|
||||
/// Stores what is pending one last time, stops retrying and releases the source; callers that must not lose an edit
|
||||
/// flush and ask first (<c>SequenceViewModel.ConfirmCloseAsync</c>).
|
||||
|
||||
@@ -128,4 +128,25 @@ public static class EditorSettings
|
||||
/// <summary>True when every Auto setting of <paramref name="section"/> is in Auto.</summary>
|
||||
public static bool IsSectionAuto(ProjectSettings project, AdvisorSection section) =>
|
||||
All.Where(s => s.Section == section).All(s => s.IsAuto(project));
|
||||
|
||||
/// <summary>
|
||||
/// Whether <paramref name="setting"/> applies under the switches in force: the deflicker window, strength and regions
|
||||
/// with deflicker on, the transition length with holy grail on, the shutter angle with motion blur on, the flow quality
|
||||
/// with motion blur or interpolated timing, the stabiliser's smoothing with stabilisation on. A setting that does not
|
||||
/// apply shows n/a in its row (which cannot be taken over by hand then), and the Edit path asks nothing about it.
|
||||
/// </summary>
|
||||
public static bool Applies(IAutoSetting setting, ProjectSettings project, DeepAnalysisReport? deep)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(setting);
|
||||
ArgumentNullException.ThrowIfNull(project);
|
||||
return setting.Id switch
|
||||
{
|
||||
AdvisorParameters.DeflickerWindow or AdvisorParameters.DeflickerStrength or AdvisorParameters.Regions => Deflicker.Effective(project, deep),
|
||||
AdvisorParameters.TransitionLength => HolyGrail.Effective(project, deep),
|
||||
AdvisorParameters.TargetShutterAngle => MotionBlur.Effective(project, deep),
|
||||
AdvisorParameters.FlowQuality => MotionBlur.Effective(project, deep) || TimingMode.Effective(project, deep) == Core.Project.TimingMode.Interpolated,
|
||||
AdvisorParameters.StabilizeSmoothing => Stabilize.Effective(project, deep),
|
||||
_ => true,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -1,12 +1,13 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="clr-namespace:Titano.Ui.Controls;assembly=Titano.Ui">
|
||||
xmlns:ui="clr-namespace:Titano.Ui.Controls;assembly=Titano.Ui"
|
||||
xmlns:e="clr-namespace:Titano.App.Editor">
|
||||
<!--
|
||||
Styles of the sequence editor (Editor.html, Export.html) on the kit of Titano.Ui and the client styles. Brushes are
|
||||
DynamicResource; sizes and the kit's styles StaticResource.
|
||||
-->
|
||||
|
||||
<!-- Preview height against the measuring area: the editor favours the picture, the Export tab its preset cards. -->
|
||||
<!-- Preview height against the measuring area: the editor favours the picture; the Analysis findings and the Export preset cards take more room. -->
|
||||
<GridLength x:Key="Editor.Grid.Preview">17*</GridLength>
|
||||
<GridLength x:Key="Editor.Grid.Measure">10*</GridLength>
|
||||
<GridLength x:Key="Editor.Grid.ExportPreview">9*</GridLength>
|
||||
@@ -171,6 +172,150 @@
|
||||
<Setter Property="VerticalAlignment" Value="Center" />
|
||||
</Style>
|
||||
|
||||
<!--
|
||||
The editor's title, which chooses another sequence (owner review 1, R7): subtle like Button.Subtle, but its content is measured
|
||||
at the width the header leaves, so the title ends in an ellipsis and the chevron stays.
|
||||
-->
|
||||
<Style x:Key="Button.Title" TargetType="Button" BasedOn="{StaticResource Button.Subtle}">
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Border x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}"
|
||||
BorderThickness="{TemplateBinding BorderThickness}" CornerRadius="{TemplateBinding ui:ControlState.CornerRadius}" SnapsToDevicePixels="True">
|
||||
<ContentPresenter Margin="{TemplateBinding Padding}" VerticalAlignment="Center" RecognizesAccessKey="False" />
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="Bd" Property="Background" Value="{Binding (ui:ControlState.HoverBackground), RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
<Setter TargetName="Bd" Property="BorderBrush" Value="{Binding (ui:ControlState.HoverBorderBrush), RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsPressed" Value="True">
|
||||
<Setter TargetName="Bd" Property="Background" Value="{Binding (ui:ControlState.PressedBackground), RelativeSource={RelativeSource TemplatedParent}}" />
|
||||
</Trigger>
|
||||
<Trigger Property="IsEnabled" Value="False">
|
||||
<Setter Property="Opacity" Value="0.4" />
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!-- ===================== The Edit path (owner review 1, R7): the step bar under the header ===================== -->
|
||||
|
||||
<!--
|
||||
A step's badge: its number in a ring until there is something to say, then the status glyph of DESIGN §4 (✓ done,
|
||||
▲ attention, ◐ running, ○ waiting), so colour never carries the state alone. The glyphs are not directional.
|
||||
-->
|
||||
<ControlTemplate x:Key="Template.StepBadge" TargetType="Control">
|
||||
<Grid Width="22" Height="22">
|
||||
<Ellipse x:Name="Ring" Stroke="{DynamicResource Brush.Stroke}" StrokeThickness="1.5" />
|
||||
<TextBlock x:Name="Number" Text="{Binding Number}" FontSize="11" Foreground="{DynamicResource Brush.TextMuted}" HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" />
|
||||
<ui:Icon x:Name="Glyph" Size="16" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="Collapsed" />
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<DataTrigger Binding="{Binding Status}" Value="{x:Static e:StepStatus.Done}">
|
||||
<Setter TargetName="Ring" Property="Visibility" Value="Collapsed" />
|
||||
<Setter TargetName="Number" Property="Visibility" Value="Collapsed" />
|
||||
<Setter TargetName="Glyph" Property="Visibility" Value="Visible" />
|
||||
<Setter TargetName="Glyph" Property="Glyph" Value="{StaticResource Icon.Check}" />
|
||||
<Setter TargetName="Glyph" Property="Foreground" Value="{DynamicResource Brush.Success}" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Status}" Value="{x:Static e:StepStatus.Attention}">
|
||||
<Setter TargetName="Ring" Property="Visibility" Value="Collapsed" />
|
||||
<Setter TargetName="Number" Property="Visibility" Value="Collapsed" />
|
||||
<Setter TargetName="Glyph" Property="Visibility" Value="Visible" />
|
||||
<Setter TargetName="Glyph" Property="Glyph" Value="{StaticResource Icon.Triangle}" />
|
||||
<Setter TargetName="Glyph" Property="Foreground" Value="{DynamicResource Brush.Warning}" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Status}" Value="{x:Static e:StepStatus.Running}">
|
||||
<Setter TargetName="Ring" Property="Visibility" Value="Collapsed" />
|
||||
<Setter TargetName="Number" Property="Visibility" Value="Collapsed" />
|
||||
<Setter TargetName="Glyph" Property="Visibility" Value="Visible" />
|
||||
<Setter TargetName="Glyph" Property="Glyph" Value="{StaticResource Icon.HalfDot}" />
|
||||
<Setter TargetName="Glyph" Property="Foreground" Value="{DynamicResource Brush.Warning}" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding Status}" Value="{x:Static e:StepStatus.Waiting}">
|
||||
<Setter TargetName="Ring" Property="Visibility" Value="Collapsed" />
|
||||
<Setter TargetName="Number" Property="Visibility" Value="Collapsed" />
|
||||
<Setter TargetName="Glyph" Property="Visibility" Value="Visible" />
|
||||
<Setter TargetName="Glyph" Property="Glyph" Value="{StaticResource Icon.Ring}" />
|
||||
<Setter TargetName="Glyph" Property="Foreground" Value="{DynamicResource Brush.TextFaint}" />
|
||||
</DataTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
|
||||
<!-- The step bar: every step in one row of equal cells (120.75 px each at the 1200 px minimum), no scrolling. -->
|
||||
<Style x:Key="ListBox.Steps" TargetType="ListBox" BasedOn="{StaticResource ListBox.Base}">
|
||||
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Disabled" />
|
||||
<Setter Property="ItemsPanel">
|
||||
<Setter.Value>
|
||||
<ItemsPanelTemplate>
|
||||
<UniformGrid Rows="1" />
|
||||
</ItemsPanelTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListBox">
|
||||
<ItemsPresenter />
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!--
|
||||
One step: badge, name and a connector line to the next. The current step is underlined in the accent colour with its
|
||||
name in semibold; visited steps have their name in the text colour, the others muted. Tight padding leaves a name about
|
||||
82 px at the 1200 px minimum (every English and Italian name fits, even selected); a longer one ends in an ellipsis and
|
||||
the step's tooltip starts with it.
|
||||
-->
|
||||
<Style x:Key="ListBoxItem.Step" TargetType="ListBoxItem">
|
||||
<Setter Property="FocusVisualStyle" Value="{StaticResource Focus.Inset}" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource Brush.TextMuted}" />
|
||||
<Setter Property="Height" Value="36" />
|
||||
<Setter Property="Padding" Value="4,0" />
|
||||
<Setter Property="Cursor" Value="Hand" />
|
||||
<Setter Property="ToolTip" Value="{Binding StepToolTip}" />
|
||||
<Setter Property="AutomationProperties.Name" Value="{Binding Header}" />
|
||||
<Setter Property="AutomationProperties.ItemStatus" Value="{Binding StateText}" />
|
||||
<Setter Property="AutomationProperties.AcceleratorKey" Value="{Binding Shortcut}" />
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="ListBoxItem">
|
||||
<Grid Background="Transparent">
|
||||
<Border x:Name="Bd" CornerRadius="{StaticResource Radius.Control}" Padding="{TemplateBinding Padding}" Background="Transparent">
|
||||
<DockPanel>
|
||||
<Control DockPanel.Dock="Left" Template="{StaticResource Template.StepBadge}" Focusable="False" IsTabStop="False" VerticalAlignment="Center" />
|
||||
<TextBlock x:Name="Label" DockPanel.Dock="Left" Text="{Binding Header}" FontSize="{StaticResource Size.Body}" Margin="6,0,2,0" VerticalAlignment="Center"
|
||||
TextTrimming="CharacterEllipsis" />
|
||||
<Border x:Name="Connector" Height="1" Background="{DynamicResource Brush.Stroke}" VerticalAlignment="Center" />
|
||||
</DockPanel>
|
||||
</Border>
|
||||
<Border x:Name="Underline" Height="2" Margin="4,0" VerticalAlignment="Bottom" Background="{DynamicResource Brush.Accent}" Visibility="Collapsed" />
|
||||
</Grid>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsMouseOver" Value="True">
|
||||
<Setter TargetName="Bd" Property="Background" Value="{DynamicResource Brush.Card}" />
|
||||
</Trigger>
|
||||
<DataTrigger Binding="{Binding IsVisited}" Value="True">
|
||||
<Setter Property="Foreground" Value="{DynamicResource Brush.Text}" />
|
||||
</DataTrigger>
|
||||
<Trigger Property="IsSelected" Value="True">
|
||||
<Setter TargetName="Underline" Property="Visibility" Value="Visible" />
|
||||
<Setter TargetName="Label" Property="FontWeight" Value="SemiBold" />
|
||||
<Setter Property="Foreground" Value="{DynamicResource Brush.Text}" />
|
||||
</Trigger>
|
||||
<DataTrigger Binding="{Binding IsLast}" Value="True">
|
||||
<Setter TargetName="Connector" Property="Visibility" Value="Hidden" />
|
||||
</DataTrigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
|
||||
<!--
|
||||
A finding of the warnings list: glyph and one sentence, click seeks its first frame. Its own template (no
|
||||
horizontal StackPanel as in the kit's buttons) so the sentence is measured at the panel width and wraps.
|
||||
|
||||
@@ -6,26 +6,37 @@ using Titano.Ui.Mvvm;
|
||||
namespace Titano.App.Editor;
|
||||
|
||||
/// <summary>
|
||||
/// 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". <see cref="Refresh"/> runs after every project change.
|
||||
/// One step of the Edit path (BRIEF §12.3, owner review 1 R7): its measuring tool below the filmstrip and its column
|
||||
/// on the right, with "Optimise section" and "Reset" for a section the advisor decides. <see cref="Refresh"/> runs after
|
||||
/// every project change; the editor sets where the step stands (<see cref="SetStep"/>).
|
||||
/// </summary>
|
||||
public abstract class EditorTab : LocalizedViewModel
|
||||
{
|
||||
protected EditorTab(EditorViewModel editor, string key, AdvisorSection section)
|
||||
private StepState _state = new(StepStatus.Todo, string.Empty);
|
||||
private bool _isVisited;
|
||||
|
||||
protected EditorTab(EditorViewModel editor, string key, AdvisorSection? section)
|
||||
{
|
||||
Editor = editor;
|
||||
Key = key;
|
||||
Section = section;
|
||||
OptimiseCommand = new RelayCommand(() => Editor.Optimise(Section), () => CanOptimise && !Editor.IsLocked);
|
||||
ResetCommand = new RelayCommand(() => Editor.Session.ResetSection(Section), () => CanReset && !Editor.IsLocked);
|
||||
OptimiseCommand = new RelayCommand(() =>
|
||||
{
|
||||
if (Section is { } s) Editor.Optimise(s);
|
||||
}, () => CanOptimise && !Editor.IsLocked);
|
||||
ResetCommand = new RelayCommand(() =>
|
||||
{
|
||||
if (Section is { } s) Editor.Session.ResetSection(s);
|
||||
}, () => CanReset && !Editor.IsLocked);
|
||||
}
|
||||
|
||||
public EditorViewModel Editor { get; }
|
||||
|
||||
/// <summary>"Frames", "Exposure"… (resource key suffix).</summary>
|
||||
/// <summary>"Frames", "Exposure"… (resource key suffix and <see cref="EditPath"/> step).</summary>
|
||||
public string Key { get; }
|
||||
|
||||
public AdvisorSection Section { get; }
|
||||
/// <summary>The advisor section of the step; null for a step the advisor does not decide (Analysis).</summary>
|
||||
public AdvisorSection? Section { get; }
|
||||
|
||||
public string Header => Loc.L("Editor.Tab." + Key);
|
||||
|
||||
@@ -34,10 +45,10 @@ public abstract class EditorTab : LocalizedViewModel
|
||||
/// <summary>Settings rows of the right column (empty for tabs with their own panel).</summary>
|
||||
public IReadOnlyList<SettingRow> Rows { get; protected init; } = [];
|
||||
|
||||
/// <summary>The advisor has heavier decisions for this section (stacking has none).</summary>
|
||||
public virtual bool CanOptimise => true;
|
||||
/// <summary>The advisor has heavier decisions for this section (stacking and the analysis have none).</summary>
|
||||
public virtual bool CanOptimise => Section is not null;
|
||||
|
||||
public virtual bool CanReset => true;
|
||||
public virtual bool CanReset => Section is not null;
|
||||
|
||||
/// <summary>What Optimise section does, or why it cannot run now.</summary>
|
||||
public string OptimiseToolTip => !CanOptimise ? Loc.L("Tooltips.Editor.OptimiseNone") : Editor.LockedToolTip ?? Loc.L("Tooltips.Editor.OptimiseSection");
|
||||
@@ -48,6 +59,53 @@ public abstract class EditorTab : LocalizedViewModel
|
||||
|
||||
public ICommand ResetCommand { get; }
|
||||
|
||||
// ---- The step ----
|
||||
|
||||
/// <summary>Position on the path, from 1.</summary>
|
||||
public int Number { get; internal set; }
|
||||
|
||||
/// <summary>The path's last step (its connector line is not drawn).</summary>
|
||||
public bool IsLast { get; internal set; }
|
||||
|
||||
/// <summary>Alt+1…Alt+9; empty from the tenth step on.</summary>
|
||||
public string Shortcut => Number is >= 1 and <= 9 ? Loc.L("Editor.Step.Shortcut", Number) : string.Empty;
|
||||
|
||||
/// <summary>The user opened the step since the sequence opened (or since the analysis it waited for ended).</summary>
|
||||
public bool IsVisited
|
||||
{
|
||||
get => _isVisited;
|
||||
internal set => Set(ref _isVisited, value);
|
||||
}
|
||||
|
||||
public StepStatus Status => _state.Status;
|
||||
|
||||
/// <summary>"Auto", "3 flagged frames", "Not rendered" (three words at most).</summary>
|
||||
public string StateText => _state.Text;
|
||||
|
||||
/// <summary>A sentence on the state, when there is more to say than <see cref="StateText"/>.</summary>
|
||||
public string? StateDetail => _state.Detail;
|
||||
|
||||
/// <summary>"Exposure · what the step is for · its state · Alt+3": the name first, so a name cut in the step bar can be read whole.</summary>
|
||||
public string StepToolTip => Shortcut.Length > 0
|
||||
? Loc.L("Tooltips.Editor.Step", Header, ToolTip, StateDetail ?? StateText, Number)
|
||||
: string.Join(Loc.Separator, Header, ToolTip, StateDetail ?? StateText);
|
||||
|
||||
/// <summary>The measuring area takes more of the height than the preview (the findings, the preset cards).</summary>
|
||||
public virtual bool PrefersTallMeasure => false;
|
||||
|
||||
/// <summary>Where the step stands now; raises only what changed.</summary>
|
||||
public void SetStep(StepState state)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(state);
|
||||
if (state == _state) return;
|
||||
var old = _state;
|
||||
_state = state;
|
||||
if (old.Status != state.Status) OnPropertyChanged(nameof(Status));
|
||||
if (old.Text != state.Text) OnPropertyChanged(nameof(StateText));
|
||||
if (old.Detail != state.Detail) OnPropertyChanged(nameof(StateDetail));
|
||||
OnPropertyChanged(nameof(StepToolTip));
|
||||
}
|
||||
|
||||
/// <summary>Re-reads the project (any change).</summary>
|
||||
public virtual void Refresh()
|
||||
{
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
@@ -23,11 +24,12 @@ using Titano.Ui.Visuals;
|
||||
namespace Titano.App.Editor;
|
||||
|
||||
/// <summary>
|
||||
/// The sequence editor of one open sequence (BRIEF §12.3, Editor.html): header actions, the preview with its tools
|
||||
/// (wipe compare, zoom, overlays) rendered through the pipeline at preview size (at the source's own size for 1:1 and
|
||||
/// wheel zoom), the filmstrip with markers, the section tabs and the keyboard (space, arrows, Ctrl+Z/Y, Ctrl+0/1,
|
||||
/// Ctrl+R, Ctrl+Shift+A). Preview frames, corrections, the export plan and the card estimates are computed off the UI
|
||||
/// thread; each request cancels the previous one. While an analysis or render of this sequence runs, settings are
|
||||
/// The editor of one open sequence (BRIEF §12.3, Editor.html): header actions, the preview with its tools (wipe
|
||||
/// compare, zoom, overlays) rendered through the pipeline at preview size (at the source's own size for 1:1 and wheel
|
||||
/// zoom), the filmstrip with markers, the steps of the Edit path from the analysis to the export (owner review 1, R7:
|
||||
/// each with where it stands, Previous and Next, Alt+1…8, Ctrl+PgUp/PgDn) and the keyboard (space, arrows, Ctrl+Z/Y,
|
||||
/// Ctrl+0/1, Ctrl+R, Ctrl+Shift+A). Preview frames, corrections, the export plan and the card estimates are computed off
|
||||
/// the UI thread; each request cancels the previous one. While an analysis or render of this sequence runs, settings are
|
||||
/// disabled and viewing tools stay live.
|
||||
/// </summary>
|
||||
public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
@@ -79,6 +81,14 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
private int _playLimit;
|
||||
private double? _analysisSecondsPerFrame;
|
||||
private ExportSyncGate _syncGate;
|
||||
private RenderedSettings _rendered;
|
||||
|
||||
/// <summary>The step shown came from the section's memory of this sequence (<see cref="RestoreSteps"/>).</summary>
|
||||
private bool _stepRestored;
|
||||
|
||||
/// <summary>The user chose a step since the editor opened.</summary>
|
||||
private bool _stepChosen;
|
||||
|
||||
private bool _disposed;
|
||||
|
||||
public EditorViewModel(ShellViewModel shell, EditorSession session, IReadOnlyList<IVideoEncoderProvider> encoders, EncoderHost host)
|
||||
@@ -108,11 +118,25 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
StepForwardCommand = new RelayCommand(() => CurrentIndex++);
|
||||
FitCommand = new RelayCommand(() => ZoomMode = PreviewZoomMode.Fit);
|
||||
ActualSizeCommand = new RelayCommand(() => ZoomMode = PreviewZoomMode.Actual, () => !IsExportTab);
|
||||
PreviousStepCommand = new RelayCommand(() => MoveStep(-1), () => StepIndex > 0);
|
||||
NextStepCommand = new RelayCommand(NextStep, () => !SelectedTab.IsLast || Shell.Sequence.ChangeSequenceCommand.CanExecute(null));
|
||||
GoToStepCommand = new RelayCommand(p =>
|
||||
{
|
||||
if (StepFor(p) is { } step) SelectedTab = step;
|
||||
});
|
||||
|
||||
Analysis = new AnalysisTab(this);
|
||||
Frames = new FramesTab(this);
|
||||
Exposure = new ExposureTab(this);
|
||||
Tabs = [Frames, Exposure, new MotionTab(this), new CameraTab(this), new TimeTab(this), new StackTab(this), new ExportTab(this)];
|
||||
_selectedTab = Exposure;
|
||||
Tabs = [Analysis, Frames, Exposure, new MotionTab(this), new CameraTab(this), new TimeTab(this), new StackTab(this), new ExportTab(this)];
|
||||
for (var i = 0; i < Tabs.Count; i++)
|
||||
{
|
||||
Tabs[i].Number = i + 1;
|
||||
Tabs[i].IsLast = i == Tabs.Count - 1;
|
||||
}
|
||||
_selectedTab = Step(EditPath.Start(null, session.Content));
|
||||
_selectedTab.IsVisited = true;
|
||||
_rendered = new RenderedSettings(session.Content.Renders);
|
||||
_currentIndex = session.Project.HeroFrame is { } hero && (uint)hero < (uint)FrameCount ? hero : 0;
|
||||
_currentFrameId = FrameId(_currentIndex);
|
||||
// Until the link is read (AttachJobsAsync), a sequence of this PC cannot send its renders.
|
||||
@@ -127,6 +151,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
session.Source.ReadOnlyChanged += OnReadOnlyChanged;
|
||||
shell.Services.Sync.Changed += OnSyncChanged;
|
||||
UpdateMarkers();
|
||||
RefreshSteps();
|
||||
RequestCorrections();
|
||||
RequestPlan();
|
||||
RequestPreview(immediate: true);
|
||||
@@ -140,6 +165,12 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
|
||||
public string Title => Session.Content.Sequence.DisplayTitle;
|
||||
|
||||
/// <summary>The title button's accessible name: its visible text (the title), then what it does ("Harbour sunset · Change sequence").</summary>
|
||||
public string ChangeName => Title + Loc.Separator + Loc.L("Editor.Change");
|
||||
|
||||
/// <summary>The title button's tooltip: the whole title (it may be cut), then what the button does.</summary>
|
||||
public string ChangeToolTip => Title + Loc.Separator + Loc.L("Tooltips.Editor.Change");
|
||||
|
||||
/// <summary>A server sequence edited with proxies (the header says where it lives).</summary>
|
||||
public bool IsRemote => Session.IsRemote;
|
||||
|
||||
@@ -200,32 +231,57 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
? EditorText.OutputSummary(Session.Content, plan)
|
||||
: EditorText.Summary(Session.Content, Session.Advice.Findings.Count(f => f.Severity >= FindingSeverity.Warning));
|
||||
|
||||
/// <summary>The first step: what the analyses found and where every other step stands.</summary>
|
||||
public AnalysisTab Analysis { get; }
|
||||
|
||||
public FramesTab Frames { get; }
|
||||
|
||||
public ExposureTab Exposure { get; }
|
||||
|
||||
/// <summary>The steps of the Edit path, in order (owner review 1, R7).</summary>
|
||||
public IReadOnlyList<EditorTab> Tabs { get; }
|
||||
|
||||
/// <summary>The step on screen; any step can be chosen at any time, and choosing one marks it visited.</summary>
|
||||
public EditorTab SelectedTab
|
||||
{
|
||||
get => _selectedTab;
|
||||
set
|
||||
{
|
||||
if (value is null || !Set(ref _selectedTab, value)) return;
|
||||
OnPropertyChanged(nameof(IsExportTab));
|
||||
OnPropertyChanged(nameof(Summary));
|
||||
OnToolsChanged();
|
||||
// 1:1 is not a tool of the Export tab (Export.html): its picture fits the view.
|
||||
if (IsExportTab) ZoomMode = PreviewZoomMode.Fit;
|
||||
UpdateInfo();
|
||||
RequestPreview(immediate: true);
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
if (value is null || !Tabs.Contains(value)) return;
|
||||
_stepChosen = true;
|
||||
Select(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The Export tab swaps the preview tools for compare, crop mask and a 10-second preview (Export.html).</summary>
|
||||
/// <summary>The Export step swaps the preview tools for compare, crop mask and a 10-second preview (Export.html).</summary>
|
||||
public bool IsExportTab => SelectedTab is ExportTab;
|
||||
|
||||
/// <summary>The measuring area takes more of the height than the preview (the Analysis findings, the Export preset cards).</summary>
|
||||
public bool IsTallMeasure => SelectedTab.PrefersTallMeasure;
|
||||
|
||||
/// <summary>"3 / 8".</summary>
|
||||
public string StepCounter => Loc.L("Editor.Step.Counter", SelectedTab.Number, Tabs.Count);
|
||||
|
||||
/// <summary>What screen readers hear when the step or its state changes: "Step 3 of 8: Exposure, Auto".</summary>
|
||||
public string StepAnnouncement => Loc.L("Editor.Step.Announce", SelectedTab.Number, Tabs.Count, SelectedTab.Header, SelectedTab.StateText);
|
||||
|
||||
/// <summary>"Next", "Next sequence" on the last step.</summary>
|
||||
public string NextText => Loc.L(SelectedTab.IsLast ? "Editor.Step.NextSequence" : "Editor.Step.Next");
|
||||
|
||||
public string NextToolTip => SelectedTab.IsLast ? Loc.L("Tooltips.Editor.Step.NextSequence") : Loc.L("Tooltips.Editor.Step.Next", Tabs[StepIndex + 1].Header);
|
||||
|
||||
public string PreviousToolTip => StepIndex == 0 ? Loc.L("Tooltips.Editor.Step.First") : Loc.L("Tooltips.Editor.Step.Previous", Tabs[StepIndex - 1].Header);
|
||||
|
||||
public ICommand PreviousStepCommand { get; }
|
||||
|
||||
/// <summary>The next step; on the last one, the choice of the next sequence.</summary>
|
||||
public ICommand NextStepCommand { get; }
|
||||
|
||||
/// <summary>Opens a step, given as the step itself, its number (Alt+n) or its key.</summary>
|
||||
public ICommand GoToStepCommand { get; }
|
||||
|
||||
private int StepIndex => SelectedTab.Number - 1;
|
||||
|
||||
// ---- Frames ----
|
||||
|
||||
public int FrameCount => Session.Content.Count;
|
||||
@@ -518,6 +574,30 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
/// <summary>"Optimise section": the advisor's heavier decisions, reported in a toast (what changed, from what to what).</summary>
|
||||
public void Optimise(AdvisorSection section) => Report(Session.Optimise(section));
|
||||
|
||||
/// <summary>The step <paramref name="delta"/> steps away, stopping at the first and the last (Ctrl+PgUp, Ctrl+PgDn).</summary>
|
||||
public void MoveStep(int delta)
|
||||
{
|
||||
var index = StepIndex + delta;
|
||||
if ((uint)index < (uint)Tabs.Count) SelectedTab = Tabs[index];
|
||||
}
|
||||
|
||||
/// <summary>The step on screen and the steps visited, which the section gives back when the sequence opens again in this run.</summary>
|
||||
public StepMemory StepMemory() => new(SelectedTab.Key, [.. Tabs.Where(t => t.IsVisited).Select(t => t.Key)], EditPath.AnalysisStamp(Session.Content));
|
||||
|
||||
/// <summary>
|
||||
/// Shows the step <paramref name="memory"/> kept, with its visited marks (before the editor is on screen); a deep
|
||||
/// analysis that ended while the sequence was closed leaves only that step visited, as it would have with the editor open.
|
||||
/// </summary>
|
||||
public void RestoreSteps(StepMemory memory)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(memory);
|
||||
var sameAnalysis = memory.Analysis == EditPath.AnalysisStamp(Session.Content);
|
||||
foreach (var tab in Tabs) tab.IsVisited = sameAnalysis && memory.Visited.Contains(tab.Key);
|
||||
if (Tabs.FirstOrDefault(t => t.Key == memory.Step) is not { } step) return;
|
||||
_stepRestored = true;
|
||||
Select(step);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Queues a render of the project's export (with its batch presets when <paramref name="batch"/>): on this PC's
|
||||
/// engine, or one server job per preset for a server sequence.
|
||||
@@ -590,6 +670,14 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
var jobs = await Session.Source.ListJobsAsync(CancellationToken.None);
|
||||
foreach (var job in jobs) _jobs.Track(job);
|
||||
foreach (var job in jobs.OrderBy(j => j.Finished)) LearnAnalysisSpeed(job);
|
||||
// A sequence opened while its analysis waits, runs or is paused shows that first (EditPath.Start), unless the user or
|
||||
// the section's memory chose a step meanwhile; the step shown only until then is not counted as visited.
|
||||
if (!_stepRestored && !_stepChosen && Step(EditPath.Start(null, Session.Content, _jobs.Active(JobKind.DeepAnalyse))) is var start
|
||||
&& !ReferenceEquals(start, _selectedTab))
|
||||
{
|
||||
_selectedTab.IsVisited = false;
|
||||
Select(start);
|
||||
}
|
||||
OnBusyChanged();
|
||||
}
|
||||
|
||||
@@ -749,6 +837,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
OnPropertyChanged(nameof(Summary));
|
||||
foreach (var tab in Tabs) tab.OnPlanChanged();
|
||||
UpdateInfo();
|
||||
RefreshSteps();
|
||||
RefreshCommands();
|
||||
}
|
||||
|
||||
@@ -793,6 +882,68 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
return int.Max(1, (int)(plan.Setup.Plan.IncludedFrames.Count * double.Min(1, 10 / plan.Setup.Plan.DurationSeconds)));
|
||||
}
|
||||
|
||||
// ---- Steps ----
|
||||
|
||||
private void Select(EditorTab step)
|
||||
{
|
||||
step.IsVisited = true;
|
||||
if (!Set(ref _selectedTab, step, nameof(SelectedTab))) return;
|
||||
OnPropertyChanged(nameof(IsExportTab));
|
||||
OnPropertyChanged(nameof(IsTallMeasure));
|
||||
OnPropertyChanged(nameof(Summary));
|
||||
OnStepNavigationChanged();
|
||||
OnToolsChanged();
|
||||
// 1:1 is not a tool of the Export step (Export.html): its picture fits the view.
|
||||
if (IsExportTab) ZoomMode = PreviewZoomMode.Fit;
|
||||
UpdateInfo();
|
||||
RequestPreview(immediate: true);
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
|
||||
private void OnStepNavigationChanged()
|
||||
{
|
||||
OnPropertyChanged(nameof(StepCounter));
|
||||
OnPropertyChanged(nameof(StepAnnouncement));
|
||||
OnPropertyChanged(nameof(NextText));
|
||||
OnPropertyChanged(nameof(NextToolTip));
|
||||
OnPropertyChanged(nameof(PreviousToolTip));
|
||||
}
|
||||
|
||||
private EditorTab Step(string key) => Tabs.First(t => t.Key == key);
|
||||
|
||||
private EditorTab? StepFor(object? parameter) => parameter switch
|
||||
{
|
||||
EditorTab tab when Tabs.Contains(tab) => tab,
|
||||
int number => (uint)(number - 1) < (uint)Tabs.Count ? Tabs[number - 1] : null,
|
||||
string text when int.TryParse(text, NumberStyles.None, CultureInfo.InvariantCulture, out var number) =>
|
||||
(uint)(number - 1) < (uint)Tabs.Count ? Tabs[number - 1] : null,
|
||||
string key => Tabs.FirstOrDefault(t => t.Key == key),
|
||||
_ => null,
|
||||
};
|
||||
|
||||
private void NextStep()
|
||||
{
|
||||
if (!SelectedTab.IsLast) MoveStep(1);
|
||||
else if (Shell.Sequence.ChangeSequenceCommand.CanExecute(null)) Shell.Sequence.ChangeSequenceCommand.Execute(null);
|
||||
}
|
||||
|
||||
/// <summary>Works out where every step stands: after any change of the project, the sequence, its jobs or the plan.</summary>
|
||||
private void RefreshSteps()
|
||||
{
|
||||
if (_disposed) return;
|
||||
var facts = new PathFacts(Session.Content, Session.Advice, Session.Project, _jobs.Active(JobKind.DeepAnalyse), _jobs.Active(JobKind.Render),
|
||||
_planned ? RenderBlockedReason : null, _rendered.Matches(Session.Project));
|
||||
foreach (var tab in Tabs) tab.SetStep(EditPath.Of(tab.Key, facts));
|
||||
Analysis.OnStepChanged();
|
||||
OnPropertyChanged(nameof(StepAnnouncement));
|
||||
}
|
||||
|
||||
/// <summary>A deep analysis the editor followed ended: the steps it changed are to be looked at again.</summary>
|
||||
private void ClearVisited()
|
||||
{
|
||||
foreach (var tab in Tabs) tab.IsVisited = ReferenceEquals(tab, SelectedTab);
|
||||
}
|
||||
|
||||
// ---- Changes ----
|
||||
|
||||
private void OnToolsChanged()
|
||||
@@ -807,6 +958,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
{
|
||||
foreach (var tab in Tabs) tab.Refresh();
|
||||
UpdateMarkers();
|
||||
RefreshSteps();
|
||||
RequestCorrections();
|
||||
RequestPlan();
|
||||
RequestPreview();
|
||||
@@ -822,11 +974,13 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
Planner = new ExportPlanner(Session.Content, _encoders, _host);
|
||||
if (Thumbnails.Count != FrameCount) Thumbnails = new EditorThumbnails(Session.Source, FrameCount);
|
||||
Corrections = null;
|
||||
_rendered = new RenderedSettings(Session.Content.Renders);
|
||||
foreach (var tab in Tabs) tab.OnContentChanged();
|
||||
OnPropertyChanged(nameof(Summary));
|
||||
OnPropertyChanged(nameof(FrameCount));
|
||||
CurrentIndex = shown;
|
||||
UpdateMarkers();
|
||||
RefreshSteps();
|
||||
RequestCorrections();
|
||||
RequestPlan();
|
||||
RequestPreview(immediate: true);
|
||||
@@ -857,6 +1011,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
foreach (var tab in Tabs) tab.OnContentChanged();
|
||||
UpdateMarkers();
|
||||
UpdateInfo();
|
||||
RefreshSteps();
|
||||
}
|
||||
base.OnLanguageChanged();
|
||||
}
|
||||
@@ -974,6 +1129,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
else OnServerJobChanged();
|
||||
LearnAnalysisSpeed(job);
|
||||
if (!wasActive) return;
|
||||
if (job is { Kind: JobKind.DeepAnalyse, State: JobState.Done }) ClearVisited();
|
||||
// A render this editor followed to its end is said here, with its output, unless the Jobs screen said it first.
|
||||
if (job.State == JobState.Done) _ = ReloadAsync(job.Kind == JobKind.Render && Shell.Jobs.ClaimRenderToast(job.Id) ? job : null);
|
||||
else if (IsRemote && job.State is JobState.Failed or JobState.Cancelled) ReportServerJobEnded(job);
|
||||
@@ -1108,6 +1264,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
OnPropertyChanged(nameof(OptimiseAllToolTip));
|
||||
OnServerJobChanged();
|
||||
foreach (var tab in Tabs) tab.OnBusyChanged();
|
||||
RefreshSteps();
|
||||
RefreshCommands();
|
||||
}
|
||||
|
||||
|
||||
@@ -423,6 +423,9 @@ public sealed class ExportTab : EditorTab
|
||||
EditExport(e => e with { Batch = value ? [.. e.Batch, presetId] : [.. e.Batch.Where(b => !b.Equals(presetId, StringComparison.OrdinalIgnoreCase))] });
|
||||
}
|
||||
|
||||
/// <summary>The preset cards take more of the height than the preview (Export.html).</summary>
|
||||
public override bool PrefersTallMeasure => true;
|
||||
|
||||
public override void Refresh()
|
||||
{
|
||||
base.Refresh();
|
||||
|
||||
@@ -37,8 +37,11 @@ public sealed class ExposureTab : EditorTab
|
||||
: 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");
|
||||
// The same rule as the Edit path's (EditorSettings.Applies): a row shown n/a is never asked for.
|
||||
string? NoDeflicker(ProjectSettings p) =>
|
||||
EditorSettings.Applies(EditorSettings.DeflickerWindow, p, s.Content.Deep) ? null : Loc.L("Tooltips.Editor.NotApplicable.DeflickerOff");
|
||||
string? NoHolyGrail(ProjectSettings p) =>
|
||||
EditorSettings.Applies(EditorSettings.TransitionLength, p, s.Content.Deep) ? null : Loc.L("Tooltips.Editor.NotApplicable.HolyGrailOff");
|
||||
Rows =
|
||||
[
|
||||
new AutoSwitchRow(s, EditorSettings.Deflicker, "Editor.Exposure.Deflicker", "Tooltips.Editor.Exposure.Deflicker"),
|
||||
|
||||
@@ -123,7 +123,7 @@ public sealed record FindingItem(StatusKind Kind, string Text, int? Frame);
|
||||
|
||||
/// <summary>
|
||||
/// Frames (BRIEF §12.3): the virtualised frame table (index, time, exposure, ISO, aperture, size, tier, flags) with
|
||||
/// exclude/include and hero, and the warnings of the analyses; Optimise adds the advised exclusions and hero.
|
||||
/// exclude/include and hero, and the warnings of the analyses about frames; Optimise adds the advised exclusions and hero.
|
||||
/// </summary>
|
||||
public sealed class FramesTab : EditorTab
|
||||
{
|
||||
@@ -272,7 +272,8 @@ public sealed class FramesTab : EditorTab
|
||||
_hero = Editor.Session.Project.HeroFrame;
|
||||
_rows = [.. content.Frames.Select((f, i) => new FrameRow(this, f, i))];
|
||||
Frames = Sorted();
|
||||
Findings = [.. Editor.Session.Advice.Findings.OrderByDescending(f => f.Severity).Select(ToItem)];
|
||||
// The findings this step deals with, and those no step deals with; the Analysis step lists them all.
|
||||
Findings = [.. Editor.Session.Advice.Findings.Where(f => EditPath.StepOf(f.Key) is null or EditPath.Frames).OrderByDescending(f => f.Severity).Select(ToItem)];
|
||||
_selected = null;
|
||||
OnCurrentFrameChanged();
|
||||
}
|
||||
@@ -297,7 +298,7 @@ public sealed class FramesTab : EditorTab
|
||||
|
||||
private static int BitCount(FrameFlags flags) => System.Numerics.BitOperations.PopCount((uint)flags);
|
||||
|
||||
private static FindingItem ToItem(Finding finding) => new(
|
||||
internal static FindingItem ToItem(Finding finding) => new(
|
||||
finding.Severity switch
|
||||
{
|
||||
FindingSeverity.Error => StatusKind.Error,
|
||||
|
||||
@@ -82,7 +82,7 @@ public interface ISequenceSource : IAsyncDisposable
|
||||
/// <summary>A sequence as the editor opens it.</summary>
|
||||
/// <param name="Frames">Frame rows in index order.</param>
|
||||
/// <param name="Light">Light analysis of the frame metadata (BRIEF §10.1).</param>
|
||||
/// <param name="Deep">The saved deep analysis when it describes the current frames, else null.</param>
|
||||
/// <param name="Deep">The saved deep analysis when it describes the current frames, else null (<see cref="DeepOfOtherFrames"/> says why).</param>
|
||||
/// <param name="SourceWidth">Dominant oriented full-resolution width (0 when unknown).</param>
|
||||
/// <param name="ExportsFolder">Default output folder of renders; null when the sequence is not on this PC.</param>
|
||||
/// <param name="Renders">Finished renders, newest first (an empty output path when the file is not on this PC).</param>
|
||||
@@ -104,6 +104,12 @@ public sealed record SequenceContent(
|
||||
|
||||
public int Count => Frames.Count;
|
||||
|
||||
/// <summary>
|
||||
/// A saved deep analysis exists and reads, but describes another number of frames (frames were added or removed since);
|
||||
/// false when there is none or it cannot be read now (archive offline, file moved or damaged, a server that sends none).
|
||||
/// </summary>
|
||||
public bool DeepOfOtherFrames { get; init; }
|
||||
|
||||
/// <summary>Frames the render skips besides the project's exclusions.</summary>
|
||||
public IEnumerable<int> NotRenderable()
|
||||
{
|
||||
|
||||
@@ -100,8 +100,12 @@ public sealed class LocalSequenceSource : ISequenceSource
|
||||
_companions = [.. frames.Select(f => companions.GetValueOrDefault(f.Id))];
|
||||
(_paths, _folder, _files, _frameIds, _framesVersion) = (paths, folder, files, [.. frames.Select(f => f.Id)], sequence.FramesVersion);
|
||||
var context = SequenceContext.FromFrames(frames);
|
||||
return new SequenceContent(sequence, frames, ReadProject(sequence, folder), LightAnalyzer.Analyze(frames), ReadReport(folder, frames.Count),
|
||||
context.SourceWidth, context.SourceHeight, folder.Exports, [.. renders.OrderByDescending(r => r.Created)], SavedCopies.List(folder.MetaDirectory));
|
||||
var (report, otherFrames) = ReadReport(folder, frames.Count);
|
||||
return new SequenceContent(sequence, frames, ReadProject(sequence, folder), LightAnalyzer.Analyze(frames), report,
|
||||
context.SourceWidth, context.SourceHeight, folder.Exports, [.. renders.OrderByDescending(r => r.Created)], SavedCopies.List(folder.MetaDirectory))
|
||||
{
|
||||
DeepOfOtherFrames = otherFrames,
|
||||
};
|
||||
}, cancellationToken);
|
||||
}
|
||||
|
||||
@@ -255,19 +259,19 @@ public sealed class LocalSequenceSource : ISequenceSource
|
||||
private static Guid HeroFrameId(ProjectSettings project, Guid[] frameIds) =>
|
||||
project.HeroFrame is { } hero && (uint)hero < (uint)frameIds.Length ? frameIds[hero] : Guid.Empty;
|
||||
|
||||
/// <summary>The saved deep report when it describes the current frames.</summary>
|
||||
private static DeepAnalysisReport? ReadReport(SequencePaths folder, int frameCount)
|
||||
/// <summary>The saved deep report when it describes the current frames; whether one of another number of frames was read instead.</summary>
|
||||
private static (DeepAnalysisReport? Report, bool OtherFrames) ReadReport(SequencePaths folder, int frameCount)
|
||||
{
|
||||
if (!File.Exists(folder.AnalysisPath)) return null;
|
||||
if (!File.Exists(folder.AnalysisPath)) return (null, false);
|
||||
try
|
||||
{
|
||||
var report = DeepAnalysisReport.Load(folder.AnalysisPath);
|
||||
return report.FrameCount == frameCount ? report : null;
|
||||
return report.FrameCount == frameCount ? (report, false) : (null, true);
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or InvalidDataException or JsonException)
|
||||
{
|
||||
Log.Warning("editor", $"{folder.AnalysisPath} cannot be read", ex);
|
||||
return null;
|
||||
return (null, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,12 +16,11 @@ public sealed class MotionTab : EditorTab
|
||||
: 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");
|
||||
// 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"),
|
||||
|
||||
@@ -7,7 +7,8 @@ namespace Titano.App.Editor;
|
||||
/// cancelled half way (a write is a file plus an index row). A failed write keeps the project pending and is retried
|
||||
/// with a growing delay (2 s doubling up to <see cref="MaxRetryDelay"/>) until it is stored, so nothing is dropped
|
||||
/// while the archive is offline or busy. <see cref="FlushAsync"/> skips the wait and reports whether everything is
|
||||
/// stored after one more attempt. Runs on the context that scheduled the first write (the UI thread).
|
||||
/// stored after one more attempt; <see cref="HoldAsync"/> keeps a failed change as it is while the user decides about
|
||||
/// it. Runs on the context that scheduled the first write (the UI thread).
|
||||
/// </summary>
|
||||
public sealed class ProjectSaver(Func<ProjectSettings, Task> save, TimeSpan delay)
|
||||
{
|
||||
@@ -22,6 +23,15 @@ public sealed class ProjectSaver(Func<ProjectSettings, Task> save, TimeSpan dela
|
||||
private int _failures;
|
||||
private CancellationTokenSource? _wait;
|
||||
|
||||
/// <summary>No write starts until <see cref="Release"/> (or <see cref="Stop"/>): the user is being asked about the pending change.</summary>
|
||||
private bool _held;
|
||||
|
||||
/// <summary>Completes when the hold ends; the loop waits on it instead of writing.</summary>
|
||||
private TaskCompletionSource? _released;
|
||||
|
||||
/// <summary>Completes when the write under way ends (stored or failed, the outcome recorded); null between writes.</summary>
|
||||
private TaskCompletionSource? _writeEnded;
|
||||
|
||||
/// <summary>A write failed: the exception and how many writes in a row failed (1 for the first of a streak).</summary>
|
||||
public event Action<Exception, int>? Failed;
|
||||
|
||||
@@ -69,6 +79,30 @@ public sealed class ProjectSaver(Func<ProjectSettings, Task> save, TimeSpan dela
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Keeps the loop from starting another write until <see cref="Release"/> or <see cref="Stop"/>, once the write under
|
||||
/// way (if any) has ended: a retry that succeeds while the user is asked whether to discard the change would store
|
||||
/// what they are about to drop.
|
||||
/// </summary>
|
||||
/// <returns>True when a change is still not stored (it waits for the user's word); false when everything is stored.</returns>
|
||||
public async Task<bool> HoldAsync()
|
||||
{
|
||||
Task? ended;
|
||||
lock (_gate)
|
||||
{
|
||||
_held = true;
|
||||
ended = _writeEnded?.Task;
|
||||
}
|
||||
if (ended is not null) await ended;
|
||||
lock (_gate) return _pending is not null;
|
||||
}
|
||||
|
||||
/// <summary>Ends <see cref="HoldAsync"/>: the pending change is retried as before (the user kept it).</summary>
|
||||
public void Release()
|
||||
{
|
||||
lock (_gate) ReleaseHold();
|
||||
}
|
||||
|
||||
/// <summary>Drops what is pending and stops retrying (the editor closed and the user chose to discard the change).</summary>
|
||||
public void Stop()
|
||||
{
|
||||
@@ -77,9 +111,17 @@ public sealed class ProjectSaver(Func<ProjectSettings, Task> save, TimeSpan dela
|
||||
_stopped = true;
|
||||
_pending = null;
|
||||
_wait?.Cancel();
|
||||
ReleaseHold();
|
||||
}
|
||||
}
|
||||
|
||||
private void ReleaseHold()
|
||||
{
|
||||
_held = false;
|
||||
_released?.TrySetResult();
|
||||
_released = null;
|
||||
}
|
||||
|
||||
private async Task LoopAsync(Task started)
|
||||
{
|
||||
await started;
|
||||
@@ -103,6 +145,13 @@ public sealed class ProjectSaver(Func<ProjectSettings, Task> save, TimeSpan dela
|
||||
lock (_gate) _wait = null;
|
||||
timer.Dispose();
|
||||
}
|
||||
Task? hold;
|
||||
lock (_gate) hold = _held ? (_released ??= new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously)).Task : null;
|
||||
if (hold is not null)
|
||||
{
|
||||
await hold;
|
||||
continue;
|
||||
}
|
||||
ProjectSettings next;
|
||||
lock (_gate)
|
||||
{
|
||||
@@ -115,26 +164,34 @@ public sealed class ProjectSaver(Func<ProjectSettings, Task> save, TimeSpan dela
|
||||
}
|
||||
next = _pending;
|
||||
_pending = null;
|
||||
// Taken under the lock with the change, so a hold asked for from now on waits for this write.
|
||||
_writeEnded = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||
}
|
||||
int failures;
|
||||
try
|
||||
{
|
||||
await save(next);
|
||||
lock (_gate) _failures = 0;
|
||||
// Started outside the lock (a write may run synchronously up to its first wait).
|
||||
await SaveAsync(next);
|
||||
LastError = null;
|
||||
lock (_gate)
|
||||
{
|
||||
_failures = 0;
|
||||
EndWrite();
|
||||
}
|
||||
// A change made during the write is written right after it.
|
||||
wait = TimeSpan.Zero;
|
||||
continue;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LastError = ex;
|
||||
lock (_gate)
|
||||
{
|
||||
// A newer change contains this one (projects are whole snapshots); otherwise this one waits for the retry.
|
||||
if (!_stopped) _pending ??= next;
|
||||
failures = ++_failures;
|
||||
EndWrite();
|
||||
}
|
||||
LastError = ex;
|
||||
wait = TimeSpan.FromSeconds(double.Min(MaxRetryDelay.TotalSeconds, double.Pow(2, failures)));
|
||||
Failed?.Invoke(ex, failures);
|
||||
// Flushes learn the outcome after the failure was reported.
|
||||
@@ -143,6 +200,25 @@ public sealed class ProjectSaver(Func<ProjectSettings, Task> save, TimeSpan dela
|
||||
}
|
||||
}
|
||||
|
||||
private void EndWrite()
|
||||
{
|
||||
_writeEnded?.TrySetResult();
|
||||
_writeEnded = null;
|
||||
}
|
||||
|
||||
/// <summary>The write as a task, also when <c>save</c> throws before returning one.</summary>
|
||||
private Task SaveAsync(ProjectSettings project)
|
||||
{
|
||||
try
|
||||
{
|
||||
return save(project);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Task.FromException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void Complete(bool stored)
|
||||
{
|
||||
foreach (var flush in _flushes) flush.TrySetResult(stored);
|
||||
|
||||
@@ -125,8 +125,11 @@ public sealed class RemoteSequenceSource : ISequenceSource
|
||||
Created = r.Created,
|
||||
ProducedBy = r.ProducedBy,
|
||||
}).ToList();
|
||||
return new SequenceContent(sequence, frames, project, LightAnalyzer.Analyze(frames), Report(report, frames.Count), context.SourceWidth,
|
||||
context.SourceHeight, null, renders, []);
|
||||
var (deep, otherFrames) = Report(report, frames.Count);
|
||||
return new SequenceContent(sequence, frames, project, LightAnalyzer.Analyze(frames), deep, context.SourceWidth, context.SourceHeight, null, renders, [])
|
||||
{
|
||||
DeepOfOtherFrames = otherFrames,
|
||||
};
|
||||
}, cancellationToken);
|
||||
}
|
||||
|
||||
@@ -403,19 +406,19 @@ public sealed class RemoteSequenceSource : ISequenceSource
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The server's deep report when it describes the frames this PC has.</summary>
|
||||
private DeepAnalysisReport? Report(string? json, int frameCount)
|
||||
/// <summary>The server's deep report when it describes the frames this PC has; whether one of another number of frames came instead.</summary>
|
||||
private (DeepAnalysisReport? Report, bool OtherFrames) Report(string? json, int frameCount)
|
||||
{
|
||||
if (json is null) return null;
|
||||
if (json is null) return (null, false);
|
||||
try
|
||||
{
|
||||
var report = DeepAnalysisReport.FromJson(json);
|
||||
return report.FrameCount == frameCount ? report : null;
|
||||
return report.FrameCount == frameCount ? (report, false) : (null, true);
|
||||
}
|
||||
catch (Exception ex) when (ex is JsonException or InvalidDataException)
|
||||
{
|
||||
Log.Warning("editor", $"The analysis of {_remote.Sequence.DisplayTitle} on the server cannot be read", ex);
|
||||
return null;
|
||||
return (null, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ public sealed class SequenceJobs(Guid sequenceId)
|
||||
public bool IsAnalysing => _active.Values.Any(j => j.Kind == JobKind.DeepAnalyse);
|
||||
|
||||
/// <summary>The job to show: one running, else one paused, else the oldest waiting; null when there is none.</summary>
|
||||
public Job? Shown => _active.Values
|
||||
.OrderBy(j => j.State switch { JobState.Running => 0, JobState.Paused => 1, _ => 2 })
|
||||
.ThenBy(j => j.Started ?? j.Created)
|
||||
.FirstOrDefault();
|
||||
public Job? Shown => First(_active.Values);
|
||||
|
||||
/// <summary>The job of <paramref name="kind"/> to show, chosen as <see cref="Shown"/> is (the Edit path's steps).</summary>
|
||||
public Job? Active(JobKind kind) => First(_active.Values.Where(j => j.Kind == kind));
|
||||
|
||||
/// <summary>An analysis or render of this sequence.</summary>
|
||||
public bool Concerns(Job job)
|
||||
@@ -43,4 +43,9 @@ public sealed class SequenceJobs(Guid sequenceId)
|
||||
_active[job.Id] = job;
|
||||
return changed;
|
||||
}
|
||||
|
||||
private static Job? First(IEnumerable<Job> jobs) => jobs
|
||||
.OrderBy(j => j.State switch { JobState.Running => 0, JobState.Paused => 1, _ => 2 })
|
||||
.ThenBy(j => j.Started ?? j.Created)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
@@ -182,7 +182,7 @@ public sealed class AppServices : IAsyncDisposable
|
||||
ApplyJobSettings();
|
||||
}
|
||||
|
||||
/// <summary>Writes the settings file and nothing else: for choices that change only what is shown (the rail).</summary>
|
||||
/// <summary>Writes the settings file and nothing else: for choices that change only what is shown (the rail, the sequence edited last).</summary>
|
||||
public void SavePreferences() => SaveSettingsAction();
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -65,6 +65,9 @@ public sealed class AppSettings
|
||||
public AppTheme Theme { get; set; } = AppTheme.Dark;
|
||||
public bool RailCollapsed { get; set; }
|
||||
|
||||
/// <summary>The sequence opened in Edit last; the picker selects it first (owner review 1, R7).</summary>
|
||||
public Guid? LastEditedSequence { get; set; }
|
||||
|
||||
/// <summary>The first-run consent of BRIEF §21; offered only by builds with <see cref="ProductFeatures.AdsEnabled"/>.</summary>
|
||||
public bool AnonymousUsageCounts { get; set; }
|
||||
|
||||
|
||||
@@ -76,6 +76,9 @@ public sealed class SequenceItem : ObservableObject
|
||||
/// <summary>User title or "{date} {camera}".</summary>
|
||||
public string Title => _sequence.DisplayTitle;
|
||||
|
||||
/// <summary>The title (what UI Automation reads for a row a list has not realised).</summary>
|
||||
public override string ToString() => Title;
|
||||
|
||||
/// <summary>"Canon EOS R5" (brand not repeated).</summary>
|
||||
public string Camera => PathTemplate.CameraName(_sequence.CameraMake, _sequence.CameraModel);
|
||||
|
||||
|
||||
@@ -11,14 +11,17 @@
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
<ResourceDictionary Source="pack://application:,,,/Titano;component/Archive/ArchiveDialogs.xaml" />
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
<!-- A double-click is read on the card or row itself: it takes the mouse-down to select, so a gesture on the list never sees it. -->
|
||||
<Style x:Key="ListBoxItem.LibraryCard" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Card}">
|
||||
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
|
||||
<Setter Property="AutomationProperties.Name" Value="{Binding Title}" />
|
||||
<EventSetter Event="MouseDoubleClick" Handler="OnItemDoubleClick" />
|
||||
</Style>
|
||||
<Style x:Key="ListBoxItem.LibraryRow" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Row}">
|
||||
<Setter Property="Height" Value="38" />
|
||||
<Setter Property="IsSelected" Value="{Binding IsSelected, Mode=TwoWay}" />
|
||||
<Setter Property="AutomationProperties.Name" Value="{Binding Title}" />
|
||||
<EventSetter Event="MouseDoubleClick" Handler="OnItemDoubleClick" />
|
||||
</Style>
|
||||
<Style x:Key="Button.Header" TargetType="Button" BasedOn="{StaticResource Button.Subtle}">
|
||||
<Setter Property="Height" Value="28" />
|
||||
@@ -202,7 +205,6 @@
|
||||
Visibility="{Binding IsGrid, Converter={StaticResource BoolToVisibility}}" AutomationProperties.Name="{l:Loc Shell.Nav.Library}"
|
||||
ScrollViewer.ScrollChanged="OnScrollChanged" KeyboardNavigation.TabNavigation="Continue">
|
||||
<ListBox.InputBindings>
|
||||
<MouseBinding Gesture="LeftDoubleClick" Command="{Binding OpenCommand}" />
|
||||
<KeyBinding Key="Enter" Command="{Binding OpenCommand}" />
|
||||
</ListBox.InputBindings>
|
||||
<ListBox.ItemTemplate>
|
||||
@@ -266,7 +268,6 @@
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.ScrollChanged="OnScrollChanged" AutomationProperties.Name="{l:Loc Shell.Nav.Library}"
|
||||
KeyboardNavigation.TabNavigation="Continue">
|
||||
<ListBox.InputBindings>
|
||||
<MouseBinding Gesture="LeftDoubleClick" Command="{Binding OpenCommand}" />
|
||||
<KeyBinding Key="Enter" Command="{Binding OpenCommand}" />
|
||||
</ListBox.InputBindings>
|
||||
<ListBox.ItemTemplate>
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Threading;
|
||||
using Titano.App.Library;
|
||||
using Titano.Ui.Visuals;
|
||||
@@ -26,6 +27,21 @@ public partial class LibraryView : UserControl
|
||||
if (e.VerticalOffset + e.ViewportHeight >= e.ExtentHeight - 2 * Math.Max(e.ViewportHeight, 200)) _ = vm.LoadMoreAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A double-click on a card or a row opens its sequence (the left button only; not on one of its own buttons, which act
|
||||
/// on their own).
|
||||
/// </summary>
|
||||
private void OnItemDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.ChangedButton != MouseButton.Left || sender is not ListBoxItem { DataContext: SequenceItem item } container || Model is not { } vm) return;
|
||||
for (var node = Mouse.DirectlyOver as DependencyObject; node is not null && !ReferenceEquals(node, container); node = VisualTreeHelper.GetParent(node))
|
||||
{
|
||||
if (node is ButtonBase) return;
|
||||
}
|
||||
if (vm.OpenItemCommand.CanExecute(item)) vm.OpenItemCommand.Execute(item);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
/// <summary>A month of the timeline: the Library narrows to its year and the grid scrolls to it.</summary>
|
||||
private void OnSlotActivated(object sender, ChartItemEventArgs e) => Model?.ShowSlot(e.Row, e.Column);
|
||||
|
||||
|
||||
@@ -521,6 +521,12 @@ public sealed class LibraryViewModel : SectionViewModel
|
||||
/// <summary>The screen behind an open dialog takes neither clicks nor keyboard focus.</summary>
|
||||
public bool IsContentEnabled => _dialog is null;
|
||||
|
||||
/// <summary>The signed-in server's sequences without a copy here, as of the last read of the sync table (Edit's picker lists them too).</summary>
|
||||
internal IReadOnlyList<Sequence> RemoteSequences => _remote;
|
||||
|
||||
/// <summary>Thumbnails of <see cref="RemoteSequences"/>, fetched from the server.</summary>
|
||||
internal ISequenceThumbnails RemoteThumbnails => _remoteThumbnails;
|
||||
|
||||
// ---------------- Lifecycle ----------------
|
||||
|
||||
/// <summary>Binds to the index and loads filters, totals, saved views, the server's cards and the first page.</summary>
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
<UserControl x:Class="Titano.App.Sections.SequencePickerView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:ui="clr-namespace:Titano.Ui.Controls;assembly=Titano.Ui"
|
||||
xmlns:v="clr-namespace:Titano.Ui.Visuals;assembly=Titano.Ui"
|
||||
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
|
||||
xmlns:lib="clr-namespace:Titano.App.Library"
|
||||
IsVisibleChanged="OnVisibleChanged">
|
||||
<!--
|
||||
The sequence picker of Edit (owner review 1, R7), over the section's view model: one searchable list of this PC's and
|
||||
the server's sequences, newest first; Enter or a double-click opens one, Esc clears the search and then goes back to
|
||||
the open sequence. Each row reads as its title to screen readers; the date, frames and states columns are as wide as
|
||||
their widest row, so the states are never cut.
|
||||
-->
|
||||
<UserControl.Resources>
|
||||
<DataTemplate x:Key="Template.Status" DataType="{x:Type v:CardStatus}">
|
||||
<ui:StatusGlyph Kind="{Binding Kind}" Text="{Binding Text}" ToolTip="{Binding ToolTip}" Margin="0,0,8,0" />
|
||||
</DataTemplate>
|
||||
<ItemsPanelTemplate x:Key="Panel.Row">
|
||||
<StackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
<!-- A double-click is read on the row itself: the row takes the mouse-down to select, so a gesture on the list never sees it. -->
|
||||
<Style x:Key="ListBoxItem.PickerRow" TargetType="ListBoxItem" BasedOn="{StaticResource ListBoxItem.Row}">
|
||||
<Setter Property="AutomationProperties.Name" Value="{Binding Title}" />
|
||||
<EventSetter Event="MouseDoubleClick" Handler="OnRowDoubleClick" />
|
||||
</Style>
|
||||
</UserControl.Resources>
|
||||
|
||||
<Border Style="{StaticResource Border.Panel}" MaxWidth="880" Margin="16,24,16,16">
|
||||
<Grid>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="56" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="6" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<DockPanel Margin="16,0">
|
||||
<TextBlock DockPanel.Dock="Left" Text="{l:Loc Editor.Picker.Title}" Style="{StaticResource Text.Title}" VerticalAlignment="Center" Margin="0,0,16,0"
|
||||
TextTrimming="CharacterEllipsis" MaxWidth="220" />
|
||||
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Primary}" Content="{l:Loc Common.Open}" Command="{Binding Picker.OpenCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Editor.Picker.Open}" ToolTipService.ShowOnDisabled="True" VerticalAlignment="Center" Margin="8,0,0,0" />
|
||||
<Button DockPanel.Dock="Right" Content="{l:Loc Editor.Picker.Cancel}" Command="{Binding CancelPickCommand}" ToolTip="{Binding CancelPickToolTip}"
|
||||
VerticalAlignment="Center" Margin="8,0,0,0" Visibility="{Binding CanCancelPick, Converter={StaticResource BoolToVisibility}}" />
|
||||
<TextBox x:Name="Search" MaxWidth="360" HorizontalAlignment="Left" VerticalAlignment="Center" Text="{Binding Picker.SearchText, UpdateSourceTrigger=PropertyChanged}"
|
||||
ui:Field.Glyph="{StaticResource Icon.Search}" ui:Field.Placeholder="{l:Loc Library.Search}" ToolTip="{l:Loc Tooltips.Editor.Picker.Search}"
|
||||
AutomationProperties.Name="{l:Loc Library.Search}" PreviewKeyDown="OnSearchKeyDown" />
|
||||
</DockPanel>
|
||||
|
||||
<!-- A server sequence chosen without its proxies here: they download first, then it opens. -->
|
||||
<DockPanel Grid.Row="1" Margin="16,0,16,8" Visibility="{Binding FetchingText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
|
||||
<Button DockPanel.Dock="Right" Style="{StaticResource Button.Link}" Content="{l:Loc Shell.Nav.Jobs}" Command="{Binding OpenJobsCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Nav.Jobs}" Margin="8,0,0,0" VerticalAlignment="Center" />
|
||||
<ui:StatusGlyph Kind="Running" Text="{Binding FetchingText}" ToolTip="{Binding FetchingText}" VerticalAlignment="Center" />
|
||||
</DockPanel>
|
||||
|
||||
<ProgressBar Grid.Row="2" Margin="16,0" Height="6" IsIndeterminate="True" Visibility="{Binding Picker.IsLoading, Converter={StaticResource BoolToVisibility}}"
|
||||
AutomationProperties.Name="{l:Loc Editor.Picker.Loading}" />
|
||||
|
||||
<ListBox x:Name="List" Grid.Row="3" Margin="0,4,0,8" ItemsSource="{Binding Picker.Items}" SelectedItem="{Binding Picker.Selected}" SelectionMode="Single"
|
||||
ItemContainerStyle="{StaticResource ListBoxItem.PickerRow}" TextSearch.TextPath="Title" VirtualizingPanel.IsVirtualizing="True"
|
||||
VirtualizingPanel.VirtualizationMode="Recycling" VirtualizingPanel.ScrollUnit="Pixel" ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.ScrollChanged="OnScrollChanged" AutomationProperties.Name="{l:Loc Editor.Picker.List}" ToolTip="{l:Loc Tooltips.Editor.Picker.Row}"
|
||||
KeyboardNavigation.TabNavigation="Continue" Grid.IsSharedSizeScope="True" SelectionChanged="OnSelectionChanged">
|
||||
<ListBox.InputBindings>
|
||||
<KeyBinding Key="Enter" Command="{Binding Picker.OpenCommand}" />
|
||||
</ListBox.InputBindings>
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type lib:SequenceItem}">
|
||||
<Grid Height="40">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="2*" MinWidth="140" />
|
||||
<ColumnDefinition Width="Auto" MinWidth="84" SharedSizeGroup="PickerDate" />
|
||||
<ColumnDefinition Width="*" MinWidth="80" />
|
||||
<ColumnDefinition Width="Auto" MinWidth="56" SharedSizeGroup="PickerFrames" />
|
||||
<ColumnDefinition Width="Auto" SharedSizeGroup="PickerStates" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<!-- Pictures stay left to right in a right-to-left window. -->
|
||||
<Border Width="64" Height="36" CornerRadius="4" Background="{DynamicResource Brush.Card}" ClipToBounds="True" FlowDirection="LeftToRight"
|
||||
lib:ThumbnailLoading.Width="64">
|
||||
<Image Source="{Binding Thumbnail}" Stretch="UniformToFill" />
|
||||
</Border>
|
||||
<!-- Cells that may be shortened show their text in their tooltip (an empty camera has none). -->
|
||||
<TextBlock Grid.Column="1" Style="{StaticResource Text.Cell}" Text="{Binding Title}" Margin="12,0,0,0" FontWeight="SemiBold" ToolTip="{Binding Title}" />
|
||||
<TextBlock Grid.Column="2" Style="{StaticResource Text.Cell}" Text="{Binding DateText}" Margin="12,0,0,0" Foreground="{DynamicResource Brush.TextMuted}" />
|
||||
<TextBlock Grid.Column="3" Style="{StaticResource Text.Cell}" Text="{Binding Camera}" Margin="12,0,0,0" Foreground="{DynamicResource Brush.TextMuted}"
|
||||
ToolTip="{Binding Camera, Converter={x:Static ui:EmptyToNullConverter.Instance}}" />
|
||||
<TextBlock Grid.Column="4" Style="{StaticResource Text.CellNumber}" Text="{Binding FramesText}" Margin="12,0,0,0" />
|
||||
<ItemsControl Grid.Column="5" Margin="12,0,0,0" ItemsSource="{Binding Statuses}" ItemTemplate="{StaticResource Template.Status}"
|
||||
ItemsPanel="{StaticResource Panel.Row}" VerticalAlignment="Center" Focusable="False" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<ui:EmptyState Grid.Row="3" Message="{l:Loc Library.Empty}" Visibility="{Binding Picker.IsEmptyLibrary, Converter={StaticResource BoolToVisibility}}">
|
||||
<Button Style="{StaticResource Button.Primary}" Content="{l:Loc Shell.Nav.Import}" Command="{Binding OpenImportCommand}" ToolTip="{l:Loc Tooltips.Nav.Import}" />
|
||||
</ui:EmptyState>
|
||||
<ui:EmptyState Grid.Row="3" Message="{l:Loc Editor.Picker.NoMatch}" Visibility="{Binding Picker.IsNoMatch, Converter={StaticResource BoolToVisibility}}">
|
||||
<Button Content="{l:Loc Editor.Picker.Clear}" Command="{Binding Picker.ClearCommand}" ToolTip="{l:Loc Tooltips.Editor.Picker.Clear}" />
|
||||
</ui:EmptyState>
|
||||
</Grid>
|
||||
</Border>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,112 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using Titano.App.Library;
|
||||
|
||||
namespace Titano.App.Sections;
|
||||
|
||||
/// <summary>
|
||||
/// The picker's keyboard and mouse: the search box takes the focus when the picker shows, ↓ goes to the list, Enter opens
|
||||
/// the selected sequence (else the first) once the list has caught up with what was typed, Esc clears the search and then
|
||||
/// goes back to the open sequence; a double-click opens a row. The selected row is always scrolled into view.
|
||||
/// </summary>
|
||||
public partial class SequencePickerView : UserControl
|
||||
{
|
||||
public SequencePickerView()
|
||||
{
|
||||
InitializeComponent();
|
||||
PreviewKeyDown += OnPreviewKeyDown;
|
||||
}
|
||||
|
||||
private SequenceViewModel? Section => DataContext as SequenceViewModel;
|
||||
|
||||
private void OnVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.NewValue is not true) return;
|
||||
Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
if (!IsVisible) return;
|
||||
// Logical focus first, so the search box has it also in a window that is not active yet.
|
||||
FocusManager.SetFocusedElement(FocusManager.GetFocusScope(Search), Search);
|
||||
Keyboard.Focus(Search);
|
||||
// Selected while the picker was hidden, or before the view existed (arriving in Edit).
|
||||
if (List.SelectedItem is { } item) List.ScrollIntoView(item);
|
||||
}, DispatcherPriority.Input);
|
||||
}
|
||||
|
||||
/// <summary>The selected row is in view: the one chosen first when the list loads, after each search, after ↓.</summary>
|
||||
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (List.SelectedItem is { } item) List.ScrollIntoView(item);
|
||||
}
|
||||
|
||||
/// <summary>A double-click on a row opens it (the left button only).</summary>
|
||||
private void OnRowDoubleClick(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.ChangedButton != MouseButton.Left || sender is not ListBoxItem { DataContext: SequenceItem item } || Section is not { } section) return;
|
||||
if (section.Picker.OpenItemCommand.CanExecute(item)) section.Picker.OpenItemCommand.Execute(item);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
/// <summary>Esc anywhere in the picker: the search first, then back to the open sequence.</summary>
|
||||
private void OnPreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key != Key.Escape || Section is not { } section) return;
|
||||
if (section.Picker.SearchText.Length > 0)
|
||||
{
|
||||
section.Picker.SearchText = string.Empty;
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (section.CancelPickCommand.CanExecute(null))
|
||||
{
|
||||
section.CancelPickCommand.Execute(null);
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// In the search box, Enter opens the selected sequence and ↓ moves to it in the list, both once the list matches what
|
||||
/// was typed (a key pressed within the search's 250 ms acts on the new list, not on the old one).
|
||||
/// </summary>
|
||||
private void OnSearchKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (Section is not { } section) return;
|
||||
switch (e.Key)
|
||||
{
|
||||
case Key.Enter:
|
||||
if (section.Picker.SearchOpenCommand.CanExecute(null)) section.Picker.SearchOpenCommand.Execute(null);
|
||||
e.Handled = true;
|
||||
break;
|
||||
case Key.Down:
|
||||
e.Handled = true;
|
||||
_ = DownAsync(section);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DownAsync(SequenceViewModel section)
|
||||
{
|
||||
await section.Picker.SettleAsync();
|
||||
if (!section.ShowsPicker || section.Picker.Items.Count == 0) return;
|
||||
section.Picker.Selected ??= section.Picker.Items[0];
|
||||
FocusSelectedRow();
|
||||
}
|
||||
|
||||
private void FocusSelectedRow()
|
||||
{
|
||||
if (List.SelectedItem is not { } item) return;
|
||||
List.ScrollIntoView(item);
|
||||
Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
if (List.ItemContainerGenerator.ContainerFromItem(item) is ListBoxItem row) row.Focus();
|
||||
}, DispatcherPriority.Loaded);
|
||||
}
|
||||
|
||||
/// <summary>The next page when the list nears its end.</summary>
|
||||
private void OnScrollChanged(object sender, ScrollChangedEventArgs e)
|
||||
{
|
||||
if (Section is not { } section || e.ExtentHeight <= 0) return;
|
||||
if (e.VerticalOffset + e.ViewportHeight >= e.ExtentHeight - 2 * Math.Max(e.ViewportHeight, 200)) _ = section.Picker.LoadMoreAsync();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using Titano.App.Library;
|
||||
using Titano.App.Shell;
|
||||
using Titano.Core.Model;
|
||||
using Titano.Data;
|
||||
using Titano.Data.Repositories;
|
||||
using Titano.Ui.Mvvm;
|
||||
|
||||
namespace Titano.App.Sections;
|
||||
|
||||
/// <summary>
|
||||
/// The sequence picker of the Edit section (owner review 1, R7): this PC's sequences and, while signed in, the server's
|
||||
/// sequences without a copy here, newest first, searched by title, camera or tag as the user types (after 250 ms, like
|
||||
/// the Library) and read page by page as the list scrolls. One sequence is chosen and opened; when the list loads, the
|
||||
/// open sequence is selected, else the one edited last (pages are read until it is listed), else the first.
|
||||
/// </summary>
|
||||
public sealed class SequencePickerViewModel : LocalizedViewModel
|
||||
{
|
||||
private readonly SequenceViewModel _section;
|
||||
private readonly DispatcherTimer _searchDelay;
|
||||
private readonly RemoteMerge _merge = new();
|
||||
private readonly AsyncRelayCommand _open;
|
||||
private LibraryPager? _pager;
|
||||
private string _searchText = string.Empty;
|
||||
private SequenceItem? _selected;
|
||||
private bool _isLoading;
|
||||
private bool _hasLoaded;
|
||||
private Task _loading = Task.CompletedTask;
|
||||
private int _pageSize = LibraryPager.DefaultPageSize;
|
||||
|
||||
/// <summary>Counts reloads, so a reload that a newer one replaced stops reading pages.</summary>
|
||||
private int _generation;
|
||||
|
||||
public SequencePickerViewModel(SequenceViewModel section)
|
||||
{
|
||||
_section = section;
|
||||
_searchDelay = new DispatcherTimer { Interval = TimeSpan.FromMilliseconds(250) };
|
||||
_searchDelay.Tick += (_, _) => _ = ReloadAsync();
|
||||
_open = new AsyncRelayCommand(() => (Selected ?? Items.FirstOrDefault()) is { } item ? _section.PickAsync(item) : Task.CompletedTask, () => Items.Count > 0);
|
||||
OpenItemCommand = new AsyncRelayCommand((p, _) => p is SequenceItem item ? _section.PickAsync(item) : Task.CompletedTask);
|
||||
SearchOpenCommand = new AsyncRelayCommand(OpenFromSearchAsync);
|
||||
ClearCommand = new RelayCommand(() => SearchText = string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>The sequences listed, in order.</summary>
|
||||
public ObservableCollection<SequenceItem> Items { get; } = [];
|
||||
|
||||
/// <summary>Title, camera or tag text; the list follows a moment after the last key.</summary>
|
||||
public string SearchText
|
||||
{
|
||||
get => _searchText;
|
||||
set
|
||||
{
|
||||
if (!Set(ref _searchText, value ?? string.Empty)) return;
|
||||
_searchDelay.Stop();
|
||||
_searchDelay.Start();
|
||||
}
|
||||
}
|
||||
|
||||
public SequenceItem? Selected
|
||||
{
|
||||
get => _selected;
|
||||
set => Set(ref _selected, value);
|
||||
}
|
||||
|
||||
/// <summary>A page is being read (the thin bar under the toolbar).</summary>
|
||||
public bool IsLoading
|
||||
{
|
||||
get => _isLoading;
|
||||
private set => Set(ref _isLoading, value);
|
||||
}
|
||||
|
||||
/// <summary>There is no sequence at all: Import is offered.</summary>
|
||||
public bool IsEmptyLibrary => _hasLoaded && !_isLoading && Items.Count == 0 && string.IsNullOrWhiteSpace(_searchText);
|
||||
|
||||
/// <summary>The search matches nothing: Clear search is offered.</summary>
|
||||
public bool IsNoMatch => _hasLoaded && !_isLoading && Items.Count == 0 && !string.IsNullOrWhiteSpace(_searchText);
|
||||
|
||||
/// <summary>The list read last (capture and tests wait for it).</summary>
|
||||
public Task Loading => _loading;
|
||||
|
||||
/// <summary>Opens the selected sequence, else the first listed (Enter).</summary>
|
||||
public ICommand OpenCommand => _open;
|
||||
|
||||
/// <summary>Opens a row (double-click, Enter in the list).</summary>
|
||||
public ICommand OpenItemCommand { get; }
|
||||
|
||||
/// <summary>Enter in the search box: once the list matches what was typed, opens its selected sequence, else its first.</summary>
|
||||
public ICommand SearchOpenCommand { get; }
|
||||
|
||||
public ICommand ClearCommand { get; }
|
||||
|
||||
/// <summary>Rows read per page (tests set a small one; the next read uses it).</summary>
|
||||
internal int PageSize
|
||||
{
|
||||
get => _pageSize;
|
||||
set
|
||||
{
|
||||
_pageSize = value;
|
||||
_pager?.Cancel();
|
||||
_pager = null;
|
||||
}
|
||||
}
|
||||
|
||||
private ShellViewModel Shell => _section.Shell;
|
||||
|
||||
/// <summary>Reads the list again from its first page (the picker shows, the search changed).</summary>
|
||||
public Task ReloadAsync()
|
||||
{
|
||||
_searchDelay.Stop();
|
||||
_generation++;
|
||||
_loading = LoadFirstAsync();
|
||||
return _loading;
|
||||
}
|
||||
|
||||
/// <summary>Completes once the list matches the search text: a search still waiting for its 250 ms runs now.</summary>
|
||||
public async Task SettleAsync()
|
||||
{
|
||||
if (_searchDelay.IsEnabled) await ReloadAsync();
|
||||
else await _loading;
|
||||
}
|
||||
|
||||
/// <summary>The next page, when the list scrolled near its end.</summary>
|
||||
public Task LoadMoreAsync()
|
||||
{
|
||||
if (_pager is not { HasMore: true, IsLoading: false }) return Task.CompletedTask;
|
||||
_loading = ApplyAsync(_pager.LoadMoreAsync(), first: false);
|
||||
return _loading;
|
||||
}
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
_searchDelay.Stop();
|
||||
_pager?.Cancel();
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
private async Task OpenFromSearchAsync()
|
||||
{
|
||||
await SettleAsync();
|
||||
if (_section.ShowsPicker && (Selected ?? Items.FirstOrDefault()) is { } item) await _section.PickAsync(item);
|
||||
}
|
||||
|
||||
private async Task LoadFirstAsync()
|
||||
{
|
||||
var generation = _generation;
|
||||
var filter = new LibraryFilter { Text = string.IsNullOrWhiteSpace(_searchText) ? null : _searchText.Trim(), Sort = SequenceSort.Newest };
|
||||
_merge.Reset(filter, Shell.Library.RemoteSequences);
|
||||
if (Shell.Services.Database is not { } db)
|
||||
{
|
||||
// Still opening: neither "no sequences" nor Import yet (the shell reads the list again once the index is open).
|
||||
if (Shell.Services.OpenError is null) return;
|
||||
// No index (it could not open): the server's sequences alone, if any.
|
||||
await ApplyAsync(Task.FromResult<LibraryPage?>(new LibraryPage(0, [], IsFirst: true, HasMore: false)), first: true);
|
||||
return;
|
||||
}
|
||||
_pager ??= new LibraryPager((q, ct) => db.Sequences.ListAsync(q, ct), PageSize);
|
||||
await ApplyAsync(_pager.ResetAsync(filter), first: true);
|
||||
// The sequence to select may be older than the first page: without a search every sequence is listed, newest first,
|
||||
// so the pages are read until it comes (it exists), then it is selected.
|
||||
if (filter.Text is not null || Wanted is not { } wanted || Items.Any(i => i.Id == wanted)) return;
|
||||
if (await db.Sequences.GetAsync(wanted) is null && Shell.Library.RemoteSequences.All(s => s.Id != wanted)) return;
|
||||
while (generation == _generation && _pager is { HasMore: true } pager && Items.All(i => i.Id != wanted))
|
||||
await ApplyAsync(pager.LoadMoreAsync(), first: false);
|
||||
if (generation == _generation) Preselect();
|
||||
}
|
||||
|
||||
private async Task ApplyAsync(Task<LibraryPage?> pending, bool first)
|
||||
{
|
||||
IsLoading = true;
|
||||
RaiseStates();
|
||||
try
|
||||
{
|
||||
if (await pending is not { } page) return;
|
||||
if (page.IsFirst) Items.Clear();
|
||||
foreach (var sequence in _merge.Merge(page.Items, last: !page.HasMore))
|
||||
{
|
||||
var remote = sequence is { Origin: SequenceOrigin.Server, SyncState: SyncState.RemoteOnly };
|
||||
Items.Add(new SequenceItem(sequence, remote ? Shell.Library.RemoteThumbnails : Shell.Services.Thumbnails as ISequenceThumbnails));
|
||||
}
|
||||
_hasLoaded = true;
|
||||
if (first) Preselect();
|
||||
}
|
||||
catch (Exception ex) when (ex is DatabaseException or InvalidOperationException)
|
||||
{
|
||||
Shell.ReportError(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsLoading = _pager?.IsLoading ?? false;
|
||||
RaiseStates();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The sequence selected first: the open one, else the one edited last.</summary>
|
||||
private Guid? Wanted => _section.OpenSequenceId ?? Shell.Services.Settings.LastEditedSequence;
|
||||
|
||||
/// <summary>The open sequence, else the one edited last, else the first.</summary>
|
||||
private void Preselect()
|
||||
{
|
||||
var wanted = Wanted;
|
||||
Selected = Items.FirstOrDefault(i => i.Id == wanted) ?? Items.FirstOrDefault();
|
||||
}
|
||||
|
||||
private void RaiseStates()
|
||||
{
|
||||
OnPropertyChanged(nameof(IsEmptyLibrary));
|
||||
OnPropertyChanged(nameof(IsNoMatch));
|
||||
_open.RaiseCanExecuteChanged();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,8 @@
|
||||
xmlns:ui="clr-namespace:Titano.Ui.Controls;assembly=Titano.Ui"
|
||||
xmlns:v="clr-namespace:Titano.Ui.Visuals;assembly=Titano.Ui"
|
||||
xmlns:l="clr-namespace:Titano.Ui.Localization;assembly=Titano.Ui"
|
||||
xmlns:infra="clr-namespace:Titano.App.Infrastructure"
|
||||
xmlns:sections="clr-namespace:Titano.App.Sections"
|
||||
KeyDown="OnKeyDown" Loaded="OnLoaded">
|
||||
<UserControl.Resources>
|
||||
<ResourceDictionary>
|
||||
@@ -12,187 +14,261 @@
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</UserControl.Resources>
|
||||
<UserControl.InputBindings>
|
||||
<!-- Owner review 1, R7: the picker over the open sequence. -->
|
||||
<KeyBinding Key="O" Modifiers="Control" Command="{Binding ChangeSequenceCommand}" />
|
||||
</UserControl.InputBindings>
|
||||
|
||||
<Grid>
|
||||
<ui:EmptyState Message="{l:Loc Editor.Empty}" Visibility="{Binding IsEmpty, Converter={StaticResource BoolToVisibility}}">
|
||||
<Button Style="{StaticResource Button.Primary}" Content="{l:Loc Shell.Nav.Library}" Command="{Binding OpenLibraryCommand}" ToolTip="{l:Loc Tooltips.Nav.Library}" />
|
||||
</ui:EmptyState>
|
||||
<ProgressBar Width="240" IsIndeterminate="True" VerticalAlignment="Center" Visibility="{Binding IsLoading, Converter={StaticResource BoolToVisibility}}"
|
||||
AutomationProperties.Name="{l:Loc Editor.Loading}" />
|
||||
|
||||
<!-- Editor.html: header, then the preview, filmstrip and section tabs on the left and the section's settings on the right. -->
|
||||
<Grid x:Name="EditorRoot" DataContext="{Binding Editor}" Margin="16,0,16,12" IsVisibleChanged="OnEditorVisibleChanged"
|
||||
Visibility="{Binding Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
|
||||
<Grid.InputBindings>
|
||||
<KeyBinding Key="Z" Modifiers="Control" Command="{Binding UndoCommand}" />
|
||||
<KeyBinding Key="Y" Modifiers="Control" Command="{Binding RedoCommand}" />
|
||||
<KeyBinding Key="D0" Modifiers="Control" Command="{Binding FitCommand}" />
|
||||
<KeyBinding Key="D1" Modifiers="Control+Shift" Command="{Binding ActualSizeCommand}" />
|
||||
<KeyBinding Key="R" Modifiers="Control" Command="{Binding RenderCommand}" />
|
||||
<KeyBinding Key="A" Modifiers="Control+Shift" Command="{Binding AnalyseCommand}" />
|
||||
</Grid.InputBindings>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="52" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
<!--
|
||||
The open sequence stays laid out behind the picker (hidden, not collapsed: collapsing it would shrink the preview
|
||||
and render it again when it comes back), and while a switch is under way (the progress bar shows).
|
||||
-->
|
||||
<Grid x:Name="EditorHost">
|
||||
<Grid.Style>
|
||||
<Style TargetType="Grid">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsPicking}" Value="True">
|
||||
<Setter Property="Visibility" Value="Hidden" />
|
||||
</DataTrigger>
|
||||
<DataTrigger Binding="{Binding IsLoading}" Value="True">
|
||||
<Setter Property="Visibility" Value="Hidden" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Grid.Style>
|
||||
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Style="{StaticResource Button.IconSubtle}" ui:ButtonIcon.Glyph="{StaticResource Icon.Back}" Command="{Binding BackCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Editor.Back}" AutomationProperties.Name="{l:Loc Editor.Back}" Margin="-6,0,0,0" />
|
||||
<!-- The title, where a server sequence edited with proxies lives (read-only or out of date says so) and the summary share what the server
|
||||
job and the actions leave, and give way first: each ends in an ellipsis. -->
|
||||
<DockPanel Grid.Column="1" VerticalAlignment="Center">
|
||||
<TextBlock DockPanel.Dock="Left" Text="{Binding Title}" Style="{StaticResource Text.Title}" VerticalAlignment="Center" Margin="6,0,12,0" MaxWidth="320"
|
||||
TextTrimming="CharacterEllipsis" ToolTip="{Binding Title}" />
|
||||
<ui:StatusGlyph DockPanel.Dock="Left" Kind="Remote" Text="{Binding RemoteText}" ToolTip="{Binding RemoteToolTip}" FontSize="{StaticResource Size.Body}" Margin="0,0,12,0"
|
||||
MaxWidth="220" VerticalAlignment="Center" Visibility="{Binding IsRemote, Converter={StaticResource BoolToVisibility}}" />
|
||||
<TextBlock Text="{Binding Summary}" Style="{StaticResource Text.Secondary}" FontSize="{StaticResource Size.Body}" VerticalAlignment="Center"
|
||||
TextTrimming="CharacterEllipsis" Typography.NumeralAlignment="Tabular" ToolTip="{Binding Summary}" />
|
||||
</DockPanel>
|
||||
<!-- The server job: its bar, what it is and how far, and Cancel, which always stays (BRIEF §11.5): its own column, so the title gives way
|
||||
before it at the minimum window. -->
|
||||
<Grid Grid.Column="2" Margin="12,0,0,0" MaxWidth="300" VerticalAlignment="Center"
|
||||
Visibility="{Binding ServerJobText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
|
||||
<!-- Editor.html: header, the step bar, then the preview, filmstrip and the step's measure on the left and its column on the right. -->
|
||||
<Grid x:Name="EditorRoot" DataContext="{Binding Editor}" Margin="16,0,16,12" IsVisibleChanged="OnEditorVisibleChanged"
|
||||
PreviewKeyDown="OnEditorPreviewKeyDown" Visibility="{Binding Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
|
||||
<Grid.InputBindings>
|
||||
<KeyBinding Key="Z" Modifiers="Control" Command="{Binding UndoCommand}" />
|
||||
<KeyBinding Key="Y" Modifiers="Control" Command="{Binding RedoCommand}" />
|
||||
<KeyBinding Key="D0" Modifiers="Control" Command="{Binding FitCommand}" />
|
||||
<KeyBinding Key="D1" Modifiers="Control+Shift" Command="{Binding ActualSizeCommand}" />
|
||||
<KeyBinding Key="R" Modifiers="Control" Command="{Binding RenderCommand}" />
|
||||
<KeyBinding Key="A" Modifiers="Control+Shift" Command="{Binding AnalyseCommand}" />
|
||||
<!-- Steps by number; no Alt+NumPad bindings, which type characters into text fields. -->
|
||||
<KeyBinding Key="D1" Modifiers="Alt" Command="{Binding GoToStepCommand}" CommandParameter="1" />
|
||||
<KeyBinding Key="D2" Modifiers="Alt" Command="{Binding GoToStepCommand}" CommandParameter="2" />
|
||||
<KeyBinding Key="D3" Modifiers="Alt" Command="{Binding GoToStepCommand}" CommandParameter="3" />
|
||||
<KeyBinding Key="D4" Modifiers="Alt" Command="{Binding GoToStepCommand}" CommandParameter="4" />
|
||||
<KeyBinding Key="D5" Modifiers="Alt" Command="{Binding GoToStepCommand}" CommandParameter="5" />
|
||||
<KeyBinding Key="D6" Modifiers="Alt" Command="{Binding GoToStepCommand}" CommandParameter="6" />
|
||||
<KeyBinding Key="D7" Modifiers="Alt" Command="{Binding GoToStepCommand}" CommandParameter="7" />
|
||||
<KeyBinding Key="D8" Modifiers="Alt" Command="{Binding GoToStepCommand}" CommandParameter="8" />
|
||||
<KeyBinding Key="D9" Modifiers="Alt" Command="{Binding GoToStepCommand}" CommandParameter="9" />
|
||||
</Grid.InputBindings>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="52" />
|
||||
<RowDefinition Height="44" />
|
||||
<RowDefinition Height="*" />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ProgressBar Width="48" Maximum="1" Value="{Binding ServerJobProgress, Mode=OneWay}" VerticalAlignment="Center" Margin="0,0,8,0"
|
||||
AutomationProperties.Name="{Binding ServerJobText}" Visibility="{Binding HasServerJobProgress, Converter={StaticResource BoolToVisibility}}" />
|
||||
<ui:StatusGlyph Grid.Column="1" Kind="{Binding ServerJobKind}" Text="{Binding ServerJobText}" ToolTip="{Binding ServerJobToolTip}"
|
||||
FontSize="{StaticResource Size.Body}" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" />
|
||||
<Button Grid.Column="2" Style="{StaticResource Button.IconSubtle}" Width="26" Height="26" Margin="4,0,0,0" ui:ButtonIcon.Glyph="{StaticResource Icon.Cancel}"
|
||||
Command="{Binding CancelServerJobCommand}" ToolTip="{Binding CancelServerJobToolTip}" ToolTipService.ShowOnDisabled="True"
|
||||
AutomationProperties.Name="{l:Loc Editor.ServerJob.Cancel}" />
|
||||
</Grid>
|
||||
<StackPanel Grid.Column="3" Orientation="Horizontal" VerticalAlignment="Center" Margin="12,0,0,0">
|
||||
<Button Content="{l:Loc Editor.Analyse}" Command="{Binding AnalyseCommand}" ToolTip="{Binding AnalyseToolTip}" ToolTipService.ShowOnDisabled="True" />
|
||||
<Button Content="{l:Loc Editor.OptimiseAll}" Command="{Binding OptimiseAllCommand}" ToolTip="{Binding OptimiseAllToolTip}"
|
||||
ToolTipService.ShowOnDisabled="True" Margin="12,0,0,0" />
|
||||
<v:SplitButton x:Name="RenderButton" IsPrimary="True" Margin="12,0,0,0" Content="{Binding RenderText}" Command="{Binding RenderCommand}"
|
||||
ItemsSource="{Binding RenderChoices}" DisplayMemberPath="Label" SelectedItem="{Binding SelectedRenderChoice}" ToolTip="{Binding RenderToolTip}"
|
||||
ToolTipService.ShowOnDisabled="True" DropDownToolTip="{Binding RenderChoiceToolTip}"
|
||||
AutomationProperties.Name="{l:Loc Editor.RenderButton}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="{StaticResource Editor.Grid.Panel}" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid Margin="0,0,16,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition MinHeight="160">
|
||||
<RowDefinition.Style>
|
||||
<Style TargetType="RowDefinition">
|
||||
<Setter Property="Height" Value="{StaticResource Editor.Grid.Preview}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsExportTab}" Value="True">
|
||||
<Setter Property="Height" Value="{StaticResource Editor.Grid.ExportPreview}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</RowDefinition.Style>
|
||||
</RowDefinition>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition MinHeight="150">
|
||||
<RowDefinition.Style>
|
||||
<Style TargetType="RowDefinition">
|
||||
<Setter Property="Height" Value="{StaticResource Editor.Grid.Measure}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsExportTab}" Value="True">
|
||||
<Setter Property="Height" Value="{StaticResource Editor.Grid.ExportMeasure}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</RowDefinition.Style>
|
||||
</RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<v:PreviewViewport x:Name="Preview" Source="{Binding PreviewImage}" OriginalSource="{Binding OriginalImage}" IsCompareEnabled="{Binding IsCompare}"
|
||||
WipeLabel="{Binding WipeLabel}" ZoomMode="{Binding ZoomMode, Mode=TwoWay}" ShowVectors="{Binding ViewVectors}"
|
||||
MotionVectors="{Binding MotionVectors}" VectorScale="{Binding VectorScale}" ShowRegions="{Binding ViewRegions}"
|
||||
RegionBoundary="{Binding RegionBoundary}" ShowCropMask="{Binding ShowCropMask}" CropRect="{Binding CropRect}"
|
||||
CropMaskMode="{Binding CropMaskMode}" InfoText="{Binding InfoText}" ToolTip="{l:Loc Tooltips.Editor.Preview.View}"
|
||||
AutomationProperties.Name="{l:Loc Editor.Preview}" SizeChanged="OnPreviewSizeChanged">
|
||||
<v:PreviewViewport.ToolsContent>
|
||||
<!-- Tools give the keyboard back to the preview after a click, so Space keeps playing (OnToolClicked). They take a second
|
||||
line rather than lose Play and Full screen where long labels meet a narrow preview (1200 px, 200 px rail). -->
|
||||
<WrapPanel ButtonBase.Click="OnToolClicked" Margin="0,0,0,-6">
|
||||
<ToggleButton Style="{StaticResource ToggleButton.PreviewTool}" IsChecked="{Binding IsCompare}" ui:ButtonIcon.Glyph="{StaticResource Icon.Compare}"
|
||||
Content="{l:Loc Editor.Preview.Compare}" ToolTip="{l:Loc Tooltips.Editor.Preview.Compare}" />
|
||||
<ToggleButton Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource ToggleButton.PreviewTool}"
|
||||
IsChecked="{Binding ShowVectors}" ui:ButtonIcon.Glyph="{StaticResource Icon.Vectors}" Content="{l:Loc Editor.Preview.Vectors}"
|
||||
ToolTip="{l:Loc Tooltips.Editor.Preview.Vectors}" />
|
||||
<ToggleButton Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource ToggleButton.PreviewTool}"
|
||||
IsChecked="{Binding ShowRegions}" ui:ButtonIcon.Glyph="{StaticResource Icon.Regions}" Content="{l:Loc Editor.Preview.Regions}"
|
||||
ToolTip="{l:Loc Tooltips.Editor.Preview.Regions}" />
|
||||
<ToggleButton Style="{StaticResource ToggleButton.PreviewTool}" IsChecked="{Binding ShowCropMask}" ui:ButtonIcon.Glyph="{StaticResource Icon.CropMask}"
|
||||
Content="{l:Loc Editor.Preview.CropMask}" ToolTip="{l:Loc Tooltips.Editor.Preview.CropMask}" />
|
||||
<!-- "What I lose" (dimmed) or "how it will look" (hidden) outside the crop (BRIEF §12.3), beside the mask and always there (disabled
|
||||
while the mask is off), so turning the mask on never moves the other tools to another line. -->
|
||||
<ToggleButton Style="{StaticResource ToggleButton.PreviewToolIcon}" IsChecked="{Binding IsCropResult}" IsEnabled="{Binding ShowCropMask}"
|
||||
ui:ButtonIcon.Glyph="{StaticResource Icon.Eye}" ToolTip="{Binding CropModeToolTip}" ToolTipService.ShowOnDisabled="True"
|
||||
AutomationProperties.Name="{l:Loc Editor.Preview.CropResult}" />
|
||||
<ToggleButton Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource ToggleButton.PreviewTool}"
|
||||
IsChecked="{Binding IsActualSize}" Content="{l:Loc Editor.Preview.ActualSize}" ToolTip="{l:Loc Tooltips.Editor.Preview.OneToOne}" />
|
||||
<Button Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource Button.PreviewToolIcon}"
|
||||
ui:ButtonIcon.Glyph="{StaticResource Icon.Fullscreen}" Click="OnFullScreen" ToolTip="{l:Loc Tooltips.Editor.Preview.FullScreen}"
|
||||
AutomationProperties.Name="{l:Loc Editor.Preview.FullScreen}" />
|
||||
<Button Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource Button.PlayTool}"
|
||||
Command="{Binding PlayCommand}" ToolTip="{Binding PlayToolTip}" AutomationProperties.Name="{Binding PlayName}" />
|
||||
<Button Content="{l:Loc Editor.Preview.Clip}" Command="{Binding PreviewClipCommand}" ToolTip="{Binding ClipToolTip}"
|
||||
Visibility="{Binding IsExportTab, Converter={StaticResource BoolToVisibility}}">
|
||||
<Button.Style>
|
||||
<Style TargetType="Button" BasedOn="{StaticResource Button.PreviewTool}">
|
||||
<Setter Property="ui:ButtonIcon.Glyph" Value="{StaticResource Icon.Play}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsPlaying}" Value="True">
|
||||
<Setter Property="ui:ButtonIcon.Glyph" Value="{StaticResource Icon.Pause}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</Button>
|
||||
</WrapPanel>
|
||||
</v:PreviewViewport.ToolsContent>
|
||||
</v:PreviewViewport>
|
||||
<!-- The frame on screen cannot be read: one sentence instead of another frame's picture. -->
|
||||
<TextBlock Text="{Binding PreviewMessage}" Style="{StaticResource Text.Secondary}" HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
IsHitTestVisible="False" Visibility="{Binding PreviewMessage, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
|
||||
|
||||
<v:Filmstrip Grid.Row="1" Margin="0,10,0,0" Source="{Binding Thumbnails}" CurrentIndex="{Binding CurrentIndex, Mode=TwoWay}" Markers="{Binding Markers}"
|
||||
ToolTip="{l:Loc Tooltips.Editor.Filmstrip}" AutomationProperties.Name="{l:Loc Editor.Filmstrip}" />
|
||||
|
||||
<TabControl Grid.Row="2" Margin="0,10,0,0" ItemsSource="{Binding Tabs}" SelectedItem="{Binding SelectedTab}" AutomationProperties.Name="{l:Loc Editor.Sections}">
|
||||
<TabControl.Resources>
|
||||
<ResourceDictionary Source="pack://application:,,,/Titano;component/Editor/EditorMeasures.xaml" />
|
||||
</TabControl.Resources>
|
||||
<TabControl.ItemContainerStyle>
|
||||
<Style TargetType="TabItem" BasedOn="{StaticResource {x:Type TabItem}}">
|
||||
<Setter Property="Header" Value="{Binding Header}" />
|
||||
<Setter Property="ToolTip" Value="{Binding ToolTip}" />
|
||||
<Setter Property="AutomationProperties.Name" Value="{Binding Header}" />
|
||||
</Style>
|
||||
</TabControl.ItemContainerStyle>
|
||||
</TabControl>
|
||||
<Button Style="{StaticResource Button.IconSubtle}" ui:ButtonIcon.Glyph="{StaticResource Icon.Back}" Command="{Binding BackCommand}"
|
||||
ToolTip="{l:Loc Tooltips.Editor.Back}" AutomationProperties.Name="{l:Loc Editor.Back}" Margin="-6,0,0,0" />
|
||||
<!-- The title, where a server sequence edited with proxies lives (read-only or out of date says so) and the summary share what the
|
||||
server job and the actions leave, and give way first: each ends in an ellipsis. The title chooses another sequence (Ctrl+O): the
|
||||
picker covers the editor until one opens or Esc. Its tooltip and its accessible name start with the whole title. -->
|
||||
<DockPanel Grid.Column="1" VerticalAlignment="Center">
|
||||
<Button x:Name="ChangeSequence" DockPanel.Dock="Left" Style="{StaticResource Button.Title}" Margin="2,0,12,0" MaxWidth="340" Padding="6,0"
|
||||
Command="{Binding DataContext.ChangeSequenceCommand, RelativeSource={RelativeSource AncestorType=UserControl}}"
|
||||
ToolTip="{Binding ChangeToolTip}" ToolTipService.ShowOnDisabled="True" AutomationProperties.Name="{Binding ChangeName}">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{Binding Title}" Style="{StaticResource Text.Title}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" />
|
||||
<ui:Icon Grid.Column="1" Glyph="{StaticResource Icon.ChevronDown}" Size="14" Margin="6,0,0,0" VerticalAlignment="Center"
|
||||
Foreground="{DynamicResource Brush.TextMuted}" />
|
||||
</Grid>
|
||||
</Button>
|
||||
<ui:StatusGlyph DockPanel.Dock="Left" Kind="Remote" Text="{Binding RemoteText}" ToolTip="{Binding RemoteToolTip}" FontSize="{StaticResource Size.Body}" Margin="0,0,12,0"
|
||||
MaxWidth="220" VerticalAlignment="Center" Visibility="{Binding IsRemote, Converter={StaticResource BoolToVisibility}}" />
|
||||
<TextBlock Text="{Binding Summary}" Style="{StaticResource Text.Secondary}" FontSize="{StaticResource Size.Body}" VerticalAlignment="Center"
|
||||
TextTrimming="CharacterEllipsis" Typography.NumeralAlignment="Tabular" ToolTip="{Binding Summary}" />
|
||||
</DockPanel>
|
||||
<!-- The server job: its bar, what it is and how far, and Cancel, which always stays (BRIEF §11.5): its own column, so the title gives way
|
||||
before it at the minimum window. -->
|
||||
<Grid Grid.Column="2" Margin="12,0,0,0" MaxWidth="300" VerticalAlignment="Center"
|
||||
Visibility="{Binding ServerJobText, Converter={x:Static ui:NullToCollapsedConverter.Instance}}">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ProgressBar Width="48" Maximum="1" Value="{Binding ServerJobProgress, Mode=OneWay}" VerticalAlignment="Center" Margin="0,0,8,0"
|
||||
AutomationProperties.Name="{Binding ServerJobText}" Visibility="{Binding HasServerJobProgress, Converter={StaticResource BoolToVisibility}}" />
|
||||
<ui:StatusGlyph Grid.Column="1" Kind="{Binding ServerJobKind}" Text="{Binding ServerJobText}" ToolTip="{Binding ServerJobToolTip}"
|
||||
FontSize="{StaticResource Size.Body}" VerticalAlignment="Center" Typography.NumeralAlignment="Tabular" />
|
||||
<Button Grid.Column="2" Style="{StaticResource Button.IconSubtle}" Width="26" Height="26" Margin="4,0,0,0" ui:ButtonIcon.Glyph="{StaticResource Icon.Cancel}"
|
||||
Command="{Binding CancelServerJobCommand}" ToolTip="{Binding CancelServerJobToolTip}" ToolTipService.ShowOnDisabled="True"
|
||||
AutomationProperties.Name="{l:Loc Editor.ServerJob.Cancel}" />
|
||||
</Grid>
|
||||
<StackPanel Grid.Column="3" Orientation="Horizontal" VerticalAlignment="Center" Margin="12,0,0,0">
|
||||
<Button Content="{l:Loc Editor.Analyse}" Command="{Binding AnalyseCommand}" ToolTip="{Binding AnalyseToolTip}" ToolTipService.ShowOnDisabled="True" />
|
||||
<Button Content="{l:Loc Editor.OptimiseAll}" Command="{Binding OptimiseAllCommand}" ToolTip="{Binding OptimiseAllToolTip}"
|
||||
ToolTipService.ShowOnDisabled="True" Margin="12,0,0,0" />
|
||||
<v:SplitButton x:Name="RenderButton" IsPrimary="True" Margin="12,0,0,0" Content="{Binding RenderText}" Command="{Binding RenderCommand}"
|
||||
ItemsSource="{Binding RenderChoices}" DisplayMemberPath="Label" SelectedItem="{Binding SelectedRenderChoice}" ToolTip="{Binding RenderToolTip}"
|
||||
ToolTipService.ShowOnDisabled="True" DropDownToolTip="{Binding RenderChoiceToolTip}"
|
||||
AutomationProperties.Name="{l:Loc Editor.RenderButton}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
<ContentControl Grid.Column="1" Content="{Binding SelectedTab}" Focusable="False">
|
||||
<ContentControl.Resources>
|
||||
<ResourceDictionary Source="pack://application:,,,/Titano;component/Editor/EditorPanels.xaml" />
|
||||
</ContentControl.Resources>
|
||||
</ContentControl>
|
||||
<!-- The path (owner review 1, R7): one row of steps, each with where it stands; any step opens at any time (Alt+n, ←/→ in the bar). -->
|
||||
<ListBox x:Name="Steps" Grid.Row="1" Style="{StaticResource ListBox.Steps}" ItemsSource="{Binding Tabs}" SelectedItem="{Binding SelectedTab}"
|
||||
ItemContainerStyle="{StaticResource ListBoxItem.Step}" Margin="0,0,0,8" AutomationProperties.Name="{l:Loc Editor.Path}" KeyDown="OnStepsKeyDown"
|
||||
PreviewKeyDown="OnStepsPreviewKeyDown" PreviewMouseLeftButtonDown="OnStepsPreviewMouseDown" SelectionChanged="OnStepsSelectionChanged" />
|
||||
|
||||
<Grid Grid.Row="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="{StaticResource Editor.Grid.Panel}" />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Grid Margin="0,0,16,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition MinHeight="160">
|
||||
<RowDefinition.Style>
|
||||
<Style TargetType="RowDefinition">
|
||||
<Setter Property="Height" Value="{StaticResource Editor.Grid.Preview}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsTallMeasure}" Value="True">
|
||||
<Setter Property="Height" Value="{StaticResource Editor.Grid.ExportPreview}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</RowDefinition.Style>
|
||||
</RowDefinition>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition MinHeight="150">
|
||||
<RowDefinition.Style>
|
||||
<Style TargetType="RowDefinition">
|
||||
<Setter Property="Height" Value="{StaticResource Editor.Grid.Measure}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsTallMeasure}" Value="True">
|
||||
<Setter Property="Height" Value="{StaticResource Editor.Grid.ExportMeasure}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</RowDefinition.Style>
|
||||
</RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<v:PreviewViewport x:Name="Preview" Source="{Binding PreviewImage}" OriginalSource="{Binding OriginalImage}" IsCompareEnabled="{Binding IsCompare}"
|
||||
WipeLabel="{Binding WipeLabel}" ZoomMode="{Binding ZoomMode, Mode=TwoWay}" ShowVectors="{Binding ViewVectors}"
|
||||
MotionVectors="{Binding MotionVectors}" VectorScale="{Binding VectorScale}" ShowRegions="{Binding ViewRegions}"
|
||||
RegionBoundary="{Binding RegionBoundary}" ShowCropMask="{Binding ShowCropMask}" CropRect="{Binding CropRect}"
|
||||
CropMaskMode="{Binding CropMaskMode}" InfoText="{Binding InfoText}" ToolTip="{l:Loc Tooltips.Editor.Preview.View}"
|
||||
AutomationProperties.Name="{l:Loc Editor.Preview}" SizeChanged="OnPreviewSizeChanged">
|
||||
<v:PreviewViewport.ToolsContent>
|
||||
<!-- Tools give the keyboard back to the preview after a click, so Space keeps playing (OnToolClicked). They take a second
|
||||
line rather than lose Play and Full screen where long labels meet a narrow preview (1200 px, 200 px rail). -->
|
||||
<WrapPanel ButtonBase.Click="OnToolClicked" Margin="0,0,0,-6">
|
||||
<ToggleButton Style="{StaticResource ToggleButton.PreviewTool}" IsChecked="{Binding IsCompare}" ui:ButtonIcon.Glyph="{StaticResource Icon.Compare}"
|
||||
Content="{l:Loc Editor.Preview.Compare}" ToolTip="{l:Loc Tooltips.Editor.Preview.Compare}" />
|
||||
<ToggleButton Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource ToggleButton.PreviewTool}"
|
||||
IsChecked="{Binding ShowVectors}" ui:ButtonIcon.Glyph="{StaticResource Icon.Vectors}" Content="{l:Loc Editor.Preview.Vectors}"
|
||||
ToolTip="{l:Loc Tooltips.Editor.Preview.Vectors}" />
|
||||
<ToggleButton Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource ToggleButton.PreviewTool}"
|
||||
IsChecked="{Binding ShowRegions}" ui:ButtonIcon.Glyph="{StaticResource Icon.Regions}" Content="{l:Loc Editor.Preview.Regions}"
|
||||
ToolTip="{l:Loc Tooltips.Editor.Preview.Regions}" />
|
||||
<ToggleButton Style="{StaticResource ToggleButton.PreviewTool}" IsChecked="{Binding ShowCropMask}" ui:ButtonIcon.Glyph="{StaticResource Icon.CropMask}"
|
||||
Content="{l:Loc Editor.Preview.CropMask}" ToolTip="{l:Loc Tooltips.Editor.Preview.CropMask}" />
|
||||
<!-- "What I lose" (dimmed) or "how it will look" (hidden) outside the crop (BRIEF §12.3), beside the mask and always there (disabled
|
||||
while the mask is off), so turning the mask on never moves the other tools to another line. -->
|
||||
<ToggleButton Style="{StaticResource ToggleButton.PreviewToolIcon}" IsChecked="{Binding IsCropResult}" IsEnabled="{Binding ShowCropMask}"
|
||||
ui:ButtonIcon.Glyph="{StaticResource Icon.Eye}" ToolTip="{Binding CropModeToolTip}" ToolTipService.ShowOnDisabled="True"
|
||||
AutomationProperties.Name="{l:Loc Editor.Preview.CropResult}" />
|
||||
<ToggleButton Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource ToggleButton.PreviewTool}"
|
||||
IsChecked="{Binding IsActualSize}" Content="{l:Loc Editor.Preview.ActualSize}" ToolTip="{l:Loc Tooltips.Editor.Preview.OneToOne}" />
|
||||
<Button Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource Button.PreviewToolIcon}"
|
||||
ui:ButtonIcon.Glyph="{StaticResource Icon.Fullscreen}" Click="OnFullScreen" ToolTip="{l:Loc Tooltips.Editor.Preview.FullScreen}"
|
||||
AutomationProperties.Name="{l:Loc Editor.Preview.FullScreen}" />
|
||||
<Button Visibility="{Binding IsExportTab, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" Style="{StaticResource Button.PlayTool}"
|
||||
Command="{Binding PlayCommand}" ToolTip="{Binding PlayToolTip}" AutomationProperties.Name="{Binding PlayName}" />
|
||||
<Button Content="{l:Loc Editor.Preview.Clip}" Command="{Binding PreviewClipCommand}" ToolTip="{Binding ClipToolTip}"
|
||||
Visibility="{Binding IsExportTab, Converter={StaticResource BoolToVisibility}}">
|
||||
<Button.Style>
|
||||
<Style TargetType="Button" BasedOn="{StaticResource Button.PreviewTool}">
|
||||
<Setter Property="ui:ButtonIcon.Glyph" Value="{StaticResource Icon.Play}" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding IsPlaying}" Value="True">
|
||||
<Setter Property="ui:ButtonIcon.Glyph" Value="{StaticResource Icon.Pause}" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Button.Style>
|
||||
</Button>
|
||||
</WrapPanel>
|
||||
</v:PreviewViewport.ToolsContent>
|
||||
</v:PreviewViewport>
|
||||
<!-- The frame on screen cannot be read: one sentence instead of another frame's picture. -->
|
||||
<TextBlock Text="{Binding PreviewMessage}" Style="{StaticResource Text.Secondary}" HorizontalAlignment="Center" VerticalAlignment="Center"
|
||||
IsHitTestVisible="False" Visibility="{Binding PreviewMessage, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
|
||||
|
||||
<v:Filmstrip Grid.Row="1" Margin="0,10,0,0" Source="{Binding Thumbnails}" CurrentIndex="{Binding CurrentIndex, Mode=TwoWay}" Markers="{Binding Markers}"
|
||||
ToolTip="{l:Loc Tooltips.Editor.Filmstrip}" AutomationProperties.Name="{l:Loc Editor.Filmstrip}" />
|
||||
|
||||
<!-- The step's measuring tool. -->
|
||||
<ContentControl x:Name="StepMeasure" Grid.Row="2" Content="{Binding SelectedTab}" Focusable="False">
|
||||
<ContentControl.Resources>
|
||||
<ResourceDictionary Source="pack://application:,,,/Titano;component/Editor/EditorMeasures.xaml" />
|
||||
</ContentControl.Resources>
|
||||
</ContentControl>
|
||||
</Grid>
|
||||
|
||||
<!-- The step's column, then Previous · 3 / 8 · Next. -->
|
||||
<Grid Grid.Column="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="*" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<ContentControl x:Name="StepPanel" Content="{Binding SelectedTab}" Focusable="False">
|
||||
<ContentControl.Resources>
|
||||
<ResourceDictionary Source="pack://application:,,,/Titano;component/Editor/EditorPanels.xaml" />
|
||||
</ContentControl.Resources>
|
||||
</ContentControl>
|
||||
<!-- Both buttons are measured whole (the longest "Next sequence" fits the 320 px column in every language); the counter takes
|
||||
what they leave and gives way first. -->
|
||||
<Grid Grid.Row="1" Margin="0,10,0,0">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button x:Name="PreviousStep" ui:ButtonIcon.Glyph="{StaticResource Icon.ChevronLeft}" Content="{l:Loc Editor.Step.Previous}"
|
||||
Command="{Binding PreviousStepCommand}" ToolTip="{Binding PreviousToolTip}" ToolTipService.ShowOnDisabled="True" />
|
||||
<!-- The step counter says each step change to screen readers ("Step 3 of 8: Exposure, Auto"). -->
|
||||
<TextBlock Grid.Column="1" Text="{Binding StepCounter}" Style="{StaticResource Text.Secondary}" VerticalAlignment="Center" HorizontalAlignment="Center"
|
||||
Margin="8,0" TextTrimming="CharacterEllipsis" Typography.NumeralAlignment="Tabular" infra:LiveRegion.Text="{Binding StepAnnouncement}"
|
||||
AutomationProperties.LiveSetting="Polite" />
|
||||
<Button x:Name="NextStep" Grid.Column="2" Command="{Binding NextStepCommand}" ToolTip="{Binding NextToolTip}" ToolTipService.ShowOnDisabled="True"
|
||||
AutomationProperties.Name="{Binding NextText}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{Binding NextText}" VerticalAlignment="Center" />
|
||||
<ui:Icon Glyph="{StaticResource Icon.ChevronRight}" Size="14" Margin="6,0,0,0" VerticalAlignment="Center" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
<!-- The picker (owner review 1, R7): without an open sequence, or over it after Change sequence. -->
|
||||
<sections:SequencePickerView x:Name="Picker" Visibility="{Binding ShowsPicker, Converter={StaticResource BoolToVisibility}}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -25,10 +25,26 @@ public partial class SequenceView : UserControl
|
||||
EditorRoot.AddHandler(Thumb.DragCompletedEvent, new DragCompletedEventHandler((_, _) => EndEditRun()), handledEventsToo: true);
|
||||
EditorRoot.AddHandler(MouseLeftButtonUpEvent, new MouseButtonEventHandler((_, _) => EndEditRun()), handledEventsToo: true);
|
||||
EditorRoot.AddHandler(KeyUpEvent, new KeyEventHandler((_, _) => EndEditRun()), handledEventsToo: true);
|
||||
EditorRoot.IsKeyboardFocusWithinChanged += OnEditorFocusWithinChanged;
|
||||
}
|
||||
|
||||
private EditorViewModel? Editor => (DataContext as SequenceViewModel)?.Editor;
|
||||
|
||||
/// <summary>The picker covers the open sequence: its keys are the picker's.</summary>
|
||||
private bool IsPicking => (DataContext as SequenceViewModel)?.IsPicking == true;
|
||||
|
||||
/// <summary>
|
||||
/// Ctrl+PgDn and Ctrl+PgUp move one step along the path (owner review 1, R7); null for any other key. They are read as
|
||||
/// the key goes down the tree, because the filmstrip and the curve editors take Page Up and Page Down whatever the
|
||||
/// modifiers.
|
||||
/// </summary>
|
||||
internal static int? StepDelta(Key key, ModifierKeys modifiers) => modifiers != ModifierKeys.Control ? null : key switch
|
||||
{
|
||||
Key.PageDown => 1,
|
||||
Key.PageUp => -1,
|
||||
_ => null,
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// The project is saved a moment after each edit; closing the window first stores the last edit, and asks before
|
||||
/// discarding one that cannot be stored (once per window, so it holds even when another section is showing).
|
||||
@@ -70,10 +86,13 @@ public partial class SequenceView : UserControl
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Space plays or pauses, arrows step a frame (BRIEF §12.3) — unless a text field or a control that uses the key has it.</summary>
|
||||
/// <summary>
|
||||
/// Space plays or pauses, arrows step a frame (BRIEF §12.3) — unless a text field or a control that uses the key has
|
||||
/// it, or the picker covers the editor.
|
||||
/// </summary>
|
||||
private void OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Handled || Editor is not { } editor || Keyboard.Modifiers != ModifierKeys.None || e.OriginalSource is TextBoxBase) return;
|
||||
if (e.Handled || IsPicking || Editor is not { } editor || Keyboard.Modifiers != ModifierKeys.None || e.OriginalSource is TextBoxBase) return;
|
||||
var command = e.Key switch
|
||||
{
|
||||
Key.Space => editor.PlayCommand,
|
||||
@@ -86,12 +105,84 @@ public partial class SequenceView : UserControl
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
/// <summary>Ctrl+PgDn and Ctrl+PgUp: the next and the previous step, stopping at the ends.</summary>
|
||||
private void OnEditorPreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Handled || Editor is not { } editor || StepDelta(e.Key, Keyboard.Modifiers) is not { } delta) return;
|
||||
editor.MoveStep(delta);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
/// <summary>The arrows move between steps while the step bar has the keyboard; at either end they do nothing else (no frame step).</summary>
|
||||
private void OnStepsKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key is Key.Left or Key.Right or Key.Up or Key.Down) e.Handled = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On the step shown, Space plays or pauses as everywhere in the editor (the list would only select the step again), and
|
||||
/// Ctrl+Space does nothing (the list would leave the bar without a current step). Read on the way down, before the list.
|
||||
/// </summary>
|
||||
private void OnStepsPreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.Key != Key.Space || IsPicking || Editor is not { } editor || e.OriginalSource is not ListBoxItem { IsSelected: true }) return;
|
||||
if (Keyboard.Modifiers == ModifierKeys.None) editor.PlayCommand.Execute(null);
|
||||
e.Handled = Keyboard.Modifiers is ModifierKeys.None or ModifierKeys.Control;
|
||||
}
|
||||
|
||||
/// <summary>Ctrl+click on the step shown keeps it the current one (a list would unselect it).</summary>
|
||||
private void OnStepsPreviewMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if ((Keyboard.Modifiers & ModifierKeys.Control) == 0
|
||||
|| ItemsControl.ContainerFromElement(Steps, e.OriginalSource as DependencyObject) is not ListBoxItem { IsSelected: true } item) return;
|
||||
item.Focus();
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// After a step change (Alt+n, Ctrl+PgUp/PgDn, Previous/Next, a step's own button) the keyboard stays in the editor: when
|
||||
/// it was in the step bar, on a control of the step that is about to be replaced, or on Previous about to be disabled
|
||||
/// on the first step, it goes to the new step's cell; otherwise it stays where it is.
|
||||
/// </summary>
|
||||
private void OnStepsSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (!ReferenceEquals(e.OriginalSource, Steps) || IsPicking || Editor is not { } editor || e.AddedItems.Count == 0) return;
|
||||
if (Window.GetWindow(this) is not { } window || FocusManager.GetFocusedElement(window) is not DependencyObject focused) return;
|
||||
var follows = Steps.IsAncestorOf(focused) || StepMeasure.IsAncestorOf(focused) || StepPanel.IsAncestorOf(focused)
|
||||
|| (ReferenceEquals(focused, PreviousStep) && editor.SelectedTab.Number == 1);
|
||||
if (!follows) return;
|
||||
// After the step's templates are swapped and the commands re-read (Background), so the cell is laid out and nothing takes it back;
|
||||
// logical focus too, so a window that is not active gives the keyboard to the cell when it is activated.
|
||||
Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
if (Editor is not { } current || Steps.ItemContainerGenerator.ContainerFromItem(current.SelectedTab) is not ListBoxItem { IsVisible: true } cell) return;
|
||||
FocusManager.SetFocusedElement(FocusManager.GetFocusScope(cell), cell);
|
||||
Keyboard.Focus(cell);
|
||||
}, DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
/// <summary>An opened editor takes the keyboard, so its shortcuts work without clicking into it first.</summary>
|
||||
private void OnEditorVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.NewValue is true) FocusPreview();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The focused control left the editor's tree or was disabled (a control of a step replaced by another, a button whose
|
||||
/// command stopped applying): the keyboard fell to the window, where none of the editor's shortcuts are, so the preview
|
||||
/// takes it back. A deliberate move out of the editor (the rail, a toast, another window) is left alone.
|
||||
/// </summary>
|
||||
private void OnEditorFocusWithinChanged(object sender, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.NewValue is true) return;
|
||||
// After WPF has re-evaluated the focus (Input), which is what raised this.
|
||||
Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
if (Window.GetWindow(this) is { IsActive: true } window && ReferenceEquals(Keyboard.FocusedElement, window) && EditorRoot.IsVisible && !IsPicking && Editor is not null)
|
||||
Keyboard.Focus(Preview);
|
||||
}, DispatcherPriority.Background);
|
||||
}
|
||||
|
||||
/// <summary>A tool clicked with the mouse hands the keyboard back to the preview (Space keeps playing); keyboard users keep their focus.</summary>
|
||||
private void OnToolClicked(object sender, RoutedEventArgs e)
|
||||
{
|
||||
@@ -100,10 +191,11 @@ public partial class SequenceView : UserControl
|
||||
|
||||
private void FocusPreview()
|
||||
{
|
||||
if (Editor is null) return;
|
||||
if (Editor is null || IsPicking) return;
|
||||
Dispatcher.BeginInvoke(() =>
|
||||
{
|
||||
if (Preview.IsVisible && !IsKeyboardFocusWithin) Keyboard.Focus(Preview);
|
||||
// Back from the picker, the focus is still in it (now hidden): the preview takes it.
|
||||
if (Preview.IsVisible && (!IsKeyboardFocusWithin || Picker.IsKeyboardFocusWithin)) Keyboard.Focus(Preview);
|
||||
}, DispatcherPriority.Input);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Windows.Input;
|
||||
using System.Windows.Threading;
|
||||
using Titano.App.Editor;
|
||||
using Titano.App.Infrastructure;
|
||||
using Titano.App.Library;
|
||||
using Titano.App.Shell;
|
||||
using Titano.Core.Diagnostics;
|
||||
using Titano.Core.Export;
|
||||
@@ -18,54 +19,124 @@ using Titano.Ui.Mvvm;
|
||||
namespace Titano.App.Sections;
|
||||
|
||||
/// <summary>
|
||||
/// The Sequence section (BRIEF §12.3): opens the sequence the Library, Jobs or the Server screen chose into an
|
||||
/// <see cref="EditorViewModel"/> (from this PC's archive, or a server sequence with this PC's proxies) and closes the
|
||||
/// previous one after saving it; without a sequence it shows the empty state. A server sequence whose proxies are
|
||||
/// missing or out of date fetches them first and opens once they are here. A failed open is reported and leaves the
|
||||
/// section usable; an edit that cannot be saved is never dropped without the user's confirmation.
|
||||
/// The Edit section (BRIEF §12.3; owner review 1, R7, formerly Sequence): opens the sequence the Library, Jobs, the
|
||||
/// Server screen or its own picker chose into an <see cref="EditorViewModel"/> (from this PC's archive, or a server
|
||||
/// sequence with this PC's proxies). The next sequence is read first; only then does the open one close, after its
|
||||
/// last edit is stored. Without a sequence, or after Change sequence, it shows the picker (the editor stays open behind
|
||||
/// it until another sequence opens). A server sequence whose proxies are missing or out of date fetches them first and
|
||||
/// opens once they are here, the open sequence staying open meanwhile. A failed open is reported once and leaves the
|
||||
/// open sequence open; an edit that cannot be saved is never dropped without the user's confirmation, and never written
|
||||
/// after they chose to drop it. The step each sequence showed is kept for the rest of the run.
|
||||
/// </summary>
|
||||
public sealed class SequenceViewModel : SectionViewModel
|
||||
{
|
||||
private readonly Dispatcher _dispatcher = Dispatcher.CurrentDispatcher;
|
||||
private readonly Dictionary<Guid, StepMemory> _steps = [];
|
||||
private EditorViewModel? _editor;
|
||||
private Guid? _openId;
|
||||
private bool _isLoading;
|
||||
private bool _isPicking;
|
||||
private bool _showsPicker = true;
|
||||
|
||||
/// <summary>The shell's <see cref="ShellViewModel.SequenceRequests"/> this section has answered.</summary>
|
||||
private int _seenRequests;
|
||||
private Task _switch = Task.CompletedTask;
|
||||
private ProxyFetch? _fetch;
|
||||
|
||||
public SequenceViewModel(ShellViewModel shell)
|
||||
: base(SectionKey.Sequence, "Icon.Sequence")
|
||||
: base(SectionKey.Edit, "Icon.Sequence")
|
||||
{
|
||||
Shell = shell;
|
||||
OpenLibraryCommand = new RelayCommand(() => Shell.Navigate(SectionKey.Library));
|
||||
Picker = new SequencePickerViewModel(this);
|
||||
OpenImportCommand = new RelayCommand(() => Shell.Navigate(SectionKey.Import));
|
||||
OpenJobsCommand = new RelayCommand(() => Shell.Navigate(SectionKey.Jobs));
|
||||
ChangeSequenceCommand = new RelayCommand(() => IsPicking = true, () => _editor is not null && !_isLoading && !_isPicking);
|
||||
CancelPickCommand = new RelayCommand(KeepOpenSequence, () => CanCancelPick);
|
||||
shell.PropertyChanged += OnShellChanged;
|
||||
}
|
||||
|
||||
public ShellViewModel Shell { get; }
|
||||
|
||||
public ICommand OpenLibraryCommand { get; }
|
||||
/// <summary>The list the next sequence is chosen from.</summary>
|
||||
public SequencePickerViewModel Picker { get; }
|
||||
|
||||
/// <summary>The open sequence; null shows the empty state.</summary>
|
||||
/// <summary>Import, from the picker of an empty library.</summary>
|
||||
public ICommand OpenImportCommand { get; }
|
||||
|
||||
/// <summary>The Jobs screen, from the picker's line about proxies on their way.</summary>
|
||||
public ICommand OpenJobsCommand { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Shows the picker over the open sequence (Ctrl+O, the title's ▾, Next on the last step); the editor is not closed and
|
||||
/// its changes keep being saved as usual.
|
||||
/// </summary>
|
||||
public ICommand ChangeSequenceCommand { get; }
|
||||
|
||||
/// <summary>Hides the picker again, back to the open sequence (Esc); a server sequence chosen meanwhile no longer opens over it.</summary>
|
||||
public ICommand CancelPickCommand { get; }
|
||||
|
||||
/// <summary>The open sequence; null shows the picker.</summary>
|
||||
public EditorViewModel? Editor
|
||||
{
|
||||
get => _editor;
|
||||
private set
|
||||
{
|
||||
if (!Set(ref _editor, value)) return;
|
||||
OnPropertyChanged(nameof(IsEmpty));
|
||||
// A sequence that opens ends the choice.
|
||||
if (value is not null)
|
||||
{
|
||||
_isPicking = false;
|
||||
OnPropertyChanged(nameof(IsPicking));
|
||||
Picker.SearchText = string.Empty;
|
||||
}
|
||||
OnPropertyChanged(nameof(Title));
|
||||
OnPickerChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsLoading { get => _isLoading; private set => Set(ref _isLoading, value); }
|
||||
/// <summary>The id of the open sequence; null when none is open.</summary>
|
||||
public Guid? OpenSequenceId => _editor is null ? null : _openId;
|
||||
|
||||
public bool IsEmpty => _editor is null && !_isLoading;
|
||||
public bool IsLoading
|
||||
{
|
||||
get => _isLoading;
|
||||
private set
|
||||
{
|
||||
if (Set(ref _isLoading, value)) OnPickerChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The picker shows over the open sequence, which stays laid out behind it.</summary>
|
||||
public bool IsPicking
|
||||
{
|
||||
get => _isPicking;
|
||||
private set
|
||||
{
|
||||
if (!Set(ref _isPicking, value)) return;
|
||||
OnPropertyChanged(nameof(Title));
|
||||
OnPickerChanged();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The picker is on screen: no sequence is open, or another is being chosen.</summary>
|
||||
public bool ShowsPicker => _showsPicker;
|
||||
|
||||
/// <summary>An open sequence waits behind the picker, so Cancel (Esc) goes back to it; not while a switch is under way.</summary>
|
||||
public bool CanCancelPick => _isPicking && _editor is not null && !_isLoading;
|
||||
|
||||
public string? CancelPickToolTip => _editor is { } editor ? Loc.L("Tooltips.Editor.Picker.Cancel", editor.Title) : null;
|
||||
|
||||
/// <summary>The server sequence whose proxies are on their way before it opens; null when none.</summary>
|
||||
public string? FetchingTitle => _fetch?.Title;
|
||||
|
||||
/// <summary>"Getting the proxies · Harbour sunset".</summary>
|
||||
public string? FetchingText => _fetch is { } fetch ? string.Join(Loc.Separator, Loc.L("Editor.Proxies.Fetching"), fetch.Title) : null;
|
||||
|
||||
/// <summary>The open sequence has an edit not stored yet (the save follows each change after a moment, and retries after a failure).</summary>
|
||||
public bool HasPendingSave => _editor?.Session.HasPendingSave == true;
|
||||
|
||||
/// <summary>"Titano — Harbour sunset" while a sequence is open.</summary>
|
||||
public override string Title => _editor?.Title ?? Label;
|
||||
/// <summary>"Titano — Harbour sunset" while a sequence is open and shown; the section's name while choosing one.</summary>
|
||||
public override string Title => !_isPicking && _editor is { } editor ? editor.Title : Label;
|
||||
|
||||
/// <summary>Opens <paramref name="sequenceId"/> (the editor of another sequence is saved and closed first).</summary>
|
||||
/// <param name="reload">Opens it again even when it is the open one (its proxies were fetched again).</param>
|
||||
@@ -83,10 +154,30 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
public async Task<EditorViewModel?> ShowAsync(Guid sequenceId)
|
||||
{
|
||||
Shell.OpenSequence(sequenceId);
|
||||
// Already chosen and shown but not open (an earlier open failed): opening it again is what is asked now.
|
||||
if (_openId != sequenceId && _switch.IsCompleted) _ = OpenAsync(sequenceId);
|
||||
// Already the sequence asked for but not open (the shell did not change, so nothing started): opening it again is
|
||||
// what is asked now, unless its proxies are on their way (it opens when they are here).
|
||||
if (_openId != sequenceId && _switch.IsCompleted && Shell.CurrentSequenceId == sequenceId && !Fetching(sequenceId)) _ = OpenAsync(sequenceId);
|
||||
await Settled(_switch);
|
||||
return _openId == sequenceId ? Editor : null;
|
||||
if (_openId != sequenceId) return null;
|
||||
// Asking for the open sequence ends a choice of another.
|
||||
IsPicking = false;
|
||||
return Editor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Opens the sequence chosen in the picker: the open one simply shows again; another opens once it is read, after the
|
||||
/// open one's last edit is stored (or the user chose to discard it). Keeping an edit that cannot be stored keeps the
|
||||
/// open sequence; a server sequence whose proxies are not here yet leaves the picker on screen while they arrive.
|
||||
/// </summary>
|
||||
public async Task PickAsync(SequenceItem item)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(item);
|
||||
if (_editor is not null && item.Id == _openId)
|
||||
{
|
||||
KeepOpenSequence();
|
||||
return;
|
||||
}
|
||||
await ShowAsync(item.Id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -100,36 +191,61 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
var sync = services.Sync;
|
||||
if (sync.Server is not { } server || sync.Service is not { } service) throw new InvalidOperationException(Loc.L("Editor.Error.SignedOut"));
|
||||
if (services.Engine is not { } engine || services.Database is not { } db) throw new InvalidOperationException(Loc.L("Editor.Error.NoEngine"));
|
||||
var followed = _fetch is { } current && current.RemoteId == remoteId ? current.JobId : Guid.Empty;
|
||||
StopFetch();
|
||||
var fetch = new ProxyFetch(remoteId, title, engine);
|
||||
fetch.Handler = job => _dispatcher.BeginInvoke(() => OnFetchChanged(fetch, job));
|
||||
engine.JobChanged += fetch.Handler;
|
||||
_fetch = fetch;
|
||||
var job = await service.EnqueueDownloadAsync(engine, server, remoteId, title, SyncDownloadMode.Proxies, null);
|
||||
OnFetchingChanged();
|
||||
Job job;
|
||||
try
|
||||
{
|
||||
job = await service.EnqueueDownloadAsync(engine, server, remoteId, title, SyncDownloadMode.Proxies, null);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// Nothing is on its way: the picker's line about it goes, and asking for the sequence again tries again.
|
||||
if (ReferenceEquals(_fetch, fetch)) StopFetch();
|
||||
throw;
|
||||
}
|
||||
fetch.JobId = job.Id;
|
||||
Shell.Notify(Loc.L("Editor.Proxies.Fetching"), title, Loc.L("Shell.Nav.Jobs"), Loc.L("Tooltips.Nav.Jobs"), () => Shell.Navigate(SectionKey.Jobs));
|
||||
// The download already followed (the same sequence asked for again) is not announced twice.
|
||||
if (job.Id != followed)
|
||||
Shell.Notify(Loc.L("Editor.Proxies.Fetching"), title, Loc.L("Shell.Nav.Jobs"), Loc.L("Tooltips.Nav.Jobs"), () => Shell.Navigate(SectionKey.Jobs));
|
||||
// A download that ended before its id was known here is handled now.
|
||||
if (await db.Jobs.GetAsync(job.Id) is { State: JobState.Done or JobState.Failed or JobState.Cancelled } ended) OnFetchChanged(fetch, ended);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stores the open sequence's last edit. When the save fails (archive offline, read-only, busy), asks whether to
|
||||
/// discard the edit (BRIEF §12.1: modals only for destructive confirmations).
|
||||
/// discard the edit (BRIEF §12.1: modals only for destructive confirmations). No retry runs while the question is
|
||||
/// open, so the answer holds: Discard drops the edit unwritten, Keep editing lets the retries go on.
|
||||
/// </summary>
|
||||
/// <returns>True when the editor may close: everything is stored or the user chose to discard.</returns>
|
||||
public async Task<bool> ConfirmCloseAsync()
|
||||
{
|
||||
if (Editor is not { } editor || await editor.Session.FlushAsync()) return true;
|
||||
return Shell.Services.Dialogs.Confirm(new ConfirmRequest
|
||||
var session = editor.Session;
|
||||
if (!await session.HoldPendingAsync())
|
||||
{
|
||||
// A retry stored it meanwhile: nothing to ask.
|
||||
session.KeepPending();
|
||||
return true;
|
||||
}
|
||||
var discard = Shell.Services.Dialogs.Confirm(new ConfirmRequest
|
||||
{
|
||||
Heading = Loc.L("Editor.Unsaved.Title"),
|
||||
Message = Loc.L("Editor.Unsaved.Message", editor.Title, editor.Session.LastSaveError?.Message ?? string.Empty),
|
||||
Message = Loc.L("Editor.Unsaved.Message", editor.Title, session.LastSaveError?.Message ?? string.Empty),
|
||||
SafeText = Loc.L("Editor.Unsaved.Keep"),
|
||||
SafeToolTip = Loc.L("Tooltips.Editor.Unsaved.Keep"),
|
||||
ActionText = Loc.L("Editor.Unsaved.Discard"),
|
||||
ActionToolTip = Loc.L("Tooltips.Editor.Unsaved.Discard"),
|
||||
IsDestructive = true,
|
||||
});
|
||||
if (discard) session.DiscardPending();
|
||||
else session.KeepPending();
|
||||
return discard;
|
||||
}
|
||||
|
||||
/// <summary>Closes the open sequence (after <see cref="ConfirmCloseAsync"/>, which stores its last edit).</summary>
|
||||
@@ -137,6 +253,7 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
{
|
||||
await Settled(_switch);
|
||||
if (Editor is not { } editor) return;
|
||||
Remember(editor);
|
||||
Editor = null;
|
||||
_openId = null;
|
||||
await editor.DisposeAsync();
|
||||
@@ -146,6 +263,7 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
internal void Attach(EditorViewModel editor)
|
||||
{
|
||||
_openId = editor.Session.Content.Sequence.Id;
|
||||
if (_steps.TryGetValue(editor.Session.Content.Sequence.Id, out var memory)) editor.RestoreSteps(memory);
|
||||
Editor = editor;
|
||||
}
|
||||
|
||||
@@ -154,17 +272,80 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
Shell.PropertyChanged -= OnShellChanged;
|
||||
StopFetch();
|
||||
Editor?.Dispose();
|
||||
Picker.Dispose();
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
protected override void OnActivated()
|
||||
{
|
||||
if (Shell.CurrentSequenceId is { } id && id != _openId) _ = OpenAsync(id);
|
||||
OpenRequested();
|
||||
ShowRequested();
|
||||
if (_showsPicker) _ = Picker.ReloadAsync();
|
||||
}
|
||||
|
||||
/// <summary>Opens the sequence the shell asks for when it is not the open one (nor one whose proxies are on their way).</summary>
|
||||
private void OpenRequested()
|
||||
{
|
||||
if (Shell.CurrentSequenceId is { } id && id != _openId && !Fetching(id)) _ = OpenAsync(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asking for the open sequence again (the Library, Jobs, a project file, also while Edit is on screen) ends a choice of
|
||||
/// another; coming back to Edit alone leaves the choice on screen.
|
||||
/// </summary>
|
||||
private void ShowRequested()
|
||||
{
|
||||
if (Shell.SequenceRequests == _seenRequests) return;
|
||||
_seenRequests = Shell.SequenceRequests;
|
||||
if (_editor is not null && Shell.CurrentSequenceId == _openId) KeepOpenSequence();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Back to the open sequence (Cancel, Esc, or the open sequence chosen again): it is again the one asked for, and a
|
||||
/// server sequence still waiting for its proxies no longer opens over it when they arrive (its download goes on).
|
||||
/// </summary>
|
||||
private void KeepOpenSequence()
|
||||
{
|
||||
if (_fetch is { } pending && pending.RemoteId != _openId) StopFetch();
|
||||
Shell.KeepSequence(_openId);
|
||||
IsPicking = false;
|
||||
}
|
||||
|
||||
/// <summary>The proxies of server sequence <paramref name="sequenceId"/> are on their way: it opens when they are here.</summary>
|
||||
private bool Fetching(Guid sequenceId) => _fetch?.RemoteId == sequenceId;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the picker shows changed (a sequence opened or failed to, Change sequence, Cancel): it reads the list again
|
||||
/// each time it appears on screen.
|
||||
/// </summary>
|
||||
private void OnPickerChanged()
|
||||
{
|
||||
OnPropertyChanged(nameof(CanCancelPick));
|
||||
OnPropertyChanged(nameof(CancelPickToolTip));
|
||||
var shows = !_isLoading && (_editor is null || _isPicking);
|
||||
if (shows != _showsPicker)
|
||||
{
|
||||
_showsPicker = shows;
|
||||
OnPropertyChanged(nameof(ShowsPicker));
|
||||
if (shows && IsSelected) _ = Picker.ReloadAsync();
|
||||
}
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
|
||||
private void OnFetchingChanged()
|
||||
{
|
||||
OnPropertyChanged(nameof(FetchingTitle));
|
||||
OnPropertyChanged(nameof(FetchingText));
|
||||
}
|
||||
|
||||
/// <summary>Keeps the step <paramref name="editor"/> shows and the steps visited, for when its sequence opens again in this run.</summary>
|
||||
private void Remember(EditorViewModel editor) => _steps[editor.Session.Content.Sequence.Id] = editor.StepMemory();
|
||||
|
||||
private void OnShellChanged(object? sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == nameof(ShellViewModel.CurrentSequenceId) && IsSelected) OnActivated();
|
||||
if (!IsSelected) return;
|
||||
if (e.PropertyName == nameof(ShellViewModel.CurrentSequenceId)) OpenRequested();
|
||||
else if (e.PropertyName == nameof(ShellViewModel.SequenceRequests)) ShowRequested();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -228,6 +409,7 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
if (_fetch is not { } fetch) return;
|
||||
_fetch = null;
|
||||
if (fetch.Handler is { } handler) fetch.Engine.JobChanged -= handler;
|
||||
OnFetchingChanged();
|
||||
}
|
||||
|
||||
/// <summary>Set hero changed the frame the Library shows (any thread): its card loads the new thumbnail.</summary>
|
||||
@@ -253,26 +435,17 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
{
|
||||
await Settled(previous);
|
||||
if (sequenceId == _openId && !reload) return;
|
||||
// The open sequence keeps its editor while its last edit is neither stored nor deliberately discarded.
|
||||
if (!await ConfirmCloseAsync()) return;
|
||||
// Asked for again while its proxies are on their way (the next visit, a second pick): it opens when they are here.
|
||||
if (!reload && Fetching(sequenceId)) return;
|
||||
var services = Shell.Services;
|
||||
// The progress bar shows until the switch ends; the picker, its Cancel and the editor are hidden meanwhile.
|
||||
IsLoading = true;
|
||||
OnPropertyChanged(nameof(IsEmpty));
|
||||
ISequenceSource? source = null;
|
||||
try
|
||||
{
|
||||
if (Editor is { } old)
|
||||
{
|
||||
Editor = null;
|
||||
await old.DisposeAsync();
|
||||
}
|
||||
_openId = sequenceId;
|
||||
if (await OpenSourceAsync(services, sequenceId) is not { } opened)
|
||||
{
|
||||
// The proxies are on their way; the sequence opens when they are here.
|
||||
_openId = null;
|
||||
return;
|
||||
}
|
||||
var (source, title) = opened;
|
||||
// The next sequence is read first: the open one stays open when this one cannot open now.
|
||||
if (await OpenSourceAsync(services, sequenceId) is not { } opened) return;
|
||||
source = opened.Source;
|
||||
SequenceContent content;
|
||||
try
|
||||
{
|
||||
@@ -282,34 +455,62 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
{
|
||||
// The server's frames are no longer these proxies: fetch them again, then open.
|
||||
await source.DisposeAsync();
|
||||
_openId = null;
|
||||
await FetchProxiesAsync(sequenceId, title);
|
||||
source = null;
|
||||
await FetchProxiesAsync(sequenceId, opened.Title);
|
||||
return;
|
||||
}
|
||||
catch
|
||||
// Only now does the open sequence close: its last edit is stored first, or discarded on the user's word. Keeping
|
||||
// it keeps the open sequence as the one asked for, so the next visit to Edit does not ask once more.
|
||||
if (!await ConfirmCloseAsync())
|
||||
{
|
||||
await source.DisposeAsync();
|
||||
throw;
|
||||
Shell.KeepSequence(_openId);
|
||||
IsPicking = false;
|
||||
return;
|
||||
}
|
||||
// A server sequence that was waiting for its proxies is no longer the one asked for.
|
||||
if (_fetch is { } pending && pending.RemoteId != sequenceId) StopFetch();
|
||||
if (Editor is { } old)
|
||||
{
|
||||
Remember(old);
|
||||
Editor = null;
|
||||
_openId = null;
|
||||
await old.DisposeAsync();
|
||||
}
|
||||
var processing = services.Processing?.Options;
|
||||
var encoders = processing?.Encoders ?? [];
|
||||
var session = new EditorSession(source, content, [.. encoders.SelectMany(e => e.Capabilities)]);
|
||||
var editor = new EditorViewModel(Shell, session, encoders, processing?.Host ?? EncoderHost.Client);
|
||||
// The session owns the source from here on.
|
||||
source = null;
|
||||
EditorViewModel editor;
|
||||
try
|
||||
{
|
||||
editor = new EditorViewModel(Shell, session, encoders, processing?.Host ?? EncoderHost.Client);
|
||||
}
|
||||
catch
|
||||
{
|
||||
await session.DisposeAsync();
|
||||
throw;
|
||||
}
|
||||
if (_steps.TryGetValue(sequenceId, out var memory)) editor.RestoreSteps(memory);
|
||||
_openId = sequenceId;
|
||||
Editor = editor;
|
||||
services.Settings.LastEditedSequence = sequenceId;
|
||||
services.SavePreferences();
|
||||
await editor.AttachJobsAsync();
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
// Whatever failed (index, decoder set-up, advisor, the job list), the section stays usable: an editor that
|
||||
// opened stays open, otherwise the next Open tries again.
|
||||
if (Editor is null) _openId = null;
|
||||
// Whatever failed (index, decoder set-up, advisor, the job list), the section stays usable: the sequence open
|
||||
// before (or the one that has just opened) stays open and is again the one asked for, so coming back to Edit
|
||||
// neither tries nor reports it again; choosing the sequence again does.
|
||||
Log.Warning("editor", $"Sequence {sequenceId} could not be opened", ex);
|
||||
Shell.ReportError(ex);
|
||||
Shell.KeepSequence(OpenSequenceId);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (source is not null) await source.DisposeAsync();
|
||||
IsLoading = false;
|
||||
OnPropertyChanged(nameof(IsEmpty));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1559,6 +1559,7 @@ public sealed class SettingsViewModel : SectionViewModel
|
||||
RecentServers = _s.RecentServers,
|
||||
Window = _s.Window,
|
||||
RailCollapsed = _s.RailCollapsed,
|
||||
LastEditedSequence = _s.LastEditedSequence,
|
||||
FirstRunCompleted = _s.FirstRunCompleted,
|
||||
JobsClearedAt = _s.JobsClearedAt,
|
||||
};
|
||||
@@ -1629,11 +1630,13 @@ public sealed class SettingsViewModel : SectionViewModel
|
||||
Shell.Notify(Loc.L("Errors.Settings.Import"), isError: true);
|
||||
return;
|
||||
}
|
||||
// Everything but the session, the window and its rail, and the first-run flag.
|
||||
// Everything but the session, the window and its rail, the sequence edited last (another PC's ids mean nothing here)
|
||||
// and the first-run flag.
|
||||
imported.ProtectedToken = _s.ProtectedToken;
|
||||
imported.ServerUrl = _s.ServerUrl;
|
||||
imported.Window = _s.Window;
|
||||
imported.RailCollapsed = _s.RailCollapsed;
|
||||
imported.LastEditedSequence = _s.LastEditedSequence;
|
||||
imported.FirstRunCompleted = _s.FirstRunCompleted;
|
||||
ApplyAll(imported);
|
||||
// Settings of a PC never rewrite the shared archive.json: the imported templates and sizes are the defaults of new
|
||||
|
||||
@@ -17,13 +17,13 @@
|
||||
<ui:TitanoWindow.InputBindings>
|
||||
<KeyBinding Key="D1" Modifiers="Control" Command="{Binding NavigateCommand}" CommandParameter="{x:Static shell:SectionKey.Library}" />
|
||||
<KeyBinding Key="D2" Modifiers="Control" Command="{Binding NavigateCommand}" CommandParameter="{x:Static shell:SectionKey.Import}" />
|
||||
<KeyBinding Key="D3" Modifiers="Control" Command="{Binding NavigateCommand}" CommandParameter="{x:Static shell:SectionKey.Sequence}" />
|
||||
<KeyBinding Key="D3" Modifiers="Control" Command="{Binding NavigateCommand}" CommandParameter="{x:Static shell:SectionKey.Edit}" />
|
||||
<KeyBinding Key="D4" Modifiers="Control" Command="{Binding NavigateCommand}" CommandParameter="{x:Static shell:SectionKey.Archive}" />
|
||||
<KeyBinding Key="D5" Modifiers="Control" Command="{Binding NavigateCommand}" CommandParameter="{x:Static shell:SectionKey.Jobs}" />
|
||||
<KeyBinding Key="D6" Modifiers="Control" Command="{Binding NavigateCommand}" CommandParameter="{x:Static shell:SectionKey.Server}" />
|
||||
<KeyBinding Key="NumPad1" Modifiers="Control" Command="{Binding NavigateCommand}" CommandParameter="{x:Static shell:SectionKey.Library}" />
|
||||
<KeyBinding Key="NumPad2" Modifiers="Control" Command="{Binding NavigateCommand}" CommandParameter="{x:Static shell:SectionKey.Import}" />
|
||||
<KeyBinding Key="NumPad3" Modifiers="Control" Command="{Binding NavigateCommand}" CommandParameter="{x:Static shell:SectionKey.Sequence}" />
|
||||
<KeyBinding Key="NumPad3" Modifiers="Control" Command="{Binding NavigateCommand}" CommandParameter="{x:Static shell:SectionKey.Edit}" />
|
||||
<KeyBinding Key="NumPad4" Modifiers="Control" Command="{Binding NavigateCommand}" CommandParameter="{x:Static shell:SectionKey.Archive}" />
|
||||
<KeyBinding Key="NumPad5" Modifiers="Control" Command="{Binding NavigateCommand}" CommandParameter="{x:Static shell:SectionKey.Jobs}" />
|
||||
<KeyBinding Key="NumPad6" Modifiers="Control" Command="{Binding NavigateCommand}" CommandParameter="{x:Static shell:SectionKey.Server}" />
|
||||
|
||||
@@ -116,8 +116,10 @@ public static class ScreenCapture
|
||||
shell.Navigate(SectionKey.About);
|
||||
written += await SaveAsync(window, directory, "about", theme);
|
||||
|
||||
shell.Navigate(SectionKey.Sequence);
|
||||
written += await SaveAsync(window, directory, "sequence", theme);
|
||||
// Edit with no sequence open: the picker (owner review 1, R7).
|
||||
shell.Navigate(SectionKey.Edit);
|
||||
await shell.Sequence.Picker.Loading;
|
||||
written += await SaveAsync(window, directory, "edit-picker", theme, waitForThumbnails: shell);
|
||||
|
||||
foreach (var state in ImportScenes.States)
|
||||
{
|
||||
@@ -218,10 +220,11 @@ public static class ScreenCapture
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The sequence editor on the synthetic sunset: every section in both themes (<c>sequence-<tab>-<theme>.png</c>,
|
||||
/// the Camera tab with a keyframe selected, the Export tab as Export.html with the crop mask and no compare), then
|
||||
/// the preview overlays, the waveform, the "what changed" toast of Optimise all, the Export tab of the sequence once
|
||||
/// the server has it (Sync on) with two "Save both" copies to restore, and the busy state.
|
||||
/// The editor on the synthetic sunset: every step of the Edit path in both themes (<c>edit-<step>-<theme>.png</c>,
|
||||
/// the Camera step with a keyframe selected, the Export step as Export.html with the crop mask and no compare), then
|
||||
/// the preview overlays, the waveform, the "what changed" toast of Optimise all, the picker over the open sequence
|
||||
/// (<c>edit-change</c>), the Export step of the sequence once the server has it (Sync on) with two "Save both" copies
|
||||
/// to restore, and the Analysis step while the analysis runs (<c>edit-busy</c>).
|
||||
/// </summary>
|
||||
private static async Task<int> CaptureEditorAsync(MainWindow window, ShellViewModel shell, SampleData sample, string directory)
|
||||
{
|
||||
@@ -243,22 +246,28 @@ public static class ScreenCapture
|
||||
editor.SelectedTab = tab;
|
||||
editor.IsCompare = tab is not ExportTab;
|
||||
editor.CurrentIndex = tab is ExportTab ? 40 : 45;
|
||||
written += await SaveEditorAsync(window, editor, directory, "sequence-" + tab.Key.ToLowerInvariant(), theme);
|
||||
written += await SaveEditorAsync(window, editor, directory, "edit-" + tab.Key.ToLowerInvariant(), theme);
|
||||
}
|
||||
|
||||
editor.SelectedTab = editor.Exposure;
|
||||
editor.IsCompare = true;
|
||||
editor.ShowVectors = editor.ShowRegions = true;
|
||||
written += await SaveEditorAsync(window, editor, directory, "sequence-exposure-overlays", theme);
|
||||
written += await SaveEditorAsync(window, editor, directory, "edit-exposure-overlays", theme);
|
||||
editor.ShowVectors = editor.ShowRegions = false;
|
||||
editor.Exposure.ChartMode = ExposureChart.Waveform;
|
||||
written += await SaveEditorAsync(window, editor, directory, "sequence-exposure-waveform", theme);
|
||||
written += await SaveEditorAsync(window, editor, directory, "edit-exposure-waveform", theme);
|
||||
editor.Exposure.ChartMode = ExposureChart.Luminance;
|
||||
|
||||
editor.OptimiseAllCommand.Execute(null);
|
||||
written += await SaveEditorAsync(window, editor, directory, "sequence-optimise", theme);
|
||||
written += await SaveEditorAsync(window, editor, directory, "edit-optimise", theme);
|
||||
editor.Session.Undo();
|
||||
foreach (var toast in window.Toasts.Toasts.ToList()) window.Toasts.Dismiss(toast);
|
||||
|
||||
// Change sequence: the picker over the open sequence, which stays open behind it until another opens.
|
||||
shell.Sequence.ChangeSequenceCommand.Execute(null);
|
||||
await shell.Sequence.Picker.Loading;
|
||||
written += await SaveAsync(window, directory, "edit-change", theme, waitForThumbnails: shell);
|
||||
shell.Sequence.CancelPickCommand.Execute(null);
|
||||
}
|
||||
|
||||
// The server has the sequence (Sync can be ticked) and two copies of this PC's settings were kept by "Save both".
|
||||
@@ -272,7 +281,7 @@ public static class ScreenCapture
|
||||
foreach (var theme in Themes)
|
||||
{
|
||||
ThemeManager.Apply(theme);
|
||||
written += await SaveEditorAsync(window, editor, directory, "sequence-export-copies", theme);
|
||||
written += await SaveEditorAsync(window, editor, directory, "edit-export-copies", theme);
|
||||
}
|
||||
export.SyncToServer = false;
|
||||
editor.SelectedTab = editor.Exposure;
|
||||
@@ -280,15 +289,16 @@ public static class ScreenCapture
|
||||
|
||||
written += await CaptureRightToLeftAsync(window, shell, editor, directory);
|
||||
|
||||
// Last, as it stays: an analysis of the sequence running (settings disabled, viewing tools live).
|
||||
// Last, as it stays: an analysis of the sequence running (settings disabled, viewing tools live), on the step that follows it.
|
||||
await sample.MarkAnalysingAsync(id);
|
||||
await editor.AttachJobsAsync();
|
||||
editor.SelectedTab = editor.Analysis;
|
||||
// The job bar shows the analysis, the one job running.
|
||||
await shell.Jobs.ReloadAsync();
|
||||
foreach (var theme in Themes)
|
||||
{
|
||||
ThemeManager.Apply(theme);
|
||||
written += await SaveEditorAsync(window, editor, directory, "sequence-busy", theme);
|
||||
written += await SaveEditorAsync(window, editor, directory, "edit-busy", theme);
|
||||
}
|
||||
return written;
|
||||
}
|
||||
@@ -309,11 +319,11 @@ public static class ScreenCapture
|
||||
shell.Navigate(SectionKey.Library);
|
||||
written += await SaveAsync(window, directory, "library-rtl", AppTheme.Dark, waitForThumbnails: shell);
|
||||
|
||||
shell.Navigate(SectionKey.Sequence);
|
||||
shell.Navigate(SectionKey.Edit);
|
||||
editor.SelectedTab = editor.Exposure;
|
||||
editor.IsCompare = true;
|
||||
editor.CurrentIndex = 45;
|
||||
written += await SaveEditorAsync(window, editor, directory, "sequence-exposure-rtl", AppTheme.Dark);
|
||||
written += await SaveEditorAsync(window, editor, directory, "edit-exposure-rtl", AppTheme.Dark);
|
||||
|
||||
await ImportScenes.ShowAsync(shell, "plan");
|
||||
DismissToasts(window);
|
||||
@@ -323,17 +333,17 @@ public static class ScreenCapture
|
||||
{
|
||||
UiLanguage.Apply("en");
|
||||
}
|
||||
shell.Navigate(SectionKey.Sequence);
|
||||
shell.Navigate(SectionKey.Edit);
|
||||
editor.CurrentIndex = frame;
|
||||
return written;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A server sequence open with this PC's proxies (Sunrise over Superga, cached by the sync captures): the server in
|
||||
/// the header, the preview from the proxies, the project from the server (<c>sequence-remote</c>); its Export tab,
|
||||
/// where the server picks the encoder and keeps the renders (<c>sequence-remote-export</c>); a render running on the
|
||||
/// server with its bar and Cancel (<c>sequence-remote-running</c>); then, last as it stays, the sequence opened by an
|
||||
/// account without the Edit right (<c>sequence-remote-readonly</c>).
|
||||
/// the header, the preview from the proxies, the project from the server (<c>edit-remote</c>); its Export tab,
|
||||
/// where the server picks the encoder and keeps the renders (<c>edit-remote-export</c>); a render running on the
|
||||
/// server with its bar and Cancel (<c>edit-remote-running</c>); then, last as it stays, the sequence opened by an
|
||||
/// account without the Edit right (<c>edit-remote-readonly</c>).
|
||||
/// </summary>
|
||||
private static async Task<int> CaptureRemoteEditorAsync(MainWindow window, ShellViewModel shell, SampleData sample, string directory)
|
||||
{
|
||||
@@ -353,10 +363,10 @@ public static class ScreenCapture
|
||||
ThemeManager.Apply(theme);
|
||||
editor.SelectedTab = editor.Exposure;
|
||||
editor.IsCompare = true;
|
||||
written += await SaveEditorAsync(window, editor, directory, "sequence-remote", theme);
|
||||
written += await SaveEditorAsync(window, editor, directory, "edit-remote", theme);
|
||||
editor.SelectedTab = export;
|
||||
editor.IsCompare = false;
|
||||
written += await SaveEditorAsync(window, editor, directory, "sequence-remote-export", theme);
|
||||
written += await SaveEditorAsync(window, editor, directory, "edit-remote-export", theme);
|
||||
}
|
||||
|
||||
sample.RunServerRender();
|
||||
@@ -366,7 +376,7 @@ public static class ScreenCapture
|
||||
foreach (var theme in Themes)
|
||||
{
|
||||
ThemeManager.Apply(theme);
|
||||
written += await SaveEditorAsync(window, editor, directory, "sequence-remote-running", theme);
|
||||
written += await SaveEditorAsync(window, editor, directory, "edit-remote-running", theme);
|
||||
}
|
||||
|
||||
sample.EndServerJobs();
|
||||
@@ -382,7 +392,7 @@ public static class ScreenCapture
|
||||
foreach (var theme in Themes)
|
||||
{
|
||||
ThemeManager.Apply(theme);
|
||||
written += await SaveEditorAsync(window, viewer, directory, "sequence-remote-readonly", theme);
|
||||
written += await SaveEditorAsync(window, viewer, directory, "edit-remote-readonly", theme);
|
||||
}
|
||||
return written;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@ public enum SectionKey
|
||||
{
|
||||
Library,
|
||||
Import,
|
||||
Sequence,
|
||||
|
||||
/// <summary>One sequence analysed, edited and rendered step by step (owner review 1, R7; formerly Sequence).</summary>
|
||||
Edit,
|
||||
Archive,
|
||||
Jobs,
|
||||
Server,
|
||||
|
||||
@@ -30,6 +30,7 @@ public sealed class ShellViewModel : LocalizedViewModel
|
||||
private int _unseenFailures;
|
||||
private WelcomeViewModel? _welcome;
|
||||
private Guid? _currentSequenceId;
|
||||
private int _sequenceRequests;
|
||||
|
||||
public ShellViewModel(AppServices services)
|
||||
{
|
||||
@@ -146,24 +147,44 @@ public sealed class ShellViewModel : LocalizedViewModel
|
||||
private set => Set(ref _currentSequenceId, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Counts <see cref="OpenSequence"/> calls: asking for the open sequence again (the Library, Jobs, a project file) ends a
|
||||
/// choice of another in Edit, while coming back to Edit alone does not (owner review 1, R7).
|
||||
/// </summary>
|
||||
public int SequenceRequests
|
||||
{
|
||||
get => _sequenceRequests;
|
||||
private set => Set(ref _sequenceRequests, value);
|
||||
}
|
||||
|
||||
/// <summary>Loads the data of every screen once the index is open (or failed to open).</summary>
|
||||
public async Task StartAsync()
|
||||
{
|
||||
if (Services.OpenError is { } error) ReportError(error);
|
||||
Jobs.Attach();
|
||||
await Library.AttachAsync();
|
||||
// Edit opened before the index did shows its picker empty until now (neither "no sequences" nor Import).
|
||||
if (Sequence.ShowsPicker && Sequence.IsSelected) _ = Sequence.Picker.ReloadAsync();
|
||||
Settings.Attach();
|
||||
About.Attach();
|
||||
await Server.AttachAsync();
|
||||
}
|
||||
|
||||
/// <summary>Opens a sequence in the editor.</summary>
|
||||
/// <summary>Opens a sequence in Edit.</summary>
|
||||
public void OpenSequence(Guid sequenceId)
|
||||
{
|
||||
CurrentSequenceId = sequenceId;
|
||||
Navigate(SectionKey.Sequence);
|
||||
SequenceRequests++;
|
||||
Navigate(SectionKey.Edit);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Edit's open sequence (or none) is again the sequence asked for: after Keep editing, a choice cancelled, an open that
|
||||
/// failed, or the sequence asked for deleted. Coming back to Edit then neither asks once more nor tries again; asking
|
||||
/// for a sequence again (<see cref="OpenSequence"/>) does.
|
||||
/// </summary>
|
||||
internal void KeepSequence(Guid? sequenceId) => CurrentSequenceId = sequenceId;
|
||||
|
||||
/// <summary>Closes the first-run overlay for good.</summary>
|
||||
public void CompleteWelcome()
|
||||
{
|
||||
|
||||
@@ -435,7 +435,7 @@ internal sealed class AdvisorRules
|
||||
return;
|
||||
}
|
||||
var shake = _deep.Shake;
|
||||
if (shake.MeasuredFraction < 0.5)
|
||||
if (shake.MeasuredFraction < ShakeSummary.MinMeasuredFraction)
|
||||
{
|
||||
Missing(section, AdvisorParameters.Stabilize, AdvisorKeys.MissingShake, R(100 * shake.MeasuredFraction, 0));
|
||||
return;
|
||||
|
||||
@@ -89,7 +89,14 @@ public sealed record WhiteBalanceSummary(double JitterLog2, double DriftLog2, do
|
||||
/// <param name="CropCost">Area fraction a centred crop must give up to hide every correction.</param>
|
||||
/// <param name="PanPxPerFrame">Average drift of the smoothed path.</param>
|
||||
/// <param name="MeasuredFraction">Share of frame pairs whose shift could be measured (textured patches).</param>
|
||||
public sealed record ShakeSummary(double RmsPx, double MaxPx, double CropCost, double PanPxPerFrame, bool PanDetected, double MeasuredFraction);
|
||||
public sealed record ShakeSummary(double RmsPx, double MaxPx, double CropCost, double PanPxPerFrame, bool PanDetected, double MeasuredFraction)
|
||||
{
|
||||
/// <summary>
|
||||
/// Below this share of measured frame pairs the shake is unknown: the advisor decides nothing about stabilisation and
|
||||
/// the editor shows no shake value (unmeasured shifts count as none, so the path would look steadier than it is).
|
||||
/// </summary>
|
||||
public const double MinMeasuredFraction = 0.5;
|
||||
}
|
||||
|
||||
/// <param name="MedianPx">Median of the sampled pairs' median flow magnitude, source px per frame.</param>
|
||||
/// <param name="P95Px">Median of the sampled pairs' 95th-percentile magnitude: the typical speed of moving content.</param>
|
||||
|
||||
Reference in new issue
Block a user