Browse Source

Merge branch 'master' into master

pull/2560/head
Artyom 7 years ago
committed by GitHub
parent
commit
d8199f9da2
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      native/Avalonia.Native/inc/avalonia-native.h
  2. 10
      native/Avalonia.Native/src/OSX/cursor.h
  3. 5
      native/Avalonia.Native/src/OSX/cursor.mm
  4. 10
      native/Avalonia.Native/src/OSX/window.mm
  5. 3
      src/Avalonia.Controls/Primitives/SelectingItemsControl.cs
  6. 1
      src/Avalonia.Input/Cursors.cs
  7. 4
      src/Avalonia.Input/TouchDevice.cs
  8. 10
      src/Avalonia.Themes.Default/Accents/BaseDark.xaml
  9. 10
      src/Avalonia.Themes.Default/Accents/BaseLight.xaml
  10. 6
      src/Avalonia.Themes.Default/NotificationCard.xaml
  11. 24
      src/Avalonia.X11/X11CursorFactory.cs
  12. 3
      src/Avalonia.X11/XLib.cs
  13. 3
      src/Gtk/Avalonia.Gtk3/CursorFactory.cs
  14. 1
      src/Gtk/Avalonia.Gtk3/GdkCursor.cs
  15. 2
      src/Markup/Avalonia.Markup.Xaml/XamlIl/xamlil.github
  16. 1
      src/Windows/Avalonia.Win32/CursorFactory.cs
  17. 35
      tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs

1
native/Avalonia.Native/inc/avalonia-native.h

@ -144,6 +144,7 @@ enum AvnStandardCursorType
CursorDragMove, CursorDragMove,
CursorDragCopy, CursorDragCopy,
CursorDragLink, CursorDragLink,
CursorNone
}; };
enum AvnWindowEdge enum AvnWindowEdge

10
native/Avalonia.Native/src/OSX/cursor.h

@ -11,18 +11,24 @@ class Cursor : public ComSingleObject<IAvnCursor, &IID_IAvnCursor>
{ {
private: private:
NSCursor * _native; NSCursor * _native;
bool _isHidden;
public: public:
FORWARD_IUNKNOWN() FORWARD_IUNKNOWN()
Cursor(NSCursor * cursor) Cursor(NSCursor * cursor, bool isHidden = false)
{ {
_native = cursor; _native = cursor;
_isHidden = isHidden;
} }
NSCursor* GetNative() NSCursor* GetNative()
{ {
return _native; return _native;
} }
bool IsHidden ()
{
return _isHidden;
}
}; };
extern std::map<AvnStandardCursorType, Cursor*> s_cursorMap; extern std::map<AvnStandardCursorType, Cursor*> s_cursorMap;

5
native/Avalonia.Native/src/OSX/cursor.mm

@ -21,6 +21,7 @@ class CursorFactory : public ComSingleObject<IAvnCursorFactory, &IID_IAvnCursorF
Cursor* resizeRightCursor = new Cursor([NSCursor resizeRightCursor]); Cursor* resizeRightCursor = new Cursor([NSCursor resizeRightCursor]);
Cursor* resizeWestEastCursor = new Cursor([NSCursor resizeLeftRightCursor]); Cursor* resizeWestEastCursor = new Cursor([NSCursor resizeLeftRightCursor]);
Cursor* operationNotAllowedCursor = new Cursor([NSCursor operationNotAllowedCursor]); Cursor* operationNotAllowedCursor = new Cursor([NSCursor operationNotAllowedCursor]);
Cursor* noCursor = new Cursor([NSCursor arrowCursor], true);
std::map<AvnStandardCursorType, Cursor*> s_cursorMap = std::map<AvnStandardCursorType, Cursor*> s_cursorMap =
{ {
@ -46,11 +47,13 @@ class CursorFactory : public ComSingleObject<IAvnCursorFactory, &IID_IAvnCursorF
{ CursorIbeam, IBeamCursor }, { CursorIbeam, IBeamCursor },
{ CursorLeftSide, resizeLeftCursor }, { CursorLeftSide, resizeLeftCursor },
{ CursorRightSide, resizeRightCursor }, { CursorRightSide, resizeRightCursor },
{ CursorNo, operationNotAllowedCursor } { CursorNo, operationNotAllowedCursor },
{ CursorNone, noCursor }
}; };
public: public:
FORWARD_IUNKNOWN() FORWARD_IUNKNOWN()
virtual HRESULT GetCursor (AvnStandardCursorType cursorType, IAvnCursor** retOut) override virtual HRESULT GetCursor (AvnStandardCursorType cursorType, IAvnCursor** retOut) override
{ {
*retOut = s_cursorMap[cursorType]; *retOut = s_cursorMap[cursorType];

10
native/Avalonia.Native/src/OSX/window.mm

@ -353,6 +353,16 @@ public:
Cursor* avnCursor = dynamic_cast<Cursor*>(cursor); Cursor* avnCursor = dynamic_cast<Cursor*>(cursor);
this->cursor = avnCursor->GetNative(); this->cursor = avnCursor->GetNative();
UpdateCursor(); UpdateCursor();
if(avnCursor->IsHidden())
{
[NSCursor hide];
}
else
{
[NSCursor unhide];
}
return S_OK; return S_OK;
} }
} }

