Browse Source

Merge remote-tracking branch 'origin/master' into feature/fluent-slider-template

feature/fluent-slider
Dan Walmsley 6 years ago
parent
commit
a7624be454
  1. 2
      src/Avalonia.Controls/Platform/IPopupImpl.cs
  2. 21
      src/Avalonia.Controls/Primitives/Popup.cs
  3. 6
      src/Avalonia.Controls/Primitives/PopupRoot.cs
  4. 9
      src/Avalonia.Controls/Utils/BorderRenderHelper.cs
  5. 4
      src/Avalonia.DesignerSupport/Remote/Stubs.cs
  6. 5
      src/Avalonia.Native/PopupImpl.cs
  7. 12
      src/Avalonia.Themes.Fluent/Accents/BaseDark.xaml
  8. 12
      src/Avalonia.Themes.Fluent/Accents/BaseLight.xaml
  9. 8
      src/Avalonia.Themes.Fluent/Accents/FluentBaseDark.xaml
  10. 8
      src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml
  11. 6
      src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml
  12. 6
      src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml
  13. 68
      src/Avalonia.Themes.Fluent/AutoCompleteBox.xaml
  14. 38
      src/Avalonia.Themes.Fluent/PopupRoot.xaml
  15. 4
      src/Avalonia.X11/X11Window.cs
  16. 34
      src/Windows/Avalonia.Win32/PopupImpl.cs

2
src/Avalonia.Controls/Platform/IPopupImpl.cs

@ -8,5 +8,7 @@ namespace Avalonia.Platform
public interface IPopupImpl : IWindowBaseImpl public interface IPopupImpl : IWindowBaseImpl
{ {
IPopupPositioner PopupPositioner { get; } IPopupPositioner PopupPositioner { get; }
void SetWindowManagerAddShadowHint(bool enabled);
} }
} }

21
src/Avalonia.Controls/Primitives/Popup.cs

@ -19,6 +19,9 @@ namespace Avalonia.Controls.Primitives
/// </summary> /// </summary>
public class Popup : Control, IVisualTreeHost public class Popup : Control, IVisualTreeHost
{ {
public static readonly StyledProperty<bool> WindowManagerAddShadowHintProperty =
AvaloniaProperty.Register<PopupRoot, bool>(nameof(WindowManagerAddShadowHint), true);
/// <summary> /// <summary>
/// Defines the <see cref="Child"/> property. /// Defines the <see cref="Child"/> property.
/// </summary> /// </summary>
@ -89,7 +92,7 @@ namespace Avalonia.Controls.Primitives
{ {
IsHitTestVisibleProperty.OverrideDefaultValue<Popup>(false); IsHitTestVisibleProperty.OverrideDefaultValue<Popup>(false);
ChildProperty.Changed.AddClassHandler<Popup>((x, e) => x.ChildChanged(e)); ChildProperty.Changed.AddClassHandler<Popup>((x, e) => x.ChildChanged(e));
IsOpenProperty.Changed.AddClassHandler<Popup>((x, e) => x.IsOpenChanged((AvaloniaPropertyChangedEventArgs<bool>)e)); IsOpenProperty.Changed.AddClassHandler<Popup>((x, e) => x.IsOpenChanged((AvaloniaPropertyChangedEventArgs<bool>)e));
} }
/// <summary> /// <summary>
@ -104,6 +107,12 @@ namespace Avalonia.Controls.Primitives
public IPopupHost? Host => _openState?.PopupHost; public IPopupHost? Host => _openState?.PopupHost;
public bool WindowManagerAddShadowHint
{
get { return GetValue(WindowManagerAddShadowHintProperty); }
set { SetValue(WindowManagerAddShadowHintProperty, value); }
}
/// <summary> /// <summary>
/// Gets or sets the control to display in the popup. /// Gets or sets the control to display in the popup.
/// </summary> /// </summary>
@ -293,6 +302,8 @@ namespace Avalonia.Controls.Primitives
_openState = new PopupOpenState(topLevel, popupHost, cleanupPopup); _openState = new PopupOpenState(topLevel, popupHost, cleanupPopup);
WindowManagerAddShadowHintChanged(popupHost, WindowManagerAddShadowHint);
popupHost.Show(); popupHost.Show();
using (BeginIgnoringIsOpen()) using (BeginIgnoringIsOpen())
@ -332,6 +343,14 @@ namespace Avalonia.Controls.Primitives
return Disposable.Create((unsubscribe, target, handler), state => state.unsubscribe(state.target, state.handler)); return Disposable.Create((unsubscribe, target, handler), state => state.unsubscribe(state.target, state.handler));
} }
private void WindowManagerAddShadowHintChanged(IPopupHost host, bool hint)
{
if(host is PopupRoot pr)
{
pr.PlatformImpl.SetWindowManagerAddShadowHint(hint);
}
}
/// <summary> /// <summary>
/// Called when the <see cref="IsOpen"/> property changes. /// Called when the <see cref="IsOpen"/> property changes.
/// </summary> /// </summary>

