feat: update light theme.

This commit is contained in:
rabbitism
2023-06-21 20:12:43 +08:00
parent 105c996af4
commit c4f49765b8
7 changed files with 85 additions and 25 deletions

View File

@@ -13,8 +13,8 @@ namespace Ursa.Controls;
/// CurrentPage starts from 1.
/// Pagination only stores an approximate index internally.
/// </summary>
[TemplatePart(PART_PreviousButton, typeof(Button))]
[TemplatePart(PART_NextButton, typeof(Button))]
[TemplatePart(PART_PreviousButton, typeof(PaginationButton))]
[TemplatePart(PART_NextButton, typeof(PaginationButton))]
[TemplatePart(PART_ButtonPanel, typeof(StackPanel))]
[TemplatePart(PART_SizeChangerComboBox, typeof(ComboBox))]
public class Pagination: TemplatedControl
@@ -23,8 +23,8 @@ public class Pagination: TemplatedControl
public const string PART_NextButton = "PART_NextButton";
public const string PART_ButtonPanel = "PART_ButtonPanel";
public const string PART_SizeChangerComboBox = "PART_SizeChangerComboBox";
private Button? _previousButton;
private Button? _nextButton;
private PaginationButton? _previousButton;
private PaginationButton? _nextButton;
private StackPanel? _buttonPanel;
private readonly PaginationButton[] _buttons = new PaginationButton[7];
private ComboBox? _sizeChangerComboBox;
@@ -34,8 +34,8 @@ public class Pagination: TemplatedControl
base.OnApplyTemplate(e);
if (_previousButton != null) _previousButton.Click -= OnButtonClick;
if (_nextButton != null) _nextButton.Click -= OnButtonClick;
_previousButton = e.NameScope.Find<Button>(PART_PreviousButton);
_nextButton = e.NameScope.Find<Button>(PART_NextButton);
_previousButton = e.NameScope.Find<PaginationButton>(PART_PreviousButton);
_nextButton = e.NameScope.Find<PaginationButton>(PART_NextButton);
_buttonPanel = e.NameScope.Find<StackPanel>(PART_ButtonPanel);
_sizeChangerComboBox = e.NameScope.Find<ComboBox>(PART_SizeChangerComboBox);
if (_previousButton != null) _previousButton.Click += OnButtonClick;
@@ -110,6 +110,24 @@ public class Pagination: TemplatedControl
set => SetValue(PageButtonThemeProperty, value);
}
public static readonly StyledProperty<bool> ShowPageSizeSelectorProperty = AvaloniaProperty.Register<Pagination, bool>(
nameof(ShowPageSizeSelector));
public bool ShowPageSizeSelector
{
get => GetValue(ShowPageSizeSelectorProperty);
set => SetValue(ShowPageSizeSelectorProperty, value);
}
public static readonly StyledProperty<bool> ShowQuickJumpProperty = AvaloniaProperty.Register<Pagination, bool>(
nameof(ShowQuickJump));
public bool ShowQuickJump
{
get => GetValue(ShowQuickJumpProperty);
set => SetValue(ShowQuickJumpProperty, value);
}
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
{
base.OnPropertyChanged(change);
@@ -156,11 +174,11 @@ public class Pagination: TemplatedControl
{
if (sender is PaginationButton pageButton)
{
if (pageButton.IsLeftForward)
if (pageButton.IsFastForward)
{
AddCurrentPage(-5);
}
else if (pageButton.IsRightForward)
else if (pageButton.IsFastBackward)
{
AddCurrentPage(5);
}
@@ -258,5 +276,7 @@ public class Pagination: TemplatedControl
}
CurrentPage = currentPage;
if (_previousButton != null) _previousButton.IsEnabled = CurrentPage > 1;
if( _nextButton!=null) _nextButton.IsEnabled = CurrentPage < PageCount;
}
}

View File

@@ -7,7 +7,7 @@ using Avalonia.Styling;
namespace Ursa.Controls;
[PseudoClasses(PC_Left, PC_Right, PC_Selected)]
public class PaginationButton: Button, IStyleable
public class PaginationButton: Button
{
public const string PC_Left = ":left";
public const string PC_Right = ":right";
@@ -21,16 +21,16 @@ public class PaginationButton: Button, IStyleable
get => GetValue(PageProperty);
set => SetValue(PageProperty, value);
}
public bool IsLeftForward { get; private set; }
public bool IsRightForward { get; private set; }
internal bool IsFastForward { get; private set; }
internal bool IsFastBackward { get; private set; }
internal void SetStatus(int page, bool isSelected, bool isLeft, bool isRight)
{
PseudoClasses.Set(PC_Selected, isSelected);
PseudoClasses.Set(PC_Left, isLeft);
PseudoClasses.Set(PC_Right, isRight);
IsLeftForward = isLeft;
IsRightForward = isRight;
IsFastForward = isLeft;
IsFastBackward = isRight;
Page = page;
}