3
src/Avalonia.Controls/Primitives/SelectingItemsControl.cs

@ -54,7 +54,8 @@ namespace Avalonia.Controls.Primitives
nameof(SelectedIndex), nameof(SelectedIndex),
o => o.SelectedIndex, o => o.SelectedIndex,
(o, v) => o.SelectedIndex = v, (o, v) => o.SelectedIndex = v,
unsetValue: -1); unsetValue: -1,
defaultBindingMode: BindingMode.TwoWay);
/// <summary> /// <summary>
/// Defines the <see cref="SelectedItem"/> property. /// Defines the <see cref="SelectedItem"/> property.

1
src/Avalonia.Input/Cursors.cs

@ -38,6 +38,7 @@ namespace Avalonia.Input
DragMove, DragMove,
DragCopy, DragCopy,
DragLink, DragLink,
None,
// Not available in GTK directly, see http://www.pixelbeat.org/programming/x_cursors/ // Not available in GTK directly, see http://www.pixelbeat.org/programming/x_cursors/
// We might enable them later, preferably, by loading pixmax direclty from theme with fallback image // We might enable them later, preferably, by loading pixmax direclty from theme with fallback image

4
src/Avalonia.Input/TouchDevice.cs

@ -42,7 +42,7 @@ namespace Avalonia.Input
var target = pointer.GetEffectiveCapture() ?? args.Root; var target = pointer.GetEffectiveCapture() ?? args.Root;
if (args.Type == RawPointerEventType.TouchBegin) if (args.Type == RawPointerEventType.TouchBegin)
{ {
var modifiers = GetModifiers(args.InputModifiers, pointer.IsPrimary); var modifiers = GetModifiers(args.InputModifiers, false);
target.RaiseEvent(new PointerPressedEventArgs(target, pointer, target.RaiseEvent(new PointerPressedEventArgs(target, pointer,
args.Root, args.Position, new PointerPointProperties(modifiers), args.Root, args.Position, new PointerPointProperties(modifiers),
modifiers)); modifiers));
@ -51,7 +51,7 @@ namespace Avalonia.Input
if (args.Type == RawPointerEventType.TouchEnd) if (args.Type == RawPointerEventType.TouchEnd)
{ {
_pointers.Remove(args.TouchPointId); _pointers.Remove(args.TouchPointId);
var modifiers = GetModifiers(args.InputModifiers, false); var modifiers = GetModifiers(args.InputModifiers, pointer.IsPrimary);
using (pointer) using (pointer)
{ {
target.RaiseEvent(new PointerReleasedEventArgs(target, pointer, target.RaiseEvent(new PointerReleasedEventArgs(target, pointer,

10
src/Avalonia.Themes.Default/Accents/BaseDark.xaml

@ -46,11 +46,11 @@
<SolidColorBrush x:Key="ErrorBrush" Color="{DynamicResource ErrorColor}"></SolidColorBrush> <SolidColorBrush x:Key="ErrorBrush" Color="{DynamicResource ErrorColor}"></SolidColorBrush>
<SolidColorBrush x:Key="ErrorLowBrush" Color="{DynamicResource ErrorLowColor}"></SolidColorBrush> <SolidColorBrush x:Key="ErrorLowBrush" Color="{DynamicResource ErrorLowColor}"></SolidColorBrush>
<SolidColorBrush x:Key="NotificationCardBackgroundBrush" Color="#444444"/> <SolidColorBrush x:Key="NotificationCardBackgroundBrush" Color="#444444" Opacity="0.75"/>
<SolidColorBrush x:Key="NotificationCardInformationBackgroundBrush" Color="Teal"/> <SolidColorBrush x:Key="NotificationCardInformationBackgroundBrush" Color="#007ACC" Opacity="0.75"/>
<SolidColorBrush x:Key="NotificationCardSuccessBackgroundBrush" Color="LimeGreen"/> <SolidColorBrush x:Key="NotificationCardSuccessBackgroundBrush" Color="#1F9E45" Opacity="0.75"/>
<SolidColorBrush x:Key="NotificationCardWarningBackgroundBrush" Color="Orange"/> <SolidColorBrush x:Key="NotificationCardWarningBackgroundBrush" Color="#FDB328" Opacity="0.75"/>
<SolidColorBrush x:Key="NotificationCardErrorBackgroundBrush" Color="OrangeRed"/> <SolidColorBrush x:Key="NotificationCardErrorBackgroundBrush" Color="#BD202C" Opacity="0.75"/>
<Thickness x:Key="ThemeBorderThickness">1,1,1,1</Thickness> <Thickness x:Key="ThemeBorderThickness">1,1,1,1</Thickness>
<sys:Double x:Key="ThemeDisabledOpacity">0.5</sys:Double> <sys:Double x:Key="ThemeDisabledOpacity">0.5</sys:Double>

10
src/Avalonia.Themes.Default/Accents/BaseLight.xaml

@ -46,11 +46,11 @@
<SolidColorBrush x:Key="ErrorBrush" Color="{DynamicResource ErrorColor}"></SolidColorBrush> <SolidColorBrush x:Key="ErrorBrush" Color="{DynamicResource ErrorColor}"></SolidColorBrush>
<SolidColorBrush x:Key="ErrorLowBrush" Color="{DynamicResource ErrorLowColor}"></SolidColorBrush> <SolidColorBrush x:Key="ErrorLowBrush" Color="{DynamicResource ErrorLowColor}"></SolidColorBrush>
<SolidColorBrush x:Key="NotificationCardBackgroundBrush" Color="#444444"/> <SolidColorBrush x:Key="NotificationCardBackgroundBrush" Color="#444444" Opacity="0.75"/>
<SolidColorBrush x:Key="NotificationCardInformationBackgroundBrush" Color="Teal"/> <SolidColorBrush x:Key="NotificationCardInformationBackgroundBrush" Color="#007ACC" Opacity="0.75"/>
<SolidColorBrush x:Key="NotificationCardSuccessBackgroundBrush" Color="LimeGreen"/> <SolidColorBrush x:Key="NotificationCardSuccessBackgroundBrush" Color="#1F9E45" Opacity="0.75"/>
<SolidColorBrush x:Key="NotificationCardWarningBackgroundBrush" Color="Orange"/> <SolidColorBrush x:Key="NotificationCardWarningBackgroundBrush" Color="#FDB328" Opacity="0.75"/>
<SolidColorBrush x:Key="NotificationCardErrorBackgroundBrush" Color="OrangeRed"/> <SolidColorBrush x:Key="NotificationCardErrorBackgroundBrush" Color="#BD202C" Opacity="0.75"/>
<Thickness x:Key="ThemeBorderThickness">1</Thickness> <Thickness x:Key="ThemeBorderThickness">1</Thickness>
<sys:Double x:Key="ThemeDisabledOpacity">0.5</sys:Double> <sys:Double x:Key="ThemeDisabledOpacity">0.5</sys:Double>

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

@ -13,7 +13,7 @@
BorderBrush="{TemplateBinding BorderBrush}" BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}" BorderThickness="{TemplateBinding BorderThickness}"
Margin="8,8,0,0"> Margin="8,8,0,0">
<ContentControl MinHeight="150" Content="{TemplateBinding Content}" /> <ContentControl Name="PART_Content" Content="{TemplateBinding Content}" />
</Border> </Border>
</LayoutTransformControl> </LayoutTransformControl>
</ControlTemplate> </ControlTemplate>
@ -40,6 +40,10 @@
</Style.Animations> </Style.Animations>
</Style> </Style>
<Style Selector="NotificationCard/template/ ContentControl#PART_Content">
<Setter Property="MinHeight" Value="150" />
</Style>
<Style Selector="NotificationCard[IsClosing=true] /template/ LayoutTransformControl#PART_LayoutTransformControl"> <Style Selector="NotificationCard[IsClosing=true] /template/ LayoutTransformControl#PART_LayoutTransformControl">
<Setter Property="RenderTransformOrigin" Value="50%,0%"/> <Setter Property="RenderTransformOrigin" Value="50%,0%"/>
<Style.Animations> <Style.Animations>

24
src/Avalonia.X11/X11CursorFactory.cs

@ -8,6 +8,8 @@ namespace Avalonia.X11
{ {
class X11CursorFactory : IStandardCursorFactory class X11CursorFactory : IStandardCursorFactory
{ {
private static IntPtr _nullCursor;
private readonly IntPtr _display; private readonly IntPtr _display;
private Dictionary<CursorFontShape, IntPtr> _cursors; private Dictionary<CursorFontShape, IntPtr> _cursors;
@ -42,16 +44,34 @@ namespace Avalonia.X11
public X11CursorFactory(IntPtr display) public X11CursorFactory(IntPtr display)
{ {
_display = display; _display = display;
_nullCursor = GetNullCursor(display);
_cursors = Enum.GetValues(typeof(CursorFontShape)).Cast<CursorFontShape>() _cursors = Enum.GetValues(typeof(CursorFontShape)).Cast<CursorFontShape>()
.ToDictionary(id => id, id => XLib.XCreateFontCursor(_display, id)); .ToDictionary(id => id, id => XLib.XCreateFontCursor(_display, id));
} }
public IPlatformHandle GetCursor(StandardCursorType cursorType) public IPlatformHandle GetCursor(StandardCursorType cursorType)
{ {
var handle = s_mapping.TryGetValue(cursorType, out var shape) IntPtr handle;
if (cursorType == StandardCursorType.None)
{
handle = _nullCursor;
}
else
{
handle = s_mapping.TryGetValue(cursorType, out var shape)
? _cursors[shape] ? _cursors[shape]
: _cursors[CursorFontShape.XC_top_left_arrow]; : _cursors[CursorFontShape.XC_top_left_arrow];
}
return new PlatformHandle(handle, "XCURSOR"); return new PlatformHandle(handle, "XCURSOR");
} }
private static IntPtr GetNullCursor(IntPtr display)
{
XColor color = new XColor();
byte[] data = new byte[] { 0 };
IntPtr window = XLib.XRootWindow(display, 0);
IntPtr pixmap = XLib.XCreateBitmapFromData(display, window, data, 1, 1);
return XLib.XCreatePixmapCursor(display, pixmap, pixmap, ref color, ref color, 0, 0);
}
} }
} }

3
src/Avalonia.X11/XLib.cs

@ -321,6 +321,9 @@ namespace Avalonia.X11
public static extern IntPtr XCreatePixmapCursor(IntPtr display, IntPtr source, IntPtr mask, public static extern IntPtr XCreatePixmapCursor(IntPtr display, IntPtr source, IntPtr mask,
ref XColor foreground_color, ref XColor background_color, int x_hot, int y_hot); ref XColor foreground_color, ref XColor background_color, int x_hot, int y_hot);
[DllImport(libX11)]
public static extern IntPtr XCreateBitmapFromData(IntPtr display, IntPtr drawable, byte[] data, int width, int height);
[DllImport(libX11)] [DllImport(libX11)]
public static extern IntPtr XCreatePixmapFromBitmapData(IntPtr display, IntPtr drawable, byte[] data, int width, public static extern IntPtr XCreatePixmapFromBitmapData(IntPtr display, IntPtr drawable, byte[] data, int width,
int height, IntPtr fg, IntPtr bg, int depth); int height, IntPtr fg, IntPtr bg, int depth);

3
src/Gtk/Avalonia.Gtk3/CursorFactory.cs

@ -12,6 +12,7 @@ namespace Avalonia.Gtk3
private static readonly Dictionary<StandardCursorType, object> CursorTypeMapping = new Dictionary private static readonly Dictionary<StandardCursorType, object> CursorTypeMapping = new Dictionary
<StandardCursorType, object> <StandardCursorType, object>
{ {
{StandardCursorType.None, CursorType.Blank},
{StandardCursorType.AppStarting, CursorType.Watch}, {StandardCursorType.AppStarting, CursorType.Watch},
{StandardCursorType.Arrow, CursorType.LeftPtr}, {StandardCursorType.Arrow, CursorType.LeftPtr},
{StandardCursorType.Cross, CursorType.Cross}, {StandardCursorType.Cross, CursorType.Cross},
@ -80,4 +81,4 @@ namespace Avalonia.Gtk3
return rv; return rv;
} }
} }
} }

1
src/Gtk/Avalonia.Gtk3/GdkCursor.cs

@ -2,6 +2,7 @@
{ {
enum GdkCursorType enum GdkCursorType
{ {
Blank = -2,
CursorIsPixmap = -1, CursorIsPixmap = -1,
XCursor = 0, XCursor = 0,
Arrow = 2, Arrow = 2,

2
src/Markup/Avalonia.Markup.Xaml/XamlIl/xamlil.github

@ -1 +1 @@
Subproject commit 1e3ffc315401f0b2eb96a0e79b25c2fc19a80d78 Subproject commit a73c5234831267b23160e01a9fbc83be633f69fc

1
src/Windows/Avalonia.Win32/CursorFactory.cs

@ -41,6 +41,7 @@ namespace Avalonia.Win32
private static readonly Dictionary<StandardCursorType, int> CursorTypeMapping = new Dictionary private static readonly Dictionary<StandardCursorType, int> CursorTypeMapping = new Dictionary
<StandardCursorType, int> <StandardCursorType, int>
{ {
{StandardCursorType.None, 0},
{StandardCursorType.AppStarting, 32650}, {StandardCursorType.AppStarting, 32650},
{StandardCursorType.Arrow, 32512}, {StandardCursorType.Arrow, 32512},
{StandardCursorType.Cross, 32515}, {StandardCursorType.Cross, 32515},

35
tests/Avalonia.Controls.UnitTests/Primitives/SelectingItemsControlTests.cs

@ -749,6 +749,40 @@ namespace Avalonia.Controls.UnitTests.Primitives
Assert.Equal("b", target.SelectedItem); Assert.Equal("b", target.SelectedItem);
} }
[Fact]
public void Mode_For_SelectedIndex_Is_TwoWay_By_Default()
{
var items = new[]
{
new Item(),
new Item(),
new Item(),
};
var vm = new MasterViewModel
{
Child = new ChildViewModel
{
Items = items,
SelectedIndex = 1,
}
};
var target = new SelectingItemsControl { DataContext = vm };
var itemsBinding = new Binding("Child.Items");
var selectedIndBinding = new Binding("Child.SelectedIndex");
target.Bind(SelectingItemsControl.ItemsProperty, itemsBinding);
target.Bind(SelectingItemsControl.SelectedIndexProperty, selectedIndBinding);
Assert.Equal(1, target.SelectedIndex);
target.SelectedIndex = 2;
Assert.Equal(2, target.SelectedIndex);
Assert.Equal(2, vm.Child.SelectedIndex);
}
private FuncControlTemplate Template() private FuncControlTemplate Template()
{ {
return new FuncControlTemplate<SelectingItemsControl>(control => return new FuncControlTemplate<SelectingItemsControl>(control =>
@ -785,6 +819,7 @@ namespace Avalonia.Controls.UnitTests.Primitives
{ {
public IList<Item> Items { get; set; } public IList<Item> Items { get; set; }
public Item SelectedItem { get; set; } public Item SelectedItem { get; set; }
public int SelectedIndex { get; set; }
} }
private class RootWithItems : TestRoot private class RootWithItems : TestRoot

Loading…
Cancel
Save