6
src/Avalonia.Controls/Primitives/PopupRoot.cs

@ -17,14 +17,14 @@ namespace Avalonia.Controls.Primitives
public sealed class PopupRoot : WindowBase, IInteractive, IHostedVisualTreeRoot, IDisposable, IStyleHost, IPopupHost public sealed class PopupRoot : WindowBase, IInteractive, IHostedVisualTreeRoot, IDisposable, IStyleHost, IPopupHost
{ {
private readonly TopLevel _parent; private readonly TopLevel _parent;
private PopupPositionerParameters _positionerParameters; private PopupPositionerParameters _positionerParameters;
/// <summary> /// <summary>
/// Initializes static members of the <see cref="PopupRoot"/> class. /// Initializes static members of the <see cref="PopupRoot"/> class.
/// </summary> /// </summary>
static PopupRoot() static PopupRoot()
{ {
BackgroundProperty.OverrideDefaultValue(typeof(PopupRoot), Brushes.White); BackgroundProperty.OverrideDefaultValue(typeof(PopupRoot), Brushes.White);
} }
/// <summary> /// <summary>
@ -53,7 +53,7 @@ namespace Avalonia.Controls.Primitives
/// Gets the platform-specific window implementation. /// Gets the platform-specific window implementation.
/// </summary> /// </summary>
[CanBeNull] [CanBeNull]
public new IPopupImpl PlatformImpl => (IPopupImpl)base.PlatformImpl; public new IPopupImpl PlatformImpl => (IPopupImpl)base.PlatformImpl;
/// <summary> /// <summary>
/// Gets the parent control in the event route. /// Gets the parent control in the event route.

9
src/Avalonia.Controls/Utils/BorderRenderHelper.cs

@ -118,12 +118,11 @@ namespace Avalonia.Controls.Utils
pen = new Pen(borderBrush, borderThickness); pen = new Pen(borderBrush, borderThickness);
} }
var rrect = new RoundedRect(new Rect(_size), _cornerRadius.TopLeft, _cornerRadius.TopRight, var rect = new Rect(_size);
_cornerRadius.BottomRight, _cornerRadius.BottomLeft);
if (Math.Abs(borderThickness) > double.Epsilon) if (Math.Abs(borderThickness) > double.Epsilon)
{ rect = rect.Deflate(borderThickness * 0.5);
rrect = rrect.Deflate(borderThickness * 0.5, borderThickness * 0.5); var rrect = new RoundedRect(rect, _cornerRadius.TopLeft, _cornerRadius.TopRight,
} _cornerRadius.BottomRight, _cornerRadius.BottomLeft);
context.PlatformImpl.DrawRectangle(background, pen, rrect, boxShadows); context.PlatformImpl.DrawRectangle(background, pen, rrect, boxShadows);
} }

4
src/Avalonia.DesignerSupport/Remote/Stubs.cs

@ -146,6 +146,10 @@ namespace Avalonia.DesignerSupport.Remote
public void SetTransparencyLevelHint(WindowTransparencyLevel transparencyLevel) { } public void SetTransparencyLevelHint(WindowTransparencyLevel transparencyLevel) { }
public void SetWindowManagerAddShadowHint(bool enabled)
{
}
public WindowTransparencyLevel TransparencyLevel { get; private set; } public WindowTransparencyLevel TransparencyLevel { get; private set; }
} }

5
src/Avalonia.Native/PopupImpl.cs

@ -59,6 +59,11 @@ namespace Avalonia.Native
} }
public override IPopupImpl CreatePopup() => new PopupImpl(_factory, _opts, _glFeature, this); public override IPopupImpl CreatePopup() => new PopupImpl(_factory, _opts, _glFeature, this);
public void SetWindowManagerAddShadowHint(bool enabled)
{
}
public IPopupPositioner PopupPositioner { get; } public IPopupPositioner PopupPositioner { get; }
} }
} }

