mirror of
https://gitee.com/chinware/atomui.git
synced 2024-12-02 03:47:52 +08:00
Merge branch 'feature/dropdownbutton' into develop
This commit is contained in:
commit
de2bd782cb
@ -243,5 +243,6 @@
|
||||
</atom:DropdownButton>
|
||||
</WrapPanel>
|
||||
</showcase:ShowCaseItem>
|
||||
|
||||
</showcase:ShowCasePanel>
|
||||
</UserControl>
|
@ -78,9 +78,8 @@ internal abstract class BaseButtonTheme : BaseControlTheme
|
||||
HorizontalContentAlignment = HorizontalAlignment.Center,
|
||||
VerticalContentAlignment = VerticalAlignment.Center,
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Center
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
};
|
||||
|
||||
CreateTemplateParentBinding(extraContentPresenter, ContentPresenter.IsVisibleProperty, Button.RightExtraContentProperty,
|
||||
BindingMode.Default,
|
||||
ObjectConverters.IsNotNull);
|
||||
@ -88,7 +87,7 @@ internal abstract class BaseButtonTheme : BaseControlTheme
|
||||
|
||||
DockPanel.SetDock(extraContentPresenter, Dock.Right);
|
||||
|
||||
var rootLayout = new DockPanel()
|
||||
var rootLayout = new DockPanel
|
||||
{
|
||||
Name = RootLayoutPart,
|
||||
LastChildFill = true
|
||||
@ -145,7 +144,7 @@ internal abstract class BaseButtonTheme : BaseControlTheme
|
||||
}
|
||||
{
|
||||
var extraContentStyle = new Style(selector => selector.Nesting().Template().Name(RightExtraContentPart));
|
||||
extraContentStyle.Add(ContentPresenter.PaddingProperty, ButtonTokenResourceKey.ExtraContentMargin);
|
||||
extraContentStyle.Add(ContentPresenter.MarginProperty, ButtonTokenResourceKey.ExtraContentMargin);
|
||||
middleSizeStyle.Add(extraContentStyle);
|
||||
}
|
||||
Add(middleSizeStyle);
|
||||
@ -162,7 +161,7 @@ internal abstract class BaseButtonTheme : BaseControlTheme
|
||||
}
|
||||
{
|
||||
var extraContentStyle = new Style(selector => selector.Nesting().Template().Name(RightExtraContentPart));
|
||||
extraContentStyle.Add(ContentPresenter.PaddingProperty, ButtonTokenResourceKey.ExtraContentMarginSM);
|
||||
extraContentStyle.Add(ContentPresenter.MarginProperty, ButtonTokenResourceKey.ExtraContentMarginSM);
|
||||
smallSizeStyle.Add(extraContentStyle);
|
||||
}
|
||||
Add(smallSizeStyle);
|
||||
|
@ -503,12 +503,13 @@ public class Button : AvaloniaButton,
|
||||
normalFilledBrushKey = GlobalTokenResourceKey.ColorPrimary;
|
||||
selectedFilledBrushKey = GlobalTokenResourceKey.ColorPrimaryActive;
|
||||
activeFilledBrushKey = GlobalTokenResourceKey.ColorPrimaryHover;
|
||||
if (IsDanger) {
|
||||
normalFilledBrushKey = GlobalTokenResourceKey.ColorError;
|
||||
selectedFilledBrushKey = GlobalTokenResourceKey.ColorErrorActive;
|
||||
activeFilledBrushKey = GlobalTokenResourceKey.ColorErrorBorderHover;
|
||||
}
|
||||
}
|
||||
if (IsDanger) {
|
||||
normalFilledBrushKey = GlobalTokenResourceKey.ColorError;
|
||||
selectedFilledBrushKey = GlobalTokenResourceKey.ColorErrorActive;
|
||||
activeFilledBrushKey = GlobalTokenResourceKey.ColorErrorBorderHover;
|
||||
}
|
||||
|
||||
} else if (ButtonType == ButtonType.Text) {
|
||||
normalFilledBrushKey = ButtonTokenResourceKey.DefaultColor;
|
||||
selectedFilledBrushKey = ButtonTokenResourceKey.DefaultColor;
|
||||
|
@ -225,6 +225,21 @@ internal class ButtonToken : AbstractControlDesignToken
|
||||
/// </summary>
|
||||
public double ContentLineHeightSM { get; set; } = double.NaN;
|
||||
|
||||
/// <summary>
|
||||
/// 按钮右边一个额外的区域对右侧的小号外边距
|
||||
/// </summary>
|
||||
public Thickness ExtraContentMarginSM { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 按钮右边一个额外的区域对右侧的外边距
|
||||
/// </summary>
|
||||
public Thickness ExtraContentMargin { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 按钮右边一个额外的区域对右侧的大号外边距
|
||||
/// </summary>
|
||||
public Thickness ExtraContentMarginLG { get; set; }
|
||||
|
||||
#region 内部 Token 定义
|
||||
|
||||
/// <summary>
|
||||
|
@ -153,11 +153,27 @@ public class DropdownButton : Button
|
||||
};
|
||||
BindUtils.RelayBind(this, IconSizeProperty, _openIndicatorIcon, PathIcon.WidthProperty);
|
||||
BindUtils.RelayBind(this, IconSizeProperty, _openIndicatorIcon, PathIcon.HeightProperty);
|
||||
RightExtraContent = _openIndicatorIcon;
|
||||
|
||||
base.OnApplyTemplate(e);
|
||||
TokenResourceBinder.CreateGlobalTokenBinding(this, MarginToAnchorProperty, GlobalTokenResourceKey.MarginXXS);
|
||||
SetupFlyoutProperties();
|
||||
if (IsShowIndicator) {
|
||||
RightExtraContent = _openIndicatorIcon;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs e)
|
||||
{
|
||||
base.OnPropertyChanged(e);
|
||||
if (VisualRoot is not null) {
|
||||
if (e.Property == IsShowIndicatorProperty) {
|
||||
if (IsShowIndicator) {
|
||||
RightExtraContent = _openIndicatorIcon;
|
||||
} else {
|
||||
RightExtraContent = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnDetachedFromVisualTree(VisualTreeAttachmentEventArgs e)
|
||||
@ -394,9 +410,9 @@ public class DropdownButton : Button
|
||||
}
|
||||
|
||||
protected override void NotifyIconBrushCalculated(in TokenResourceKey normalFilledBrushKey,
|
||||
in TokenResourceKey selectedFilledBrushKey,
|
||||
in TokenResourceKey activeFilledBrushKey,
|
||||
in TokenResourceKey disabledFilledBrushKey)
|
||||
in TokenResourceKey selectedFilledBrushKey,
|
||||
in TokenResourceKey activeFilledBrushKey,
|
||||
in TokenResourceKey disabledFilledBrushKey)
|
||||
{
|
||||
if (_openIndicatorIcon is not null) {
|
||||
TokenResourceBinder.CreateGlobalTokenBinding(_openIndicatorIcon, PathIcon.NormalFilledBrushProperty,
|
||||
|
@ -123,6 +123,9 @@ namespace AtomUI.Theme.Styling
|
||||
public static readonly TokenResourceKey ContentLineHeight = new TokenResourceKey("Button.ContentLineHeight", "AtomUI.Token");
|
||||
public static readonly TokenResourceKey ContentLineHeightLG = new TokenResourceKey("Button.ContentLineHeightLG", "AtomUI.Token");
|
||||
public static readonly TokenResourceKey ContentLineHeightSM = new TokenResourceKey("Button.ContentLineHeightSM", "AtomUI.Token");
|
||||
public static readonly TokenResourceKey ExtraContentMarginSM = new TokenResourceKey("Button.ExtraContentMarginSM", "AtomUI.Token");
|
||||
public static readonly TokenResourceKey ExtraContentMargin = new TokenResourceKey("Button.ExtraContentMargin", "AtomUI.Token");
|
||||
public static readonly TokenResourceKey ExtraContentMarginLG = new TokenResourceKey("Button.ExtraContentMarginLG", "AtomUI.Token");
|
||||
public static readonly TokenResourceKey IconOnyPadding = new TokenResourceKey("Button.IconOnyPadding", "AtomUI.Token");
|
||||
public static readonly TokenResourceKey IconOnyPaddingLG = new TokenResourceKey("Button.IconOnyPaddingLG", "AtomUI.Token");
|
||||
public static readonly TokenResourceKey IconOnyPaddingSM = new TokenResourceKey("Button.IconOnyPaddingSM", "AtomUI.Token");
|
||||
|
Loading…
Reference in New Issue
Block a user