Files
Chronos/src/Chronos.App/Editor/SliderActivity.cs
T
Alby96andClaude Opus 5.5 7413b72ecc feat(editor): step controls for orientation, crop, look and output size
Owner review 1 asked for the Camera step to frame the picture the way the
mockup does, so the step now offers Aspect, Rotation (icon buttons), Mirror
and Flip switches, Straighten, Crop size, Crop X and Crop Y, and Reset
framing. Cropping by margins is gone: the crop box is now held to the chosen
aspect.

- EditorSession gains Orient and ResetFraming. Edit and Optimise refit a
  box that was already held to the aspect whenever the aspect or the export
  box changes, and do it in the same undo step. A crop from an older project
  that was placed by offsets is left for the render to fit.
- Straighten drives the preview's grid through the new SliderActivity
  attached behaviour, which a NumberRow switches on with ShowsGrid.
- Exposure gains a Look group with Filter and Strength. A newer project's
  extra look data is kept as it is.
- Export: Width and Height now edit the preset's own box, and a new Output
  size row shows the size after the chosen proportions are applied, marked
  Capped when the encoder shrinks it. ExportPlan carries OutputSize and
  EncodedSize.
- New SwitchRow, IconActionsRow and GroupRow rows with their panel
  templates.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-04 20:24:03 +01:00

51 lines
2.5 KiB
C#

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);
}
}