Browse Source

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

pull/3597/head
Dariusz Komosiński 7 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() static DataGridColumnHeader()
{ {
AreSeparatorsVisibleProperty.Changed.AddClassHandler<DataGridColumnHeader>((x,e) => x.OnAreSeparatorsVisibleChanged(e)); AreSeparatorsVisibleProperty.Changed.AddClassHandler<DataGridColumnHeader>((x, e) => x.OnAreSeparatorsVisibleChanged(e));
} }
/// <summary> /// <summary>
@ -103,7 +103,7 @@ namespace Avalonia.Controls
{ {
get; get;
set; set;
} }
internal DataGrid OwningGrid => OwningColumn?.OwningGrid; internal DataGrid OwningGrid => OwningColumn?.OwningGrid;
internal int ColumnIndex internal int ColumnIndex
@ -116,19 +116,19 @@ namespace Avalonia.Controls
} }
return OwningColumn.Index; return OwningColumn.Index;
} }
} }
internal ListSortDirection? CurrentSortingState internal ListSortDirection? CurrentSortingState
{ {
get; get;
private set; private set;
} }
private bool IsMouseOver private bool IsMouseOver
{ {
get; get;
set; set;
} }
private bool IsPressed private bool IsPressed
{ {
@ -158,14 +158,14 @@ namespace Avalonia.Controls
&& OwningGrid.DataConnection.AllowSort) && OwningGrid.DataConnection.AllowSort)
{ {
var sort = OwningColumn.GetSortDescription(); var sort = OwningColumn.GetSortDescription();
if(sort != null) if (sort != null)
{ {
CurrentSortingState = sort.Descending ? ListSortDirection.Descending : ListSortDirection.Ascending; CurrentSortingState = sort.Descending ? ListSortDirection.Descending : ListSortDirection.Ascending;
} }
} }
PseudoClasses.Set(":sortascending", PseudoClasses.Set(":sortascending",
CurrentSortingState.HasValue && CurrentSortingState.Value == ListSortDirection.Ascending); CurrentSortingState.HasValue && CurrentSortingState.Value == ListSortDirection.Ascending);
PseudoClasses.Set(":sortdescending", PseudoClasses.Set(":sortdescending",
CurrentSortingState.HasValue && CurrentSortingState.Value == ListSortDirection.Descending); CurrentSortingState.HasValue && CurrentSortingState.Value == ListSortDirection.Descending);
} }
@ -195,7 +195,7 @@ namespace Avalonia.Controls
// completed a click without dragging, so we're sorting // completed a click without dragging, so we're sorting
InvokeProcessSort(keyModifiers); InvokeProcessSort(keyModifiers);
handled = true; handled = true;
} }
internal void InvokeProcessSort(KeyModifiers keyModifiers) internal void InvokeProcessSort(KeyModifiers keyModifiers)
{ {
@ -208,7 +208,7 @@ namespace Avalonia.Controls
{ {
Avalonia.Threading.Dispatcher.UIThread.Post(() => ProcessSort(keyModifiers)); Avalonia.Threading.Dispatcher.UIThread.Post(() => ProcessSort(keyModifiers));
} }
} }
//TODO GroupSorting //TODO GroupSorting
internal void ProcessSort(KeyModifiers keyModifiers) internal void ProcessSort(KeyModifiers keyModifiers)
@ -246,45 +246,49 @@ namespace Avalonia.Controls
owningGrid.DataConnection.SortDescriptions.Clear(); owningGrid.DataConnection.SortDescriptions.Clear();
} }
if (sort != null) // if ctrl is held down, we only clear the sort directions
if (!ctrl)
{ {
newSort = sort.SwitchSortDirection(); if (sort != null)
// 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); newSort = sort.SwitchSortDirection();
owningGrid.DataConnection.SortDescriptions.Insert(oldIndex, newSort);
// 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 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); 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) private bool CanReorderColumn(DataGridColumn column)
{ {
return OwningGrid.CanUserReorderColumns return OwningGrid.CanUserReorderColumns
&& !(column is DataGridFillerColumn) && !(column is DataGridFillerColumn)
&& (column.CanUserReorderInternal.HasValue && column.CanUserReorderInternal.Value || !column.CanUserReorderInternal.HasValue); && (column.CanUserReorderInternal.HasValue && column.CanUserReorderInternal.Value || !column.CanUserReorderInternal.HasValue);
} }
/// <summary> /// <summary>
/// Determines whether a column can be resized by dragging the border of its header. If star sizing /// 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 false;
} }
return column.ActualCanUserResize; return column.ActualCanUserResize;
} }
private static bool TrySetResizeColumn(DataGridColumn column) private static bool TrySetResizeColumn(DataGridColumn column)
{ {
@ -316,7 +320,7 @@ namespace Avalonia.Controls
return true; return true;
} }
return false; return false;
} }
//TODO DragDrop //TODO DragDrop
@ -371,7 +375,7 @@ namespace Avalonia.Controls
{ {
if (_dragMode == DragMode.MouseDown) if (_dragMode == DragMode.MouseDown)
{ {
OnMouseLeftButtonUp_Click(args.KeyModifiers, ref handled); OnMouseLeftButtonUp_Click(args.KeyModifiers, ref handled);
} }
else if (_dragMode == DragMode.Reorder) else if (_dragMode == DragMode.Reorder)
{ {
@ -449,7 +453,7 @@ namespace Avalonia.Controls
OnMouseLeave(); OnMouseLeave();
ApplyState(); ApplyState();
} }
private void DataGridColumnHeader_PointerPressed(object sender, PointerPressedEventArgs e) private void DataGridColumnHeader_PointerPressed(object sender, PointerPressedEventArgs e)
{ {
@ -577,7 +581,7 @@ namespace Avalonia.Controls
{ {
return OwningGrid.Columns.Count - 1; return OwningGrid.Columns.Count - 1;
} }
} }
/// <summary> /// <summary>
/// Returns true if the mouse is /// Returns true if the mouse is
@ -723,7 +727,7 @@ namespace Avalonia.Controls
Point targetPosition = new Point(0, 0); Point targetPosition = new Point(0, 0);
if (targetColumn == null || targetColumn == OwningGrid.ColumnsInternal.FillerColumn || targetColumn.IsFrozen != OwningColumn.IsFrozen) if (targetColumn == null || targetColumn == OwningGrid.ColumnsInternal.FillerColumn || targetColumn.IsFrozen != OwningColumn.IsFrozen)
{ {
targetColumn = targetColumn =
OwningGrid.ColumnsInternal.GetLastColumn( OwningGrid.ColumnsInternal.GetLastColumn(
isVisible: true, isVisible: true,
isFrozen: OwningColumn.IsFrozen, isFrozen: OwningColumn.IsFrozen,
@ -741,7 +745,7 @@ namespace Avalonia.Controls
handled = true; handled = true;
} }
} }
private void OnMouseMove_Resize(ref bool handled, Point mousePositionHeaders) private void OnMouseMove_Resize(ref bool handled, Point mousePositionHeaders)
{ {
@ -764,7 +768,7 @@ namespace Avalonia.Controls
handled = true; handled = true;
} }
} }
private void SetDragCursor(Point mousePosition) private void SetDragCursor(Point mousePosition)
{ {

3
src/Avalonia.Controls/ContextMenu.cs

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

4
src/Avalonia.Input/NavigationDirection.cs

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

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

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

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

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

Loading…
Cancel
Save