Browse Source
Clamp progressbar indicator width and height to never drop below zero when calculating size. (#17816)
Fixes #17393
pull/16805/head
Kieran Devlin
1 year ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
4 additions and
4 deletions
-
src/Avalonia.Controls/ProgressBar.cs
|
|
@ -378,17 +378,17 @@ namespace Avalonia.Controls |
|
|
// Indicator size calculation should consider the ProgressBar's Padding property setting
|
|
|
// Indicator size calculation should consider the ProgressBar's Padding property setting
|
|
|
if (Orientation == Orientation.Horizontal) |
|
|
if (Orientation == Orientation.Horizontal) |
|
|
{ |
|
|
{ |
|
|
_indicator.Width = (barSize.Width - _indicator.Margin.Left - _indicator.Margin.Right) * percent; |
|
|
var width = (barSize.Width - _indicator.Margin.Left - _indicator.Margin.Right) * percent; |
|
|
|
|
|
_indicator.Width = width > 0 ? width : 0; |
|
|
_indicator.Height = double.NaN; |
|
|
_indicator.Height = double.NaN; |
|
|
} |
|
|
} |
|
|
else |
|
|
else |
|
|
{ |
|
|
{ |
|
|
_indicator.Width = double.NaN; |
|
|
_indicator.Width = double.NaN; |
|
|
_indicator.Height = (barSize.Height - _indicator.Margin.Top - _indicator.Margin.Bottom) * |
|
|
var height = (barSize.Height - _indicator.Margin.Top - _indicator.Margin.Bottom) * percent; |
|
|
percent; |
|
|
_indicator.Height = height > 0 ? height : 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Percentage = percent * 100; |
|
|
Percentage = percent * 100; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|