From c29a21afc2eee3fbdb04cab379360f7ce08fd401 Mon Sep 17 00:00:00 2001 From: Dan Walmsley Date: Sun, 10 Jun 2018 11:39:52 +0100 Subject: [PATCH 1/4] ensure tooltips fit inside screen edges. --- src/Avalonia.Controls/ToolTip.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Avalonia.Controls/ToolTip.cs b/src/Avalonia.Controls/ToolTip.cs index 464e4188d2..10e964d014 100644 --- a/src/Avalonia.Controls/ToolTip.cs +++ b/src/Avalonia.Controls/ToolTip.cs @@ -234,11 +234,12 @@ namespace Avalonia.Controls { Close(); - _popup = new PopupRoot { Content = this }; + _popup = new PopupRoot { Content = this, }; ((ISetLogicalParent)_popup).SetParent(control); _popup.Position = Popup.GetPosition(control, GetPlacement(control), _popup, GetHorizontalOffset(control), GetVerticalOffset(control)); _popup.Show(); + _popup.SnapInsideScreenEdges(); } private void Close() From 1a4fd00f2b77d0a648b00ca680227bb164c53ddd Mon Sep 17 00:00:00 2001 From: Ivan Garcia Date: Tue, 12 Jun 2018 17:25:43 -0400 Subject: [PATCH 2/4] Fix trailing newlines in textboxes when using NetCore/Skia Fixes issue where if a textbox's text ended with a newline character the additional line at the end would not render. Did this by, in these cases, adding an additional blank AvaloniaFormattedTextLine. This also fixes an issue where line widths were being measured incorrectly because the Substring() call used for that measurement was using line.Start before it was initialized for the current line. --- src/Skia/Avalonia.Skia/FormattedTextImpl.cs | 31 +++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/Skia/Avalonia.Skia/FormattedTextImpl.cs b/src/Skia/Avalonia.Skia/FormattedTextImpl.cs index 00f0a48a7b..13dcd9669d 100644 --- a/src/Skia/Avalonia.Skia/FormattedTextImpl.cs +++ b/src/Skia/Avalonia.Skia/FormattedTextImpl.cs @@ -560,13 +560,11 @@ namespace Avalonia.Skia } measured = LineBreak(Text, curOff, length, _paint, constraint, out trailingnumber); - AvaloniaFormattedTextLine line = new AvaloniaFormattedTextLine(); line.TextLength = measured; - + line.Start = curOff; subString = Text.Substring(line.Start, line.TextLength); lineWidth = _paint.MeasureText(subString); - line.Start = curOff; line.Length = measured - trailingnumber; line.Width = lineWidth; line.Height = _lineHeight; @@ -575,10 +573,33 @@ namespace Avalonia.Skia _skiaLines.Add(line); curY += _lineHeight; - curY += mLeading; - curOff += measured; + + //if this is the last line and there are trailing newline characters then + //insert a additional line + if (curOff >= length) + { + var subStringMinusNewlines = subString.TrimEnd('\n', '\r'); + var lengthDiff = subString.Length - subStringMinusNewlines.Length; + if (lengthDiff > 0) + { + AvaloniaFormattedTextLine lastLine = new AvaloniaFormattedTextLine(); + lastLine.TextLength = lengthDiff; + lastLine.Start = curOff - lengthDiff; + var lastLineSubString = Text.Substring(line.Start, line.TextLength); + var lastLineWidth = _paint.MeasureText(lastLineSubString); + lastLine.Length = 0; + lastLine.Width = lastLineWidth; + lastLine.Height = _lineHeight; + lastLine.Top = curY; + + _skiaLines.Add(lastLine); + + curY += _lineHeight; + curY += mLeading; + } + } } // Now convert to Avalonia data formats From 3d092b9fcf31bdb7e7132565b0bd9b2088018149 Mon Sep 17 00:00:00 2001 From: sdoroff Date: Tue, 12 Jun 2018 23:41:13 -0400 Subject: [PATCH 3/4] Added a Scroll event to ScrollBar The event is fired when the ScrollBar's value is changed through interaction with the ScrollBar's Track --- src/Avalonia.Controls/Primitives/ScrollBar.cs | 37 +++++++++++++ .../Primitives/ScrollEventType.cs | 53 +++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 src/Avalonia.Controls/Primitives/ScrollEventType.cs diff --git a/src/Avalonia.Controls/Primitives/ScrollBar.cs b/src/Avalonia.Controls/Primitives/ScrollBar.cs index 0057b15150..3ddcb06303 100644 --- a/src/Avalonia.Controls/Primitives/ScrollBar.cs +++ b/src/Avalonia.Controls/Primitives/ScrollBar.cs @@ -6,9 +6,21 @@ using System.Reactive; using System.Reactive.Linq; using Avalonia.Data; using Avalonia.Interactivity; +using Avalonia.Input; namespace Avalonia.Controls.Primitives { + public class ScrollEventArgs : EventArgs + { + public ScrollEventArgs(ScrollEventType eventType, double newValue) + { + ScrollEventType = eventType; + NewValue = newValue; + } + public double NewValue { get; private set; } + public ScrollEventType ScrollEventType { get; private set; } + } + /// /// A scrollbar control. /// @@ -44,6 +56,9 @@ namespace Avalonia.Controls.Primitives { PseudoClass(OrientationProperty, o => o == Orientation.Vertical, ":vertical"); PseudoClass(OrientationProperty, o => o == Orientation.Horizontal, ":horizontal"); + + Thumb.DragDeltaEvent.AddClassHandler(o => o.OnThumbDragDelta, RoutingStrategies.Bubble); + Thumb.DragCompletedEvent.AddClassHandler(o => o.OnThumbDragComplete, RoutingStrategies.Bubble); } /// @@ -88,6 +103,8 @@ namespace Avalonia.Controls.Primitives set { SetValue(OrientationProperty, value); } } + public event EventHandler Scroll; + /// /// Calculates whether the scrollbar should be visible. /// @@ -140,6 +157,8 @@ namespace Avalonia.Controls.Primitives _pageUpButton = e.NameScope.Find