These are chat archives for AvaloniaUI/Avalonia

5th
Nov 2017
jp2masa
@jp2masa
Nov 05 2017 01:30

I have this style in App.xaml:

<Style Selector="DropDown /template/ ToggleButton#toggle">
    <Setter Property="Background" Value="#000000" />
</Style>

but it's not working, is it possible to override the Background property in this ToggleButton?

Nikita Tsukanov
@kekekeks
Nov 05 2017 08:28
@grokys Do we still have properties from templates with LocalValue?
AlessandroMiorelli
@AlessandroMiorelli
Nov 05 2017 09:20

@kekekeks sorry if I'm so boring. I added UseSkia

        var builder = AppBuilder.Configure(app)
            .UsePlatformDetect()
            .UseSkia()
            .SetupWithoutStarting();

and moved "new Bitmap 2

              var r = AvaloniaLocator.Current.GetService<IPlatformRenderInterface>();Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            var fb = new Framebuffer(PixelFormat.Bgra8888, (int)this.Width, (int)this.Height);

            using (var target = r.CreateRenderTarget(new object[] { fb }))
            using (var ctx = new DrawingContext(target.CreateDrawingContext(null)))
            {
                ImmediateRenderer.Render(this, ctx);
            }

            Trace.WriteLine(stopwatch.ElapsedMilliseconds);
            var bmp = new Bitmap(PixelFormat.Bgra8888, fb.Address, fb.Width, fb.Height, fb.RowBytes);
            bmp.Save(@"D:\test1.bmp");

            fb.Deallocate();

            using (var rtb = new RenderTargetBitmap((int)this.Width, (int)this.Height))
            {
                stopwatch.Restart();
                rtb.Render(this);
                Trace.WriteLine(stopwatch.ElapsedMilliseconds);
                rtb.Save(@"D:\test2.png");
            }

but RenderTargetBitmap Render seems to be little bit faster than ImmediateRenderer.Render
Is this the right way? Am I measuring the right time?

Can I always render in a buffer instead on monitor?
Nikita Tsukanov
@kekekeks
Nov 05 2017 09:26

little bit faster

Now do RTB first and framebuffer second, you'll see the opposite results

Your benchmark is still incorrect
There is no actual performance difference between rendering to RTB and a framebuffer
AlessandroMiorelli
@AlessandroMiorelli
Nov 05 2017 09:31
Please could you give me suggestions to do it better. Thank you
Nikita Tsukanov
@kekekeks
Nov 05 2017 09:33
Implement ILockedFramebuffer on top of your IntPtr and pass it to platform render interface
AlessandroMiorelli
@AlessandroMiorelli
Nov 05 2017 10:53
Is it possible to render always in framebuffer? I don't need to see the window on my monitor. Maybe it is faster
Nikita Tsukanov
@kekekeks
Nov 05 2017 10:54
You need to implement your own ITopLevelImpl
See LinuxFramebuffer platform in our source code
Note: this API is unstable and a subject to change in future versions
AlessandroMiorelli
@AlessandroMiorelli
Nov 05 2017 10:58
ok, thank you
AlessandroMiorelli
@AlessandroMiorelli
Nov 05 2017 11:10
I'm using Glyphs to draw text on my WPF application (https://msdn.microsoft.com/en-us/library/system.windows.documents.glyphs(v=vs.110).aspx). Has Avalonia something like that?
I need to have the chars in specified positions
Nikita Tsukanov
@kekekeks
Nov 05 2017 11:11
We don't have low-level API for text rendering yet
Steven Kirk
@grokys
Nov 05 2017 15:32
@danwalmsley AvaloniaUI/Avalonia#1261 should fix your problem - sorry it took a bit longer than expected!
i knew it'd be a one-liner
Vitalij Mikhailov
@Aragas
Nov 05 2017 20:58
Hi guys, did someone report problems with using nightly nuget builds with OS X already?
Nikita Tsukanov
@kekekeks
Nov 05 2017 21:01
nope
what kind of problems?
Vitalij Mikhailov
@Aragas
Nov 05 2017 21:02
Give me a second, doing last test to be sure

It is a nuget only issue. Seems that MonoMac is broken or something.
https://pastebin.com/Dcbau4f1
Here is the stacktrace.

When I switched from nuget to referencing the Avalonia projects directly by including them to the solution, everything worked fine.
Using .net core 2.0

