Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Avalonia to 11.2.1 #152

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
<Copyright>Copyright © Evgeny Gorbovoy 2021 - 2022</Copyright>
</PropertyGroup>
<PropertyGroup>
<AvaloniaVersion>11.0.9</AvaloniaVersion>
<AvaloniaVersion>11.2.1</AvaloniaVersion>
</PropertyGroup>
</Project>
12 changes: 9 additions & 3 deletions src/Consolonia.Core/Drawing/ConsoleBrush.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,16 @@
// Calculate the distance from the center
double dx = x - centerX;
double dy = y - centerY;
double distance = Math.Sqrt(dx * dx + dy * dy);

// Normalize the distance based on the brush radius
double normalizedDistance = distance / (Math.Min(width, height) * radialBrush.Radius);
// Calculate the distance based on separate X and Y radii
double distanceX = dx / (width * radialBrush.RadiusX.Scalar);
double distanceY = dy / (height * radialBrush.RadiusY.Scalar);
double distance = Math.Sqrt(distanceX * distanceX + distanceY * distanceY);

// Normalize the distance
double normalizedDistance = distance /
Math.Sqrt(radialBrush.RadiusX.Scalar * radialBrush.RadiusX.Scalar +
radialBrush.RadiusY.Scalar * radialBrush.RadiusY.Scalar);

// Clamp the normalized distance to [0, 1]
normalizedDistance = Math.Min(Math.Max(normalizedDistance, 0), 1);
Expand Down Expand Up @@ -185,7 +191,7 @@
break;
}

if (before == null && after == null)

Check notice on line 194 in src/Consolonia.Core/Drawing/ConsoleBrush.cs

View workflow job for this annotation

GitHub Actions / build

"[ConvertIfStatementToSwitchStatement] Convert 'if' statement into 'switch' statement" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Drawing/ConsoleBrush.cs(194,13)
throw new ArgumentException("no gradientstops defined");

if (before == null) return after.Color;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using Avalonia;
using Avalonia.Platform;

namespace Consolonia.Core.Drawing
Expand All @@ -20,6 +21,13 @@ public IRenderTarget CreateRenderTarget(IEnumerable<object> surfaces)
return new RenderTarget(surfaces);
}

public IDrawingContextLayerImpl CreateOffscreenRenderTarget(PixelSize pixelSize, double scaling)
{
throw new NotImplementedException();
}

public bool IsLost => false;

public IReadOnlyDictionary<Type, object> PublicFeatures => new Dictionary<Type, object>();
tomlm marked this conversation as resolved.
Show resolved Hide resolved
}
}
7 changes: 7 additions & 0 deletions src/Consolonia.Core/Drawing/ConsoloniaRenderInterface.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@

public IBitmapImpl LoadBitmap(string fileName)
{
using (FileStream stream = File.OpenRead(fileName))

Check notice on line 65 in src/Consolonia.Core/Drawing/ConsoloniaRenderInterface.cs

View workflow job for this annotation

GitHub Actions / build

"[ConvertToUsingDeclaration] Convert into 'using' declaration" on /home/runner/work/Consolonia/Consolonia/src/Consolonia.Core/Drawing/ConsoloniaRenderInterface.cs(65,13)
{
return new BitmapImpl(stream);
}
Expand Down Expand Up @@ -176,10 +176,17 @@
throw new NotImplementedException();
}

public IPlatformRenderInterfaceRegion CreateRegion()
{
throw new NotImplementedException();
}

public bool SupportsIndividualRoundRects => false;

public AlphaFormat DefaultAlphaFormat => throw new NotImplementedException();

public PixelFormat DefaultPixelFormat => throw new NotImplementedException();

public bool SupportsRegions => false;
}
}
26 changes: 23 additions & 3 deletions src/Consolonia.Core/Drawing/DrawingContextImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ public DrawingContextImpl(ConsoleWindow consoleWindow, PixelBuffer pixelBuffer)

private Rect CurrentClip => _clipStack.Peek();

public RenderOptions RenderOptions { get; set; }

public void Dispose()
{
}
Expand Down Expand Up @@ -215,7 +217,7 @@ public void DrawGlyphRun(IBrush foreground, IGlyphRunImpl glyphRun)
DrawStringInternal(foreground, text, glyphRun.GlyphTypeface);
}

