Browse Source

Merge branch 'master' into fixes/3590-nested-resources

pull/3597/head
Dariusz Komosiński 6 years ago
committed by GitHub
parent
commit
43d69ebe7f
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 88
      src/Avalonia.Controls.DataGrid/DataGridColumnHeader.cs
  2. 3
      src/Avalonia.Controls/ContextMenu.cs
  3. 4
      src/Avalonia.Input/NavigationDirection.cs
  4. 1
      src/Avalonia.Themes.Default/ComboBox.xaml
  5. 6
      src/Avalonia.Themes.Default/MenuItem.xaml

88
src/Avalonia.Controls.DataGrid/DataGridColumnHeader.cs

@ -67,7 +67,7 @@ namespace Avalonia.Controls
static DataGridColumnHeader()
{
AreSeparatorsVisibleProperty.Changed.AddClassHandler<DataGridColumnHeader>((x,e) => x.OnAreSeparatorsVisibleChanged(e));
AreSeparatorsVisibleProperty.Changed.AddClassHandler<DataGridColumnHeader>((x, e) => x.OnAreSeparatorsVisibleChanged(e));
}
/// <summary>
@ -103,7 +103,7 @@ namespace Avalonia.Controls
{
get;
set;
}
}
internal DataGrid OwningGrid => OwningColumn?.OwningGrid;
internal int ColumnIndex
@ -116,19 +116,19 @@ namespace Avalonia.Controls
}
return OwningColumn.Index;
}
}
}
internal ListSortDirection? CurrentSortingState
{
get;
private set;
}
}
private bool IsMouseOver
{
get;
set;
}
}
private bool IsPressed
{
@ -158,14 +158,14 @@ namespace Avalonia.Controls
&& OwningGrid.DataConnection.AllowSort)
{
var sort = OwningColumn.GetSortDescription();
if(sort != null)
if (sort != null)
{
CurrentSortingState = sort.Descending ? ListSortDirection.Descending : ListSortDirection.Ascending;
}
}
PseudoClasses.Set(":sortascending",
PseudoClasses.Set(":sortascending",
CurrentSortingState.HasValue && CurrentSortingState.Value == ListSortDirection.Ascending);
PseudoClasses.Set(":sortdescending",
PseudoClasses.Set(":sortdescending",
CurrentSortingState.HasValue && CurrentSortingState.Value == ListSortDirection.Descending);
}
@ -195,7 +195,7 @@ namespace Avalonia.Controls
// completed a click without dragging, so we're sorting
InvokeProcessSort(keyModifiers);
handled = true;
}
}
internal void InvokeProcessSort(KeyModifiers keyModifiers)
{
@ -208,7 +208,7 @@ namespace Avalonia.Controls
{
Avalonia.Threading.Dispatcher.UIThread.Post(() => ProcessSort(keyModifiers));
}
}
}
//TODO GroupSorting
internal void ProcessSort(KeyModifiers keyModifiers)
@ -246,45 +246,49 @@ namespace Avalonia.Controls
owningGrid.DataConnection.SortDescriptions.Clear();
}
if (sort != null)
// if ctrl is held down, we only clear the sort directions
if (!ctrl)
{
newSort = sort.SwitchSortDirection();
// changing direction should not affect sort order, so we replace this column's
// sort description instead of just adding it to the end of the collection
int oldIndex = owningGrid.DataConnection.SortDescriptions.IndexOf(sort);
if (oldIndex >= 0)
if (sort != null)
{
owningGrid.DataConnection.SortDescriptions.Remove(sort);
owningGrid.DataConnection.SortDescriptions.Insert(oldIndex, newSort);
newSort = sort.SwitchSortDirection();
// changing direction should not affect sort order, so we replace this column's
// sort description instead of just adding it to the end of the collection
int oldIndex = owningGrid.DataConnection.SortDescriptions.IndexOf(sort);
if (oldIndex >= 0)
{
owningGrid.DataConnection.SortDescriptions.Remove(sort);
owningGrid.DataConnection.SortDescriptions.Insert(oldIndex, newSort);
}
else
{
owningGrid.DataConnection.SortDescriptions.Add(newSort);
}
}
else
{
string propertyName = OwningColumn.GetSortPropertyName();
// no-opt if we couldn't find a property to sort on
if (string.IsNullOrEmpty(propertyName))
{
return;
}
newSort = DataGridSortDescription.FromPath(propertyName, culture: collectionView.Culture);
owningGrid.DataConnection.SortDescriptions.Add(newSort);
}
}
else
{
string propertyName = OwningColumn.GetSortPropertyName();
// no-opt if we couldn't find a property to sort on
if (string.IsNullOrEmpty(propertyName))
{
return;
}
newSort = DataGridSortDescription.FromPath(propertyName, culture: collectionView.Culture);
owningGrid.DataConnection.SortDescriptions.Add(newSort);
}
}
}
}
}
private bool CanReorderColumn(DataGridColumn column)
{
return OwningGrid.CanUserReorderColumns
return OwningGrid.CanUserReorderColumns
&& !(column is DataGridFillerColumn)
&& (column.CanUserReorderInternal.HasValue && column.CanUserReorderInternal.Value || !column.CanUserReorderInternal.HasValue);
}
}
/// <summary>
/// Determines whether a column can be resized by dragging the border of its header. If star sizing
@ -302,7 +306,7 @@ namespace Avalonia.Controls
return false;
}
return column.ActualCanUserResize;
}
}
private static bool TrySetResizeColumn(DataGridColumn column)
{
@ -316,7 +320,7 @@ namespace Avalonia.Controls
return true;
}
return false;
}
}
//TODO DragDrop
@ -371,7 +375,7 @@ namespace Avalonia.Controls
{
if (_dragMode == DragMode.MouseDown)
{
OnMouseLeftButtonUp_Click(args.KeyModifiers, ref handled);
OnMouseLeftButtonUp_Click(args.KeyModifiers, ref handled);
}
else if (_dragMode == DragMode.Reorder)
{
@ -449,7 +453,7 @@ namespace Avalonia.Controls
OnMouseLeave();
ApplyState();
}
}
private void DataGridColumnHeader_PointerPressed(object sender, PointerPressedEventArgs e)
{
@ -577,7 +581,7 @@ namespace Avalonia.Controls
{
return OwningGrid.Columns.Count - 1;
}
}
}
/// <summary>
/// Returns true if the mouse is
@ -723,7 +727,7 @@ namespace Avalonia.Controls
Point targetPosition = new Point(0, 0);
if (targetColumn == null || targetColumn == OwningGrid.ColumnsInternal.FillerColumn || targetColumn.IsFrozen != OwningColumn.IsFrozen)
{
targetColumn =
targetColumn =
OwningGrid.ColumnsInternal.GetLastColumn(
isVisible: true,
isFrozen: OwningColumn.IsFrozen,
@ -741,7 +745,7 @@ namespace Avalonia.Controls
handled = true;
}
}
}
private void OnMouseMove_Resize(ref bool handled, Point mousePositionHeaders)
{
@ -764,7 +768,7 @@ namespace Avalonia.Controls
handled = true;
}
}
}
private void SetDragCursor(Point mousePosition)
{

3
src/Avalonia.Controls/ContextMenu.cs

@ -104,8 +104,7 @@ namespace Avalonia.Controls
{
PlacementMode = PlacementMode.Pointer,
PlacementTarget = control,
StaysOpen = false,
ObeyScreenEdges = true
StaysOpen = false
};
_popup.Opened += PopupOpened;

4
src/Avalonia.Input/NavigationDirection.cs

@ -100,12 +100,12 @@ namespace Avalonia.Input
/// </returns>
public static NavigationDirection? ToNavigationDirection(
this Key key,
InputModifiers modifiers = InputModifiers.None)
KeyModifiers modifiers = KeyModifiers.None)
{
switch (key)
{
case Key.Tab:
return (modifiers & InputModifiers.Shift) != 0 ?
return (modifiers & KeyModifiers.Shift) != 0 ?
NavigationDirection.Next : NavigationDirection.Previous;
case Key.Up:
return NavigationDirection.Up;

1
src/Avalonia.Themes.Default/ComboBox.xaml

@ -37,7 +37,6 @@
MinWidth="{Binding Bounds.Width, RelativeSource={RelativeSource TemplatedParent}}"
MaxHeight="{TemplateBinding MaxDropDownHeight}"
PlacementTarget="{TemplateBinding}"
ObeyScreenEdges="True"
StaysOpen="False">
<Border BorderBrush="{DynamicResource ThemeBorderMidBrush}"
BorderThickness="1">

6
src/Avalonia.Themes.Default/MenuItem.xaml

@ -45,8 +45,7 @@
<Popup Name="PART_Popup"
PlacementMode="Right"
StaysOpen="True"
IsOpen="{TemplateBinding IsSubMenuOpen, Mode=TwoWay}"
ObeyScreenEdges="True">
IsOpen="{TemplateBinding IsSubMenuOpen, Mode=TwoWay}">
<Border Background="{TemplateBinding Background}"
BorderBrush="{DynamicResource ThemeBorderMidBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
@ -95,8 +94,7 @@
</ContentPresenter>
<Popup Name="PART_Popup"
IsOpen="{TemplateBinding IsSubMenuOpen, Mode=TwoWay}"
StaysOpen="True"
ObeyScreenEdges="True">
StaysOpen="True">
<Border Background="{TemplateBinding Background}"
BorderBrush="{DynamicResource ThemeBorderMidBrush}"
BorderThickness="{TemplateBinding BorderThickness}">

Loading…
Cancel
Save