gtk3 via brew installed
Nikita Tsukanov
@kekekeks
Nov 05 2017 21:07
Check LoaderExceptions
There is probably some nuget package missing or something like that
Vitalij Mikhailov
@Aragas
Nov 05 2017 21:08
There is a problem. I can't see the exception from VS Mac, only via raw dotnet run
Nikita Tsukanov
@kekekeks
Nov 05 2017 21:08
gtk3 is no longer needed
Vitalij Mikhailov
@Aragas
Nov 05 2017 21:08
Well, I imported Avalonia and Avalonia.Desktop
Nikita Tsukanov
@kekekeks
Nov 05 2017 21:08
wrap it into try/catch
Vitalij Mikhailov
@Aragas
Nov 05 2017 21:08
Right
Nikita Tsukanov
@kekekeks
Nov 05 2017 21:09
There might be something wrong in our dependency graph
Vitalij Mikhailov
@Aragas
Nov 05 2017 21:09
In Win10 it works
Nikita Tsukanov
@kekekeks
Nov 05 2017 21:09
We have to construct it manually instead of relying on nuget itself
Vitalij Mikhailov
@Aragas
Nov 05 2017 21:11
Catched two exceptions
{System.TypeLoadException: Could not load type 'Avalonia.Win32.Interop.IFileDialog' from assembly 'Avalonia.Win32, Version=0.5.2.0, Culture=neutral, PublicKeyToken=null'.}
{System.TypeLoadException: Could not load type 'Avalonia.Win32.Interop.IFileDialog' from assembly 'Avalonia.Win32, Version=0.5.2.0, Culture=neutral, PublicKeyToken=null'.}
Nikita Tsukanov
@kekekeks
Nov 05 2017 21:11
Hmmmm
Vitalij Mikhailov
@Aragas
Nov 05 2017 21:11
Oh whops, i doubled it
{System.TypeLoadException: Could not load type 'Avalonia.Win32.Interop.IShellItem' from assembly 'Avalonia.Win32, Version=0.5.2.0, Culture=neutral, PublicKeyToken=null'.}
It seems that monomac tries to load every referenced assembly
Vitalij Mikhailov
@Aragas
Nov 05 2017 21:13
And it finds the Win specific ones
Nikita Tsukanov
@kekekeks
Nov 05 2017 21:14
It should be only checking for assemblies that are referencing monomac
Vitalij Mikhailov
@Aragas
Nov 05 2017 21:14
I tried to find the issue, but as I said, when directly referencing the projects, everything seems fine
Weird
So if I understand it correctly, it loads the Windows specific libraries for some reason?
Nikita Tsukanov
@kekekeks
Nov 05 2017 21:16
Try to copy-paste
var monomac = typeof(NSApplication).Assembly;
var name = monomac.GetName ().ToString ();
            foreach (var a in AppDomain.CurrentDomain.GetAssemblies ()) {
                foreach (var r in a.GetReferencedAssemblies ()) {
                    if (name == r.ToString ()) {
                        Console.WriteLine(a.GetName());
                        break;
                    }
                }
}
Vitalij Mikhailov
@Aragas
Nov 05 2017 21:16
k
Executed fine
If you need the output, gimme a sec
Nikita Tsukanov
@kekekeks
Nov 05 2017 21:18
Did it print any assembly names?
Vitalij Mikhailov
@Aragas
Nov 05 2017 21:19
PokeD.Server.Avalonia, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
This is my main assembly
Nikita Tsukanov
@kekekeks
Nov 05 2017 21:22
Does it reference MonoMac directly?
Vitalij Mikhailov
@Aragas
Nov 05 2017 21:23
Nope, but nothing changed when i tried to. Lemme try it again just to confirm
Yep. Did not help
I see that Desktop references it, so it should be used if needed
Nikita Tsukanov
@kekekeks
Nov 05 2017 21:27
Oh, I see now
It's because of #ifdef
Vitalij Mikhailov
@Aragas
Nov 05 2017 21:28
Can you provide the line? Curious myself
Vitalij Mikhailov
@Aragas
Nov 05 2017 21:29
Changed definition name guess?
Nevermind
Nikita Tsukanov
@kekekeks
Nov 05 2017 21:30
AvaloniaUI/monomac@ade7fbf
Try with this version
Vitalij Mikhailov
@Aragas
Nov 05 2017 21:32
I will need the new nuget package then or instructions on how to build it
Nikita Tsukanov
@kekekeks
Nov 05 2017 21:32
Run make netstandard from src directory and copy bin/Release/net461/MonoMac.dll to ~/.nuget/packages/monomac.netstandard/0.0.3/lib/**
Vitalij Mikhailov
@Aragas
Nov 05 2017 21:32
Roger
Nikita Tsukanov
@kekekeks
Nov 05 2017 21:33
wait, not net461, but corresponding ones
Vitalij Mikhailov
@Aragas
Nov 05 2017 21:33
k
Nikita Tsukanov
@kekekeks
Nov 05 2017 21:34
After initial make netstandard you can use regular dotnet build
It's only needed to generate sources
Vitalij Mikhailov
@Aragas
Nov 05 2017 21:51
Sorry for the long waiting
Had some issues with git
And make is not doing it
make generated_sources 64BIT=1 make[1]: *** No rule to make target `../maccore/src/./CoreGraphics/CGPoint.cs', needed by `core.dll'. Stop. make: *** [netstandard] Error 2รท
Nikita Tsukanov
@kekekeks
Nov 05 2017 21:56
You probably didn't checked out submodules
run git submodule update --init --recursive
Vitalij Mikhailov
@Aragas
Nov 05 2017 21:57
maccore is there
nopey
Nikita Tsukanov
@kekekeks
Nov 05 2017 21:57
makefile complains about missing ../maccore/src/./CoreGraphics/CGPoint.cs
And it's a part of a submodule
Vitalij Mikhailov
@Aragas
Nov 05 2017 21:57
oh right
Everything seems there except the point
Okay, gimme a sec
You have probably manually cloned maccore instead of using submodules
Vitalij Mikhailov
@Aragas
Nov 05 2017 22:03
git initialized the wrong version
Vitalij Mikhailov
@Aragas
Nov 05 2017 22:32
Done
Aaaaand everything is working now
What a fun ride. Thanks for helping