committed by
GitHub
20 changed files with 607 additions and 75 deletions
@ -1,28 +0,0 @@ |
|||
using System; |
|||
using Avalonia.Logging; |
|||
using Avalonia.Styling; |
|||
|
|||
namespace Avalonia.Controls |
|||
{ |
|||
[Obsolete("Use ComboBox")] |
|||
public class DropDown : ComboBox, IStyleable |
|||
{ |
|||
public DropDown() |
|||
{ |
|||
Logger.TryGet(LogEventLevel.Warning, LogArea.Control)?.Log(this, "DropDown is deprecated: Use ComboBox"); |
|||
} |
|||
|
|||
Type IStyleable.StyleKey => typeof(ComboBox); |
|||
} |
|||
|
|||
[Obsolete("Use ComboBoxItem")] |
|||
public class DropDownItem : ComboBoxItem, IStyleable |
|||
{ |
|||
public DropDownItem() |
|||
{ |
|||
Logger.TryGet(LogEventLevel.Warning, LogArea.Control)?.Log(this, "DropDownItem is deprecated: Use ComboBoxItem"); |
|||
} |
|||
|
|||
Type IStyleable.StyleKey => typeof(ComboBoxItem); |
|||
} |
|||
} |
|||
@ -0,0 +1,15 @@ |
|||
namespace Avalonia.Controls |
|||
{ |
|||
/// <summary>
|
|||
/// A button with an added drop-down chevron to visually indicate it has a flyout with additional actions.
|
|||
/// </summary>
|
|||
public class DropDownButton : Button |
|||
{ |
|||
/// <summary>
|
|||
/// Initializes a new instance of the <see cref="DropDownButton"/> class.
|
|||
/// </summary>
|
|||
public DropDownButton() |
|||
{ |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
using System; |
|||
using Avalonia.Interactivity; |
|||
|
|||
namespace Avalonia.Input |
|||
{ |
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
internal interface IClickableControl |
|||
{ |
|||
event EventHandler<RoutedEventArgs> Click; |
|||
void RaiseClick(); |
|||
/// <summary>
|
|||
/// Gets a value indicating whether this control and all its parents are enabled.
|
|||
/// </summary>
|
|||
bool IsEffectivelyEnabled { get; } |
|||
} |
|||
} |
|||
@ -1,6 +1,10 @@ |
|||
using System.Reflection; |
|||
using System.Runtime.CompilerServices; |
|||
using Avalonia.Metadata; |
|||
|
|||
[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Input")] |
|||
[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Input.TextInput")] |
|||
[assembly: XmlnsDefinition("https://github.com/avaloniaui", "Avalonia.Input.GestureRecognizers")] |
|||
|
|||
[assembly: InternalsVisibleTo("Avalonia.Controls, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c1bba1142285fe0419326fb25866ba62c47e6c2b5c1ab0c95b46413fad375471232cb81706932e1cef38781b9ebd39d5100401bacb651c6c5bbf59e571e81b3bc08d2a622004e08b1a6ece82a7e0b9857525c86d2b95fab4bc3dce148558d7f3ae61aa3a234086902aeface87d9dfdd32b9d2fe3c6dd4055b5ab4b104998bd87")] |
|||
[assembly: InternalsVisibleTo("Avalonia.Controls.UnitTests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100c1bba1142285fe0419326fb25866ba62c47e6c2b5c1ab0c95b46413fad375471232cb81706932e1cef38781b9ebd39d5100401bacb651c6c5bbf59e571e81b3bc08d2a622004e08b1a6ece82a7e0b9857525c86d2b95fab4bc3dce148558d7f3ae61aa3a234086902aeface87d9dfdd32b9d2fe3c6dd4055b5ab4b104998bd87")] |
|||
|
|||
@ -0,0 +1,67 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui"> |
|||
<Style Selector="DropDownButton"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeControlMidBrush}"/> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderLowBrush}"/> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource ThemeBorderThickness}"/> |
|||
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}"/> |
|||
<Setter Property="HorizontalContentAlignment" Value="Center"/> |
|||
<Setter Property="VerticalContentAlignment" Value="Center"/> |
|||
<Setter Property="Padding" Value="4"/> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate> |
|||
<Border Name="RootBorder" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
CornerRadius="{TemplateBinding CornerRadius}" |
|||
ClipToBounds="True"> |
|||
<Grid Name="InnerGrid"> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="*" /> |
|||
<ColumnDefinition Width="Auto" /> |
|||
</Grid.ColumnDefinitions> |
|||
|
|||
<ContentPresenter Name="PART_ContentPresenter" |
|||
Grid.Column="0" |
|||
Content="{TemplateBinding Content}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Padding="{TemplateBinding Padding}" |
|||
RecognizesAccessKey="True" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" /> |
|||
|
|||
<PathIcon Name="DropDownGlyph" |
|||
Grid.Column="1" |
|||
UseLayoutRounding="False" |
|||
IsHitTestVisible="False" |
|||
Height="12" |
|||
Width="12" |
|||
Margin="0,0,10,0" |
|||
HorizontalAlignment="Right" |
|||
VerticalAlignment="Center" /> |
|||
|
|||
</Grid> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<Style Selector="DropDownButton /template/ PathIcon#DropDownGlyph"> |
|||
<Setter Property="Foreground" Value="{DynamicResource ThemeForegroundBrush}" /> |
|||
<Setter Property="Data" Value="M1939 486L2029 576L1024 1581L19 576L109 486L1024 1401L1939 486Z" /> |
|||
</Style> |
|||
|
|||
<Style Selector="DropDownButton:pointerover /template/ Border#RootBorder"> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderMidBrush}"/> |
|||
</Style> |
|||
|
|||
<Style Selector="DropDownButton:pressed /template/ Border#RootBorder"> |
|||
<Setter Property="Background" Value="{DynamicResource ThemeControlHighBrush}"/> |
|||
</Style> |
|||
|
|||
<Style Selector="DropDownButton:disabled"> |
|||
<Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}"/> |
|||
</Style> |
|||
</Styles> |
|||
@ -0,0 +1,103 @@ |
|||
<Styles xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:CompileBindings="True"> |
|||
|
|||
<Design.PreviewWith> |
|||
<Border Padding="20"> |
|||
<StackPanel Spacing="20"> |
|||
<DropDownButton Content="Click Me!" /> |
|||
<DropDownButton Content="Disabled" IsEnabled="False" /> |
|||
</StackPanel> |
|||
</Border> |
|||
</Design.PreviewWith> |
|||
|
|||
<Styles.Resources> |
|||
<x:Double x:Key="DropDownButtonMinHeight">32</x:Double> |
|||
</Styles.Resources> |
|||
|
|||
<Style Selector="DropDownButton"> |
|||
<Setter Property="Background" Value="{DynamicResource ButtonBackground}" /> |
|||
<Setter Property="Foreground" Value="{DynamicResource ButtonForeground}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrush}" /> |
|||
<Setter Property="BorderThickness" Value="{DynamicResource ButtonBorderThemeThickness}" /> |
|||
<Setter Property="Padding" Value="{DynamicResource ButtonPadding}" /> |
|||
<Setter Property="MinHeight" Value="{DynamicResource DropDownButtonMinHeight}" /> |
|||
<Setter Property="HorizontalAlignment" Value="Left" /> |
|||
<Setter Property="VerticalAlignment" Value="Center" /> |
|||
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> |
|||
<Setter Property="VerticalContentAlignment" Value="Center" /> |
|||
<!--<Setter Property="UseSystemFocusVisuals" Value="{StaticResource UseSystemFocusVisuals}" /> |
|||
<Setter Property="FocusVisualMargin" Value="-3" />--> |
|||
<Setter Property="CornerRadius" Value="{DynamicResource ControlCornerRadius}" /> |
|||
<Setter Property="Template"> |
|||
<Setter.Value> |
|||
<ControlTemplate> |
|||
<Border x:Name="RootBorder" |
|||
Background="{TemplateBinding Background}" |
|||
BorderBrush="{TemplateBinding BorderBrush}" |
|||
BorderThickness="{TemplateBinding BorderThickness}" |
|||
CornerRadius="{TemplateBinding CornerRadius}" |
|||
ClipToBounds="True"> |
|||
<Grid x:Name="InnerGrid"> |
|||
<Grid.ColumnDefinitions> |
|||
<ColumnDefinition Width="*" /> |
|||
<ColumnDefinition Width="Auto" /> |
|||
</Grid.ColumnDefinitions> |
|||
|
|||
<ContentPresenter x:Name="PART_ContentPresenter" |
|||
Grid.Column="0" |
|||
Content="{TemplateBinding Content}" |
|||
ContentTemplate="{TemplateBinding ContentTemplate}" |
|||
Padding="{TemplateBinding Padding}" |
|||
RecognizesAccessKey="True" |
|||
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}" |
|||
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" /> |
|||
|
|||
<PathIcon x:Name="DropDownGlyph" |
|||
Grid.Column="1" |
|||
UseLayoutRounding="False" |
|||
IsHitTestVisible="False" |
|||
Height="12" |
|||
Width="12" |
|||
Margin="0,0,10,0" |
|||
HorizontalAlignment="Right" |
|||
VerticalAlignment="Center" /> |
|||
|
|||
</Grid> |
|||
</Border> |
|||
</ControlTemplate> |
|||
</Setter.Value> |
|||
</Setter> |
|||
</Style> |
|||
|
|||
<!-- Normal State --> |
|||
<Style Selector="DropDownButton /template/ PathIcon#DropDownGlyph"> |
|||
<Setter Property="Foreground" Value="{DynamicResource ComboBoxDropDownGlyphForeground}" /> |
|||
<Setter Property="Data" Value="M1939 486L2029 576L1024 1581L19 576L109 486L1024 1401L1939 486Z" /> |
|||
</Style> |
|||
|
|||
<!-- PointerOver State --> |
|||
<Style Selector="DropDownButton:pointerover /template/ Border#RootBorder"> |
|||
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundPointerOver}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushPointerOver}" /> |
|||
<Setter Property="TextElement.Foreground" Value="{DynamicResource ButtonForegroundPointerOver}" /> |
|||
</Style> |
|||
|
|||
<!-- Pressed State --> |
|||
<Style Selector="DropDownButton:pressed /template/ Border#RootBorder"> |
|||
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundPressed}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushPressed}" /> |
|||
<Setter Property="TextElement.Foreground" Value="{DynamicResource ButtonForegroundPressed}" /> |
|||
</Style> |
|||
|
|||
<!-- Disabled State --> |
|||
<Style Selector="DropDownButton:disabled /template/ Border#RootBorder"> |
|||
<Setter Property="Background" Value="{DynamicResource ButtonBackgroundDisabled}" /> |
|||
<Setter Property="BorderBrush" Value="{DynamicResource ButtonBorderBrushDisabled}" /> |
|||
<Setter Property="TextElement.Foreground" Value="{DynamicResource ButtonForegroundDisabled}" /> |
|||
</Style> |
|||
<Style Selector="DropDownButton:disabled /template/ PathIcon#DropDownGlyph"> |
|||
<Setter Property="Foreground" Value="{DynamicResource ButtonForegroundDisabled}" /> |
|||
</Style> |
|||
|
|||
</Styles> |
|||
Loading…
Reference in new issue