12
src/Avalonia.Themes.Fluent/Accents/BaseDark.xaml

@ -139,6 +139,7 @@
<SolidColorBrush x:Key="SystemControlErrorTextForegroundBrush" Color="{StaticResource SystemErrorTextColor}" /> <SolidColorBrush x:Key="SystemControlErrorTextForegroundBrush" Color="{StaticResource SystemErrorTextColor}" />
<SolidColorBrush x:Key="SystemControlTransientBorderBrush" Color="#000000" Opacity="0.36" /> <SolidColorBrush x:Key="SystemControlTransientBorderBrush" Color="#000000" Opacity="0.36" />
<!--<AcrylicBrush x:Key="SystemControlTransientBackgroundBrush" BackgroundSource="HostBackdrop" TintColor="{StaticResource SystemChromeAltHighColor}" TintOpacity="0.8" FallbackColor="{StaticResource SystemChromeMediumLowColor}" />--> <!--<AcrylicBrush x:Key="SystemControlTransientBackgroundBrush" BackgroundSource="HostBackdrop" TintColor="{StaticResource SystemChromeAltHighColor}" TintOpacity="0.8" FallbackColor="{StaticResource SystemChromeMediumLowColor}" />-->
<SolidColorBrush x:Key="SystemControlTransientBackgroundBrush" Color="{StaticResource SystemChromeMediumLowColor}" />
<StaticResource x:Key="SystemControlDescriptionTextForegroundBrush" ResourceKey="SystemControlPageTextBaseMediumBrush" /> <StaticResource x:Key="SystemControlDescriptionTextForegroundBrush" ResourceKey="SystemControlPageTextBaseMediumBrush" />
<x:Boolean x:Key="IsApplicationFocusVisualKindReveal">False</x:Boolean> <x:Boolean x:Key="IsApplicationFocusVisualKindReveal">False</x:Boolean>
@ -159,8 +160,7 @@
<x:Double x:Key="AppBarThemeMinimalHeight">24</x:Double> <x:Double x:Key="AppBarThemeMinimalHeight">24</x:Double>
<x:Double x:Key="AppBarThemeCompactHeight">40</x:Double> <x:Double x:Key="AppBarThemeCompactHeight">40</x:Double>
<x:Double x:Key="AppBarExpandButtonCircleDiameter">3</x:Double> <x:Double x:Key="AppBarExpandButtonCircleDiameter">3</x:Double>
<x:Double x:Key="AutoSuggestListMaxHeight">374</x:Double> <x:Double x:Key="AutoCompleteListBorderOpacity">0</x:Double>
<x:Double x:Key="AutoSuggestListBorderOpacity">0</x:Double>
<Thickness x:Key="CheckBoxBorderThemeThickness">2</Thickness> <Thickness x:Key="CheckBoxBorderThemeThickness">2</Thickness>
<Thickness x:Key="CheckBoxCheckedStrokeThickness">0</Thickness> <Thickness x:Key="CheckBoxCheckedStrokeThickness">0</Thickness>
<x:Double x:Key="ComboBoxArrowThemeFontSize">21</x:Double> <x:Double x:Key="ComboBoxArrowThemeFontSize">21</x:Double>
@ -258,10 +258,10 @@
<Thickness x:Key="AppBarTopBorderThemeThickness">0,0,0,0</Thickness> <Thickness x:Key="AppBarTopBorderThemeThickness">0,0,0,0</Thickness>
<Thickness x:Key="AppBarTopThemePadding">0,0,0,0</Thickness> <Thickness x:Key="AppBarTopThemePadding">0,0,0,0</Thickness>
<Thickness x:Key="AppBarExpandButtonCircleInnerPadding">3,0,3,0</Thickness> <Thickness x:Key="AppBarExpandButtonCircleInnerPadding">3,0,3,0</Thickness>
<Thickness x:Key="AutoSuggestListBorderThemeThickness">1</Thickness> <Thickness x:Key="AutoCompleteListBorderThemeThickness">1</Thickness>
<Thickness x:Key="AutoSuggestListMargin">0,2,0,2</Thickness> <Thickness x:Key="AutoCompleteListMargin">0,2,0,2</Thickness>
<Thickness x:Key="AutoSuggestListPadding">-1,0,-1,0</Thickness> <Thickness x:Key="AutoCompleteListPadding">-1,0,-1,0</Thickness>
<Thickness x:Key="AutoSuggestListViewItemMargin">12,11,0,13</Thickness> <Thickness x:Key="AutoCompleteListViewItemMargin">12,11,0,13</Thickness>
<Thickness x:Key="ButtonBorderThemeThickness">2</Thickness> <Thickness x:Key="ButtonBorderThemeThickness">2</Thickness>
<Thickness x:Key="CalendarDatePickerBorderThemeThickness">2</Thickness> <Thickness x:Key="CalendarDatePickerBorderThemeThickness">2</Thickness>
<Thickness x:Key="ComboBoxBorderThemeThickness">2</Thickness> <Thickness x:Key="ComboBoxBorderThemeThickness">2</Thickness>

