Browse Source

Merge branch 'master' into fixes/Warnings/CS0436

pull/11582/head
Max Katz 3 years ago
committed by GitHub
parent
commit
8dc0607673
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/Avalonia.Base/Input/TouchDevice.cs
  2. 40
      src/Avalonia.Controls.ColorPicker/ColorPalettes/FlatColorPalette.cs
  3. 18
      src/Avalonia.Controls.ColorPicker/ColorSpectrum/ColorSpectrum.cs
  4. 19
      src/Avalonia.Controls/TreeView.cs
  5. 1
      src/Avalonia.Diagnostics/Diagnostics/ViewModels/MainViewModel.cs

2
src/Avalonia.Base/Input/TouchDevice.cs

@ -51,7 +51,7 @@ namespace Avalonia.Input
pointer.Capture(hit);
}
var target = pointer.Captured ?? args.Root;
var target = pointer.Captured ?? args.InputHitTestResult ?? args.Root;
var gestureTarget = pointer.CapturedGestureRecognizer?.Target;
var updateKind = args.Type.ToUpdateKind();
var keyModifier = args.InputModifiers.ToKeyModifiers();

40
src/Avalonia.Controls.ColorPicker/ColorPalettes/FlatColorPalette.cs

@ -266,26 +266,26 @@ namespace Avalonia.Controls
MidnightBlue9 = 0xFF1C2833,
MidnightBlue10 = 0xFF17202A,
Pomegranate = Pomegranate3,
Alizarin = Alizarin3,
Amethyst = Amethyst3,
Wisteria = Wisteria3,
BelizeHole = BelizeHole3,
PeterRiver = PeterRiver3,
Turquoise = Turquoise3,
GreenSea = GreenSea3,
Nephritis = Nephritis3,
Emerald = Emerald3,
Sunflower = Sunflower3,
Orange = Orange3,
Carrot = Carrot3,
Pumpkin = Pumpkin3,
Clouds = Clouds3,
Silver = Silver3,
Concrete = Concrete3,
Asbestos = Asbestos3,
WetAsphalt = WetAsphalt3,
MidnightBlue = MidnightBlue3,
Pomegranate = Pomegranate6,
Alizarin = Alizarin6,
Amethyst = Amethyst6,
Wisteria = Wisteria6,
BelizeHole = BelizeHole6,
PeterRiver = PeterRiver6,
Turquoise = Turquoise6,
GreenSea = GreenSea6,
Nephritis = Nephritis6,
Emerald = Emerald6,
Sunflower = Sunflower6,
Orange = Orange6,
Carrot = Carrot6,
Pumpkin = Pumpkin6,
Clouds = Clouds6,
Silver = Silver6,
Concrete = Concrete6,
Asbestos = Asbestos6,
WetAsphalt = WetAsphalt6,
MidnightBlue = MidnightBlue6,
};
// See: https://htmlcolorcodes.com/assets/downloads/flat-design-colors/flat-design-color-chart.png

18
src/Avalonia.Controls.ColorPicker/ColorSpectrum/ColorSpectrum.cs

@ -45,7 +45,6 @@ namespace Avalonia.Controls.Primitives
private bool _updatingColor = false;
private bool _updatingHsvColor = false;
private bool _coercedInitialColor = false;
private bool _isPointerPressed = false;
private bool _shouldShowLargeSelection = false;
private List<Hsv> _hsvValues = new List<Hsv>();
@ -622,7 +621,7 @@ namespace Avalonia.Controls.Primitives
// that no color has been selected by the user. Note that #00000000 is different than
// #00FFFFFF (Transparent).
//
// In this situation, the first time the user clicks on the spectrum the third
// In this situation, whenever the user clicks on the spectrum, the third
// component and alpha component will remain zero. This is because the spectrum only
// controls two components at any given time.
//
@ -633,16 +632,19 @@ namespace Avalonia.Controls.Primitives
// though the desired value is simply full color.
//
// To work around this usability issue with an initial #00000000 color, the selected
// color is coerced (only the first time) into a color with maximum third component
// value and maximum alpha. This can only happen once and only if those two components
// are already zero.
// color is coerced into a color with maximum third component value and maximum alpha.
// This can only happen here in the spectrum if those two components are already zero.
//
// In the past this coercion was restricted to occur only one time. However, when
// ColorPicker controls are re-used or recycled #00000000 can be set multiple times.
// Each time needs this special logic for usability so now anytime the color is
// changed on the spectrum this logic will run.
//
// Also note this is NOT currently done for #00FFFFFF (Transparent) but based on
// further usability study that case may need to be handled here as well. Right now
// Transparent is treated as a normal color value with the alpha intentionally set
// to zero so the alpha slider must still be adjusted after the spectrum.
if (!_coercedInitialColor &&
IsLoaded)
if (IsLoaded)
{
bool isAlphaComponentZero = (alpha == 0.0);
bool isThirdComponentZero = false;
@ -691,8 +693,6 @@ namespace Avalonia.Controls.Primitives
newHsv.H = 360.0;
break;
}
_coercedInitialColor = true;
}
}

19
src/Avalonia.Controls/TreeView.cs

@ -84,6 +84,11 @@ namespace Avalonia.Controls
/// <summary>
/// Gets or sets a value indicating whether to automatically scroll to newly selected items.
/// </summary>
/// <remarks>
/// This property is of limited use with <see cref="TreeView"/> as it will only scroll
/// to realized items. To scroll to a non-expanded item, you need to ensure that its
/// ancestors are expanded.
/// </remarks>
public bool AutoScrollToSelectedItem
{
get => GetValue(AutoScrollToSelectedItemProperty);
@ -353,9 +358,13 @@ namespace Avalonia.Controls
SelectedItemsAdded(e.NewItems!.Cast<object>().ToArray());
if (AutoScrollToSelectedItem)
var selectedItem = SelectedItem;
if (AutoScrollToSelectedItem &&
selectedItem is not null &&
e.NewItems![0] == selectedItem)
{
var container = ContainerFromItem(e.NewItems![0]!);
var container = TreeContainerFromItem(selectedItem);
container?.BringIntoView();
}
@ -531,6 +540,12 @@ namespace Avalonia.Controls
// The IsSelected property is not set on the container: update the container
// selection based on the current selection as understood by this control.
MarkContainerSelected(container, SelectedItems.Contains(item));
// If the newly realized container is the selected container, scroll to it after layout.
if (AutoScrollToSelectedItem && SelectedItem == item)
{
Dispatcher.UIThread.Post(container.BringIntoView, DispatcherPriority.Loaded);
}
}
/// <inheritdoc/>

1
src/Avalonia.Diagnostics/Diagnostics/ViewModels/MainViewModel.cs

@ -44,6 +44,7 @@ namespace Avalonia.Diagnostics.ViewModels
SelectedTab = 0;
if (root is TopLevel topLevel)
{
_pointerOverRoot = topLevel;
_pointerOverSubscription = topLevel.GetObservable(TopLevel.PointerOverElementProperty)
.Subscribe(x => PointerOverElement = x);

Loading…
Cancel
Save