fix(socials): live preview of the bar appearance + the crash on dragging a slider
Two bugs from the creator's first look at the new controls.
1. CRASH — '{DependencyProperty.UnsetValue}' is not a valid value for property 'Fill'.
The token conversion deleted `YtSliderKnobHoverBrush` while two slider triggers still
referenced it. WPF does not fail that at build time: it substitutes UnsetValue and throws at
the next layout, inside `Ellipse.OnRender` — so the first slider touched (the new opacity one)
killed the app. The brush is back, as a glossier version of the rest state.
Guard: `ThemeResourceTests` scans every app XAML and proves each {StaticResource} key is
defined (theme/App resources or the same file). Proven by removing the key again — the test
names it.
2. PREVIEW DID NOTHING — the preview bar is its own XAML rendering (not the rasterized strip the
compositor overlays), and it was hard-wired white-on-transparent, so the drawer's controls had
nothing to move. Now:
- `SocialBarTextBrush` / `SocialBarBackgroundBrush` come from the same `SocialBarStyle` the
renderer bakes, so preview and output cannot disagree.
- the preview draws the plate (same colour + opacity) and the drop shadow.
- the drawer applies changes to the live config as you edit (`ApplyAppearancePreview`), and
Cancel restores the pre-edit snapshot — so the preview tracks the controls without
persisting anything until Save.
46 tests green (theme, socials, design tokens, layout store, real-MainWindow meter test).
This commit is contained in:
@@ -31,6 +31,13 @@ public partial class MainViewModel
|
||||
/// <summary>Green glow on the bar while it's on the stream.</summary>
|
||||
public SolidColorBrush SocialBarGlowBrush => BarOnBrush;
|
||||
|
||||
/// <summary>Glyph colour of the bar — the preview draws the same value the renderer paints,
|
||||
/// so the two cannot drift apart (creator request 2026-10-30).</summary>
|
||||
public SolidColorBrush SocialBarTextBrush => SocialBarStyle.From(_socials).TextBrush;
|
||||
|
||||
/// <summary>The preview's plate: same colour AND same opacity the renderer bakes in.</summary>
|
||||
public SolidColorBrush SocialBarBackgroundBrush => SocialBarStyle.From(_socials).BackgroundBrush;
|
||||
|
||||
/// <summary>The global socials config (entries + bar settings), or null.</summary>
|
||||
public SocialsConfig? Socials => _socials;
|
||||
|
||||
@@ -137,13 +144,28 @@ public partial class MainViewModel
|
||||
SignOutYouTubeAsync,
|
||||
_youtubeAuth.CurrentChannel,
|
||||
_socials);
|
||||
// Live preview: the drawer edits the REAL config, so colour/opacity/shadow land on the
|
||||
// preview immediately instead of waiting for Save. Cancel restores the snapshot below.
|
||||
_socialsBeforeEdit = _socials;
|
||||
dialog.PropertyChanged += (_, e) =>
|
||||
{
|
||||
if (e.PropertyName is null) return;
|
||||
if (!IsAppearanceProperty(e.PropertyName)) return;
|
||||
ApplyAppearancePreview(dialog);
|
||||
};
|
||||
dialog.SaveRequested += () =>
|
||||
{
|
||||
_socials = dialog.BuildSocialsConfig();
|
||||
NotifySocialsChanged();
|
||||
CloseSocialsDrawer();
|
||||
};
|
||||
dialog.CancelRequested += CloseSocialsDrawer;
|
||||
dialog.CancelRequested += () =>
|
||||
{
|
||||
_socials = _socialsBeforeEdit;
|
||||
NotifySocialsChanged();
|
||||
OnPropertyChanged(nameof(SocialBarVisible));
|
||||
CloseSocialsDrawer();
|
||||
};
|
||||
SocialsDrawer = dialog;
|
||||
BroadcastForm.IsDrawerOpen = false;
|
||||
Ypp.IsDrawerOpen = false;
|
||||
@@ -153,6 +175,28 @@ public partial class MainViewModel
|
||||
OnPropertyChanged(nameof(SocialsDrawerOpen));
|
||||
}
|
||||
|
||||
private SocialsConfig? _socialsBeforeEdit;
|
||||
|
||||
private static bool IsAppearanceProperty(string name) => name is
|
||||
nameof(SocialsDialogViewModel.BarEnabled) or nameof(SocialsDialogViewModel.BarTextColor)
|
||||
or nameof(SocialsDialogViewModel.BarBackgroundEnabled) or nameof(SocialsDialogViewModel.BarBackgroundColor)
|
||||
or nameof(SocialsDialogViewModel.BarBackgroundOpacity) or nameof(SocialsDialogViewModel.BarTextShadow);
|
||||
|
||||
/// <summary>Paints the drawer's current appearance onto the live config and re-renders the
|
||||
/// strip. Nothing is persisted here — Save writes, Cancel restores the snapshot.</summary>
|
||||
private void ApplyAppearancePreview(SocialsDialogViewModel dialog)
|
||||
{
|
||||
if (_socials == null) return;
|
||||
_socials.BarEnabled = dialog.BarEnabled;
|
||||
_socials.BarTextColor = dialog.BarTextColor;
|
||||
_socials.BarBackgroundEnabled = dialog.BarBackgroundEnabled;
|
||||
_socials.BarBackgroundColor = dialog.BarBackgroundColor;
|
||||
_socials.BarBackgroundOpacity = dialog.BarBackgroundOpacity;
|
||||
_socials.BarTextShadow = dialog.BarTextShadow;
|
||||
NotifySocialsChanged();
|
||||
OnPropertyChanged(nameof(SocialBarVisible));
|
||||
}
|
||||
|
||||
internal void CloseSocialsDrawer()
|
||||
{
|
||||
if (!SocialsDrawerOpen) return;
|
||||
@@ -164,6 +208,8 @@ public partial class MainViewModel
|
||||
private void NotifySocialsChanged()
|
||||
{
|
||||
RenderSocialBarFrame();
|
||||
OnPropertyChanged(nameof(SocialBarTextBrush));
|
||||
OnPropertyChanged(nameof(SocialBarBackgroundBrush));
|
||||
OnPropertyChanged(nameof(HasSocials));
|
||||
OnPropertyChanged(nameof(SocialBarVisible));
|
||||
OnPropertyChanged(nameof(SocialBarDotBrush));
|
||||
|
||||
Reference in New Issue
Block a user