feat(editor): visual crop, rotate/mirror/flip/straighten, colour looks (owner review 1 phase 4) (#26)
CI / Build and test (push) Successful in 8m19s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 12m9s
CI / PostgreSQL 16 integration (push) Successful in 7m49s
CI / PostgreSQL 17 integration (push) Successful in 7m19s
CI / Docker image (push) Successful in 46s
Release / Server image (push) Successful in 1m14s
CI / Build and test (push) Successful in 8m19s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 12m9s
CI / PostgreSQL 16 integration (push) Successful in 7m49s
CI / PostgreSQL 17 integration (push) Successful in 7m19s
CI / Docker image (push) Successful in 46s
Release / Server image (push) Successful in 1m14s
Owner review 1 R5 + R6. Camera rotation, mirror, flip, straighten and crop handles locked to the output; an Exposure Look group; Export output size ("proportions win"); settings format 2 with older-node gates. Also fixes project text and hashes differing between Windows and Linux.
Closes #19
Closes #20
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
This commit was merged in pull request #26.
This commit is contained in:
1 parent
db389a54f2
commit
188b2c2e55
355 files changed
+10549
-1061
No files matched your search
@@ -422,6 +422,26 @@ public sealed class SampleData
|
||||
return id;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The editor sample framed for a phone (owner review 1, R5): a 9:16 crop box locked to the proportions, smaller than
|
||||
/// the largest and moved right of and above the centre, so its handles and the scrim show on every side.
|
||||
/// </summary>
|
||||
public static ProjectSettings PortraitCrop(EditorSession session, ProjectSettings project)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(session);
|
||||
return CameraTab.WithCropRows(session, EditorSettings.Aspect.WithManual(project, "9:16"), size: 0.72, x: 0.6, y: -0.5);
|
||||
}
|
||||
|
||||
/// <summary>The editor sample levelled by hand (owner review 1, R6): straightened 3° clockwise.</summary>
|
||||
public static ProjectSettings Straightened(ProjectSettings project)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(project);
|
||||
return project with { Camera = project.Camera with { Straighten = 3 } };
|
||||
}
|
||||
|
||||
/// <summary>The editor sample with a colour look (owner review 1, R6): Sepia at 60 %.</summary>
|
||||
public static ProjectSettings SepiaLook(ProjectSettings project) => ExposureTab.WithLook(project, "sepia", 0.6);
|
||||
|
||||
/// <summary>A deep analysis of <paramref name="sequenceId"/> half way through: the editor's busy state (settings wait, viewing stays live).</summary>
|
||||
public async Task MarkAnalysingAsync(Guid sequenceId)
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Windows.Input;
|
||||
using Chronos.App.Infrastructure;
|
||||
using Chronos.Core.Advice;
|
||||
using Chronos.Core.Export;
|
||||
using Chronos.Core.Imaging.Geometry;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Mathematics;
|
||||
using Chronos.Core.Project;
|
||||
@@ -13,9 +14,10 @@ using Chronos.Ui.Visuals;
|
||||
namespace Chronos.App.Editor;
|
||||
|
||||
/// <summary>
|
||||
/// Camera (BRIEF §12.3): the free crop of the frame (margins), the output aspect and its placement inside the crop, and
|
||||
/// Camera (BRIEF §12.3, owner review 1 R5/R6): the output aspect, the orientation (quarter turns, mirror, flip,
|
||||
/// straighten), the crop box locked to the aspect (its size and its place in the frame; the preview edits it too), and
|
||||
/// virtual-camera keyframes edited as a zoom curve over the sequence (X = frame, Y = zoom) with the selected keyframe's
|
||||
/// framing below.
|
||||
/// framing below. Reset framing clears the crop and the orientation, never the keyframes.
|
||||
/// </summary>
|
||||
public sealed class CameraTab : EditorTab
|
||||
{
|
||||
@@ -27,30 +29,111 @@ public sealed class CameraTab : EditorTab
|
||||
public CameraTab(EditorViewModel editor)
|
||||
: base(editor, "Camera", AdvisorSection.Camera)
|
||||
{
|
||||
var s = editor.Session;
|
||||
Rows =
|
||||
Rows = FramingRows(editor.Session);
|
||||
AddKeyCommand = new RelayCommand(AddKey, () => !Editor.IsLocked && Keys.All(k => k.Frame != Editor.CurrentIndex));
|
||||
RemoveKeyCommand = new RelayCommand(RemoveKey, () => !Editor.IsLocked && SelectedKey >= 0);
|
||||
ResetFramingCommand = new RelayCommand(() => Editor.Session.ResetFraming(), () => !Editor.IsLocked && HasFraming);
|
||||
CommitCurveCommand = new RelayCommand(CommitCurve);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The quarter turns the Rotation row shows, as the user sees them: the stored turn is that of the unmirrored picture,
|
||||
/// which runs the other way while exactly one of Mirror and Flip is on (a mirror reverses the sense of a turn), so a
|
||||
/// press of Rotate right always counts up.
|
||||
/// </summary>
|
||||
public static int ShownTurns(CameraSettings camera)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(camera);
|
||||
var turns = FrameOrientation.TurnsOf(camera.Rotate);
|
||||
return camera.Mirror ^ camera.Flip ? (4 - turns) % 4 : turns;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The step's rows, top to bottom: Aspect (a change refits the crop, <see cref="EditorSession.KeepCropLocked"/>),
|
||||
/// Rotation (a quarter turn per press, as the user sees the picture), Mirror, Flip, Straighten (±15°, the preview's
|
||||
/// grid while it is used), and the crop box as Crop size (a share of the largest box the aspect allows), Crop X and
|
||||
/// Crop Y (its centre within the frame's slack). The crop rows write the locked box itself with the offsets at 0, so a
|
||||
/// legacy crop placed by offsets is baked in at its first edit (<see cref="CropFrame.Locked"/>).
|
||||
/// </summary>
|
||||
public static IReadOnlyList<SettingRow> FramingRows(EditorSession session)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(session);
|
||||
var s = session;
|
||||
string? NoSlack(ProjectSettings p, bool horizontal) =>
|
||||
CropFrame.HasSlack(LockedBox(s, p), horizontal) ? null : Loc.L("Tooltips.Editor.NotApplicable.NoSlack");
|
||||
return
|
||||
[
|
||||
CropRow(s, CropSide.Left, "Editor.Camera.CropLeft"),
|
||||
CropRow(s, CropSide.Right, "Editor.Camera.CropRight"),
|
||||
CropRow(s, CropSide.Top, "Editor.Camera.CropTop"),
|
||||
CropRow(s, CropSide.Bottom, "Editor.Camera.CropBottom"),
|
||||
new AutoChoiceRow<string>(s, EditorSettings.Aspect, "Editor.Camera.Aspect", "Tooltips.Editor.Camera.Aspect",
|
||||
[
|
||||
new Choice("source", "Editor.Aspect.Source"), new Choice("16:9", "Editor.Aspect.Ratio", "16:9"), new Choice("21:9", "Editor.Aspect.Ratio", "21:9"),
|
||||
new Choice("4:3", "Editor.Aspect.Ratio", "4:3"), new Choice("3:2", "Editor.Aspect.Ratio", "3:2"), new Choice("1:1", "Editor.Aspect.Ratio", "1:1"),
|
||||
new Choice("9:16", "Editor.Aspect.Ratio", "9:16"), new Choice("4:5", "Editor.Aspect.Ratio", "4:5"),
|
||||
]),
|
||||
new NumberRow(s, "Editor.Camera.OffsetX", "Tooltips.Editor.Camera.OffsetX", -1, 1, 0.05, p => p.Camera.OffsetX,
|
||||
(p, v) => p with { Camera = p.Camera with { OffsetX = v } }, EditorText.Placement),
|
||||
new NumberRow(s, "Editor.Camera.OffsetY", "Tooltips.Editor.Camera.OffsetY", -1, 1, 0.05, p => p.Camera.OffsetY,
|
||||
(p, v) => p with { Camera = p.Camera with { OffsetY = v } }, EditorText.Placement),
|
||||
new IconActionsRow("Editor.Camera.Rotation", "Tooltips.Editor.Camera.Rotation",
|
||||
() => Loc.L("Editor.Value.Degrees", (ShownTurns(s.Project.Camera) * 90).ToString(Loc.Culture)),
|
||||
[
|
||||
new IconAction("Icon.RotateLeft", "Editor.Camera.RotateLeft", "Tooltips.Editor.Camera.RotateLeft", () => s.Orient(OrientationOp.RotateLeft)),
|
||||
new IconAction("Icon.RotateRight", "Editor.Camera.RotateRight", "Tooltips.Editor.Camera.RotateRight", () => s.Orient(OrientationOp.RotateRight)),
|
||||
]),
|
||||
new SwitchRow(s, "Editor.Camera.Mirror", "Tooltips.Editor.Camera.Mirror", p => p.Camera.Mirror, _ => s.Orient(OrientationOp.Mirror)),
|
||||
new SwitchRow(s, "Editor.Camera.Flip", "Tooltips.Editor.Camera.Flip", p => p.Camera.Flip, _ => s.Orient(OrientationOp.Flip)),
|
||||
new NumberRow(s, "Editor.Camera.Straighten", "Tooltips.Editor.Camera.Straighten", -FrameOrientation.MaxStraighten, FrameOrientation.MaxStraighten, 0.1,
|
||||
p => FrameOrientation.StraightenOf(p.Camera.Straighten),
|
||||
(p, v) => p with { Camera = p.Camera with { Straighten = double.Round(v, 1) + 0.0 } }, Degrees)
|
||||
{ ShowsGrid = true },
|
||||
new NumberRow(s, "Editor.Camera.CropSize", "Tooltips.Editor.Camera.CropSize", CropFrame.MinimumShare, 1, 0.01, p => CropRows(s, p).Size,
|
||||
(p, v) => WithCropRows(s, p, size: v), v => Formatting.Percent(v)),
|
||||
new NumberRow(s, "Editor.Camera.CropX", "Tooltips.Editor.Camera.CropX", -1, 1, 0.01, p => CropRows(s, p).X,
|
||||
(p, v) => WithCropRows(s, p, x: v), EditorText.Placement, p => NoSlack(p, horizontal: true)),
|
||||
new NumberRow(s, "Editor.Camera.CropY", "Tooltips.Editor.Camera.CropY", -1, 1, 0.01, p => CropRows(s, p).Y,
|
||||
(p, v) => WithCropRows(s, p, y: v), EditorText.Placement, p => NoSlack(p, horizontal: false)),
|
||||
];
|
||||
AddKeyCommand = new RelayCommand(AddKey, () => !Editor.IsLocked && Keys.All(k => k.Frame != Editor.CurrentIndex));
|
||||
RemoveKeyCommand = new RelayCommand(RemoveKey, () => !Editor.IsLocked && SelectedKey >= 0);
|
||||
CommitCurveCommand = new RelayCommand(CommitCurve);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
/// <summary>The crop box the editor shows for <paramref name="project"/>: the stored crop locked to the output proportions (<see cref="CropFrame.Locked"/>).</summary>
|
||||
public static RectD LockedBox(EditorSession session, ProjectSettings project)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(session);
|
||||
ArgumentNullException.ThrowIfNull(project);
|
||||
var camera = project.Camera;
|
||||
return CropFrame.Locked(camera.Crop, session.CropLockRatio(project), camera.OffsetX, camera.OffsetY);
|
||||
}
|
||||
|
||||
/// <summary>The Crop size, Crop X and Crop Y rows of <paramref name="project"/> (<see cref="CropFrame.ToRows"/>).</summary>
|
||||
public static (double Size, double X, double Y) CropRows(EditorSession session, ProjectSettings project)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(session);
|
||||
return CropFrame.ToRows(LockedBox(session, project), session.CropLockRatio(project));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <paramref name="project"/> with one of the crop rows changed: the locked box of the rows written as the crop (null
|
||||
/// for the whole view), the offsets at 0.
|
||||
/// </summary>
|
||||
public static ProjectSettings WithCropRows(EditorSession session, ProjectSettings project, double? size = null, double? x = null, double? y = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(session);
|
||||
ArgumentNullException.ThrowIfNull(project);
|
||||
var ratio = session.CropLockRatio(project);
|
||||
var rows = CropFrame.ToRows(LockedBox(session, project), ratio);
|
||||
var box = CropFrame.FromRows(size ?? rows.Size, x ?? rows.X, y ?? rows.Y, ratio);
|
||||
return project with { Camera = project.Camera with { Crop = CropFrame.ToCrop(box), OffsetX = 0, OffsetY = 0 } };
|
||||
}
|
||||
|
||||
/// <summary>Straighten as its row shows it: "−1.2°", "0°".</summary>
|
||||
public static string Degrees(double value) => Loc.L("Editor.Value.Degrees", value.ToString("0.0;−0.0;0", Loc.Culture));
|
||||
|
||||
/// <summary>Something Reset framing clears is set: a crop, offsets, a rotation, mirror, flip or straighten.</summary>
|
||||
public bool HasFraming => EditorSession.HasFraming(Editor.Session.Project.Camera);
|
||||
|
||||
/// <summary>Reset framing (next to Optimise section and Reset).</summary>
|
||||
public ICommand ResetFramingCommand { get; }
|
||||
|
||||
/// <summary>What Reset framing clears, that there is nothing to clear, or why it waits.</summary>
|
||||
public string ResetFramingToolTip => Editor.LockedToolTip
|
||||
?? Loc.L(HasFraming ? "Tooltips.Editor.Camera.ResetFraming" : "Tooltips.Editor.Camera.ResetFramingNone");
|
||||
|
||||
/// <summary>Keyframes as curve points: X = frame / (count − 1), Y = (zoom − 1) / (<see cref="MaxZoom"/> − 1). Edited in place by the curve editor.</summary>
|
||||
public ObservableCollection<Point> KeyPoints { get; } = [];
|
||||
|
||||
@@ -70,13 +153,13 @@ public sealed class CameraTab : EditorTab
|
||||
public double SelectedCenterX
|
||||
{
|
||||
get => HasSelectedKey ? Keys[SelectedKey].CenterX : 0.5;
|
||||
set => EditSelected(k => k with { CenterX = double.Clamp(value, 0, 1) });
|
||||
set => EditSelected(k => k with { CenterX = CropFrame.Grid(double.Clamp(value, 0, 1)) });
|
||||
}
|
||||
|
||||
public double SelectedCenterY
|
||||
{
|
||||
get => HasSelectedKey ? Keys[SelectedKey].CenterY : 0.5;
|
||||
set => EditSelected(k => k with { CenterY = double.Clamp(value, 0, 1) });
|
||||
set => EditSelected(k => k with { CenterY = CropFrame.Grid(double.Clamp(value, 0, 1)) });
|
||||
}
|
||||
|
||||
public double SelectedZoom
|
||||
@@ -128,6 +211,8 @@ public sealed class CameraTab : EditorTab
|
||||
}
|
||||
if (SelectedKey >= Keys.Count) SelectedKey = Keys.Count - 1;
|
||||
OnSelectedKeyChanged();
|
||||
OnPropertyChanged(nameof(HasFraming));
|
||||
OnPropertyChanged(nameof(ResetFramingToolTip));
|
||||
}
|
||||
|
||||
/// <summary>The curve editor finished an edit (add, move, delete): the points become the keyframes, keeping each one's framing.</summary>
|
||||
@@ -157,13 +242,9 @@ public sealed class CameraTab : EditorTab
|
||||
OnPropertyChanged(nameof(AddKeyToolTip));
|
||||
OnPropertyChanged(nameof(RemoveKeyToolTip));
|
||||
OnPropertyChanged(nameof(CurveToolTip));
|
||||
OnPropertyChanged(nameof(ResetFramingToolTip));
|
||||
}
|
||||
|
||||
/// <summary>A margin of the free crop (<see cref="CropMargins"/>); all zero = the whole frame.</summary>
|
||||
private static NumberRow CropRow(EditorSession session, CropSide side, string headerKey) => new(session, headerKey, "Tooltips.Editor.Camera.Crop", 0,
|
||||
CropMargins.MaxMargin, 0.01, p => CropMargins.Of(p.Camera.Crop)[(int)side],
|
||||
(p, v) => p with { Camera = p.Camera with { Crop = CropMargins.With(p.Camera.Crop, side, v) } }, v => Formatting.Percent(v));
|
||||
|
||||
private Point ToPoint(CameraKey key) => new(Editor.FrameCount > 1 ? (double)key.Frame / (Editor.FrameCount - 1) : 0, (key.Zoom - 1) / (MaxZoom - 1));
|
||||
|
||||
private void AddKey()
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Input;
|
||||
using Chronos.Ui.Visuals;
|
||||
|
||||
namespace Chronos.App.Editor;
|
||||
|
||||
/// <summary>
|
||||
/// Runs a command after every finished edit of the crop box on a <see cref="PreviewViewport"/> (a drag released, a key
|
||||
/// press), with the <see cref="CropEditEventArgs"/> as its parameter (owner review 1, R5).
|
||||
/// </summary>
|
||||
public static class CropCommit
|
||||
{
|
||||
public static readonly DependencyProperty CommandProperty = DependencyProperty.RegisterAttached(
|
||||
"Command", typeof(ICommand), typeof(CropCommit), new PropertyMetadata(null, OnCommandChanged));
|
||||
|
||||
public static ICommand? GetCommand(DependencyObject d) => (ICommand?)d.GetValue(CommandProperty);
|
||||
|
||||
public static void SetCommand(DependencyObject d, ICommand? value) => d.SetValue(CommandProperty, value);
|
||||
|
||||
private static void OnCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is not PreviewViewport viewport) return;
|
||||
viewport.CropEditCompleted -= OnEditCompleted;
|
||||
if (e.NewValue is not null) viewport.CropEditCompleted += OnEditCompleted;
|
||||
}
|
||||
|
||||
private static void OnEditCompleted(object sender, CropEditEventArgs e)
|
||||
{
|
||||
if (GetCommand((DependencyObject)sender) is { } command && command.CanExecute(e)) command.Execute(e);
|
||||
}
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
namespace Chronos.App.Editor;
|
||||
|
||||
/// <summary>Margins of the free crop, in the order of <see cref="CropMargins.Of"/> (opposites differ in the lowest bit).</summary>
|
||||
public enum CropSide
|
||||
{
|
||||
Left,
|
||||
Right,
|
||||
Top,
|
||||
Bottom,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Camera tab's crop margins over <c>CameraSettings.Crop</c> (a normalised x, y, width, height rectangle, null for the
|
||||
/// whole frame): each margin at most <see cref="MaxMargin"/>, opposite margins leaving at least <see cref="MinSize"/>.
|
||||
/// </summary>
|
||||
public static class CropMargins
|
||||
{
|
||||
public const double MaxMargin = 0.45;
|
||||
|
||||
public const double MinSize = 0.1;
|
||||
|
||||
/// <summary>Left, right, top and bottom margins of <paramref name="crop"/> (zeros for none or an invalid one, which the render ignores too).</summary>
|
||||
public static double[] Of(double[]? crop) => crop is [var x, var y, var w, var h] && double.IsFinite(x + y + w + h)
|
||||
? [double.Clamp(x, 0, 1), double.Clamp(1 - x - w, 0, 1), double.Clamp(y, 0, 1), double.Clamp(1 - y - h, 0, 1)]
|
||||
: [0, 0, 0, 0];
|
||||
|
||||
/// <summary><paramref name="crop"/> with one margin changed; null when no margin is left (the whole frame).</summary>
|
||||
public static double[]? With(double[]? crop, CropSide side, double value)
|
||||
{
|
||||
var margins = Of(crop);
|
||||
var opposite = (int)side ^ 1;
|
||||
margins[(int)side] = double.Clamp(value, 0, double.Min(MaxMargin, 1 - MinSize - margins[opposite]));
|
||||
if (margins.All(m => m == 0)) return null;
|
||||
var (left, right, top, bottom) = (margins[0], margins[1], margins[2], margins[3]);
|
||||
return [left, top, 1 - left - right, 1 - top - bottom];
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@ using Chronos.App.Jobs;
|
||||
using Chronos.Core.Advice;
|
||||
using Chronos.Core.Analysis;
|
||||
using Chronos.Core.Analysis.Deep;
|
||||
using Chronos.Core.Imaging.Color;
|
||||
using Chronos.Core.Imaging.Geometry;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Core.Project;
|
||||
@@ -223,13 +225,17 @@ public static class EditPath
|
||||
|| (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>
|
||||
/// <summary>
|
||||
/// Values of the section set by hand that are not Auto settings: crop, offsets, orientation and camera moves; fit to a
|
||||
/// duration; the exposure offset and the look.
|
||||
/// </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.Camera => !CropFrame.IsWhole(project.Camera.Crop) || project.Camera.OffsetX != 0 || project.Camera.OffsetY != 0
|
||||
|| project.Camera.Keyframes.Count > 0 || project.Camera.IsOriented,
|
||||
AdvisorSection.Timing => project.Timing.FitToSeconds is > 0,
|
||||
AdvisorSection.Exposure => project.Exposure.ExposureOffsetEv != 0,
|
||||
// A look that changes no pixel (none, 0 %, a filter this Chronos does not know, which renders as none) is no hand value.
|
||||
AdvisorSection.Exposure => project.Exposure.ExposureOffsetEv != 0 || project.Look is { IsIdentity: false } look && LookFilter.IsKnown(look.Filter),
|
||||
_ => false,
|
||||
};
|
||||
|
||||
|
||||
@@ -101,9 +101,62 @@
|
||||
<Setter TargetName="NotApplicable" Property="Visibility" Value="Visible" />
|
||||
<Setter TargetName="Slider" Property="IsEnabled" Value="False" />
|
||||
</DataTrigger>
|
||||
<!-- Straighten: while the slider is dragged or focused, the preview shows its fine grid (owner review 1, R6). -->
|
||||
<DataTrigger Binding="{Binding ShowsGrid}" Value="True">
|
||||
<Setter TargetName="Slider" Property="e:SliderActivity.Tracks" Value="True" />
|
||||
<Setter TargetName="Slider" Property="e:SliderActivity.IsActive"
|
||||
Value="{Binding DataContext.Editor.IsStraightening, RelativeSource={RelativeSource AncestorType=ItemsControl}, Mode=OneWayToSource}" />
|
||||
</DataTrigger>
|
||||
</DataTemplate.Triggers>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- A plain switch (Mirror, Flip): one toggle is one undo step. -->
|
||||
<DataTemplate DataType="{x:Type e:SwitchRow}">
|
||||
<Grid Margin="0,0,0,12" MinHeight="26">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{Binding Header}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTip="{Binding ToolTip}" />
|
||||
<CheckBox Grid.Column="1" Style="{StaticResource CheckBox.Switch}" Margin="8,0,0,0" IsChecked="{Binding IsOn}" VerticalAlignment="Center"
|
||||
ToolTip="{Binding ToolTip}" AutomationProperties.Name="{Binding Header}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- Label, value, then 28 px icon-only buttons (Rotation: "90°", Rotate left, Rotate right). -->
|
||||
<DataTemplate DataType="{x:Type e:IconActionsRow}">
|
||||
<Grid Margin="0,0,0,12" MinHeight="28">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<TextBlock Text="{Binding Header}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" ToolTip="{Binding ToolTip}" />
|
||||
<TextBlock Grid.Column="1" Style="{StaticResource Text.RowValue}" Text="{Binding Value}" Margin="8,0,0,0" ToolTip="{Binding ToolTip}" />
|
||||
<ItemsControl Grid.Column="2" ItemsSource="{Binding Actions}" Focusable="False" VerticalAlignment="Center">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Horizontal" />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type e:IconAction}">
|
||||
<Button Style="{StaticResource Button.Icon}" Width="28" Height="28" MinWidth="28" Margin="6,0,0,0" ui:ButtonIcon.Glyph="{Binding Glyph}"
|
||||
Command="{Binding Command}" ToolTip="{Binding ToolTip}" ToolTipService.ShowOnDisabled="True" AutomationProperties.Name="{Binding Name}" />
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- A group inside a step's column (Look on Exposure): a 1 px divider, then its name. -->
|
||||
<DataTemplate DataType="{x:Type e:GroupRow}">
|
||||
<StackPanel Margin="0,2,0,12">
|
||||
<Border Height="1" Background="{DynamicResource Brush.Stroke}" Margin="0,0,0,12" />
|
||||
<TextBlock Text="{Binding Header}" Style="{StaticResource Text.Body}" FontWeight="SemiBold" TextTrimming="CharacterEllipsis" ToolTip="{Binding ToolTip}" />
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
|
||||
<DataTemplate DataType="{x:Type e:ChoiceRow}">
|
||||
<Grid Margin="0,0,0,12" MinHeight="32">
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -135,18 +188,28 @@
|
||||
</DataTemplate.Triggers>
|
||||
</DataTemplate>
|
||||
|
||||
<!-- ===================== Section frame: title, rows, extra content, Optimise section · Reset ===================== -->
|
||||
<!--
|
||||
===================== Section frame: title, rows, extra content, Optimise section · Reset =====================
|
||||
The ContentControl's Tag is a step's own action, on its line above them (Camera: Reset framing; the three buttons do
|
||||
not fit one line of the 320 px column).
|
||||
-->
|
||||
<ControlTemplate x:Key="Template.SectionPanel" TargetType="ContentControl">
|
||||
<Border Style="{StaticResource Border.EditorPanel}">
|
||||
<DockPanel>
|
||||
<TextBlock DockPanel.Dock="Top" Text="{Binding Header}" Style="{StaticResource Text.Section}" Margin="0,0,0,14" />
|
||||
<Grid DockPanel.Dock="Bottom" Margin="0,12,0,0">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Button Content="{l:Loc Editor.OptimiseSection}" Command="{Binding OptimiseCommand}" ToolTip="{Binding OptimiseToolTip}" ToolTipService.ShowOnDisabled="True" />
|
||||
<Button Grid.Column="1" Style="{StaticResource Button.SectionReset}" Content="{l:Loc Editor.Reset}" Margin="8,0,0,0" Command="{Binding ResetCommand}"
|
||||
<ContentPresenter Grid.ColumnSpan="2" Content="{TemplateBinding Tag}" HorizontalAlignment="Right" Margin="0,0,0,8"
|
||||
Visibility="{TemplateBinding Tag, Converter={x:Static ui:NullToCollapsedConverter.Instance}}" />
|
||||
<Button Grid.Row="1" Content="{l:Loc Editor.OptimiseSection}" Command="{Binding OptimiseCommand}" ToolTip="{Binding OptimiseToolTip}" ToolTipService.ShowOnDisabled="True" />
|
||||
<Button Grid.Row="1" Grid.Column="1" Style="{StaticResource Button.SectionReset}" Content="{l:Loc Editor.Reset}" Margin="8,0,0,0" Command="{Binding ResetCommand}"
|
||||
ToolTip="{Binding ResetToolTip}" Visibility="{Binding CanReset, Converter={StaticResource BoolToVisibility}}" />
|
||||
</Grid>
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled" Focusable="False">
|
||||
@@ -211,9 +274,13 @@
|
||||
<ContentControl Template="{StaticResource Template.SectionPanel}" Focusable="False" />
|
||||
</DataTemplate>
|
||||
|
||||
<!-- Camera: rows, then the selected keyframe's framing. -->
|
||||
<!-- Camera: rows (aspect, orientation, crop), then the keyframes and the selected keyframe's framing; Reset framing above Optimise section · Reset. -->
|
||||
<DataTemplate DataType="{x:Type e:CameraTab}">
|
||||
<ContentControl Template="{StaticResource Template.SectionPanel}" Focusable="False">
|
||||
<ContentControl.Tag>
|
||||
<Button Style="{StaticResource Button.SectionReset}" Content="{l:Loc Editor.Camera.ResetFraming}" Command="{Binding ResetFramingCommand}"
|
||||
ToolTip="{Binding ResetFramingToolTip}" ToolTipService.ShowOnDisabled="True" />
|
||||
</ContentControl.Tag>
|
||||
<StackPanel Margin="0,4,0,0">
|
||||
<Grid MinHeight="26" Margin="0,0,0,8">
|
||||
<Grid.ColumnDefinitions>
|
||||
@@ -364,6 +431,7 @@
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Style="{StaticResource Text.Label}" Text="{l:Loc Editor.Export.Container}" ToolTip="{l:Loc Editor.Export.Container}" />
|
||||
<ComboBox Grid.Column="1" Margin="0,0,0,8" ItemsSource="{Binding Containers}" SelectedItem="{Binding SelectedContainer}" DisplayMemberPath="Label"
|
||||
@@ -389,8 +457,13 @@
|
||||
<TextBlock Grid.Column="3" Text="{Binding AspectText}" Style="{StaticResource Text.Hint}" FontSize="{StaticResource Size.Secondary}" Margin="6,0,0,0" />
|
||||
</Grid>
|
||||
|
||||
<TextBlock Grid.Row="3" Style="{StaticResource Text.Label}" Text="{l:Loc Editor.Export.FrameRate}" ToolTip="{l:Loc Editor.Export.FrameRate}" />
|
||||
<Grid Grid.Row="3" Grid.Column="1" Margin="0,0,0,8">
|
||||
<!-- What is rendered: the chosen proportions fitted in the box above (owner review 1, R5), "(capped)" when the encoder shrinks it. -->
|
||||
<TextBlock Grid.Row="3" Style="{StaticResource Text.Label}" Text="{l:Loc Editor.Export.OutputSize}" ToolTip="{l:Loc Editor.Export.OutputSize}" />
|
||||
<TextBlock Grid.Row="3" Grid.Column="1" Margin="0,0,0,8" MinHeight="24" Style="{StaticResource Text.Number}" Text="{Binding OutputSizeText}"
|
||||
ToolTip="{Binding OutputSizeToolTip}" VerticalAlignment="Center" TextTrimming="CharacterEllipsis" />
|
||||
|
||||
<TextBlock Grid.Row="4" Style="{StaticResource Text.Label}" Text="{l:Loc Editor.Export.FrameRate}" ToolTip="{l:Loc Editor.Export.FrameRate}" />
|
||||
<Grid Grid.Row="4" Grid.Column="1" Margin="0,0,0,8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
@@ -406,8 +479,8 @@
|
||||
Visibility="{Binding IsFrameRateAuto, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
|
||||
</Grid>
|
||||
|
||||
<TextBlock Grid.Row="4" Style="{StaticResource Text.Label}" Text="{l:Loc Editor.Export.Quality}" ToolTip="{l:Loc Editor.Export.Quality}" />
|
||||
<Grid Grid.Row="4" Grid.Column="1" Margin="0,0,0,8" MinHeight="32">
|
||||
<TextBlock Grid.Row="5" Style="{StaticResource Text.Label}" Text="{l:Loc Editor.Export.Quality}" ToolTip="{l:Loc Editor.Export.Quality}" />
|
||||
<Grid Grid.Row="5" Grid.Column="1" Margin="0,0,0,8" MinHeight="32">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" MinWidth="64" />
|
||||
@@ -421,8 +494,8 @@
|
||||
Visibility="{Binding IsQualityApplicable, Converter={x:Static ui:InverseBoolToVisibilityConverter.Instance}}" />
|
||||
</Grid>
|
||||
|
||||
<TextBlock Grid.Row="5" Style="{StaticResource Text.Label}" Text="{l:Loc Editor.Export.Encoder}" ToolTip="{l:Loc Editor.Export.Encoder}" />
|
||||
<Grid Grid.Row="5" Grid.Column="1" Margin="0,0,0,8">
|
||||
<TextBlock Grid.Row="6" Style="{StaticResource Text.Label}" Text="{l:Loc Editor.Export.Encoder}" ToolTip="{l:Loc Editor.Export.Encoder}" />
|
||||
<Grid Grid.Row="6" Grid.Column="1" Margin="0,0,0,8">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*" />
|
||||
<ColumnDefinition Width="Auto" />
|
||||
@@ -443,18 +516,18 @@
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
|
||||
<TextBlock Grid.Row="6" Style="{StaticResource Text.Label}" Text="{l:Loc Editor.Export.Colour}" ToolTip="{l:Loc Editor.Export.Colour}" />
|
||||
<ComboBox Grid.Row="6" Grid.Column="1" Margin="0,0,0,8" ItemsSource="{Binding Depths}" SelectedItem="{Binding SelectedDepth}" DisplayMemberPath="Label"
|
||||
<TextBlock Grid.Row="7" Style="{StaticResource Text.Label}" Text="{l:Loc Editor.Export.Colour}" ToolTip="{l:Loc Editor.Export.Colour}" />
|
||||
<ComboBox Grid.Row="7" Grid.Column="1" Margin="0,0,0,8" ItemsSource="{Binding Depths}" SelectedItem="{Binding SelectedDepth}" DisplayMemberPath="Label"
|
||||
IsEnabled="{Binding CanChooseDepth}" ToolTip="{l:Loc Tooltips.Editor.Export.Colour}" ToolTipService.ShowOnDisabled="True"
|
||||
AutomationProperties.Name="{l:Loc Editor.Export.Colour}" />
|
||||
|
||||
<TextBlock Grid.Row="7" Style="{StaticResource Text.Label}" Text="{l:Loc Editor.Export.FileName}" ToolTip="{l:Loc Editor.Export.FileName}" />
|
||||
<TextBox Grid.Row="7" Grid.Column="1" Margin="0,0,0,8" Text="{Binding NameTemplate.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
|
||||
<TextBlock Grid.Row="8" Style="{StaticResource Text.Label}" Text="{l:Loc Editor.Export.FileName}" ToolTip="{l:Loc Editor.Export.FileName}" />
|
||||
<TextBox Grid.Row="8" Grid.Column="1" Margin="0,0,0,8" Text="{Binding NameTemplate.Text, UpdateSourceTrigger=PropertyChanged, ValidatesOnNotifyDataErrors=True}"
|
||||
shell:EditBehavior.Field="{Binding NameTemplate}" ToolTip="{Binding NameTemplate.ToolTip}" AutomationProperties.Name="{l:Loc Editor.Export.FileName}" />
|
||||
|
||||
<TextBlock Grid.Row="8" Style="{StaticResource Text.Label}" Text="{l:Loc Editor.Export.SaveTo}" ToolTip="{l:Loc Editor.Export.SaveTo}" />
|
||||
<TextBlock Grid.Row="9" Style="{StaticResource Text.Label}" Text="{l:Loc Editor.Export.SaveTo}" ToolTip="{l:Loc Editor.Export.SaveTo}" />
|
||||
<!-- The folder ends in an ellipsis (its full path is in the tooltip). -->
|
||||
<ComboBox Grid.Row="8" Grid.Column="1" ItemsSource="{Binding SaveChoices}" SelectedItem="{Binding SelectedSave}" IsEnabled="{Binding CanChooseFolder}"
|
||||
<ComboBox Grid.Row="9" Grid.Column="1" ItemsSource="{Binding SaveChoices}" SelectedItem="{Binding SelectedSave}" IsEnabled="{Binding CanChooseFolder}"
|
||||
ToolTip="{Binding SaveToolTip}" ToolTipService.ShowOnDisabled="True" AutomationProperties.Name="{l:Loc Editor.Export.SaveTo}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate DataType="{x:Type e:SaveChoice}">
|
||||
@@ -464,7 +537,7 @@
|
||||
</ComboBox>
|
||||
<!-- Export.html "Sync" (12 px): also send the render to the server the sequence is linked to. Under the folder rather than beside
|
||||
it, as in the mockup, so that neither is cut in the 194 px field column in longer languages. -->
|
||||
<CheckBox Grid.Row="9" Grid.Column="1" Margin="0,6,0,0" HorizontalAlignment="Left" FontSize="{StaticResource Size.Secondary}"
|
||||
<CheckBox Grid.Row="10" Grid.Column="1" Margin="0,6,0,0" HorizontalAlignment="Left" FontSize="{StaticResource Size.Secondary}"
|
||||
Content="{l:Loc Editor.Export.Sync}" IsChecked="{Binding SyncToServer}" IsEnabled="{Binding CanSync}" ToolTip="{Binding SyncToolTip}"
|
||||
ToolTipService.ShowOnDisabled="True" />
|
||||
</Grid>
|
||||
|
||||
@@ -1,7 +1,9 @@
|
||||
using Chronos.Core.Advice;
|
||||
using Chronos.Core.Diagnostics;
|
||||
using Chronos.Core.Export;
|
||||
using Chronos.Core.Imaging.Geometry;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Core.Render;
|
||||
using Chronos.Core.Video;
|
||||
using Chronos.Data.Archiving.Jobs;
|
||||
using Chronos.Data.Processing;
|
||||
@@ -109,12 +111,89 @@ public sealed class EditorSession : IAsyncDisposable
|
||||
/// </summary>
|
||||
public ProjectConflictException? Conflict { get; private set; }
|
||||
|
||||
/// <summary>Applies <paramref name="change"/> as an undoable step; false when it changes nothing.</summary>
|
||||
/// <summary>
|
||||
/// Applies <paramref name="change"/> as an undoable step; false when it changes nothing. A crop box locked to the
|
||||
/// output proportions follows a change of them (<see cref="KeepCropLocked"/>) in the same step.
|
||||
/// </summary>
|
||||
/// <param name="mergeKey">Consecutive edits with the same key are one undo step (a slider drag).</param>
|
||||
public bool Edit(Func<ProjectSettings, ProjectSettings> change, string? mergeKey = null)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(change);
|
||||
return !IsReadOnly && History.Apply(change(Project), mergeKey);
|
||||
if (IsReadOnly) return false;
|
||||
var before = Project;
|
||||
return History.Apply(KeepCropLocked(before, change(before), Content.SourceWidth, Content.SourceHeight), mergeKey);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// One press of the Camera step's orientation controls (Rotate left or right, Mirror, Flip) as one undo step: the
|
||||
/// picture turns or mirrors as the user sees it, and the crop and the keyframes with it (<see cref="OrientationEdit"/>,
|
||||
/// owner review 1, R6).
|
||||
/// </summary>
|
||||
public bool Orient(OrientationOp op) => Edit(p => OrientationEdit.Apply(p, op));
|
||||
|
||||
/// <summary>
|
||||
/// "Reset framing": the crop, its offsets, the rotation, mirror, flip and straighten cleared as one undo step; the
|
||||
/// keyframes stay (<see cref="WithoutFraming"/>).
|
||||
/// </summary>
|
||||
public bool ResetFraming() => Edit(WithoutFraming);
|
||||
|
||||
/// <summary>The crop's width over its height in normalised view units for <paramref name="project"/> (<see cref="LockRatioOf"/>).</summary>
|
||||
public double CropLockRatio(ProjectSettings project) => LockRatioOf(project, Content.SourceWidth, Content.SourceHeight);
|
||||
|
||||
/// <summary>
|
||||
/// The lock ratio of the Camera step's crop (<see cref="RenderGeometry.LockRatio"/>): the output ratio the render fits
|
||||
/// the crop to, in units of the view frame of a source of the given size; a 1×1 view when the size is unknown.
|
||||
/// </summary>
|
||||
public static double LockRatioOf(ProjectSettings project, int sourceWidth, int sourceHeight)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(project);
|
||||
var (width, height) = sourceWidth > 0 && sourceHeight > 0 ? (sourceWidth, sourceHeight) : (1, 1);
|
||||
return RenderGeometry.Create(project.Camera, ExportResolver.Resolve(project.Export), width, height).LockRatio;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The project without framing: no crop, no offsets, no rotation, mirror, flip or straighten. The orientation is undone
|
||||
/// press by press (<see cref="OrientationEdit"/>: the flip, the mirror, then quarter turns back), so the keyframes, the
|
||||
/// parked ones and the aspect stay on the content they framed: a 9:16 set on a quarter-turned landscape is 16:9 again.
|
||||
/// </summary>
|
||||
public static ProjectSettings WithoutFraming(ProjectSettings project)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(project);
|
||||
var upright = project;
|
||||
if (upright.Camera.Flip) upright = OrientationEdit.Apply(upright, OrientationOp.Flip);
|
||||
if (upright.Camera.Mirror) upright = OrientationEdit.Apply(upright, OrientationOp.Mirror);
|
||||
for (var turns = FrameOrientation.TurnsOf(upright.Camera.Rotate); turns > 0; turns--) upright = OrientationEdit.Apply(upright, OrientationOp.RotateLeft);
|
||||
return upright with { Camera = upright.Camera with { Crop = null, OffsetX = 0, OffsetY = 0, Rotate = 0, Mirror = false, Flip = false, Straighten = 0 } };
|
||||
}
|
||||
|
||||
/// <summary>Something <see cref="ResetFraming"/> clears is set.</summary>
|
||||
public static bool HasFraming(CameraSettings camera)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(camera);
|
||||
return camera.Crop is not null || camera.OffsetX != 0 || camera.OffsetY != 0 || camera.Rotate != 0 || camera.Mirror || camera.Flip || camera.Straighten != 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// <paramref name="after"/> with its crop refitted to new output proportions (owner review 1, R5: an aspect change, a
|
||||
/// turn of a "source" aspect, an export preset of another shape): a box that was locked to the proportions before keeps
|
||||
/// its centre and area at the new ratio (<see cref="CropFrame.Refit"/>). A legacy free crop, one placed by offsets, and a
|
||||
/// box already at the new ratio stay as they are (the render fits them, <see cref="AspectRatio.FitCrop"/>).
|
||||
/// </summary>
|
||||
public static ProjectSettings KeepCropLocked(ProjectSettings before, ProjectSettings after, int sourceWidth, int sourceHeight)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(before);
|
||||
ArgumentNullException.ThrowIfNull(after);
|
||||
var camera = after.Camera;
|
||||
if (CropFrame.IsWhole(camera.Crop) || camera.OffsetX != 0 || camera.OffsetY != 0) return after;
|
||||
if (ReferenceEquals(before.Camera, camera) && ReferenceEquals(before.Export, after.Export)) return after;
|
||||
var ratio = LockRatioOf(after, sourceWidth, sourceHeight);
|
||||
var box = CropFrame.Of(camera.Crop);
|
||||
if (IsLocked(box, ratio)) return after;
|
||||
if (before.Camera.OffsetX != 0 || before.Camera.OffsetY != 0 || !IsLocked(CropFrame.Of(before.Camera.Crop), LockRatioOf(before, sourceWidth, sourceHeight)))
|
||||
return after;
|
||||
return after with { Camera = camera with { Crop = CropFrame.ToCrop(CropFrame.Refit(box, ratio)) } };
|
||||
|
||||
static bool IsLocked(RectD box, double lockRatio) => double.Abs(box.Width / box.Height / lockRatio - 1) < 1e-6;
|
||||
}
|
||||
|
||||
/// <summary>The drag or key press behind a run of merged edits ended (<see cref="ProjectHistory.EndRun"/>).</summary>
|
||||
@@ -148,7 +227,8 @@ public sealed class EditorSession : IAsyncDisposable
|
||||
|
||||
/// <summary>
|
||||
/// Applies a sequence preset (BRIEF §10.3) as one undoable step: its timing, exposure, motion, aspect and export
|
||||
/// preset; the user's frames (exclusions, hero), crop, keyframes, remap curve, exposure offset and output naming stay.
|
||||
/// preset; the user's frames (exclusions, hero), crop (refitted to the preset's aspect), orientation, keyframes, remap
|
||||
/// curve, exposure offset, look and output naming stay.
|
||||
/// </summary>
|
||||
public bool ApplyPreset(SequencePreset preset)
|
||||
{
|
||||
@@ -437,17 +517,28 @@ public sealed class EditorSession : IAsyncDisposable
|
||||
{
|
||||
if (IsReadOnly) return [];
|
||||
var settings = Project;
|
||||
var advice = AdviceFor(settings.Camera);
|
||||
var changes = new List<SettingChange>();
|
||||
foreach (var section in sections)
|
||||
{
|
||||
var result = Advisor.Optimise(section, settings, Advice);
|
||||
var result = Advisor.Optimise(section, settings, advice);
|
||||
settings = result.Settings;
|
||||
changes.AddRange(result.Changes);
|
||||
}
|
||||
History.Apply(settings);
|
||||
History.Apply(KeepCropLocked(Project, settings, Content.SourceWidth, Content.SourceHeight));
|
||||
return changes;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The advice for the view of <paramref name="camera"/>: <see cref="Advice"/> while the camera is not turned, flipped or straightened,
|
||||
/// else worked out again on the turned view (<see cref="SequenceContext.ForCamera"/>), so that "Optimise" after a turn
|
||||
/// keeps the transposed aspect <see cref="OrientationEdit"/> wrote instead of the unturned one.
|
||||
/// </summary>
|
||||
private AdvisorResult AdviceFor(CameraSettings camera) =>
|
||||
camera.Rotate == Context.Rotate && camera.Flip == Context.Flip && camera.Straighten.Equals(Context.Straighten)
|
||||
? Advice
|
||||
: Advisor.Recommend(Content.Light, Content.Deep, Context.ForCamera(camera));
|
||||
|
||||
private void OnSaveFailed(Exception ex, int failures)
|
||||
{
|
||||
// A conflict is retried without the network until the user settles it: noted once, when it is found.
|
||||
|
||||
@@ -13,6 +13,7 @@ using Chronos.Core.Advice;
|
||||
using Chronos.Core.Analysis;
|
||||
using Chronos.Core.Diagnostics;
|
||||
using Chronos.Core.Export;
|
||||
using Chronos.Core.Imaging.Geometry;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Core.Project;
|
||||
@@ -64,9 +65,18 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
private bool _showRegions;
|
||||
private bool _showCropMask;
|
||||
private bool _exportCropMask = true;
|
||||
|
||||
/// <summary>The Camera step's Crop mask, on by default: the crop box is edited there (owner review 1, R5).</summary>
|
||||
private bool _cameraCropMask = true;
|
||||
private CropMaskMode _cropMaskMode = CropMaskMode.ShowLoss;
|
||||
private PreviewZoomMode _zoomMode = PreviewZoomMode.Fit;
|
||||
private Rect _cropRect = new(0, 0, 1, 1);
|
||||
private Rect _editCrop = new(0, 0, 1, 1);
|
||||
private double _cropLockRatio = 1;
|
||||
private bool _isStraightening;
|
||||
|
||||
/// <summary>The orientation of the camera the picture on screen was framed with (the crop box maps onto that view frame).</summary>
|
||||
private (int Rotate, bool Mirror, bool Flip, double Straighten) _shownOrientation;
|
||||
private IReadOnlyList<Point>? _regionBoundary;
|
||||
private IReadOnlyList<MotionVector>? _motionVectors;
|
||||
private int _previewEdge = DefaultPreviewEdge;
|
||||
@@ -126,6 +136,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
{
|
||||
if (StepFor(p) is { } step) SelectedTab = step;
|
||||
});
|
||||
CommitCropCommand = new RelayCommand(CommitCrop, _ => CropEditable);
|
||||
|
||||
Analysis = new AnalysisTab(this);
|
||||
Frames = new FramesTab(this);
|
||||
@@ -144,6 +155,8 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
// Until the link is read (AttachJobsAsync), a sequence of this PC cannot send its renders.
|
||||
_syncGate = session.IsRemote ? ExportSyncGate.Remote : ExportSyncGate.SignedOut;
|
||||
RenderChoices = [.. ExportPresets.BuiltIn.Select(p => new Choice(p.Id, p.NameKey))];
|
||||
_shownOrientation = OrientationOf(session.Project.Camera);
|
||||
UpdateCropBox();
|
||||
|
||||
session.ProjectChanged += OnProjectChanged;
|
||||
session.ContentChanged += OnContentChanged;
|
||||
@@ -277,6 +290,9 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
/// <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 Camera step: its crop mask shows the crop box itself, edited on the picture (owner review 1, R5).</summary>
|
||||
public bool IsCameraTab => SelectedTab is CameraTab;
|
||||
|
||||
/// <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;
|
||||
|
||||
@@ -364,21 +380,75 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The Crop mask tool of the current tab: the Export tab has its own, on by default (Export.html).</summary>
|
||||
/// <summary>
|
||||
/// The Crop mask tool of the current tab: the Export tab has its own, on by default (Export.html), and so has the Camera
|
||||
/// step, where the crop box is edited (owner review 1, R5).
|
||||
/// </summary>
|
||||
public bool ShowCropMask
|
||||
{
|
||||
get => IsExportTab ? _exportCropMask : _showCropMask;
|
||||
get => IsExportTab ? _exportCropMask : IsCameraTab ? _cameraCropMask : _showCropMask;
|
||||
set
|
||||
{
|
||||
if (value == ShowCropMask) return;
|
||||
if (IsExportTab) _exportCropMask = value;
|
||||
else if (IsCameraTab) _cameraCropMask = value;
|
||||
else _showCropMask = value;
|
||||
OnPropertyChanged();
|
||||
OnPropertyChanged(nameof(CropModeToolTip));
|
||||
OnCropEditableChanged();
|
||||
RequestPreview(immediate: true);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The crop box is moved and resized on the preview: the Camera step with its mask on, while the project can change
|
||||
/// (not read-only, in a newer format, outdated or busy) and the picture on screen shows the project's view frame (after
|
||||
/// a turn, a mirror, a flip or a straighten, the box waits for the picture it applies to: a drag before it would place
|
||||
/// a box of the old frame in the new one).
|
||||
/// </summary>
|
||||
public bool CropEditable => IsCameraTab && ShowCropMask && IsEditable && !Session.Project.IsNewerFormat && FrameCount > 0
|
||||
&& OrientationOf(Session.Project.Camera) == _shownOrientation;
|
||||
|
||||
/// <summary>
|
||||
/// The crop box the Camera step shows and edits (<see cref="RenderGeometry.EditableCrop"/>), normalised in the view frame
|
||||
/// the Source picture shows; the preview sets it to each finished edit before <see cref="CommitCropCommand"/> runs.
|
||||
/// </summary>
|
||||
public Rect EditCrop
|
||||
{
|
||||
get => _editCrop;
|
||||
set
|
||||
{
|
||||
if (!Set(ref _editCrop, value)) return;
|
||||
if (IsCameraTab) OnPropertyChanged(nameof(CropRect));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The crop box's width over its height in normalised units (<see cref="RenderGeometry.LockRatio"/>): the output proportions on the view frame.</summary>
|
||||
public double CropLockRatio { get => _cropLockRatio; private set => Set(ref _cropLockRatio, value); }
|
||||
|
||||
/// <summary>
|
||||
/// Writes a finished edit of the crop box (<see cref="CropEditEventArgs"/>, or a normalised <see cref="Rect"/>) as the
|
||||
/// camera crop, locked and with the offsets at 0 (owner review 1, R5): one drag is one undo step, a run of key presses
|
||||
/// merges into one ("Camera.Crop") that the key release ends.
|
||||
/// </summary>
|
||||
public ICommand CommitCropCommand { get; }
|
||||
|
||||
/// <summary>The Straighten slider is dragged or has the keyboard: the preview shows a fine grid to level the horizon against.</summary>
|
||||
public bool IsStraightening
|
||||
{
|
||||
get => _isStraightening;
|
||||
set
|
||||
{
|
||||
if (Set(ref _isStraightening, value)) OnPropertyChanged(nameof(ShowStraightenGrid));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The straighten grid over the preview (Camera step, while straightening).</summary>
|
||||
public bool ShowStraightenGrid => IsStraightening && IsCameraTab;
|
||||
|
||||
/// <summary>What a drag on the preview does: the crop box's moves and keys while it is edited there, else compare, pan and zoom.</summary>
|
||||
public string PreviewToolTip => Loc.L(CropEditable ? "Tooltips.Editor.Preview.CropEdit" : "Tooltips.Editor.Preview.View");
|
||||
|
||||
/// <summary>Overlays the viewport draws: only tools that have a button on the current tab.</summary>
|
||||
public bool ViewVectors => ShowVectors && !IsExportTab;
|
||||
|
||||
@@ -422,7 +492,20 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
set => ZoomMode = value ? PreviewZoomMode.Actual : PreviewZoomMode.Fit;
|
||||
}
|
||||
|
||||
public Rect CropRect { get => _cropRect; private set => Set(ref _cropRect, value); }
|
||||
/// <summary>
|
||||
/// The crop mask: on the Camera step the crop box (<see cref="EditCrop"/>), elsewhere the footprint of the frame's output
|
||||
/// (stabilisation and camera pose included) on the Source picture.
|
||||
/// </summary>
|
||||
public Rect CropRect
|
||||
{
|
||||
get => IsCameraTab ? _editCrop : _cropRect;
|
||||
private set
|
||||
{
|
||||
if (_cropRect == value) return;
|
||||
_cropRect = value;
|
||||
if (!IsCameraTab) OnPropertyChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public IReadOnlyList<Point>? RegionBoundary { get => _regionBoundary; private set => Set(ref _regionBoundary, value); }
|
||||
|
||||
@@ -551,10 +634,19 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
|
||||
public bool CanRender => RenderBlockedReason is null;
|
||||
|
||||
/// <summary>The settings format a render of <see cref="RenderExport"/> needs (<see cref="Chronos.Data.Processing.ProcessingJobs.RequiredFormat"/>).</summary>
|
||||
private int RenderFormat =>
|
||||
Chronos.Data.Processing.ProcessingJobs.RequiredFormat(Session.Project, RenderExport, Session.Content.SourceWidth, Session.Content.SourceHeight);
|
||||
|
||||
/// <summary>Why the project's export cannot be rendered now, localised; null when it can.</summary>
|
||||
public string? RenderBlockedReason => Plan switch
|
||||
{
|
||||
_ when IsRemote && !Shell.Services.Sync.CanRender => Loc.L("Tooltips.Editor.Render.NoRight", ServerName),
|
||||
// Settings or proportions the server would render otherwise (owner review 1, phase 4: an older server, Send and render too).
|
||||
// A workspace project rendered on this PC from its originals (phase 5c) renders with this PC's engine: the server's
|
||||
// format does not decide (sending its version home is held by the workspace's own gate).
|
||||
_ when IsRemote && Session.Source is not IProjectRenders { RendersLocally: true }
|
||||
&& ServerJobs.NeedsNewerServer(RenderFormat, Shell.Services.Sync.SettingsFormat) is { } newer => newer,
|
||||
_ when IsOutdated => Loc.L("Tooltips.Editor.Outdated", ServerName),
|
||||
null when _planned => Loc.L("Tooltips.Editor.Render.NoSource"),
|
||||
null => Loc.L("Tooltips.Editor.Render.Planning"),
|
||||
@@ -793,6 +885,13 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
PreviewImage = r.Corrected;
|
||||
OriginalImage = r.Original;
|
||||
CropRect = r.Crop;
|
||||
// The crop box of the picture now on screen: its view frame, its proportions.
|
||||
var shown = OrientationOf(request.Project.Camera);
|
||||
var reframed = shown != _shownOrientation;
|
||||
_shownOrientation = shown;
|
||||
CropLockRatio = r.LockRatio;
|
||||
EditCrop = r.EditCrop;
|
||||
if (reframed) OnCropEditableChanged();
|
||||
RegionBoundary = ViewRegions ? r.Horizon : null;
|
||||
MotionVectors = ViewVectors ? r.Vectors : null;
|
||||
WaveformImage = r.Waveform;
|
||||
@@ -976,14 +1075,69 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
|
||||
private void OnToolsChanged()
|
||||
{
|
||||
OnPropertyChanged(nameof(IsCameraTab));
|
||||
OnPropertyChanged(nameof(ShowCropMask));
|
||||
OnPropertyChanged(nameof(CropModeToolTip));
|
||||
OnPropertyChanged(nameof(ViewVectors));
|
||||
OnPropertyChanged(nameof(ViewRegions));
|
||||
OnPropertyChanged(nameof(CropRect));
|
||||
OnPropertyChanged(nameof(ShowStraightenGrid));
|
||||
OnCropEditableChanged();
|
||||
}
|
||||
|
||||
/// <summary>Whether the crop box is edited on the preview, and what a drag there does.</summary>
|
||||
private void OnCropEditableChanged()
|
||||
{
|
||||
OnPropertyChanged(nameof(CropEditable));
|
||||
OnPropertyChanged(nameof(PreviewToolTip));
|
||||
}
|
||||
|
||||
/// <summary>The rendered orientation members of <paramref name="camera"/>: the view frame the crop box is normalised in.</summary>
|
||||
private static (int, bool, bool, double) OrientationOf(CameraSettings camera) =>
|
||||
(FrameOrientation.TurnsOf(camera.Rotate), camera.Mirror, camera.Flip, FrameOrientation.StraightenOf(camera.Straighten));
|
||||
|
||||
/// <summary>
|
||||
/// The crop box and its proportions for the project now, at once, while the picture on screen shows the same view frame
|
||||
/// (a crop row, an aspect or preset change: no frame to wait for); a turn, mirror, flip or straighten waits for the
|
||||
/// picture it applies to.
|
||||
/// </summary>
|
||||
private void UpdateCropBox()
|
||||
{
|
||||
var project = Session.Project;
|
||||
if (OrientationOf(project.Camera) != _shownOrientation || Session.Content.SourceWidth <= 0 || Session.Content.SourceHeight <= 0) return;
|
||||
try
|
||||
{
|
||||
var geometry = RenderGeometry.Create(project.Camera, ExportResolver.Resolve(project.Export), Session.Content.SourceWidth, Session.Content.SourceHeight);
|
||||
CropLockRatio = geometry.LockRatio;
|
||||
var box = geometry.EditableCrop;
|
||||
EditCrop = new Rect(box.X, box.Y, box.Width, box.Height);
|
||||
}
|
||||
catch (Exception ex) when (ex is ArgumentException or InvalidOperationException or RenderException)
|
||||
{
|
||||
Log.Warning("editor", "The crop box could not be worked out", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void CommitCrop(object? parameter)
|
||||
{
|
||||
var (crop, nudge) = parameter switch
|
||||
{
|
||||
CropEditEventArgs edit => (edit.Crop, edit.IsNudge),
|
||||
Rect rect => (rect, false),
|
||||
_ => (Rect.Empty, false),
|
||||
};
|
||||
if (crop.IsEmpty || !CropEditable) return;
|
||||
// The box itself, locked to the proportions on screen, with the offsets at 0: the render's FitCrop returns it unchanged.
|
||||
var box = CropFrame.Clamp(new RectD(crop.X, crop.Y, crop.Width, crop.Height), CropLockRatio);
|
||||
EditCrop = new Rect(box.X, box.Y, box.Width, box.Height);
|
||||
Session.Edit(p => p with { Camera = p.Camera with { Crop = CropFrame.ToCrop(box), OffsetX = 0, OffsetY = 0 } }, "Camera.Crop");
|
||||
if (!nudge) Session.EndEditRun();
|
||||
}
|
||||
|
||||
private void OnProjectChanged()
|
||||
{
|
||||
UpdateCropBox();
|
||||
OnCropEditableChanged();
|
||||
foreach (var tab in Tabs) tab.Refresh();
|
||||
UpdateMarkers();
|
||||
RefreshSteps();
|
||||
@@ -1002,6 +1156,7 @@ 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;
|
||||
UpdateCropBox();
|
||||
_rendered = new RenderedSettings(Session.Content.Renders);
|
||||
foreach (var tab in Tabs) tab.OnContentChanged();
|
||||
OnPropertyChanged(nameof(Summary));
|
||||
@@ -1340,6 +1495,7 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
OnPropertyChanged(nameof(IsAnalysing));
|
||||
OnPropertyChanged(nameof(IsLocked));
|
||||
OnPropertyChanged(nameof(IsEditable));
|
||||
OnCropEditableChanged();
|
||||
OnPropertyChanged(nameof(LockedToolTip));
|
||||
OnPropertyChanged(nameof(AnalyseToolTip));
|
||||
OnPropertyChanged(nameof(OptimiseAllToolTip));
|
||||
@@ -1370,13 +1526,15 @@ public sealed class EditorViewModel : LocalizedViewModel, IAsyncDisposable
|
||||
}
|
||||
|
||||
/// <summary>A rendered preview as frozen bitmaps and overlays in picture pixels (built off the UI thread).</summary>
|
||||
private sealed record PreviewResult(ImageSource Corrected, ImageSource Original, Rect Crop, IReadOnlyList<Point> Horizon, IReadOnlyList<MotionVector> Vectors,
|
||||
ImageSource? Waveform)
|
||||
private sealed record PreviewResult(ImageSource Corrected, ImageSource Original, Rect Crop, Rect EditCrop, double LockRatio, IReadOnlyList<Point> Horizon,
|
||||
IReadOnlyList<MotionVector> Vectors, ImageSource? Waveform)
|
||||
{
|
||||
public static PreviewResult From(PreviewFrame frame) => new(
|
||||
EditorImages.ToBitmap(frame.Corrected),
|
||||
EditorImages.ToBitmap(frame.Original),
|
||||
new Rect(frame.Crop.X, frame.Crop.Y, frame.Crop.Width, frame.Crop.Height),
|
||||
new Rect(frame.EditCrop.X, frame.EditCrop.Y, frame.EditCrop.Width, frame.EditCrop.Height),
|
||||
frame.LockRatio,
|
||||
[.. frame.Horizon.Select(p => new Point(p.X, p.Y))],
|
||||
[.. frame.Vectors.Select(v => new MotionVector(v.X, v.Y, v.Dx, v.Dy))],
|
||||
frame.Waveform is { } waveform ? EditorImages.ToMask(waveform) : null);
|
||||
|
||||
@@ -22,6 +22,18 @@ public sealed record ExportChoice(string Id, string Name, string ExportPresetId,
|
||||
public sealed record ExportPlan(ResolvedExport Export, RenderSetup Setup, ExportEstimate Estimate, string FileName, string? NameError)
|
||||
{
|
||||
public string PresetName => ProcessingJobs.PresetName(Export);
|
||||
|
||||
/// <summary>
|
||||
/// The size the render asks for (<see cref="RenderSize.Of"/>, owner review 1 R5: the preset's box fitted to the chosen
|
||||
/// proportions, 4K at 9:16 = 2160×3840), before the encoder caps it.
|
||||
/// </summary>
|
||||
public (int Width, int Height) OutputSize { get; init; }
|
||||
|
||||
/// <summary>The size the encoder makes (<see cref="OutputSize"/> or smaller, when the encoder takes no more).</summary>
|
||||
public (int Width, int Height) EncodedSize => (Setup.Encoder.Settings.Width, Setup.Encoder.Settings.Height);
|
||||
|
||||
/// <summary>The encoder shrank the output (by more than the rounding to even sizes every encoder makes).</summary>
|
||||
public bool IsCapped => EncodedSize.Width < OutputSize.Width - 1 || EncodedSize.Height < OutputSize.Height - 1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -74,7 +86,9 @@ public sealed class ExportPlanner(SequenceContent content, IReadOnlyList<IVideoE
|
||||
};
|
||||
var setup = RenderSetup.Create(input, new RenderTarget(resolved, ExportNaming.FallbackName), Encoders, host);
|
||||
var (name, error) = FileName(export.NameTemplate, resolved, setup);
|
||||
return new ExportPlan(resolved, setup, setup.Estimate(model), name, error);
|
||||
// The estimates follow the setup, which renders the adapted size the encoder may cap (RenderSetup.Create).
|
||||
var size = RenderSize.Of(input.Project.Camera, resolved, content.SourceWidth, content.SourceHeight, RenderOptions.Default.MaxWorkingLongEdge);
|
||||
return new ExportPlan(resolved, setup, setup.Estimate(model), name, error) { OutputSize = size };
|
||||
}
|
||||
|
||||
/// <summary>The first problem of a name template, localised; null when it is valid.</summary>
|
||||
|
||||
@@ -280,6 +280,27 @@ public sealed class ExportTab : EditorTab
|
||||
|
||||
public EditableField Height { get; }
|
||||
|
||||
/// <summary>
|
||||
/// "2160 × 3840": what the render makes of the box (Width × Height) and the chosen proportions (owner review 1, R5),
|
||||
/// "(capped)" when the encoder takes no more; null before the plan.
|
||||
/// </summary>
|
||||
public string? OutputSizeText => Editor.Plan is { } plan ? OutputSizeOf(plan) : null;
|
||||
|
||||
/// <summary>Where the output size comes from, or the largest size the encoder takes when it capped it.</summary>
|
||||
public string OutputSizeToolTip => OutputSizeToolTipOf(Editor.Plan);
|
||||
|
||||
/// <summary>The Output size row of <paramref name="plan"/>: "2160 × 3840", or "1080 × 1920 (capped)".</summary>
|
||||
public static string OutputSizeOf(ExportPlan plan)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(plan);
|
||||
return plan.IsCapped ? Loc.L("Editor.Export.Capped", SizeText(plan.EncodedSize)) : SizeText(plan.OutputSize);
|
||||
}
|
||||
|
||||
/// <summary>The Output size row's tooltip for <paramref name="plan"/>.</summary>
|
||||
public static string OutputSizeToolTipOf(ExportPlan? plan) => plan is { IsCapped: true }
|
||||
? Loc.L("Tooltips.Editor.Export.OutputCapped", SizeText(LargestTaken(plan)))
|
||||
: Loc.L("Tooltips.Editor.Export.OutputSize");
|
||||
|
||||
/// <summary>"16:9".</summary>
|
||||
public string AspectText => Editor.Plan is { } plan ? Aspect(plan.Setup.Encoder.Settings.Width, plan.Setup.Encoder.Settings.Height) : string.Empty;
|
||||
|
||||
@@ -473,6 +494,7 @@ public sealed class ExportTab : EditorTab
|
||||
try
|
||||
{
|
||||
UpdateLists();
|
||||
LoadBox();
|
||||
SaveChoices = !CanChooseFolder ? [new SaveChoice(null)]
|
||||
: Export.Folder is { } folder ? [new SaveChoice(null), new SaveChoice(folder), new SaveChoice(null, Browse: true)]
|
||||
: [new SaveChoice(null), new SaveChoice(null, Browse: true)];
|
||||
@@ -493,9 +515,7 @@ public sealed class ExportTab : EditorTab
|
||||
_refreshing = true;
|
||||
try
|
||||
{
|
||||
var settings = Editor.Plan?.Setup.Encoder.Settings;
|
||||
if (!Width.IsDirty) Width.Load(settings?.Width.ToString(CultureInfo.InvariantCulture) ?? string.Empty);
|
||||
if (!Height.IsDirty) Height.Load(settings?.Height.ToString(CultureInfo.InvariantCulture) ?? string.Empty);
|
||||
LoadBox();
|
||||
UpdateLists();
|
||||
Notices = Editor.Plan is { } plan ? PlanNotices(plan) : [];
|
||||
OnAllPropertiesChanged();
|
||||
@@ -547,6 +567,35 @@ public sealed class ExportTab : EditorTab
|
||||
base.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Width and Height edit the preset's box, which the chosen proportions are fitted in (owner review 1, R5): they show the
|
||||
/// resolved box (empty for a side the preset leaves to the source), not the size rendered (Output size).
|
||||
/// </summary>
|
||||
private void LoadBox()
|
||||
{
|
||||
var resolved = Resolved;
|
||||
if (!Width.IsDirty) Width.Load(resolved.Width > 0 ? resolved.Width.ToString(CultureInfo.InvariantCulture) : string.Empty);
|
||||
if (!Height.IsDirty) Height.Load(resolved.Height > 0 ? resolved.Height.ToString(CultureInfo.InvariantCulture) : string.Empty);
|
||||
}
|
||||
|
||||
/// <summary>"2160 × 3840".</summary>
|
||||
private static string SizeText((int Width, int Height) size) =>
|
||||
size.Width.ToString(Loc.Culture) + " × " + size.Height.ToString(Loc.Culture);
|
||||
|
||||
/// <summary>
|
||||
/// The encoder's largest size turned as the output is (as <see cref="EncoderSelector"/> fits it) when the output is
|
||||
/// larger; otherwise the codec level capped it, and the size made is the largest it takes.
|
||||
/// </summary>
|
||||
private static (int Width, int Height) LargestTaken(ExportPlan plan)
|
||||
{
|
||||
var (width, height) = plan.OutputSize;
|
||||
if (plan.Setup.Encoder.Capability is not { } capability) return plan.EncodedSize;
|
||||
var (maxWidth, maxHeight) = (width >= height) == (capability.MaxWidth >= capability.MaxHeight)
|
||||
? (capability.MaxWidth, capability.MaxHeight)
|
||||
: (capability.MaxHeight, capability.MaxWidth);
|
||||
return width > maxWidth || height > maxHeight ? (maxWidth, maxHeight) : plan.EncodedSize;
|
||||
}
|
||||
|
||||
/// <summary>The choices that depend on the resolved codec (new lists only when they change, so selections stay bound).</summary>
|
||||
private void UpdateLists()
|
||||
{
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
using Chronos.App.Infrastructure;
|
||||
using Chronos.Core.Advice;
|
||||
using Chronos.Core.Imaging.Color;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Core.Render;
|
||||
@@ -20,7 +22,7 @@ public enum ExposureChart
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Exposure (BRIEF §12.3): deflicker, regions, holy-grail transitions and white balance. The luminance chart shows the
|
||||
/// Exposure (BRIEF §12.3): deflicker, regions, holy-grail transitions, white balance and the look. The luminance chart shows the
|
||||
/// measured luminance (Sun) against the target curve the corrections produce (Accent), the sky region (dashed) and the
|
||||
/// exposure steps as received; the flicker chart the frame-to-frame change before and after correction; the waveform
|
||||
/// the luma distribution of the corrected frame on screen.
|
||||
@@ -58,11 +60,54 @@ public sealed class ExposureTab : EditorTab
|
||||
new InfoRow("Editor.Exposure.Temperature", "Tooltips.Editor.Exposure.Temperature", Temperature),
|
||||
new NumberRow(s, "Editor.Exposure.Offset", "Tooltips.Editor.Exposure.Offset", -3, 3, 0.1, p => p.Exposure.ExposureOffsetEv,
|
||||
(p, v) => p with { Exposure = p.Exposure with { ExposureOffsetEv = v } }, v => Loc.L("Editor.Value.Ev", EditorText.Ev(v))),
|
||||
.. LookRows(s),
|
||||
];
|
||||
Refresh();
|
||||
BuildChart();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Look group at the end of the step (owner review 1, R6): the filter (None, Mono, Sepia, Warm, Cool, Vivid, Muted,
|
||||
/// Fade) and its strength, "n/a" without a filter. The look is a project setting outside Exposure, so moving these never
|
||||
/// measures again (<see cref="WithLook"/>).
|
||||
/// </summary>
|
||||
public static IReadOnlyList<SettingRow> LookRows(EditorSession session)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(session);
|
||||
string? NoLook(ProjectSettings p) => HasFilter(p) ? null : Loc.L("Tooltips.Editor.NotApplicable.NoLook");
|
||||
return
|
||||
[
|
||||
new GroupRow("Editor.Look.Group", "Tooltips.Editor.Look.Group"),
|
||||
new ChoiceRow(session, "Editor.Look.Filter", "Tooltips.Editor.Look.Filter",
|
||||
[.. LookFilter.Names.Select(n => new Choice(n, "Editor.Look." + char.ToUpperInvariant(n[0]) + n[1..]))],
|
||||
p => p.Look?.Filter ?? LookFilter.None, (p, v) => WithLook(p, (string)v, p.Look?.Strength)),
|
||||
new NumberRow(session, "Editor.Look.Strength", "Tooltips.Editor.Look.Strength", MinimumStrength, 1, 0.01, p => HasFilter(p) ? p.Look!.Strength ?? 1 : 1,
|
||||
(p, v) => WithLook(p, p.Look?.Filter, double.Round(v, 2)), v => Formatting.Percent(v), NoLook),
|
||||
];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Strength row's lowest value: None is the one way to a look that changes nothing, so the editor never stores a
|
||||
/// filter at 0 % (an identity look that would still change the project's text and hash).
|
||||
/// </summary>
|
||||
public const double MinimumStrength = 0.01;
|
||||
|
||||
/// <summary>
|
||||
/// <paramref name="project"/> with the look <paramref name="filter"/> at <paramref name="strength"/>: none when the filter
|
||||
/// is None or the strength 0 (so a project without a look keeps settings format 1 and its text: the editor writes
|
||||
/// <c>Look = null</c> whenever the look is the identity), the strength omitted at 100 %. Values of a newer Chronos
|
||||
/// inside the look are kept.
|
||||
/// </summary>
|
||||
public static ProjectSettings WithLook(ProjectSettings project, string? filter, double? strength)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(project);
|
||||
if (filter is null || filter == LookFilter.None || strength is <= 0) return project with { Look = null };
|
||||
var look = (project.Look ?? new LookSettings()) with { Filter = filter, Strength = strength is >= 1 ? null : strength };
|
||||
return project with { Look = look };
|
||||
}
|
||||
|
||||
private static bool HasFilter(ProjectSettings project) => project.Look?.Filter is { } filter && filter != LookFilter.None && LookFilter.IsKnown(filter);
|
||||
|
||||
/// <summary>Luminance, flicker or waveform (the switch beside the chart).</summary>
|
||||
public ExposureChart ChartMode
|
||||
{
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
</Window.Resources>
|
||||
<!-- Full screen at native resolution (BRIEF §12.3) with collapsible shot data; Esc closes, arrows step, space plays. -->
|
||||
<v:PreviewViewport x:Name="Viewport" Source="{Binding PreviewImage}" OriginalSource="{Binding OriginalImage}" IsCompareEnabled="{Binding IsCompare}"
|
||||
WipeLabel="{Binding WipeLabel}" ZoomMode="Actual" InfoText="{Binding InfoText}" AutomationProperties.Name="{l:Loc Editor.Preview}">
|
||||
WipeLabel="{Binding WipeLabel}" ZoomMode="Actual" InfoText="{Binding InfoText}" ToolTip="{l:Loc Tooltips.Editor.Preview.View}"
|
||||
AutomationProperties.Name="{l:Loc Editor.Preview}">
|
||||
<v:PreviewViewport.ToolsContent>
|
||||
<!-- The tools' 6 px bottom margin is for a second line in the editor; one line takes it back. -->
|
||||
<StackPanel Orientation="Horizontal" Margin="0,0,0,-6">
|
||||
|
||||
@@ -15,7 +15,11 @@ public enum PreviewFraming
|
||||
/// <summary>Through the render geometry (stabilisation, virtual camera, crop): what the video shows.</summary>
|
||||
Output,
|
||||
|
||||
/// <summary>The whole frame, exposure-corrected; <see cref="PreviewFrame.Crop"/> marks what the output keeps.</summary>
|
||||
/// <summary>
|
||||
/// The whole view frame (owner review 1, R6: the frame turned, mirrored, flipped and straightened as the camera says;
|
||||
/// the decoded frame itself without them), exposure-corrected, without stabilisation, camera pose or crop;
|
||||
/// <see cref="PreviewFrame.Crop"/> marks what the output keeps and <see cref="PreviewFrame.EditCrop"/> the crop box.
|
||||
/// </summary>
|
||||
Source,
|
||||
}
|
||||
|
||||
@@ -36,9 +40,24 @@ public sealed class PreviewFrame(int index, ImageBuffer corrected, ImageBuffer o
|
||||
|
||||
public ImageBuffer Original { get; } = original;
|
||||
|
||||
/// <summary>The output's part of the picture, normalised (the whole picture in <see cref="PreviewFraming.Output"/>).</summary>
|
||||
/// <summary>
|
||||
/// The output's part of the picture on this frame, normalised: the footprint of the frame's output (stabilisation and
|
||||
/// camera pose included) in the view frame; the whole picture in <see cref="PreviewFraming.Output"/>. The Export step's mask.
|
||||
/// </summary>
|
||||
public RectD Crop { get; init; } = new(0, 0, 1, 1);
|
||||
|
||||
/// <summary>
|
||||
/// The crop box the Camera step shows and edits (<see cref="RenderGeometry.EditableCrop"/>), normalised in the view
|
||||
/// frame, the same on every frame: in <see cref="PreviewFraming.Source"/> it maps 1:1 onto the picture.
|
||||
/// </summary>
|
||||
public RectD EditCrop { get; init; } = new(0, 0, 1, 1);
|
||||
|
||||
/// <summary>The crop box's width over its height in normalised units (<see cref="RenderGeometry.LockRatio"/>).</summary>
|
||||
public double LockRatio { get; init; } = 1;
|
||||
|
||||
/// <summary>The view frame's size at full resolution (<see cref="RenderGeometry.ViewWidth"/>): the source's, swapped by an odd turn.</summary>
|
||||
public (int Width, int Height) ViewSize { get; init; }
|
||||
|
||||
/// <summary>Sky/land boundary in picture pixels; empty when the analysis found no horizon.</summary>
|
||||
public IReadOnlyList<(double X, double Y)> Horizon { get; init; } = [];
|
||||
|
||||
@@ -58,8 +77,10 @@ public sealed class PreviewFrame(int index, ImageBuffer corrected, ImageBuffer o
|
||||
/// The corrected-frame preview through the render pipeline at preview size (BRIEF §12.3). The render pipeline has no
|
||||
/// single-frame entry point, so the per-frame steps of <c>RenderRun</c> are followed here: corrections from
|
||||
/// <see cref="RenderPreparation"/> exactly as a render prepares them, then each frame through the render's exposure
|
||||
/// stage, its single geometry warp and the highlight knee. Stacking and motion blur need neighbouring frames and are
|
||||
/// left to the render.
|
||||
/// stage, its single geometry warp and its finish (look, then highlight knee). Stacking and motion blur need neighbouring frames and are
|
||||
/// left to the render. The Source framing of an oriented camera warps the corrected and the original picture once each
|
||||
/// into the whole view frame (<see cref="RenderGeometry.ViewFor"/>), so the crop box maps onto it 1:1; without a turn,
|
||||
/// mirror, flip or straighten it is the decoded frame itself, at no cost.
|
||||
/// <para>
|
||||
/// Preparing is split so a slider never decodes the sequence again: a measuring preparation (luminance, colour means,
|
||||
/// stabilisation; keyed on the settings that change what is measured) runs once, and every other change re-solves
|
||||
@@ -144,16 +165,20 @@ public sealed class PreviewRenderer(SequenceContent content, ISequenceSource sou
|
||||
var (geometry, edge) = setup.Value;
|
||||
var frame = await PictureAsync(request.Index, request, corrections, geometry, edge, cancellationToken).ConfigureAwait(false);
|
||||
if (frame is null) return null;
|
||||
var (corrected, original, plan) = frame.Value;
|
||||
var (corrected, original, footprint, frameSize) = frame.Value;
|
||||
try
|
||||
{
|
||||
var vectors = request.Vectors && request.Index + 1 < content.Count
|
||||
? await VectorsAsync(request, corrections, corrected.Width, corrected.Height, cancellationToken).ConfigureAwait(false)
|
||||
: [];
|
||||
var source = request.Framing == PreviewFraming.Source;
|
||||
return new PreviewFrame(request.Index, corrected, original)
|
||||
{
|
||||
Crop = request.Framing == PreviewFraming.Source ? CropOf(plan, corrected.Width, corrected.Height) : new RectD(0, 0, 1, 1),
|
||||
Horizon = request.Framing == PreviewFraming.Source ? HorizonOf(corrected.Width, corrected.Height) : [],
|
||||
Crop = footprint,
|
||||
EditCrop = geometry.EditableCrop,
|
||||
LockRatio = geometry.LockRatio,
|
||||
ViewSize = (geometry.ViewWidth, geometry.ViewHeight),
|
||||
Horizon = source ? HorizonOf(geometry, frameSize.Width, frameSize.Height) : [],
|
||||
Vectors = vectors,
|
||||
Waveform = request.Waveform ? LumaWaveform.Measure(corrected) : null,
|
||||
};
|
||||
@@ -259,9 +284,16 @@ public sealed class PreviewRenderer(SequenceContent content, ISequenceSource sou
|
||||
return (geometry, int.Max(16, edge));
|
||||
}
|
||||
|
||||
/// <summary>Decodes, corrects and frames one source frame: (corrected, original, output→picture plan).</summary>
|
||||
private async Task<(ImageBuffer, ImageBuffer, GeometryPlan?)?> PictureAsync(int index, PreviewRequest request, RenderCorrections? corrections,
|
||||
RenderGeometry geometry, int edge, CancellationToken cancellationToken)
|
||||
/// <summary>
|
||||
/// Decodes, corrects and frames one source frame: (corrected, original, the output's footprint on the picture
|
||||
/// normalised, the decoded frame's size).
|
||||
/// </summary>
|
||||
/// <param name="finish">
|
||||
/// The look and the highlight knee applied (the picture shown); false for the motion vectors, whose flow sees frames as the
|
||||
/// render's does: exposure and geometry only, never the look (owner review 1, phase 4).
|
||||
/// </param>
|
||||
private async Task<(ImageBuffer, ImageBuffer, RectD, (int Width, int Height))?> PictureAsync(int index, PreviewRequest request, RenderCorrections? corrections,
|
||||
RenderGeometry geometry, int edge, CancellationToken cancellationToken, bool finish = true)
|
||||
{
|
||||
var decoded = await source.DecodeAsync(index, edge, DecodePurpose.Proxy, cancellationToken).ConfigureAwait(false);
|
||||
if (decoded is null) return null;
|
||||
@@ -271,19 +303,29 @@ public sealed class PreviewRenderer(SequenceContent content, ISequenceSource sou
|
||||
{
|
||||
corrected = raw.Clone();
|
||||
if (corrections is not null && corrections.FrameCount == content.Count) ApplyExposure(corrected, index, corrections);
|
||||
var frame = (raw.Width, raw.Height);
|
||||
var settings = geometry.For(raw.Width, raw.Height, index, corrections?.StabilizationAt(index, raw.Width, raw.Height) ?? Affine2D.Identity);
|
||||
var plan = GeometryStage.Plan(raw.Width, raw.Height, settings);
|
||||
if (request.Framing == PreviewFraming.Output)
|
||||
var footprint = new RectD(0, 0, 1, 1);
|
||||
GeometrySettings? warp = settings;
|
||||
if (request.Framing == PreviewFraming.Source)
|
||||
{
|
||||
var framed = GeometryStage.Apply(corrected, settings, cancellationToken);
|
||||
footprint = geometry.FootprintInView(GeometryStage.Plan(raw.Width, raw.Height, settings), raw.Width, raw.Height);
|
||||
// The whole view frame: the same turn, mirror, flip and straighten as the render, without pose or stabilisation.
|
||||
var orientation = geometry.Orientation.Resized(raw.Width, raw.Height);
|
||||
warp = orientation.IsIdentity ? null : geometry.ViewFor(raw.Width, raw.Height, orientation.ViewWidth, orientation.ViewHeight);
|
||||
}
|
||||
if (warp is not null)
|
||||
{
|
||||
var framed = GeometryStage.Apply(corrected, warp, cancellationToken);
|
||||
corrected.Dispose();
|
||||
corrected = framed;
|
||||
framed = GeometryStage.Apply(raw, settings, cancellationToken);
|
||||
framed = GeometryStage.Apply(raw, warp, cancellationToken);
|
||||
raw.Dispose();
|
||||
raw = framed;
|
||||
}
|
||||
if (request.Project.Exposure.HighlightKnee is > 0 and < 1 and var knee) ExposureProcessor.Apply(corrected, 0, null, knee);
|
||||
return (corrected, raw, request.Framing == PreviewFraming.Output ? null : plan);
|
||||
// The look and the knee change the corrected side only: the wipe compares before and after.
|
||||
if (finish) FrameFinish.Apply(corrected, request.Project.Look, request.Project.Exposure.HighlightKnee);
|
||||
return (corrected, raw, footprint, frame);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -315,13 +357,13 @@ public sealed class PreviewRenderer(SequenceContent content, ISequenceSource sou
|
||||
{
|
||||
var small = request with { LongEdge = int.Min(request.LongEdge, VectorLongEdge), Vectors = false, Waveform = false };
|
||||
if (Geometry(small, corrections) is not var (geometry, edge)) return [];
|
||||
var current = await PictureAsync(request.Index, small, corrections, geometry, edge, cancellationToken).ConfigureAwait(false);
|
||||
if (current is not var (a, aOriginal, _)) return [];
|
||||
var current = await PictureAsync(request.Index, small, corrections, geometry, edge, cancellationToken, finish: false).ConfigureAwait(false);
|
||||
if (current is not var (a, aOriginal, _, _)) return [];
|
||||
aOriginal.Dispose();
|
||||
using (a)
|
||||
{
|
||||
var next = await PictureAsync(request.Index + 1, small, corrections, geometry, edge, cancellationToken).ConfigureAwait(false);
|
||||
if (next is not var (b, bOriginal, _)) return [];
|
||||
var next = await PictureAsync(request.Index + 1, small, corrections, geometry, edge, cancellationToken, finish: false).ConfigureAwait(false);
|
||||
if (next is not var (b, bOriginal, _, _)) return [];
|
||||
bOriginal.Dispose();
|
||||
using (b)
|
||||
{
|
||||
@@ -344,27 +386,26 @@ public sealed class PreviewRenderer(SequenceContent content, ISequenceSource sou
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The output's footprint on the source picture (bounding box of the warped output corners), normalised.</summary>
|
||||
private static RectD CropOf(GeometryPlan? plan, int width, int height)
|
||||
{
|
||||
if (plan is not { } p) return new RectD(0, 0, 1, 1);
|
||||
double left = double.MaxValue, top = double.MaxValue, right = double.MinValue, bottom = double.MinValue;
|
||||
foreach (var (u, v) in new[] { (-0.5, -0.5), (p.OutputWidth - 0.5, -0.5), (-0.5, p.OutputHeight - 0.5), (p.OutputWidth - 0.5, p.OutputHeight - 0.5) })
|
||||
{
|
||||
var (x, y) = p.OutputToSource.Apply(u, v);
|
||||
(left, top, right, bottom) = (double.Min(left, x + 0.5), double.Min(top, y + 0.5), double.Max(right, x + 0.5), double.Max(bottom, y + 0.5));
|
||||
}
|
||||
left = double.Clamp(left / width, 0, 1);
|
||||
top = double.Clamp(top / height, 0, 1);
|
||||
return new RectD(left, top, double.Clamp(right / width, 0, 1) - left, double.Clamp(bottom / height, 0, 1) - top);
|
||||
}
|
||||
|
||||
/// <summary>The analysed horizon (normalised rows at evenly spaced columns) in pixels of the whole-frame picture.</summary>
|
||||
private IReadOnlyList<(double X, double Y)> HorizonOf(int width, int height)
|
||||
/// <summary>
|
||||
/// The analysed horizon (normalised rows at evenly spaced columns) in pixels of the Source picture: measured on the
|
||||
/// decoded frame of <paramref name="width"/>×<paramref name="height"/>, mapped into the view frame when the camera turns,
|
||||
/// mirrors, flips or straightens it (<see cref="RenderGeometry.ViewToFrame"/>⁻¹, pixel-centre coordinates).
|
||||
/// </summary>
|
||||
private IReadOnlyList<(double X, double Y)> HorizonOf(RenderGeometry geometry, int width, int height)
|
||||
{
|
||||
if (content.Deep?.Regions is not { Horizon: { Length: > 1 } rows }) return [];
|
||||
var toView = geometry.Orientation.IsIdentity ? (Affine2D?)null : geometry.ViewToFrame(width, height).Invert();
|
||||
var points = new (double X, double Y)[rows.Length];
|
||||
for (var k = 0; k < rows.Length; k++) points[k] = ((double)k / (rows.Length - 1) * width, rows[k] * height);
|
||||
for (var k = 0; k < rows.Length; k++)
|
||||
{
|
||||
var (x, y) = ((double)k / (rows.Length - 1) * width, rows[k] * height);
|
||||
if (toView is { } map)
|
||||
{
|
||||
var (vx, vy) = map.Apply(x - 0.5, y - 0.5);
|
||||
(x, y) = (vx + 0.5, vy + 0.5);
|
||||
}
|
||||
points[k] = (x, y);
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,13 +45,19 @@ public sealed class RemoteSequenceSource : ISequenceSource
|
||||
private readonly IFrameSource _pixels;
|
||||
private readonly ServerJobs _jobs;
|
||||
private readonly bool _noEditRight;
|
||||
private readonly int _serverFormat;
|
||||
private Stored? _stored;
|
||||
private int _framesVersion = -1;
|
||||
private int _outdated;
|
||||
private int _disposed;
|
||||
|
||||
/// <param name="readOnly">The account may look at the sequence but not change it (no Edit right on the server).</param>
|
||||
public RemoteSequenceSource(RemoteSequence remote, IRemoteSequenceApi api, ImageDecoder decoder, bool readOnly = false)
|
||||
/// <param name="serverFormat">
|
||||
/// The highest settings format the server reads (<see cref="Chronos.App.Server.SyncHost.SettingsFormat"/>; an older server's 1): settings
|
||||
/// that need more are never sent to it (owner review 1, phase 4), it would store them and then fail every render of them.
|
||||
/// </param>
|
||||
public RemoteSequenceSource(RemoteSequence remote, IRemoteSequenceApi api, ImageDecoder decoder, bool readOnly = false,
|
||||
int serverFormat = ProjectSettings.CurrentVersion)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(remote);
|
||||
ArgumentNullException.ThrowIfNull(api);
|
||||
@@ -59,6 +65,7 @@ public sealed class RemoteSequenceSource : ISequenceSource
|
||||
_remote = remote;
|
||||
_api = api;
|
||||
_noEditRight = readOnly;
|
||||
_serverFormat = serverFormat;
|
||||
_frames = remote.OpenFrames(decoder);
|
||||
_pixels = (IFrameSource)_frames;
|
||||
_jobs = new ServerJobs(api, remote.Sequence.Id, remote.Sequence.DisplayTitle, job => JobChanged?.Invoke(job), OnEventAsync, OnReconnectedAsync);
|
||||
@@ -154,6 +161,9 @@ public sealed class RemoteSequenceSource : ISequenceSource
|
||||
if (ProjectMerge.SameValues(merged, stored)) return merged;
|
||||
if (IsOutdated) throw new ProxiesOutdatedException(Loc.L("Editor.Error.FramesChanged"));
|
||||
if (_noEditRight) throw new EditorException(Loc.L("Editor.Error.RemoteReadOnly"));
|
||||
// A turn, a mirror, a straighten or a look needs format 2, which an older server cannot read: kept here (the
|
||||
// toast says why) until the edit is undone or the server is updated.
|
||||
if (ServerJobs.NeedsNewerServer(merged.WrittenFormat, _serverFormat) is { } newer) throw new EditorException(newer);
|
||||
if (changedThere && ProjectMerge.Conflicts(basis, project, stored) is { Count: > 0 } conflicts)
|
||||
throw new ProjectConflictException(Loc.L("Editor.Error.SaveConflict"), stored, conflicts);
|
||||
var hero = merged.HeroFrame == stored.HeroFrame ? (Guid?)null : HeroFrameId(merged);
|
||||
|
||||
@@ -56,6 +56,13 @@ internal sealed class ServerJobs : IAsyncDisposable
|
||||
/// <summary>The connection the jobs travel on (the source's other calls use it too).</summary>
|
||||
public IRemoteSequenceApi Api { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Why something that needs settings format <paramref name="required"/> cannot go to a server that reads
|
||||
/// <paramref name="serverFormat"/> (owner review 1, phase 4: a render, a push, Send and render); null when it can. The
|
||||
/// desktop disables the action with this as its tooltip.
|
||||
/// </summary>
|
||||
public static string? NeedsNewerServer(int required, int serverFormat) => required > serverFormat ? Loc.L("Tooltips.Server.NeedsNewerServer") : null;
|
||||
|
||||
/// <summary>Queues <paramref name="request"/> on the server (its priority set after, when it is not the user's); returns the job id.</summary>
|
||||
/// <exception cref="EditorException">The sequence is gone from the server.</exception>
|
||||
public async Task<Guid> SubmitAsync(ArchiveJobRequest request, CancellationToken cancellationToken)
|
||||
|
||||
@@ -3,6 +3,7 @@ using System.Windows.Input;
|
||||
using Chronos.Core.Advice;
|
||||
using Chronos.Core.Localization;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Ui.Controls;
|
||||
using Chronos.Ui.Mvvm;
|
||||
|
||||
namespace Chronos.App.Editor;
|
||||
@@ -306,6 +307,12 @@ public sealed class NumberRow : SettingRow
|
||||
public double Maximum { get; }
|
||||
public double Step { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Using the slider (dragged or focused) shows the preview's straighten grid (<c>Editor.IsStraightening</c>, driven
|
||||
/// by the view through <see cref="SliderActivity"/>): the Camera step's Straighten.
|
||||
/// </summary>
|
||||
public bool ShowsGrid { get; init; }
|
||||
|
||||
public double Value
|
||||
{
|
||||
get => _value;
|
||||
@@ -395,3 +402,85 @@ public sealed class InfoRow(string headerKey, string toolTipKey, Func<(string? V
|
||||
|
||||
protected override void Read() => (Value, NotApplicableReason) = read();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A plain switch (no advice): the Camera step's Mirror and Flip. Each toggle is one edit, made by
|
||||
/// <paramref name="toggle"/> with the new state (it may change more than one member, as <see cref="EditorSession.Orient"/> does).
|
||||
/// </summary>
|
||||
public sealed class SwitchRow : SettingRow
|
||||
{
|
||||
private readonly EditorSession _session;
|
||||
private readonly Func<ProjectSettings, bool> _get;
|
||||
private readonly Action<bool> _toggle;
|
||||
private bool _isOn;
|
||||
|
||||
public SwitchRow(EditorSession session, string headerKey, string toolTipKey, Func<ProjectSettings, bool> get, Action<bool> toggle)
|
||||
: base(headerKey, toolTipKey)
|
||||
{
|
||||
(_session, _get, _toggle) = (session, get, toggle);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public bool IsOn
|
||||
{
|
||||
get => _isOn;
|
||||
set
|
||||
{
|
||||
if (!Set(ref _isOn, value) || IsRefreshing) return;
|
||||
_toggle(value);
|
||||
// A toggle the project did not take (read-only) springs back.
|
||||
if (_get(_session.Project) != value) Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Read() => IsOn = _get(_session.Project);
|
||||
}
|
||||
|
||||
/// <summary>An icon-only button of an <see cref="IconActionsRow"/>: its glyph (a resource key such as "Icon.RotateLeft"), name and tooltip.</summary>
|
||||
public sealed class IconAction(string glyphKey, string nameKey, string toolTipKey, Action execute) : LocalizedViewModel
|
||||
{
|
||||
public string GlyphKey { get; } = glyphKey;
|
||||
|
||||
public IconData? Glyph => System.Windows.Application.Current?.TryFindResource(GlyphKey) as IconData;
|
||||
|
||||
/// <summary>The button's accessible name ("Rotate left").</summary>
|
||||
public string Name => Loc.L(nameKey);
|
||||
|
||||
public string ToolTip => Loc.L(toolTipKey);
|
||||
|
||||
public ICommand Command { get; } = new RelayCommand(execute);
|
||||
}
|
||||
|
||||
/// <summary>A label, a read-only value and icon-only buttons (the Camera step's Rotation: "90°", Rotate left, Rotate right).</summary>
|
||||
public sealed class IconActionsRow : SettingRow
|
||||
{
|
||||
private readonly Func<string> _read;
|
||||
private string _value = string.Empty;
|
||||
|
||||
public IconActionsRow(string headerKey, string toolTipKey, Func<string> value, IReadOnlyList<IconAction> actions)
|
||||
: base(headerKey, toolTipKey)
|
||||
{
|
||||
(_read, Actions) = (value, actions);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public string Value { get => _value; private set => Set(ref _value, value); }
|
||||
|
||||
public IReadOnlyList<IconAction> Actions { get; }
|
||||
|
||||
protected override void Read() => Value = _read();
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
foreach (var action in Actions) action.Dispose();
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The start of a group of rows inside a step's column: a divider and the group's name (the Exposure step's Look).</summary>
|
||||
public sealed class GroupRow(string headerKey, string toolTipKey) : SettingRow(headerKey, toolTipKey)
|
||||
{
|
||||
protected override void Read()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace Chronos.App.Editor;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the user is using a control (it holds the keyboard focus or the mouse capture: a slider dragged or focused),
|
||||
/// for a binding to say so (<see cref="IsActiveProperty"/>, bound one way to the source): the Camera step's Straighten
|
||||
/// shows the preview's grid while it is used (owner review 1, R6). <see cref="TracksProperty"/> starts the tracking.
|
||||
/// </summary>
|
||||
public static class SliderActivity
|
||||
{
|
||||
public static readonly DependencyProperty TracksProperty = DependencyProperty.RegisterAttached(
|
||||
"Tracks", typeof(bool), typeof(SliderActivity), new PropertyMetadata(false, OnTracksChanged));
|
||||
|
||||
public static readonly DependencyProperty IsActiveProperty = DependencyProperty.RegisterAttached(
|
||||
"IsActive", typeof(bool), typeof(SliderActivity), new FrameworkPropertyMetadata(false));
|
||||
|
||||
public static bool GetTracks(DependencyObject d) => (bool)d.GetValue(TracksProperty);
|
||||
|
||||
public static void SetTracks(DependencyObject d, bool value) => d.SetValue(TracksProperty, value);
|
||||
|
||||
public static bool GetIsActive(DependencyObject d) => (bool)d.GetValue(IsActiveProperty);
|
||||
|
||||
public static void SetIsActive(DependencyObject d, bool value) => d.SetValue(IsActiveProperty, value);
|
||||
|
||||
private static void OnTracksChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (d is not FrameworkElement element) return;
|
||||
element.IsKeyboardFocusWithinChanged -= OnChanged;
|
||||
element.IsMouseCaptureWithinChanged -= OnChanged;
|
||||
element.Unloaded -= OnUnloaded;
|
||||
if (e.NewValue is not true) return;
|
||||
element.IsKeyboardFocusWithinChanged += OnChanged;
|
||||
element.IsMouseCaptureWithinChanged += OnChanged;
|
||||
element.Unloaded += OnUnloaded;
|
||||
Update(element);
|
||||
}
|
||||
|
||||
private static void OnChanged(object sender, DependencyPropertyChangedEventArgs e) => Update((FrameworkElement)sender);
|
||||
|
||||
/// <summary>A control taken off screen (another step) is no longer being used.</summary>
|
||||
private static void OnUnloaded(object sender, RoutedEventArgs e) => ((FrameworkElement)sender).SetCurrentValue(IsActiveProperty, false);
|
||||
|
||||
/// <summary>Set through <see cref="DependencyObject.SetCurrentValue"/>, so a binding on the property stays and receives it.</summary>
|
||||
private static void Update(FrameworkElement element)
|
||||
{
|
||||
var active = element.IsKeyboardFocusWithin || element.IsMouseCaptureWithin;
|
||||
if (GetIsActive(element) != active) element.SetCurrentValue(IsActiveProperty, active);
|
||||
}
|
||||
}
|
||||
@@ -595,7 +595,7 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
ContentHash = hash,
|
||||
};
|
||||
var requests = ProcessingJobs.RenderVersion(sequence, tip, export, sourceWidth, sourceHeight);
|
||||
if (tipId is not null && string.Equals(tipHash, hash, StringComparison.OrdinalIgnoreCase)) return requests;
|
||||
if (tipId is not null && ProjectContent.MatchesHash(portable, tipHash)) return requests;
|
||||
return [.. requests.Select(r => r with { ParametersJson = WithoutVersion(r.ParametersJson) })];
|
||||
}
|
||||
|
||||
@@ -607,7 +607,7 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
private IReadOnlyList<ArchiveJobRequest> LocalRenderRequests(Sequence sequence, BundleHome home, string portable, string hash, ExportSettings export,
|
||||
int sourceWidth, int sourceHeight)
|
||||
{
|
||||
var head = HeadVersion(hash);
|
||||
var head = HeadVersion(portable);
|
||||
var version = new ProjectVersion { Id = head ?? Guid.Empty, ProjectId = ProjectId, Number = 0, SettingsJson = portable, ContentHash = hash };
|
||||
var root = _sync.Store.Root;
|
||||
var server = home.IsArchive ? null : home.Server;
|
||||
@@ -618,12 +618,12 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
];
|
||||
}
|
||||
|
||||
/// <summary>The id of the newest version the workspace holds when it holds <paramref name="hash"/>; null otherwise.</summary>
|
||||
private Guid? HeadVersion(string hash)
|
||||
/// <summary>The id of the newest version the workspace holds when it holds <paramref name="portable"/> (any line ends); null otherwise.</summary>
|
||||
private Guid? HeadVersion(string portable)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Project.Versions() is [.., var last] && string.Equals(last.ContentHash, hash, StringComparison.OrdinalIgnoreCase) ? last.Id : null;
|
||||
return Project.Versions() is [.., var last] && ProjectContent.MatchesHash(portable, last.ContentHash) ? last.Id : null;
|
||||
}
|
||||
catch (Exception ex) when (ex is IOException or InvalidDataException or UnauthorizedAccessException)
|
||||
{
|
||||
@@ -679,7 +679,7 @@ public sealed class WorkspaceSequenceSource : ISequenceSource, IProjectRenders
|
||||
{
|
||||
if (_sync.Unpushed(ProjectId).Count > 0 || Project.ReadBundle().Workspace?.Base is not { } basis) return null;
|
||||
var working = ProjectContent.ToPortable(project, Photos);
|
||||
if (string.Equals(ProjectContent.Hash(working), basis.ContentHash, StringComparison.OrdinalIgnoreCase)) return basis;
|
||||
if (ProjectContent.MatchesHash(working, basis.ContentHash)) return basis;
|
||||
// Saved before a hash or a conversion at the home named its photos anew: the same choices are in step too.
|
||||
return Project.Versions().FirstOrDefault(v => v.Id == basis.VersionId) is { } version && ProjectContent.SameChoices(version.SettingsJson, working, Photos)
|
||||
? basis
|
||||
|
||||
@@ -48,7 +48,7 @@ public sealed class LibraryActions(ShellViewModel shell)
|
||||
{
|
||||
if (sequences is [{ Origin: SequenceOrigin.Server, SyncState: SyncState.RemoteOnly } remote])
|
||||
{
|
||||
await PostAsync(() => Task.FromResult(new CreateJobRequest(DeepAnalyseKind, [remote.Id], null)), JobKind.DeepAnalyse, remote.DisplayTitle);
|
||||
await PostAsync(() => Task.FromResult<CreateJobRequest?>(new CreateJobRequest(DeepAnalyseKind, [remote.Id], null)), JobKind.DeepAnalyse, remote.DisplayTitle);
|
||||
return;
|
||||
}
|
||||
await QueueAsync(ProcessingJobs.DeepAnalysis([.. sequences.Select(s => s.Id)], Label(sequences)));
|
||||
@@ -83,7 +83,14 @@ public sealed class LibraryActions(ShellViewModel shell)
|
||||
await PostAsync(async () =>
|
||||
{
|
||||
var (project, width, height) = await RemoteProjectAsync(remote, sequence.Id);
|
||||
return new CreateJobRequest(RenderKind, [sequence.Id], ProcessingJobs.Render(sequence, project.Export with { Batch = [] }, width, height).ParametersJson);
|
||||
var export = project.Export with { Batch = [] };
|
||||
// As the editor's Render: settings or proportions an older server would render otherwise are not posted.
|
||||
if (ServerCannotRender(project, export, width, height, Services.Sync.SettingsFormat) is { } newer)
|
||||
{
|
||||
shell.Notify(Loc.L("Library.Post.Failed"), newer);
|
||||
return null;
|
||||
}
|
||||
return ServerRender(sequence, project, export, width, height);
|
||||
}, JobKind.Render, sequence.DisplayTitle);
|
||||
return;
|
||||
}
|
||||
@@ -196,7 +203,23 @@ public sealed class LibraryActions(ShellViewModel shell)
|
||||
}
|
||||
|
||||
/// <summary>Posts a job to the signed-in server, which runs it or hands it to a render node (BRIEF §14.6, §14.7).</summary>
|
||||
private async Task PostAsync(Func<Task<CreateJobRequest>> build, JobKind kind, string label)
|
||||
/// <summary>
|
||||
/// Why a server that reads settings up to <paramref name="serverFormat"/> cannot render <paramref name="project"/> with
|
||||
/// <paramref name="export"/> as this Chronos would (<see cref="ProcessingJobs.RequiredFormat"/>), localised; null when it can.
|
||||
/// </summary>
|
||||
internal static string? ServerCannotRender(ProjectSettings project, ExportSettings export, int sourceWidth, int sourceHeight, int serverFormat) =>
|
||||
Editor.ServerJobs.NeedsNewerServer(ProcessingJobs.RequiredFormat(project, export, sourceWidth, sourceHeight), serverFormat);
|
||||
|
||||
/// <summary>
|
||||
/// The server render of a remote card: sized on <paramref name="project"/> (the settings just read), which it does not
|
||||
/// embed, so the server renders the sequence's settings as they are when a node takes the job (the read may come from
|
||||
/// this PC's proxy cache, older than the server's).
|
||||
/// </summary>
|
||||
internal static CreateJobRequest ServerRender(Sequence sequence, ProjectSettings project, ExportSettings export, int sourceWidth, int sourceHeight) =>
|
||||
new(RenderKind, [sequence.Id], ProcessingJobs.Render(sequence with { SettingsJson = project.ToJson() }, export, sourceWidth, sourceHeight).ParametersJson);
|
||||
|
||||
/// <summary>Posts the job <paramref name="build"/> gives; nothing when it gives none (it said why).</summary>
|
||||
private async Task PostAsync(Func<Task<CreateJobRequest?>> build, JobKind kind, string label)
|
||||
{
|
||||
var session = Services.Server;
|
||||
if (!CanPost || session.Flow is not { Address: { } address, Token: { } token })
|
||||
@@ -206,7 +229,7 @@ public sealed class LibraryActions(ShellViewModel shell)
|
||||
}
|
||||
try
|
||||
{
|
||||
var request = await build();
|
||||
if (await build() is not { } request) return;
|
||||
using var client = new ChronosClient(address, new CertificatePinning(session.Fingerprints), $"Chronos ({Environment.MachineName})") { Token = token };
|
||||
await client.CreateJobAsync(request);
|
||||
shell.Notify(Loc.L("Library.QueuedServer", JobText.Kind(kind), label));
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
xmlns:v="clr-namespace:Chronos.Ui.Visuals;assembly=Chronos.Ui"
|
||||
xmlns:l="clr-namespace:Chronos.Ui.Localization;assembly=Chronos.Ui"
|
||||
xmlns:infra="clr-namespace:Chronos.App.Infrastructure"
|
||||
xmlns:e="clr-namespace:Chronos.App.Editor"
|
||||
xmlns:sections="clr-namespace:Chronos.App.Sections"
|
||||
KeyDown="OnKeyDown" Loaded="OnLoaded">
|
||||
<UserControl.Resources>
|
||||
@@ -118,7 +119,7 @@
|
||||
<ContextMenu>
|
||||
<MenuItem Header="{l:Loc Editor.Project.SaveVersion}" Command="{Binding Project.SaveVersionCommand}" InputGestureText="Ctrl+S"
|
||||
ToolTip="{Binding Project.SaveVersionToolTip}" ToolTipService.ShowOnDisabled="True" />
|
||||
<MenuItem Header="{l:Loc Editor.Project.Sync}" Command="{Binding Project.SyncCommand}" ToolTip="{Binding Project.StateToolTip}" ToolTipService.ShowOnDisabled="True" />
|
||||
<MenuItem Header="{l:Loc Editor.Project.Sync}" Command="{Binding Project.SyncCommand}" ToolTip="{Binding Project.SyncToolTip}" ToolTipService.ShowOnDisabled="True" />
|
||||
<MenuItem Header="{l:Loc Editor.Project.History}" Command="{Binding Project.HistoryCommand}" ToolTip="{l:Loc Tooltips.Editor.Project.History}" />
|
||||
<Separator />
|
||||
<MenuItem Header="{l:Loc Editor.Project.Open}" Command="{Binding Project.OpenProjectCommand}" ToolTip="{l:Loc Tooltips.Editor.Project.Open}" />
|
||||
@@ -223,7 +224,9 @@
|
||||
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}"
|
||||
CropMaskMode="{Binding CropMaskMode}" CropEditable="{Binding CropEditable}" CropLockRatio="{Binding CropLockRatio}"
|
||||
EditCrop="{Binding EditCrop}" ShowGrid="{Binding ShowStraightenGrid}" e:CropCommit.Command="{Binding CommitCropCommand}"
|
||||
InfoText="{Binding InfoText}" ToolTip="{Binding PreviewToolTip}"
|
||||
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
|
||||
|
||||
@@ -580,7 +580,7 @@ public sealed class SequenceViewModel : SectionViewModel
|
||||
throw new InvalidOperationException(Loc.L("Editor.Error.SignedOut"));
|
||||
// The proxy cache's index and files are read off the UI thread.
|
||||
if (await Task.Run(() => service.OpenRemote(server, sequenceId)) is { } remote)
|
||||
return (new RemoteSequenceSource(remote, api, decoder, readOnly: !sync.Policy.CanEdit), remote.Sequence.DisplayTitle);
|
||||
return (new RemoteSequenceSource(remote, api, decoder, readOnly: !sync.Policy.CanEdit, serverFormat: sync.SettingsFormat), remote.Sequence.DisplayTitle);
|
||||
using (api)
|
||||
{
|
||||
string title;
|
||||
|
||||
@@ -81,6 +81,16 @@ public sealed class SyncHost(AppServices services) : ISyncConnector, IAsyncDispo
|
||||
public bool HasProjects =>
|
||||
services.Server.IsConnected && services.Server.Flow.Info?.Capabilities is { } capabilities && capabilities.Contains(ServerCapabilities.Projects);
|
||||
|
||||
/// <summary>
|
||||
/// The highest project settings format the signed-in server reads and renders (owner review 1, phase 4); 1 while signed
|
||||
/// out and for an older server, which does not announce it. Pushes and renders that need more are held back
|
||||
/// (<see cref="ServerJobs.NeedsNewerServer"/>).
|
||||
/// </summary>
|
||||
public int SettingsFormat => SettingsFormatOf(services.Server.IsConnected ? services.Server.Flow.Info : null);
|
||||
|
||||
/// <summary>The settings format a server's <c>server/info</c> announces; 1 when it announces none (an older server).</summary>
|
||||
public static int SettingsFormatOf(ServerInfo? info) => info?.SettingsFormat is > 0 and var format ? format : ProjectSettings.BaseVersion;
|
||||
|
||||
/// <summary>The home of a workspace project of server sequence <paramref name="remoteId"/>; null while signed out or when the server keeps no projects.</summary>
|
||||
public BundleHome? ServerHome(Guid remoteId) => Server is { } server && HasProjects ? new BundleHome(BundleHome.ServerKind, remoteId, null, server) : null;
|
||||
|
||||
@@ -95,7 +105,7 @@ public sealed class SyncHost(AppServices services) : ISyncConnector, IAsyncDispo
|
||||
if (home.IsArchive || !HasProjects || Volatile.Read(ref _credentials) is not { } credentials
|
||||
|| !string.Equals(home.Server, SyncService.ServerKey(credentials.Address), StringComparison.OrdinalIgnoreCase))
|
||||
return null;
|
||||
return new ServerProjectHome(SessionClient(credentials), home.SequenceId, services.Server.ServerName);
|
||||
return new ServerProjectHome(SessionClient(credentials), home.SequenceId, services.Server.ServerName, SettingsFormat);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -87,6 +87,13 @@ public static class SyncText
|
||||
["camera.offsetX"] = "Server.Setting.CameraOffset",
|
||||
["camera.offsetY"] = "Server.Setting.CameraOffset",
|
||||
["camera.keyframes"] = "Server.Setting.Keyframes",
|
||||
["camera.rotate"] = "Server.Setting.Rotation",
|
||||
["camera.mirror"] = "Server.Setting.Mirror",
|
||||
["camera.flip"] = "Server.Setting.Flip",
|
||||
["camera.straighten"] = "Server.Setting.Straighten",
|
||||
["look"] = "Server.Setting.Look",
|
||||
["look.filter"] = "Server.Setting.LookFilter",
|
||||
["look.strength"] = "Server.Setting.LookStrength",
|
||||
["stack.mode"] = "Server.Setting.Stacking",
|
||||
["stack.length"] = "Server.Setting.TrailLength",
|
||||
["export.preset"] = "Server.Setting.ExportPreset",
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Threading;
|
||||
@@ -13,6 +14,7 @@ using Chronos.App.Library;
|
||||
using Chronos.App.Server;
|
||||
using Chronos.App.Settings;
|
||||
using Chronos.Core.Diagnostics;
|
||||
using Chronos.Core.Imaging.Geometry;
|
||||
using Chronos.Ui.Controls;
|
||||
using Chronos.Ui.Theming;
|
||||
|
||||
@@ -249,7 +251,7 @@ public static class ScreenCapture
|
||||
/// 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
|
||||
/// (<c>edit-change</c>), the crop box, straighten and look scenes (<see cref="CaptureFramingAsync"/>), 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)
|
||||
@@ -295,6 +297,7 @@ public static class ScreenCapture
|
||||
written += await SaveAsync(window, directory, "edit-change", theme, waitForThumbnails: shell);
|
||||
shell.Sequence.CancelPickCommand.Execute(null);
|
||||
}
|
||||
written += await CaptureFramingAsync(window, editor, directory);
|
||||
|
||||
// The server has the sequence (Sync can be ticked) and two copies of this PC's settings were kept by "Save both".
|
||||
await sample.KeepEditorCopiesAsync(id);
|
||||
@@ -329,6 +332,66 @@ public static class ScreenCapture
|
||||
return written;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The framing and look of owner review 1 (R5/R6) in both themes, each undone after: the Camera step with a 9:16 crop
|
||||
/// box moved off centre and its handles (<c>edit-camera-crop</c>); the same view turned right and straightened 3° with
|
||||
/// the straighten grid (<c>edit-camera-straighten</c>); the Exposure step with the Sepia look at 60 % and the compare
|
||||
/// wipe (<c>edit-exposure-look</c>).
|
||||
/// </summary>
|
||||
private static async Task<int> CaptureFramingAsync(MainWindow window, EditorViewModel editor, string directory)
|
||||
{
|
||||
var written = 0;
|
||||
var session = editor.Session;
|
||||
var camera = editor.Tabs.OfType<CameraTab>().Single();
|
||||
foreach (var theme in Themes)
|
||||
{
|
||||
ThemeManager.Apply(theme);
|
||||
editor.SelectedTab = camera;
|
||||
editor.IsCompare = false;
|
||||
editor.CurrentIndex = 45;
|
||||
var steps = 0;
|
||||
if (session.Edit(p => SampleData.PortraitCrop(session, p))) steps++;
|
||||
written += await SaveEditorAsync(window, editor, directory, "edit-camera-crop", theme);
|
||||
|
||||
if (session.Orient(OrientationOp.RotateRight)) steps++;
|
||||
if (session.Edit(SampleData.Straightened)) steps++;
|
||||
editor.IsStraightening = true;
|
||||
written += await SaveEditorAsync(window, editor, directory, "edit-camera-straighten", theme);
|
||||
editor.IsStraightening = false;
|
||||
for (; steps > 0; steps--) session.Undo();
|
||||
|
||||
editor.SelectedTab = editor.Exposure;
|
||||
editor.IsCompare = true;
|
||||
var look = session.Edit(SampleData.SepiaLook);
|
||||
await Settle(window);
|
||||
// The Look group sits at the end of the step's rows: the panel is scrolled down to it.
|
||||
var panel = ScrollerOf<GroupRow>(window);
|
||||
panel?.ScrollToBottom();
|
||||
written += await SaveEditorAsync(window, editor, directory, "edit-exposure-look", theme);
|
||||
panel?.ScrollToTop();
|
||||
if (look) session.Undo();
|
||||
}
|
||||
return written;
|
||||
}
|
||||
|
||||
/// <summary>The scroll viewer around the shown row whose data is a <typeparamref name="TRow"/>; null when none is shown.</summary>
|
||||
private static ScrollViewer? ScrollerOf<TRow>(DependencyObject root)
|
||||
{
|
||||
var pending = new Stack<DependencyObject>([root]);
|
||||
while (pending.Count > 0)
|
||||
{
|
||||
var node = pending.Pop();
|
||||
if (node is FrameworkElement { DataContext: TRow, IsVisible: true } row)
|
||||
{
|
||||
for (DependencyObject? up = row; up is not null; up = VisualTreeHelper.GetParent(up))
|
||||
if (up is ScrollViewer scroller) return scroller;
|
||||
return null;
|
||||
}
|
||||
for (var i = 0; i < VisualTreeHelper.GetChildrenCount(node); i++) pending.Push(VisualTreeHelper.GetChild(node, i));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The Library, the editor's Exposure tab and the import plan in Arabic, dark: the layout mirrors while photos,
|
||||
/// charts, the filmstrip and templates stay left to right. English is restored whatever happens.
|
||||
|
||||
@@ -108,7 +108,7 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
|
||||
_source = source;
|
||||
_session = session;
|
||||
_ui = ui;
|
||||
_sync = new AsyncRelayCommand(() => SyncAsync(), () => !_isSyncing);
|
||||
_sync = new AsyncRelayCommand(() => SyncAsync(), () => !_isSyncing && PushBlockedReason is null);
|
||||
_updateMedia = new AsyncRelayCommand(UpdateMediaAsync, () => _copyJob == Guid.Empty);
|
||||
SaveVersionCommand = new RelayCommand(OpenSaveVersion, () => CanSaveVersion);
|
||||
HistoryCommand = new AsyncRelayCommand(OpenHistoryAsync);
|
||||
@@ -146,6 +146,20 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
|
||||
|
||||
public string StateToolTip => WorkspaceText.StateToolTip(_status, _isSyncing, IsServerHome);
|
||||
|
||||
/// <summary>
|
||||
/// Why the project cannot be sent to its server now (owner review 1, phase 4): its settings are of a format the server
|
||||
/// does not read (an older Chronos Server, which would refuse them); null when they can, and for a project of this PC's
|
||||
/// archive. What a sync sends decides: the working state and every local version not sent yet (one saved with a turn the
|
||||
/// working state no longer has still needs it). Sync is disabled with this as its tooltip, and a render of the server's
|
||||
/// is held; the workspace itself never sends such a version (<see cref="WorkspaceSyncException.HomeReadsOlderFormat"/>).
|
||||
/// </summary>
|
||||
public string? PushBlockedReason => IsServerHome && _source.Workspace is { } workspace && _host.HomeOf(workspace.Home) is { } home
|
||||
? ServerJobs.NeedsNewerServer(int.Max(_session.Project.WrittenFormat, _status?.UnpushedFormat ?? 0), home.SettingsFormat)
|
||||
: null;
|
||||
|
||||
/// <summary>Sync in the menu: why it is disabled, else where the project stands.</summary>
|
||||
public string SyncToolTip => PushBlockedReason ?? StateToolTip;
|
||||
|
||||
/// <summary>The ▾ button: its name, then where the project stands, then what the menu holds.</summary>
|
||||
public string MenuToolTip => Loc.L("Tooltips.Editor.Project.Menu", Name, StateText);
|
||||
|
||||
@@ -270,6 +284,12 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
|
||||
if (_host.Settings.WorkspaceVersionOnRender && !await SaveForRenderAsync()) return false;
|
||||
// Rendered on this PC from the originals the workspace holds (phase 5c): the project renders as it is.
|
||||
if (!IsServerHome || _source.RendersLocally) return true;
|
||||
// Settings the server cannot read are neither sent nor rendered there (owner review 1, phase 4: an older server).
|
||||
if (PushBlockedReason is { } newer)
|
||||
{
|
||||
_ui.Notify(Loc.L("Editor.Workspace.RenderHeld"), newer, isError: true);
|
||||
return false;
|
||||
}
|
||||
await StoreEditAsync();
|
||||
var status = await _host.StatusAsync(ProjectId);
|
||||
if (_disposed) return false;
|
||||
@@ -386,6 +406,12 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
|
||||
public async Task SyncAsync(bool quiet = false)
|
||||
{
|
||||
if (_isSyncing) return;
|
||||
// Settings the server cannot read stay here until it is updated (owner review 1, phase 4): Sync says why.
|
||||
if (PushBlockedReason is { } newer)
|
||||
{
|
||||
if (!quiet) _ui.Notify(Loc.L("Editor.Workspace.NotSent"), newer, isError: true);
|
||||
return;
|
||||
}
|
||||
SetSyncing(true);
|
||||
try
|
||||
{
|
||||
@@ -534,7 +560,7 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
|
||||
{
|
||||
await StoreEditAsync();
|
||||
var history = await _host.HistoryAsync(ProjectId, Math.Max(50, _host.Settings.WorkspaceKeptVersions));
|
||||
dialog.Show(history, ProjectContent.Hash(ProjectContent.ToPortable(_session.Project, _source.Photos)));
|
||||
dialog.Show(history, ProjectContent.ToPortable(_session.Project, _source.Photos));
|
||||
}
|
||||
catch (Exception ex) when (ex is not OutOfMemoryException)
|
||||
{
|
||||
@@ -1026,6 +1052,8 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
|
||||
OnPropertyChanged(nameof(StateText));
|
||||
OnPropertyChanged(nameof(StateKind));
|
||||
OnPropertyChanged(nameof(StateToolTip));
|
||||
OnPropertyChanged(nameof(PushBlockedReason));
|
||||
OnPropertyChanged(nameof(SyncToolTip));
|
||||
OnPropertyChanged(nameof(MenuToolTip));
|
||||
OnPropertyChanged(nameof(MenuName));
|
||||
OnPropertyChanged(nameof(HasMediaUpdate));
|
||||
@@ -1044,6 +1072,7 @@ public sealed class ProjectMenuViewModel : LocalizedViewModel
|
||||
OnPropertyChanged(nameof(CopyOriginalsToolTip));
|
||||
OnPropertyChanged(nameof(ProxiesOnlyToolTip));
|
||||
_updateMedia.RaiseCanExecuteChanged();
|
||||
_sync.RaiseCanExecuteChanged();
|
||||
CommandManager.InvalidateRequerySuggested();
|
||||
}
|
||||
}
|
||||
@@ -472,14 +472,17 @@ public sealed class HistoryDialogViewModel : ArchiveDialogViewModel
|
||||
|
||||
public IReadOnlyList<string> Compared { get => _compared; private set => Set(ref _compared, value); }
|
||||
|
||||
/// <summary>Lists <paramref name="history"/>; <paramref name="currentHash"/> marks the version the project is now.</summary>
|
||||
public void Show(WorkspaceHistory history, string? currentHash)
|
||||
/// <summary>
|
||||
/// Lists <paramref name="history"/>; <paramref name="currentPortable"/>, the project's portable text now, marks the version
|
||||
/// holding it (whatever line ends that version was saved with).
|
||||
/// </summary>
|
||||
public void Show(WorkspaceHistory history, string? currentPortable)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(history);
|
||||
Rows.Clear();
|
||||
foreach (var version in history.Versions)
|
||||
{
|
||||
var current = currentHash is not null && string.Equals(version.ContentHash, currentHash, StringComparison.OrdinalIgnoreCase);
|
||||
var current = currentPortable is not null && ProjectContent.MatchesHash(currentPortable, version.ContentHash);
|
||||
Rows.Add(new HistoryRowViewModel(version, history.Unsent.Contains(version.Id), current,
|
||||
new AsyncRelayCommand(() => CompareAsync(version), () => !IsBusy), new AsyncRelayCommand(() => RestoreAsync(version), () => !IsBusy), _server));
|
||||
}
|
||||
|
||||
@@ -133,6 +133,8 @@ public static class WorkspaceText
|
||||
// A version over the size one may be: saved here (refused before anything was written) or sent (the home stored nothing).
|
||||
ProjectVersionTooLargeException or WorkspaceSyncException { Outcome: PushOutcome.TooLarge } =>
|
||||
ForHome("Errors.Workspace.VersionTooLarge", server, ProjectSidecars.MaxVersionBytes >> 20),
|
||||
// A home that reads an older settings format (an older Chronos Server; owner review 1, phase 4): nothing was sent.
|
||||
WorkspaceSyncException { HomeReadsOlderFormat: true } => Loc.L("Tooltips.Server.NeedsNewerServer"),
|
||||
WorkspaceSyncException => ForHome("Errors.Workspace.Refused", server),
|
||||
// A server's refusal that keeps its meaning: an account that may not change projects there, above all.
|
||||
ChronosApiException { Status: HttpStatusCode.Forbidden } => Loc.L("Errors.Workspace.Forbidden"),
|
||||
|
||||
Reference in new issue
Block a user