feat(settings): brand-logo thumbnail with a hover enlargement
The creator (2026-10-30): the brand-logo field in App Settings showed only a file NAME, so a myopic user could not confirm which picture was set. Now a 28x28 thumbnail sits left of the field showing the actual image, and hovering it opens an enlarged copy (up to 420x320) beside the panel with the file name underneath. A click collapses it; moving the pointer away closes it, unless the pointer walked onto the popup itself, where it stays so the creator can look closely. Mechanics: - `MainViewModel.BrandLogoPreviewImage` decodes the stored asset ONCE and freezes it, so the thumbnail and the enlargement share one bitmap and no dispatcher hop is needed. A corrupt image returns null instead of taking the dialog down. - The thumbnail is hidden when no image is set (NotNullToVis), so there is nothing to hover and no empty frame can appear. - The popup is a separate window: WPF refuses to open one until its placement target is in a live visual tree, which is why the test hosts the control in a real window rather than asserting on a detached control. Guard: BrandLogoPreviewTests — the wiring (image binding, the no-image gate, the four gesture handlers, the readable enlargement size) and the control's open/close behaviour.
This commit is contained in:
@@ -11,6 +11,36 @@ public partial class OverlayHost : UserControl
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>Is the enlarged brand-logo preview showing? Test seam — a Popup is a separate
|
||||
/// window, so nothing else can observe it.</summary>
|
||||
internal bool IsBrandLogoPreviewOpen => BrandLogoPreviewPopup.IsOpen;
|
||||
|
||||
/// <summary>Hover opens the enlargement. Nothing to show when no image is set, so the
|
||||
/// thumbnail simply does nothing in that case.</summary>
|
||||
private void BrandLogoThumb_MouseEnter(object sender, System.Windows.Input.MouseEventArgs e)
|
||||
=> OpenBrandLogoPreview();
|
||||
|
||||
/// <summary>Leaving the thumbnail closes it — unless the pointer walked onto the popup
|
||||
/// itself (which sits beside it), where it stays put so the creator can look closely.</summary>
|
||||
private void BrandLogoThumb_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
|
||||
{
|
||||
if (BrandLogoPreviewPopup.Child?.IsMouseOver == true) return;
|
||||
CloseBrandLogoPreview();
|
||||
}
|
||||
|
||||
/// <summary>A click collapses the enlargement — the explicit "enough, thanks" gesture.</summary>
|
||||
private void BrandLogoThumb_Click(object sender, System.Windows.Input.MouseButtonEventArgs e)
|
||||
=> CloseBrandLogoPreview();
|
||||
|
||||
private void BrandLogoPreviewPopup_MouseLeave(object sender, System.Windows.Input.MouseEventArgs e)
|
||||
=> CloseBrandLogoPreview();
|
||||
|
||||
/// <summary>The thumbnail is hidden when no image is set (see the XAML), so there is nothing
|
||||
/// to open in that case — no empty frame can appear.</summary>
|
||||
internal void OpenBrandLogoPreview() => BrandLogoPreviewPopup.IsOpen = true;
|
||||
|
||||
internal void CloseBrandLogoPreview() => BrandLogoPreviewPopup.IsOpen = false;
|
||||
|
||||
private void BackToAbout_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (DataContext is MainViewModel vm)
|
||||
|
||||
Reference in New Issue
Block a user