Browse Source
PlatformColorValues gains six optional accent shade slots (AccentColorDark1-3/Light1-3); the Win32 backend fills them from the UISettings object it already holds, and SystemAccentColors prefers them over HSL-computed shades, so the palette matches Windows exactly. CheckBox/RadioButton no longer force WinUI's 120px MinWidth (v1 never had it); 8px trailing padding compensates, and the CheckBoxMinWidth/ RadioButtonMinWidth resources stay as override knobs. Both changes follow FluentAvalonia's (MIT) lead. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>pull/21771/head
8 changed files with 170 additions and 12 deletions
@ -0,0 +1,50 @@ |
|||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.Threading; |
||||
|
|
||||
|
namespace Avalonia.Themes.Fluent2.UnitTests; |
||||
|
|
||||
|
/// <summary>
|
||||
|
/// Guards the deliberate desktop-ergonomic deviations from the WinUI metrics.
|
||||
|
/// </summary>
|
||||
|
public class ControlDefaultsTests |
||||
|
{ |
||||
|
[AvaloniaFact] |
||||
|
public void CheckBox_and_RadioButton_do_not_force_winui_min_width() |
||||
|
{ |
||||
|
var theme = new Fluent2Theme(); |
||||
|
var app = Application.Current!; |
||||
|
app.Styles.Add(theme); |
||||
|
try |
||||
|
{ |
||||
|
var checkBox = new CheckBox { Content = "Ok" }; |
||||
|
var radioButton = new RadioButton { Content = "Ok" }; |
||||
|
var window = new Window |
||||
|
{ |
||||
|
Width = 400, |
||||
|
Height = 300, |
||||
|
Content = new StackPanel { Children = { checkBox, radioButton } }, |
||||
|
}; |
||||
|
window.Show(); |
||||
|
try |
||||
|
{ |
||||
|
Dispatcher.UIThread.RunJobs(); |
||||
|
|
||||
|
// WinUI forces MinWidth=120 on both; v1 never did, and neither does Fluent2.
|
||||
|
Assert.Equal(0d, checkBox.MinWidth); |
||||
|
Assert.Equal(0d, radioButton.MinWidth); |
||||
|
Assert.True(checkBox.Bounds.Width < 120, |
||||
|
$"CheckBox width {checkBox.Bounds.Width} should hug its content."); |
||||
|
Assert.True(radioButton.Bounds.Width < 120, |
||||
|
$"RadioButton width {radioButton.Bounds.Width} should hug its content."); |
||||
|
} |
||||
|
finally |
||||
|
{ |
||||
|
window.Close(); |
||||
|
} |
||||
|
} |
||||
|
finally |
||||
|
{ |
||||
|
app.Styles.Remove(theme); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue