These are chat archives for AvaloniaUI/Avalonia

11th
Jan 2019
Eliot Jones
@EliotJones
Jan 11 06:21
Thanks, I think also in this example you might get a stackoverflow if it updated the textbox (presuming the call to raiseandsetifchanged would cause the value to become "text$" then a new set event would be called with "text£" to become "text££" and so on). It's not actually something I need to do atm and everything else about it seems to work fine so I'll carry on
Basically textbox ignores text change events when it's updating text itself
I guess it should be reworked to support your scenario
Eliot Jones
@EliotJones
Jan 11 06:39
thanks, that makes sense, I don't think it's too important for now plus the risk of getting stackoverflows if I understand the routing of the events correctly, but I might take a look at the code tonight and see if I can make a PR for it
Nikita Tsukanov
@kekekeks
Jan 11 06:41
You can delay your update via Dispatcher.UIThread.InvokeAsync()
Eliot Jones
@EliotJones
Jan 11 06:43
that worked, thanks :)
Ivan Kochurkin
@KvanTTT
Jan 11 07:42
@jeffreye when the following version of AvaloniaEdit with working SearchPanel will be released on NuGet?
@danwalmsley we should use our nigtly feed for AvaloniaEdit, I think
Jeffrey Ye
@jeffreye
Jan 11 08:18
@danwalmsley did you confirm if search panel is working on your end?
danwalmsley
@danwalmsley
Jan 11 09:23
@jeffreye I did a clean and built again, and seems to work :)
Luis von der Eltz
@toytonics
Jan 11 09:24
Is there style inheritance in avalonia?
Nikita Tsukanov
@kekekeks
Jan 11 09:24
Controls can have multiple styles applied to them
Luis von der Eltz
@toytonics
Jan 11 09:30
But it's only applying the style for the dervied class for me, not using the base class style
Luis von der Eltz
@toytonics
Jan 11 09:38
Is there some special selector syntax needed for this?
Or what is the equivalent to BasedOn?
Steven Kirk
@grokys
Jan 11 09:39
@toytonics if you want the style to apply to base classes use the is selector: http://avaloniaui.net/docs/styles/selectors
Luis von der Eltz
@toytonics
Jan 11 09:40
Oh that makes sense thanks
Benedikt Schroeder
@Gillibald
Jan 11 12:19
@grokys I would like to take care of the inlines PR is it okay for you if I create a new PR with merged in skia text layout?
Luis von der Eltz
@toytonics
Jan 11 13:05
Is there a way to prevent the button from performing a click when pressing Space or Enter? It's kinda annoying
Nikita Tsukanov
@kekekeks
Jan 11 13:09
People with disabilities might want to have a word with you
Luis von der Eltz
@toytonics
Jan 11 13:09
Sure it makes sense to have it in general, but it would be nice to disable it conditionally
Nikita Tsukanov
@kekekeks
Jan 11 13:53
Does anyone know if there is some MacOS hardware with a touchscreen?
Steven Kirk
@grokys
Jan 11 15:57
@Gillibald sure!
Marco Garibaldi
@MarcoGaribaldi
Jan 11 16:02
Hi all ... while evaluating possible alternatives to develop a cross-platform desktop application I found about Avalonia. My team is considering adopting it for our project. I have tried creating a barebone application with Avalonia and retargeted to .NET Core 3. It compiles and runs properly. So, I have one question: has anyone tried to develop an application with .NET Core 3 and Avalonia? Does it make sense?
ahopper
@ahopper
Jan 11 16:07
@kekekeks there are aftermarket touch screen solutions for MacOS, not aware of any Apple ones, https://blkkat.com/macos-touch-drivers/
Benedikt Schroeder
@Gillibald
Jan 11 16:16
I am currently changing unit tests for FormattedText to use an embedded font. Do you consider DirectWrite to produce the expected values and test that values against other platforms or how did you chose valid values for measures etc?
Steven Kirk
@grokys
Jan 11 16:17
which tests in particular?
Benedikt Schroeder
@Gillibald
Jan 11 16:20
FormattedTextImplTests.Should_Measure_String_Correctly and all FormattedTextImplTests.Should_HitTest*
These values are font dependent and may produce wrong results on non windows machines because they don't use the same font. I changed the tests to use https://www.google.com/get/noto/#mono-mono
Steven Kirk
@grokys
Jan 11 16:35
ah yeah, makes 100% sense
Benedikt Schroeder
@Gillibald
Jan 11 16:58
Inlines_Direct2D1.JPG
Inlines_Skia.JPG
Looks like the Direct2D1 backend doesn't apply the corrent size to brushes that get applied to runs
Nikita Tsukanov
@kekekeks
Jan 11 17:01
@MarcoGaribaldi We don't know about any issues with .NET Core 3 so far. It even allows <OutputType>WinExe</OutputType> which eliminates the need to patch published binary
@ahopper I guess we don't need to support touch input for macOS then
Benedikt Schroeder
@Gillibald
Jan 11 17:06
AvaloniaUI/Avalonia#1950 will not build on azure until we have a custom myget package for HarfBuzzSharp and SkiaSharp.HarfBuzz
Nikita Tsukanov
@kekekeks
Jan 11 17:17
Is there some build infrastructure for SkiaSharp that would allow us to build such package?
ahopper
@ahopper
Jan 11 17:18
@kekekeks yep I've never come across macs being used in the industrial, security, kiosk type areas where these screens seem to be mainly used (but I'm by no means expert here). Considering IOS I've been amazed Apple still don't have desktop touch. Avalonia actually works nicely on win 10 with touch for me with windows turning touch into mouse, the most obvious issue is scrolling scrollpanels and textboxes
Nikita Tsukanov
@kekekeks
Jan 11 17:19
It would be way easier to develop touch support for mobile if we have it on desktop
At least things like gesture recognizers
ahopper
@ahopper
Jan 11 17:21
well I'm keen to help, my surface is my favorite bit of kit I've bought in years
Benedikt Schroeder
@Gillibald
Jan 11 19:04
I have attached the custom builds of HarfBuzzSharp and SkiaSharp.HarfBuzz to AvaloniaUI/Avalonia#1950 if someone wants to try it out.
Nikita Tsukanov
@kekekeks
Jan 11 19:21
Nope, can't try
@mattleibow_twitter Any chance of merging mono/SkiaSharp#715 ?
Doesn't seem to break API
Matthew Leibowitz
@mattleibow_twitter
Jan 11 19:25
Are you guys ready? the last message was that you were going to stuff
Benedikt Schroeder
@Gillibald
Jan 11 19:27
That part should be ready. Using it currently with AvaloniaUI/Avalonia#1950
Just needs a review I guess
This includes everything
Matthew Leibowitz
@mattleibow_twitter
Jan 11 19:30
@gillibald, I just failed the review because you renamed a parameter.
sad, but that is a breaking change.
i actually prefer text, but oh to the mistakes of the past
Benedikt Schroeder
@Gillibald
Jan 11 19:31
Will fix the naming
Nikita Tsukanov
@kekekeks
Jan 11 19:33
AFAIK changing parameter names doesn't break even ABI
Matthew Leibowitz
@mattleibow_twitter
Jan 11 19:33
if you do MyMethod(theFish: "test")
Nikita Tsukanov
@kekekeks
Jan 11 19:33
Ah, this one
Never liked that C# feature
Matthew Leibowitz
@mattleibow_twitter
Jan 11 19:35
yeah, but the iOS guys do... :wink:
never use it myself
Benedikt Schroeder
@Gillibald
Jan 11 19:36
Hmm all 3 overloads have different naming
Matthew Leibowitz
@mattleibow_twitter
Jan 11 19:36
I see you have a big file for text layout :smile:
Benedikt Schroeder
@Gillibald
Jan 11 19:37
Some basic stuff :)
Matthew Leibowitz
@mattleibow_twitter
Jan 11 19:37
just something to know - especially sice you are doing text things
google dropped support for text alignment - i don't know what i am going to do, but it is what it is
basically SKPaint.TextAlign is gone
Benedikt Schroeder
@Gillibald
Jan 11 19:38
Makes sense. I don't use that at all.
Matthew Leibowitz
@mattleibow_twitter
Jan 11 19:39
Some basic stuff :)
Just use ICU :wink: I really, really, really want to get a real text shaping engine going using all the proper libraries, but never get the time
Matthew Leibowitz
@mattleibow_twitter
Jan 11 19:44
And default params are also breaking - at runtime it won't find the method
also, i prefer not to use them to avoid other collisions
Benedikt Schroeder
@Gillibald
Jan 11 19:45
So i have to introduce more overloads
Thats fine
Matthew Leibowitz
@mattleibow_twitter
Jan 11 19:45
yup
you probably can split the public void AddUtf8(IntPtr buffer, int textLength, uint itemOffset = 0, int itemLength = -1) into 2, one with 2 params, and one with 4
no need to go overkill with all variations - people can just pass an extra parameter
although in this case, are the last two params related?
would you ever pass an offset, but not a length?
Nikita Tsukanov
@kekekeks
Jan 11 19:51
System.String::Substring has overloads for both cases
Matthew Leibowitz
@mattleibow_twitter
Jan 11 19:54
this is going to get a log of overloads here, (string) and then (byte[], int), (byte[], int, uint), (byte[], int, uint, int) x2 for intptr
but, maybe we don't need length if we have offset and itemlength?
(byte[], int length) | (byte[], uint offset, int length)?
and (byte[])
Benedikt Schroeder
@Gillibald
Jan 11 19:55
length = buffer.Length those last parameters define the part of the buffer that is being shaped
Matthew Leibowitz
@mattleibow_twitter
Jan 11 19:56
but if we pass the itemOffset and itemLength, do we still need length?
wait a sec, i am mixing my overloads here...
i see you divide by 2 and 4, does that make the temLength match the number of characters?
Benedikt Schroeder
@Gillibald
Jan 11 19:59
yes
public void AddUtf8(string utf8text)
        {            
            AddUtf8(utf8text, 0, -1);
        }

        public void AddUtf8(string utf8text, uint itemOffset, int itemLength)
        {
            var bytes = Encoding.UTF8.GetBytes (utf8text);
            AddUtf8 (bytes, itemOffset, itemLength);
        }

        public void AddUtf8(byte[] bytes)
        {
            AddUtf8(bytes, 0, -1);
        }

        public unsafe void AddUtf8(byte[] bytes, uint itemOffset, int itemLength)
        {
            fixed (byte* b = bytes)
            {
                AddUtf8((IntPtr)b, bytes.Length, itemOffset, itemLength);
            }
        }
        public void AddUtf8 (IntPtr buffer, int bufferLength)
        {
            HarfBuzzApi.hb_buffer_add_utf8 (Handle, buffer, bufferLength, 0, -1);
        }

        public void AddUtf8(IntPtr buffer, int bufferLength, uint itemOffset, int itemLength)
        {
            HarfBuzzApi.hb_buffer_add_utf8(Handle, buffer, bufferLength, itemOffset, itemLength);
        }
Just Utf8
sizeof(short) is 2
I believe
So condition is pretty much always true
Matthew Leibowitz
@mattleibow_twitter
Jan 11 20:06
i think that looks ok
but 1 thing that may be confusing - if I use (string, offset, length) and (byte, offset, length) does the meaning of offset/length change
will the offset/length always mean characters and never bytes? or is it bytes and never characters?
people using the buffer overloads may be thinking in bytes
Benedikt Schroeder
@Gillibald
Jan 11 20:09
not characters Units of Utf8 values
thats why it is called itemLength
Matthew Leibowitz
@mattleibow_twitter
Jan 11 20:11
ok... so for the utf 16, the string "hello" has 5 .net characters and will be 10 bytes - but 5 utf16 units?
Benedikt Schroeder
@Gillibald
Jan 11 20:12
Yes thats the easiest one
Utf8 and Utf32 are not so easy. You cant know in advance how many encoded units you get
Matthew Leibowitz
@mattleibow_twitter
Jan 11 20:13
but for the emoji ":adult:" which has 1 visible character, 2 .net characters
Benedikt Schroeder
@Gillibald
Jan 11 20:13
Yes a surrogate pair of 2 utf16 units
Matthew Leibowitz
@mattleibow_twitter
Jan 11 20:15
ok... if i am understanding this right - in most cases System::String.Length would typically be the same as the UTF Units?
Benedikt Schroeder
@Gillibald
Jan 11 20:15
Okay I just came to the conclusion that the overloads public void AddUtf8(string utf8text, uint itemOffset, int itemLength) and public void AddUtf32(string utf32text, uint itemOffset, int itemLength) are not usable. Somone would use the byte[] overload
Matthew Leibowitz
@mattleibow_twitter
Jan 11 20:16
yeah... you can just pass in a Substring of what you want
might be better so we allocate a smaller array to get the bytes
Benedikt Schroeder
@Gillibald
Jan 11 20:17
That is not true sadly
Nikita Tsukanov
@kekekeks
Jan 11 20:17
Add Span<byte> overloads, it's 2019 already
And Span<char>
Benedikt Schroeder
@Gillibald
Jan 11 20:17
In terms of shaping you sometimes want to know the sourrounding characters
Matthew Leibowitz
@mattleibow_twitter
Jan 11 20:17
that is just in netcore right? not yet in netstandard?
we can multitarget
Nikita Tsukanov
@kekekeks
Jan 11 20:18
Wait
Compatible with netstandard1.1
Benedikt Schroeder
@Gillibald
Jan 11 20:19
Looks like we need some more discussion about this. Lets dont rush this.
Matthew Leibowitz
@mattleibow_twitter
Jan 11 20:20
netcore 2.1 and netcore2.2
let me see what that nuget actually does...
Nikita Tsukanov
@kekekeks
Jan 11 20:22
It provides a portable implementation
Which doesn't require runtime support
Jeremy Koritzinsky
@jkoritzinsky
Jan 11 20:23
It just doesn’t have the methods that hang off core types
And its a little slower since it doesn’t have the runtime intrinsic support. But still better than using substring
Matthew Leibowitz
@mattleibow_twitter
Jan 11 20:24
ah, yeah
Benedikt Schroeder
@Gillibald
Jan 11 20:24
How would you pass Span<Char> to Encoding.UTF8.GetBytes(...)?
Matthew Leibowitz
@mattleibow_twitter
Jan 11 20:25
but i don't think it is going to help specifically with these params because itemOffset and itemLength are not actually characters or bytes...
Benedikt Schroeder
@Gillibald
Jan 11 20:25
Memory<char> works
Nikita Tsukanov
@kekekeks
Jan 11 20:25
Using char* overload probably
Benedikt Schroeder
@Gillibald
Jan 11 20:26
using (var pinHandle = text.Pin())
                {
                    buffer.AddUtf16((IntPtr)pinHandle.Pointer, text.Length, 0, text.Length);
                }
this is how i call it
thats why I introduced the IntPtr overload
Matthew Leibowitz
@mattleibow_twitter
Jan 11 20:28
is the text a span?
Benedikt Schroeder
@Gillibald
Jan 11 20:28
Memory<char>
Matthew Leibowitz
@mattleibow_twitter
Jan 11 20:29
also, what about stackalloc? as a side to avoid hitting the GC and all that
saw this: https://medium.com/@antao.almada/p-invoking-using-span-t-a398b86f95d3
Benedikt Schroeder
@Gillibald
Jan 11 20:31
Read that too
Matthew Leibowitz
@mattleibow_twitter
Jan 11 20:31
So, just so that we know, I don't mind taking a dependency on that nuget to use span - and I will see about getting this thing to multitarget to the platforms, net45, netstandard1.3 and then netcoreapp2.1 so we don't need a nuget
this is probably something that we actually need to do, I can just see someone passing 1000 chars to this thing and saying give me answers - and then we go ahead and start allocating gigabytes of memory all over the show
Nikita Tsukanov
@kekekeks
Jan 11 20:33
Span<T> has unsafe ref T GetPinnableReference()
Matthew Leibowitz
@mattleibow_twitter
Jan 11 20:33
and this is in a render loop.... 60 frames a second
the GC will just dies
Nikita Tsukanov
@kekekeks
Jan 11 20:33
I think it could be converted to char*
Benedikt Schroeder
@Gillibald
Jan 11 20:35
This only works for AddUtf16. AddUtf8 and AddUtf32 still need to allocate Memory.
Nikita Tsukanov
@kekekeks
Jan 11 20:35
You can call GetBytes this way
@Gillibald
System.Memory is way slower
And is intended for multithreaded usage
Span is stack-only type
Benedikt Schroeder
@Gillibald
Jan 11 20:37
I will do so after I refactored everything to use Span<char>
We dont need to call GetBytes that way it is already utf16 encoded
Currently I need to store a reference in SKTextRun but that will go away and I just use a single Span<char>
char* can be cast to IntPtr do will still need that Span<char> overload?
Nikita Tsukanov
@kekekeks
Jan 11 20:40
Anyway, adding Span<byte>/Span<char>/Span<int> to harfbuzz C# API is needed

char* can be cast to IntPtr do will still need that Span<char> overload?

Faster and more convenient to use

Benedikt Schroeder
@Gillibald
Jan 11 20:47
AddUtf8(Span<byte> text)
AddUtf16(Span<byte> text)
AddUtf16(Span<char> text)
AddUtf32(Span<byte> text)
AddUtf32(Span<int> text)
These are probably the most usefull combinations
Jeremy Koritzinsky
@jkoritzinsky
Jan 11 20:49
Btw GetPinnableReference is implicitly used with the C# 7.3 generalized fixed statement
Nikita Tsukanov
@kekekeks
Jan 11 20:50
Where did Span.Portable.cs go?
For some reason this file is gone from CoreFX
But apparently is still used to build System.Memory package
Jeremy Koritzinsky
@jkoritzinsky
Jan 11 21:01
Where do you see it using a Span.Portable.cs file?
Tbh I don't even see it building for netstandard any more. I think new versions are only inbox now
Nikita Tsukanov
@kekekeks
Jan 11 21:17
I've decompiled the System.Memory library shipped for netstandard20
In 4.5.0
Jeremy Koritzinsky
@jkoritzinsky
Jan 11 22:30
Yeah looks like that package isn't being built the same way any more.