12
src/Avalonia.Themes.Fluent/Accents/BaseLight.xaml

@ -139,6 +139,7 @@
<SolidColorBrush x:Key="SystemControlErrorTextForegroundBrush" Color="{StaticResource SystemErrorTextColor}" /> <SolidColorBrush x:Key="SystemControlErrorTextForegroundBrush" Color="{StaticResource SystemErrorTextColor}" />
<SolidColorBrush x:Key="SystemControlTransientBorderBrush" Color="#000000" Opacity="0.14" /> <SolidColorBrush x:Key="SystemControlTransientBorderBrush" Color="#000000" Opacity="0.14" />
<!--<AcrylicBrush x:Key="SystemControlTransientBackgroundBrush" BackgroundSource="HostBackdrop" TintColor="{StaticResource SystemChromeAltHighColor}" TintOpacity="0.8" FallbackColor="{StaticResource SystemChromeMediumLowColor}" />--> <!--<AcrylicBrush x:Key="SystemControlTransientBackgroundBrush" BackgroundSource="HostBackdrop" TintColor="{StaticResource SystemChromeAltHighColor}" TintOpacity="0.8" FallbackColor="{StaticResource SystemChromeMediumLowColor}" />-->
<SolidColorBrush x:Key="SystemControlTransientBackgroundBrush" Color="{StaticResource SystemChromeMediumLowColor}" />
<StaticResource x:Key="SystemControlDescriptionTextForegroundBrush" ResourceKey="SystemControlPageTextBaseMediumBrush" /> <StaticResource x:Key="SystemControlDescriptionTextForegroundBrush" ResourceKey="SystemControlPageTextBaseMediumBrush" />
<x:Boolean x:Key="IsApplicationFocusVisualKindReveal">False</x:Boolean> <x:Boolean x:Key="IsApplicationFocusVisualKindReveal">False</x:Boolean>
@ -158,8 +159,7 @@
<x:Double x:Key="AppBarThemeMinimalHeight">24</x:Double> <x:Double x:Key="AppBarThemeMinimalHeight">24</x:Double>
<x:Double x:Key="AppBarThemeCompactHeight">40</x:Double> <x:Double x:Key="AppBarThemeCompactHeight">40</x:Double>
<x:Double x:Key="AppBarExpandButtonCircleDiameter">3</x:Double> <x:Double x:Key="AppBarExpandButtonCircleDiameter">3</x:Double>
<x:Double x:Key="AutoSuggestListMaxHeight">374</x:Double> <x:Double x:Key="AutoCompleteListBorderOpacity">0</x:Double>
<x:Double x:Key="AutoSuggestListBorderOpacity">0</x:Double>
<Thickness x:Key="CheckBoxBorderThemeThickness">2</Thickness> <Thickness x:Key="CheckBoxBorderThemeThickness">2</Thickness>
<Thickness x:Key="CheckBoxCheckedStrokeThickness">0</Thickness> <Thickness x:Key="CheckBoxCheckedStrokeThickness">0</Thickness>
<x:Double x:Key="ComboBoxArrowThemeFontSize">21</x:Double> <x:Double x:Key="ComboBoxArrowThemeFontSize">21</x:Double>
@ -257,10 +257,10 @@
<Thickness x:Key="AppBarTopBorderThemeThickness">0,0,0,0</Thickness> <Thickness x:Key="AppBarTopBorderThemeThickness">0,0,0,0</Thickness>
<Thickness x:Key="AppBarTopThemePadding">0,0,0,0</Thickness> <Thickness x:Key="AppBarTopThemePadding">0,0,0,0</Thickness>
<Thickness x:Key="AppBarExpandButtonCircleInnerPadding">3,0,3,0</Thickness> <Thickness x:Key="AppBarExpandButtonCircleInnerPadding">3,0,3,0</Thickness>
<Thickness x:Key="AutoSuggestListBorderThemeThickness">1</Thickness> <Thickness x:Key="AutoCompleteListBorderThemeThickness">1</Thickness>
<Thickness x:Key="AutoSuggestListMargin">0,2,0,2</Thickness> <Thickness x:Key="AutoCompleteListMargin">0,2,0,2</Thickness>
<Thickness x:Key="AutoSuggestListPadding">-1,0,-1,0</Thickness> <Thickness x:Key="AutoCompleteListPadding">-1,0,-1,0</Thickness>
<Thickness x:Key="AutoSuggestListViewItemMargin">12,11,0,13</Thickness> <Thickness x:Key="AutoCompleteListViewItemMargin">12,11,0,13</Thickness>
<Thickness x:Key="ButtonBorderThemeThickness">2</Thickness> <Thickness x:Key="ButtonBorderThemeThickness">2</Thickness>
<Thickness x:Key="CalendarDatePickerBorderThemeThickness">2</Thickness> <Thickness x:Key="CalendarDatePickerBorderThemeThickness">2</Thickness>
<Thickness x:Key="ComboBoxBorderThemeThickness">2</Thickness> <Thickness x:Key="ComboBoxBorderThemeThickness">2</Thickness>

8
src/Avalonia.Themes.Fluent/Accents/FluentBaseDark.xaml

@ -137,7 +137,13 @@
<StaticResource x:Key="TextControlButtonForegroundPressed" ResourceKey="SystemControlHighlightAltChromeWhiteBrush" /> <StaticResource x:Key="TextControlButtonForegroundPressed" ResourceKey="SystemControlHighlightAltChromeWhiteBrush" />
<StaticResource x:Key="ContentLinkForegroundColor" ResourceKey="SystemControlHyperlinkTextBrush" /> <StaticResource x:Key="ContentLinkForegroundColor" ResourceKey="SystemControlHyperlinkTextBrush" />
<StaticResource x:Key="ContentLinkBackgroundColor" ResourceKey="SystemControlPageBackgroundChromeLowBrush" /> <StaticResource x:Key="ContentLinkBackgroundColor" ResourceKey="SystemControlPageBackgroundChromeLowBrush" />
<!-- Resources for AutoCompleteBox.xaml -->
<StaticResource x:Key="AutoCompleteBoxLightDismissOverlayBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" />
<StaticResource x:Key="AutoCompleteBoxSuggestionsListBackground" ResourceKey="SystemControlBackgroundChromeMediumLowBrush" />
<StaticResource x:Key="AutoCompleteBoxSuggestionsListBorderBrush" ResourceKey="SystemControlForegroundChromeHighBrush" />
<x:Double x:Key="AutoCompleteBoxIconFontSize">12</x:Double>
<!-- BaseResources for CheckBox.xaml --> <!-- BaseResources for CheckBox.xaml -->
<StaticResource x:Key="CheckBoxForegroundUnchecked" ResourceKey="SystemControlForegroundBaseHighBrush" /> <StaticResource x:Key="CheckBoxForegroundUnchecked" ResourceKey="SystemControlForegroundBaseHighBrush" />
<StaticResource x:Key="CheckBoxForegroundUncheckedPointerOver" ResourceKey="SystemControlForegroundBaseHighBrush" /> <StaticResource x:Key="CheckBoxForegroundUncheckedPointerOver" ResourceKey="SystemControlForegroundBaseHighBrush" />

8
src/Avalonia.Themes.Fluent/Accents/FluentBaseLight.xaml

