feat: Phase 0 shells, design system, server skeleton, Docker and CI
- Titano.Ui: DESIGN.md tokens (dark/light), generated 16-px icon set, styles for all standard controls, custom chrome window with snap layouts, rail, job bar, Auto/manual slider, chips, toasts. - Titano desktop shell with sections, Settings (language, theme), About and a --capture screenshot mode. - Titano Server skeleton: env/server.json configuration, self-signed TLS with fingerprint, /health, /server/info, i18n endpoint and the embedded admin panel; in-process server tests. - Docker image (multi-arch, PUID/PGID, health check), compose file, Unraid template; CI, release and nightly workflows; changelog tool. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
122 files changed
+6838
-22
No files matched your search
@@ -0,0 +1,142 @@
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Controls.Primitives;
|
||||
using System.Windows.Input;
|
||||
|
||||
namespace Titano.Ui.Controls;
|
||||
|
||||
/// <summary>
|
||||
/// Advisor-aware slider (BRIEF §10.4, DESIGN §4): in Auto the track is accent with an "Auto · value" pill whose
|
||||
/// tooltip carries the advisor's reason; touching the slider switches to manual (sun track, value shown, reset
|
||||
/// button returns to Auto). When not applicable the value reads "n/a" with the reason in the tooltip.
|
||||
/// </summary>
|
||||
[TemplatePart(Name = PartSlider, Type = typeof(Slider))]
|
||||
public class AutoSlider : Control
|
||||
{
|
||||
public const string PartSlider = "PART_Slider";
|
||||
|
||||
public static readonly DependencyProperty HeaderProperty = DependencyProperty.Register(nameof(Header), typeof(string), typeof(AutoSlider));
|
||||
public static readonly DependencyProperty ValueProperty = DependencyProperty.Register(nameof(Value), typeof(double), typeof(AutoSlider),
|
||||
new FrameworkPropertyMetadata(0.0, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, OnValueChanged));
|
||||
public static readonly DependencyProperty MinimumProperty = DependencyProperty.Register(nameof(Minimum), typeof(double), typeof(AutoSlider), new PropertyMetadata(0.0));
|
||||
public static readonly DependencyProperty MaximumProperty = DependencyProperty.Register(nameof(Maximum), typeof(double), typeof(AutoSlider), new PropertyMetadata(1.0));
|
||||
public static readonly DependencyProperty SmallChangeProperty = DependencyProperty.Register(nameof(SmallChange), typeof(double), typeof(AutoSlider), new PropertyMetadata(0.01));
|
||||
public static readonly DependencyProperty IsSnapToTickEnabledProperty = DependencyProperty.Register(nameof(IsSnapToTickEnabled), typeof(bool), typeof(AutoSlider), new PropertyMetadata(false));
|
||||
public static readonly DependencyProperty TickFrequencyProperty = DependencyProperty.Register(nameof(TickFrequency), typeof(double), typeof(AutoSlider), new PropertyMetadata(1.0));
|
||||
public static readonly DependencyProperty IsAutoProperty = DependencyProperty.Register(nameof(IsAuto), typeof(bool), typeof(AutoSlider),
|
||||
new FrameworkPropertyMetadata(true, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault));
|
||||
public static readonly DependencyProperty AutoValueProperty = DependencyProperty.Register(nameof(AutoValue), typeof(double), typeof(AutoSlider), new PropertyMetadata(0.0, OnAutoValueChanged));
|
||||
public static readonly DependencyProperty AutoReasonProperty = DependencyProperty.Register(nameof(AutoReason), typeof(string), typeof(AutoSlider));
|
||||
public static readonly DependencyProperty IsApplicableProperty = DependencyProperty.Register(nameof(IsApplicable), typeof(bool), typeof(AutoSlider), new PropertyMetadata(true));
|
||||
public static readonly DependencyProperty NotApplicableReasonProperty = DependencyProperty.Register(nameof(NotApplicableReason), typeof(string), typeof(AutoSlider));
|
||||
public static readonly DependencyProperty ValueFormatProperty = DependencyProperty.Register(nameof(ValueFormat), typeof(string), typeof(AutoSlider), new PropertyMetadata("0.##", OnFormatChanged));
|
||||
public static readonly DependencyProperty DisplayValueProperty = DependencyProperty.Register(nameof(DisplayValue), typeof(string), typeof(AutoSlider), new PropertyMetadata(string.Empty));
|
||||
public static readonly DependencyProperty AutoTextProperty = DependencyProperty.Register(nameof(AutoText), typeof(string), typeof(AutoSlider), new PropertyMetadata(string.Empty));
|
||||
public static readonly DependencyProperty SliderToolTipProperty = DependencyProperty.Register(nameof(SliderToolTip), typeof(object), typeof(AutoSlider));
|
||||
|
||||
public static readonly RoutedCommand ResetCommand = new(nameof(ResetCommand), typeof(AutoSlider));
|
||||
|
||||
private Slider? _slider;
|
||||
private bool _syncing;
|
||||
|
||||
static AutoSlider()
|
||||
{
|
||||
DefaultStyleKeyProperty.OverrideMetadata(typeof(AutoSlider), new FrameworkPropertyMetadata(typeof(AutoSlider)));
|
||||
}
|
||||
|
||||
public AutoSlider()
|
||||
{
|
||||
CommandBindings.Add(new CommandBinding(ResetCommand, (_, _) => ResetToAuto()));
|
||||
UpdateTexts();
|
||||
}
|
||||
|
||||
public string? Header { get => (string?)GetValue(HeaderProperty); set => SetValue(HeaderProperty, value); }
|
||||
public double Value { get => (double)GetValue(ValueProperty); set => SetValue(ValueProperty, value); }
|
||||
public double Minimum { get => (double)GetValue(MinimumProperty); set => SetValue(MinimumProperty, value); }
|
||||
public double Maximum { get => (double)GetValue(MaximumProperty); set => SetValue(MaximumProperty, value); }
|
||||
public double SmallChange { get => (double)GetValue(SmallChangeProperty); set => SetValue(SmallChangeProperty, value); }
|
||||
public bool IsSnapToTickEnabled { get => (bool)GetValue(IsSnapToTickEnabledProperty); set => SetValue(IsSnapToTickEnabledProperty, value); }
|
||||
public double TickFrequency { get => (double)GetValue(TickFrequencyProperty); set => SetValue(TickFrequencyProperty, value); }
|
||||
public bool IsAuto { get => (bool)GetValue(IsAutoProperty); set => SetValue(IsAutoProperty, value); }
|
||||
public double AutoValue { get => (double)GetValue(AutoValueProperty); set => SetValue(AutoValueProperty, value); }
|
||||
public string? AutoReason { get => (string?)GetValue(AutoReasonProperty); set => SetValue(AutoReasonProperty, value); }
|
||||
public bool IsApplicable { get => (bool)GetValue(IsApplicableProperty); set => SetValue(IsApplicableProperty, value); }
|
||||
public string? NotApplicableReason { get => (string?)GetValue(NotApplicableReasonProperty); set => SetValue(NotApplicableReasonProperty, value); }
|
||||
public string ValueFormat { get => (string)GetValue(ValueFormatProperty); set => SetValue(ValueFormatProperty, value); }
|
||||
|
||||
/// <summary>Formatted current value (read by the template).</summary>
|
||||
public string DisplayValue { get => (string)GetValue(DisplayValueProperty); private set => SetValue(DisplayValueProperty, value); }
|
||||
|
||||
/// <summary>"Auto · 41" pill text; the "Auto" word comes from the catalog (Common.Auto).</summary>
|
||||
public string AutoText { get => (string)GetValue(AutoTextProperty); private set => SetValue(AutoTextProperty, value); }
|
||||
|
||||
/// <summary>Tooltip of the slider track: what moving it does.</summary>
|
||||
public object? SliderToolTip { get => GetValue(SliderToolTipProperty); set => SetValue(SliderToolTipProperty, value); }
|
||||
|
||||
public override void OnApplyTemplate()
|
||||
{
|
||||
if (_slider is not null)
|
||||
{
|
||||
_slider.ValueChanged -= OnSliderValueChanged;
|
||||
_slider.PreviewMouseDown -= OnSliderTouched;
|
||||
_slider.PreviewKeyDown -= OnSliderTouched;
|
||||
}
|
||||
base.OnApplyTemplate();
|
||||
_slider = GetTemplateChild(PartSlider) as Slider;
|
||||
if (_slider is not null)
|
||||
{
|
||||
_slider.Value = IsAuto ? AutoValue : Value;
|
||||
_slider.ValueChanged += OnSliderValueChanged;
|
||||
_slider.PreviewMouseDown += OnSliderTouched;
|
||||
_slider.PreviewKeyDown += OnSliderTouched;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Returns the control to the advisor's value.</summary>
|
||||
public void ResetToAuto()
|
||||
{
|
||||
IsAuto = true;
|
||||
Value = AutoValue;
|
||||
UpdateTexts();
|
||||
}
|
||||
|
||||
private void OnSliderTouched(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (e is KeyEventArgs k && k.Key is not (Key.Left or Key.Right or Key.Up or Key.Down or Key.PageUp or Key.PageDown or Key.Home or Key.End)) return;
|
||||
IsAuto = false;
|
||||
}
|
||||
|
||||
private void OnSliderValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
|
||||
{
|
||||
if (_syncing) return;
|
||||
Value = e.NewValue;
|
||||
}
|
||||
|
||||
private static void OnValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var s = (AutoSlider)d;
|
||||
if (s._slider is not null && !s._syncing)
|
||||
{
|
||||
s._syncing = true;
|
||||
s._slider.Value = (double)e.NewValue;
|
||||
s._syncing = false;
|
||||
}
|
||||
s.UpdateTexts();
|
||||
}
|
||||
|
||||
private static void OnAutoValueChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
var s = (AutoSlider)d;
|
||||
if (s.IsAuto) s.Value = (double)e.NewValue;
|
||||
s.UpdateTexts();
|
||||
}
|
||||
|
||||
private static void OnFormatChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) => ((AutoSlider)d).UpdateTexts();
|
||||
|
||||
private void UpdateTexts()
|
||||
{
|
||||
var culture = Core.Localization.Loc.Culture;
|
||||
DisplayValue = Value.ToString(ValueFormat, culture);
|
||||
AutoText = Core.Localization.Loc.L("Common.Auto") + " · " + AutoValue.ToString(ValueFormat, culture);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user