public IDrawingContextLayerImpl CreateLayer(Size size)
public IDrawingContextLayerImpl CreateLayer(PixelSize size)
{
return new RenderTarget(_consoleWindow);
}
Expand All @@ -234,6 +236,11 @@ public void PushClip(RoundedRect clip)
PushClip(clip.Rect);
}

public void PushClip(IPlatformRenderInterfaceRegion region)
{
throw new NotImplementedException();
}

public void PopClip()
{
_clipStack.Pop();
Expand Down Expand Up @@ -286,14 +293,27 @@ public object GetFeature(Type t)
throw new NotImplementedException();
}

public RenderOptions RenderOptions { get; set; }

public Matrix Transform
{
get => _transform;
set => _transform = value * _postTransform;
}

public void DrawRegion(IBrush brush, IPen pen, IPlatformRenderInterfaceRegion region)
{
throw new NotImplementedException();
}

public void PushLayer(Rect bounds)
{
throw new NotImplementedException();
}

public void PopLayer()
{
throw new NotImplementedException();
}

/// <summary>
/// Draw a straight horizontal line or vertical line
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/Consolonia.Core/Drawing/Line.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ public bool TryGetSegment(double startDistance, double stopDistance, bool startO
public IGeometryImpl SourceGeometry { get; }
public Matrix Transform { get; }

public IGeometryImpl GetWidenedGeometry(IPen pen)
{
throw new NotImplementedException();
}

public static Line CreateMyLine(Point p1, Point p2)
{
(double x, double y) = p2 - p1;
Expand Down
5 changes: 5 additions & 0 deletions src/Consolonia.Core/Drawing/Rectangle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public bool TryGetSegment(double startDistance, double stopDistance, bool startO
throw new NotImplementedException();
}

public IGeometryImpl GetWidenedGeometry(IPen pen)
{
throw new NotImplementedException();
}

public Rect Bounds => _rect;
public double ContourLength => (_rect.Width + _rect.Height) * 2;
public IGeometryImpl SourceGeometry { get; }
Expand Down
2 changes: 1 addition & 1 deletion src/Consolonia.Core/Drawing/RenderTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void IDrawingContextLayerImpl.Blit(IDrawingContextImpl context)

bool IDrawingContextLayerImpl.CanBlit => true;

public IDrawingContextImpl CreateDrawingContext()
public IDrawingContextImpl CreateDrawingContext(bool useScaledDrawing)
tomlm marked this conversation as resolved.
Show resolved Hide resolved
{
return new DrawingContextImpl(_consoleWindow, _bufferBuffer);
}
Expand Down
26 changes: 17 additions & 9 deletions src/Consolonia.Core/Infrastructure/ConsoleWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public IPopupImpl CreatePopup()

public void SetTransparencyLevelHint(IReadOnlyList<WindowTransparencyLevel> transparencyLevels)
{
throw new NotImplementedException("Consider this");
// I think we can ignore this.
tomlm marked this conversation as resolved.
Show resolved Hide resolved
}

public void SetFrameThemeVariant(PlatformThemeVariant themeVariant)
Expand Down Expand Up @@ -134,7 +134,7 @@ public void Activate()

public void SetTopmost(bool value)
{
throw new NotImplementedException();
// todo
tomlm marked this conversation as resolved.
Show resolved Hide resolved
}

public double DesktopScaling => 1d;
Expand All @@ -152,7 +152,6 @@ public void SetTopmost(bool value)
public Size MaxAutoSizeHint { get; }

// ReSharper disable once UnassignedGetOnlyAutoProperty todo: what is this property
public IScreenImpl Screen => null!;

public void SetTitle(string title)
{
Expand Down Expand Up @@ -184,7 +183,7 @@ public void ShowTaskbarIcon(bool value)

public void CanResize(bool value)
{
throw new NotImplementedException();
// todo, enable/dsiable resizing of window
}

public void BeginMoveDrag(PointerPressedEventArgs e)
Expand All @@ -210,22 +209,22 @@ public void Move(PixelPoint point)

public void SetMinMaxSize(Size minSize, Size maxSize)
{
throw new NotImplementedException();
//throw new NotImplementedException();
}

public void SetExtendClientAreaToDecorationsHint(bool extendIntoClientAreaHint)
{
throw new NotImplementedException();
// we don't support this, we can ignore
}

public void SetExtendClientAreaChromeHints(ExtendClientAreaChromeHints hints)
{
throw new NotImplementedException();
// we don't support this, we can ignore
}

public void SetExtendClientAreaTitleBarHeightHint(double titleBarHeight)
{
throw new NotImplementedException();
// we don't support this, we can ignore
}

public WindowState WindowState { get; set; }
Expand All @@ -251,7 +250,16 @@ public object TryGetFeature(Type featureType)
if (featureType == typeof(ISystemNavigationManagerImpl))
return null;
if (featureType == typeof(ITextInputMethodImpl)) return null;
throw new NotImplementedException("Consider this");

Debug.WriteLine($"Someone asked for {featureType.Name}");

// this is a TRY function, so we return null if we don't support it.
return null;
}

public void GetWindowsZOrder(Span<Window> windows, Span<long> zOrder)
{
throw new NotImplementedException();
}

private void ConsoleOnMouseEvent(RawPointerEventType type, Point point, Vector? wheelDelta,
Expand Down
5 changes: 5 additions & 0 deletions src/Consolonia.Core/Infrastructure/ConsoloniaPlatform.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ public ITrayIconImpl CreateTrayIcon()
throw new NotImplementedException();
}

public ITopLevelImpl CreateEmbeddableTopLevel()
{
throw new NotImplementedException();
}

public void Initialize()
{
NotSupported += InternalIgnore;
Expand Down
7 changes: 7 additions & 0 deletions src/Consolonia.Core/Text/FontManagerImpl.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using Avalonia.Media;
Expand Down Expand Up @@ -40,6 +41,12 @@ public bool TryCreateGlyphTypeface(string familyName, FontStyle style, FontWeigh
return true;
}

public bool TryCreateGlyphTypeface(Stream stream, FontSimulations fontSimulations,
[NotNullWhen(true)] out IGlyphTypeface glyphTypeface)
{
throw new NotImplementedException();
}

public bool TryCreateGlyphTypeface(Stream stream, out IGlyphTypeface glyphTypeface)
{
throw new NotImplementedException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public GalleryDataGrid()
// ReSharper disable once MemberCanBeMadeStatic.Local
private void Dg1_LoadingRow(object sender, DataGridRowEventArgs e)
{
e.Row.Header = e.Row.GetIndex() + 1;
e.Row.Header = e.Row.Index + 1;
}

private void InitializeComponent()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ private void Radial_Click(object sender, Avalonia.Interactivity.RoutedEventArgs
{
Center = new RelativePoint(0.5, 0.5, RelativeUnit.Relative),
GradientOrigin = new RelativePoint(0.5, 0.5, RelativeUnit.Relative),
Radius = 0.5,
RadiusX = RelativeScalar.Parse("50%"),
RadiusY = RelativeScalar.Parse("50%"),
GradientStops = new GradientStops
{
new GradientStop { Color = Colors.Black, Offset = 0 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,14 @@ public ConsoloniaTextPresenter()
{
// we need to disable blinking caret, our terminal caret blinks itself once shown
var caretTickTimer = (DispatcherTimer)TickTimerField.GetValue(this);
caretTickTimer!.Interval =
TimeSpan.FromMilliseconds(int
.MaxValue); //see DispatcherTimer.Interval, since we can not disable it, setting it to the longest interval possible
caretTickTimer!.Tick += (_, _) => throw new NotImplementedException("How to disable timer completely?");
// TODO: consider that with avalonia 11.1.5 this is null;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we should investigate how to disable blinking in Avalonia 11.1.5 ?

if (caretTickTimer != null)
{
caretTickTimer!.Interval =
TimeSpan.FromMilliseconds(int
.MaxValue); //see DispatcherTimer.Interval, since we can not disable it, setting it to the longest interval possible
caretTickTimer!.Tick += (_, _) => throw new NotImplementedException("How to disable timer completely?");
}

CaretBrush = new ConsoleBrush(Colors.Black, PixelBackgroundMode.Transparent); // we want to draw own caret
}
Expand Down
Loading