@ -137,7 +137,13 @@
<StaticResource x:Key="TextControlButtonForegroundPressed" ResourceKey="SystemControlHighlightAltChromeWhiteBrush" /> <StaticResource x:Key="TextControlButtonForegroundPressed" ResourceKey="SystemControlHighlightAltChromeWhiteBrush" />
<StaticResource x:Key="ContentLinkForegroundColor" ResourceKey="SystemControlHyperlinkTextBrush" /> <StaticResource x:Key="ContentLinkForegroundColor" ResourceKey="SystemControlHyperlinkTextBrush" />
<StaticResource x:Key="ContentLinkBackgroundColor" ResourceKey="SystemControlPageBackgroundChromeLowBrush" /> <StaticResource x:Key="ContentLinkBackgroundColor" ResourceKey="SystemControlPageBackgroundChromeLowBrush" />
<!-- Resources for AutoCompleteBox.xaml -->
<StaticResource x:Key="AutoCompleteBoxLightDismissOverlayBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" />
<StaticResource x:Key="AutoCompleteBoxSuggestionsListBackground" ResourceKey="SystemControlBackgroundChromeMediumLowBrush" />
<StaticResource x:Key="AutoCompleteBoxSuggestionsListBorderBrush" ResourceKey="SystemControlForegroundChromeHighBrush" />
<x:Double x:Key="AutoCompleteBoxIconFontSize">12</x:Double>
<!-- BaseResources for CheckBox.xaml --> <!-- BaseResources for CheckBox.xaml -->
<StaticResource x:Key="CheckBoxForegroundUnchecked" ResourceKey="SystemControlForegroundBaseHighBrush" /> <StaticResource x:Key="CheckBoxForegroundUnchecked" ResourceKey="SystemControlForegroundBaseHighBrush" />
<StaticResource x:Key="CheckBoxForegroundUncheckedPointerOver" ResourceKey="SystemControlForegroundBaseHighBrush" /> <StaticResource x:Key="CheckBoxForegroundUncheckedPointerOver" ResourceKey="SystemControlForegroundBaseHighBrush" />

6
src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesDark.xaml

@ -82,6 +82,12 @@
<StaticResource x:Key="TextControlForegroundFocused" ResourceKey="SystemControlForegroundBaseHighBrush" /> <StaticResource x:Key="TextControlForegroundFocused" ResourceKey="SystemControlForegroundBaseHighBrush" />
<StaticResource x:Key="TextControlPlaceholderForegroundFocused" ResourceKey="SystemControlForegroundBaseMediumLowBrush" /> <StaticResource x:Key="TextControlPlaceholderForegroundFocused" ResourceKey="SystemControlForegroundBaseMediumLowBrush" />
<!-- Resources for AutoCompleteBox.xaml -->
<StaticResource x:Key="AutoCompleteBoxSuggestionsListBackground" ResourceKey="SystemControlTransientBackgroundBrush" />
<StaticResource x:Key="AutoCompleteBoxSuggestionsListBorderBrush" ResourceKey="SystemControlTransientBorderBrush" />
<StaticResource x:Key="AutoCompleteBoxLightDismissOverlayBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" />
<x:Double x:Key="AutoCompleteBoxIconFontSize">12</x:Double>
<!-- Resources for Checkbox.xaml --> <!-- Resources for Checkbox.xaml -->
<Thickness x:Key="CheckBoxBorderThemeThickness">1</Thickness> <Thickness x:Key="CheckBoxBorderThemeThickness">1</Thickness>
<Thickness x:Key="CheckBoxCheckedStrokeThickness">0</Thickness> <Thickness x:Key="CheckBoxCheckedStrokeThickness">0</Thickness>

6
src/Avalonia.Themes.Fluent/Accents/FluentControlResourcesLight.xaml

@ -82,6 +82,12 @@
<StaticResource x:Key="TextControlForegroundFocused" ResourceKey="SystemControlForegroundBaseHighBrush" /> <StaticResource x:Key="TextControlForegroundFocused" ResourceKey="SystemControlForegroundBaseHighBrush" />
<StaticResource x:Key="TextControlPlaceholderForegroundFocused" ResourceKey="SystemControlForegroundBaseMediumLowBrush" /> <StaticResource x:Key="TextControlPlaceholderForegroundFocused" ResourceKey="SystemControlForegroundBaseMediumLowBrush" />
<!-- Resources for AutoCompleteBox.xaml -->
<StaticResource x:Key="AutoCompleteBoxSuggestionsListBackground" ResourceKey="SystemControlTransientBackgroundBrush" />
<StaticResource x:Key="AutoCompleteBoxSuggestionsListBorderBrush" ResourceKey="SystemControlTransientBorderBrush" />
<StaticResource x:Key="AutoCompleteBoxLightDismissOverlayBackground" ResourceKey="SystemControlPageBackgroundMediumAltMediumBrush" />
<x:Double x:Key="AutoCompleteBoxIconFontSize">12</x:Double>
<!-- Resources for CheckBox.xaml --> <!-- Resources for CheckBox.xaml -->
<x:Double x:Key="CheckBoxBorderThemeThickness">1</x:Double> <x:Double x:Key="CheckBoxBorderThemeThickness">1</x:Double>
<x:Double x:Key="CheckBoxCheckedStrokeThickness">0</x:Double> <x:Double x:Key="CheckBoxCheckedStrokeThickness">0</x:Double>

