JT
1 year ago
25 changed files with 399 additions and 59 deletions
@ -0,0 +1,14 @@ |
|||||||
|
using Avalonia.Controls.Presenters; |
||||||
|
using Avalonia.Input; |
||||||
|
|
||||||
|
namespace StabilityMatrix.Avalonia.Controls.Scroll; |
||||||
|
|
||||||
|
public class BetterScrollContentPresenter : ScrollContentPresenter |
||||||
|
{ |
||||||
|
protected override void OnPointerWheelChanged(PointerWheelEventArgs e) |
||||||
|
{ |
||||||
|
if (e.KeyModifiers == KeyModifiers.Control) |
||||||
|
return; |
||||||
|
base.OnPointerWheelChanged(e); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,69 @@ |
|||||||
|
<ResourceDictionary xmlns="https://github.com/avaloniaui" |
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||||
|
xmlns:scroll="clr-namespace:StabilityMatrix.Avalonia.Controls.Scroll"> |
||||||
|
<Design.PreviewWith> |
||||||
|
<scroll:BetterScrollViewer Width="200" Height="200" |
||||||
|
HorizontalScrollBarVisibility="Auto"> |
||||||
|
<StackPanel Spacing="20" Width="210"> |
||||||
|
<TextBlock>Item 1</TextBlock> |
||||||
|
<TextBlock>Item 2</TextBlock> |
||||||
|
<TextBlock>Item 3</TextBlock> |
||||||
|
<TextBlock>Item 4</TextBlock> |
||||||
|
<TextBlock>Item 5</TextBlock> |
||||||
|
<TextBlock>Item 6</TextBlock> |
||||||
|
<TextBlock>Item 7</TextBlock> |
||||||
|
<TextBlock>Item 8</TextBlock> |
||||||
|
<TextBlock>Item 9</TextBlock> |
||||||
|
</StackPanel> |
||||||
|
</scroll:BetterScrollViewer> |
||||||
|
</Design.PreviewWith> |
||||||
|
|
||||||
|
<ControlTheme x:Key="{x:Type scroll:BetterScrollViewer}" TargetType="scroll:BetterScrollViewer"> |
||||||
|
<Setter Property="Background" Value="Transparent" /> |
||||||
|
<Setter Property="Template"> |
||||||
|
<ControlTemplate> |
||||||
|
<Grid ColumnDefinitions="*,Auto" RowDefinitions="*,Auto"> |
||||||
|
<scroll:BetterScrollContentPresenter x:Name="PART_ContentPresenter" |
||||||
|
Grid.Row="0" |
||||||
|
Grid.Column="0" |
||||||
|
Grid.RowSpan="2" |
||||||
|
Grid.ColumnSpan="2" |
||||||
|
Background="{TemplateBinding Background}" |
||||||
|
HorizontalSnapPointsType="{TemplateBinding HorizontalSnapPointsType}" |
||||||
|
VerticalSnapPointsType="{TemplateBinding VerticalSnapPointsType}" |
||||||
|
HorizontalSnapPointsAlignment="{TemplateBinding HorizontalSnapPointsAlignment}" |
||||||
|
VerticalSnapPointsAlignment="{TemplateBinding VerticalSnapPointsAlignment}" |
||||||
|
Padding="{TemplateBinding Padding}" |
||||||
|
ScrollViewer.IsScrollInertiaEnabled="{TemplateBinding IsScrollInertiaEnabled}"> |
||||||
|
<scroll:BetterScrollContentPresenter.GestureRecognizers> |
||||||
|
<ScrollGestureRecognizer |
||||||
|
CanHorizontallyScroll="{Binding CanHorizontallyScroll, ElementName=PART_ContentPresenter}" |
||||||
|
CanVerticallyScroll="{Binding CanVerticallyScroll, ElementName=PART_ContentPresenter}" |
||||||
|
IsScrollInertiaEnabled="{Binding (ScrollViewer.IsScrollInertiaEnabled), ElementName=PART_ContentPresenter}" /> |
||||||
|
</scroll:BetterScrollContentPresenter.GestureRecognizers> |
||||||
|
</scroll:BetterScrollContentPresenter> |
||||||
|
<ScrollBar Name="PART_HorizontalScrollBar" |
||||||
|
Orientation="Horizontal" |
||||||
|
Grid.Row="1" /> |
||||||
|
<ScrollBar Name="PART_VerticalScrollBar" |
||||||
|
Orientation="Vertical" |
||||||
|
Grid.Column="1" /> |
||||||
|
<Panel x:Name="PART_ScrollBarsSeparator" |
||||||
|
Grid.Row="1" |
||||||
|
Grid.Column="1" |
||||||
|
Background="{DynamicResource ScrollViewerScrollBarsSeparatorBackground}" |
||||||
|
Opacity="0"> |
||||||
|
<Panel.Transitions> |
||||||
|
<Transitions> |
||||||
|
<DoubleTransition Property="Opacity" Duration="0:0:0.1" /> |
||||||
|
</Transitions> |
||||||
|
</Panel.Transitions> |
||||||
|
</Panel> |
||||||
|
</Grid> |
||||||
|
</ControlTemplate> |
||||||
|
</Setter> |
||||||
|
<Style Selector="^[IsExpanded=true] /template/ Panel#PART_ScrollBarsSeparator"> |
||||||
|
<Setter Property="Opacity" Value="1" /> |
||||||
|
</Style> |
||||||
|
</ControlTheme> |
||||||
|
</ResourceDictionary> |
@ -0,0 +1,5 @@ |
|||||||
|
using Avalonia.Controls; |
||||||
|
|
||||||
|
namespace StabilityMatrix.Avalonia.Controls.Scroll; |
||||||
|
|
||||||
|
public class BetterScrollViewer : ScrollViewer { } |
@ -0,0 +1,10 @@ |
|||||||
|
namespace StabilityMatrix.Core.Models.Settings; |
||||||
|
|
||||||
|
public record struct Size(double Width, double Height) |
||||||
|
{ |
||||||
|
public static Size operator +(Size current, Size other) => |
||||||
|
new(current.Width + other.Width, current.Height + other.Height); |
||||||
|
|
||||||
|
public static Size operator -(Size current, Size other) => |
||||||
|
new(current.Width - other.Width, current.Height - other.Height); |
||||||
|
} |
Loading…
Reference in new issue