68
src/Avalonia.Themes.Fluent/AutoCompleteBox.xaml

@ -1,37 +1,69 @@
<Styles xmlns="https://github.com/avaloniaui"> <Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Design.PreviewWith>
<Border Padding="20">
<AutoCompleteBox Width="200">
<AutoCompleteBox.Items>
Alabama
Alaska
Arizona
Arkansas
California
Colorado
Connecticut
Delaware
</AutoCompleteBox.Items>
</AutoCompleteBox>
</Border>
</Design.PreviewWith>
<Style Selector="AutoCompleteBox"> <Style Selector="AutoCompleteBox">
<Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}"/> <Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/> <Setter Property="Foreground" Value="{DynamicResource TextControlForeground}" />
<Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/> <Setter Property="Background" Value="{DynamicResource TextControlBackground}" />
<Setter Property="Padding" Value="4"/> <Setter Property="BorderBrush" Value="{DynamicResource TextControlBorderBrush}" />
<Setter Property="BorderThickness" Value="{DynamicResource TextControlBorderThemeThickness}" />
<Setter Property="FontFamily" Value="{DynamicResource ContentControlThemeFontFamily}" />
<Setter Property="FontSize" Value="{DynamicResource ControlContentThemeFontSize}" />
<Setter Property="Padding" Value="{DynamicResource TextControlThemePadding}" />
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate> <ControlTemplate>
<Panel> <Grid Name="PART_LayoutRoot">
<TextBox Name="PART_TextBox" <TextBox Name="PART_TextBox"
Background="{TemplateBinding Background}" Watermark="{TemplateBinding Watermark}"
BorderBrush="{TemplateBinding BorderBrush}" Width="{TemplateBinding Width}"
Foreground="{TemplateBinding Foreground}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
FontSize="{TemplateBinding FontSize}"
FontFamily="{TemplateBinding FontFamily}"
FontWeight="{TemplateBinding FontWeight}"
Padding="{TemplateBinding Padding}" Padding="{TemplateBinding Padding}"
Watermark="{TemplateBinding Watermark}" Margin="0"
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" /> DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" />
<Popup Name="PART_Popup" <Popup Name="PART_Popup"
WindowManagerAddShadowHint="False"
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}" MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
MaxHeight="{TemplateBinding MaxDropDownHeight}" MaxHeight="{TemplateBinding MaxDropDownHeight}"
PlacementTarget="{TemplateBinding}" StaysOpen="False"
StaysOpen="False"> PlacementTarget="{TemplateBinding}">
<Border BorderBrush="{DynamicResource ThemeBorderMidBrush}" <Border Name="PART_SuggestionsContainer"
BorderThickness="1"> Padding="{DynamicResource AutoCompleteListMargin}"
BorderThickness="{DynamicResource AutoCompleteListBorderThemeThickness}"
BorderBrush="{DynamicResource AutoSuggestBoxSuggestionsListBorderBrush}"
Background="{DynamicResource AutoCompleteBoxSuggestionsListBackground}"
CornerRadius="{DynamicResource OverlayCornerRadius}">
<ListBox Name="PART_SelectingItemsControl" <ListBox Name="PART_SelectingItemsControl"
BorderThickness="0" BorderThickness="0"
Background="{TemplateBinding Background}" Background="Transparent"
Foreground="{TemplateBinding Foreground}" Foreground="{DynamicResource AutoCompleteBoxSuggestionsListForeground}"
ItemTemplate="{TemplateBinding ItemTemplate}" ItemTemplate="{TemplateBinding ItemTemplate}"
ScrollViewer.HorizontalScrollBarVisibility="Auto" Margin="{DynamicResource AutoCompleteListPadding}" />
ScrollViewer.VerticalScrollBarVisibility="Auto" />
</Border> </Border>
</Popup> </Popup>
</Panel> </Grid>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
</Style> </Style>

38
src/Avalonia.Themes.Fluent/PopupRoot.xaml

@ -1,17 +1,21 @@
<Style xmlns="https://github.com/avaloniaui" Selector="PopupRoot"> <Styles xmlns="https://github.com/avaloniaui"
<Setter Property="Background" Value="{DynamicResource ThemeBackgroundBrush}"/> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Setter Property="Template"> <Style Selector="PopupRoot">
<ControlTemplate> <Setter Property="TransparencyLevelHint" Value="Transparent" />
<Panel> <Setter Property="Background" Value="{x:Null}" />
<Border Name="PART_TransparencyFallback" IsHitTestVisible="False" /> <Setter Property="Template">
<VisualLayerManager IsPopup="True"> <ControlTemplate>
<ContentPresenter Name="PART_ContentPresenter" <Panel>
Background="{TemplateBinding Background}" <Border Name="PART_TransparencyFallback" IsHitTestVisible="False" />
ContentTemplate="{TemplateBinding ContentTemplate}" <VisualLayerManager IsPopup="True">
Content="{TemplateBinding Content}" <ContentPresenter Name="PART_ContentPresenter"
Padding="{TemplateBinding Padding}"/> Background="{TemplateBinding Background}"
</VisualLayerManager> ContentTemplate="{TemplateBinding ContentTemplate}"
</Panel> Content="{TemplateBinding Content}"
</ControlTemplate> Padding="{TemplateBinding Padding}"/>
</Setter> </VisualLayerManager>
</Style> </Panel>
</ControlTemplate>
</Setter>
</Style>
</Styles>

4
src/Avalonia.X11/X11Window.cs

@ -1098,6 +1098,10 @@ namespace Avalonia.X11
public void SetTransparencyLevelHint(WindowTransparencyLevel transparencyLevel) => public void SetTransparencyLevelHint(WindowTransparencyLevel transparencyLevel) =>
_transparencyHelper.SetTransparencyRequest(transparencyLevel); _transparencyHelper.SetTransparencyRequest(transparencyLevel);
public void SetWindowManagerAddShadowHint(bool enabled)
{
}
public WindowTransparencyLevel TransparencyLevel => _transparencyHelper.CurrentLevel; public WindowTransparencyLevel TransparencyLevel => _transparencyHelper.CurrentLevel;
} }
} }

34
src/Windows/Avalonia.Win32/PopupImpl.cs

@ -7,6 +7,8 @@ namespace Avalonia.Win32
{ {
class PopupImpl : WindowImpl, IPopupImpl class PopupImpl : WindowImpl, IPopupImpl
{ {
private bool _dropShadowHint = true;
public override void Show() public override void Show()
{ {
UnmanagedMethods.ShowWindow(Handle.Handle, UnmanagedMethods.ShowWindowCommand.ShowNoActivate); UnmanagedMethods.ShowWindow(Handle.Handle, UnmanagedMethods.ShowWindowCommand.ShowNoActivate);
@ -36,11 +38,7 @@ namespace Avalonia.Win32
IntPtr.Zero, IntPtr.Zero,
IntPtr.Zero); IntPtr.Zero);
var classes = (int)UnmanagedMethods.GetClassLongPtr(result, (int)UnmanagedMethods.ClassLongIndex.GCL_STYLE); EnableBoxShadow(result, _dropShadowHint);
classes |= (int)UnmanagedMethods.ClassStyles.CS_DROPSHADOW;
UnmanagedMethods.SetClassLong(result, UnmanagedMethods.ClassLongIndex.GCL_STYLE, new IntPtr(classes));
return result; return result;
} }
@ -68,6 +66,32 @@ namespace Avalonia.Win32
//TODO: We ignore the scaling override for now //TODO: We ignore the scaling override for now
} }
private void EnableBoxShadow (IntPtr hwnd, bool enabled)
{
var classes = (int)UnmanagedMethods.GetClassLongPtr(hwnd, (int)UnmanagedMethods.ClassLongIndex.GCL_STYLE);
if (enabled)
{
classes |= (int)UnmanagedMethods.ClassStyles.CS_DROPSHADOW;
}
else
{
classes &= ~(int)UnmanagedMethods.ClassStyles.CS_DROPSHADOW;
}
UnmanagedMethods.SetClassLong(hwnd, UnmanagedMethods.ClassLongIndex.GCL_STYLE, new IntPtr(classes));
}
public void SetWindowManagerAddShadowHint(bool enabled)
{
_dropShadowHint = enabled;
if (Handle != null)
{
EnableBoxShadow(Handle.Handle, enabled);
}
}
public IPopupPositioner PopupPositioner { get; } public IPopupPositioner PopupPositioner { get; }
} }
} }

Loading…
Cancel
Save