These are chat archives for AvaloniaUI/Avalonia

9th
May 2016
Jason Jarvis
@jazzay
May 09 2016 00:39
Did you add Rx-Main Nuget?
Gutemberg Ribeiro
@galvesribeiro
May 09 2016 00:52
it was supposed to be added since it is a dependency but I got my way around
Gutemberg Ribeiro
@galvesribeiro
May 09 2016 01:48
who implements IPlatformHandle?
Darnell Williams
@Seeker1437
May 09 2016 02:23
You would for your platform
umm I was thinking if your FB Pointer stayed the same, you could probably use that is the platform handle XD
but idk if it's stable like that
Gutemberg Ribeiro
@galvesribeiro
May 09 2016 02:33
yes it is
once opened when device turn up, it will remain the same until device is shutdown
its a pointer to the buffer mapped by MMap.Open() from linux which is the are mapped to the graphics device
so anything you write on that buffer is rendered on the screen live
Darnell Williams
@Seeker1437
May 09 2016 03:39
Cool then maybeyou you can make your IPlatformHandleImpl return the FB's FBPointer (which is fine since ofc it's an IntPtr)
during the setup you can assign it possibly
Gutemberg Ribeiro
@galvesribeiro
May 09 2016 04:03
I dont got the flow yet
dont understood who calls who and where I should make the code
Fei
@flyingxu
May 09 2016 07:03
Hi Guys, in my application I'd like to do something when the window closes, but I can't find the Closed or Closing event as in WPF, am I missing something or is there a workaround?
I do find the code public Action Closed { get; set; } but I don't think it's designed for my case
Steven Kirk
@grokys
May 09 2016 07:11
@flyingxu yes you're right - we need to add that event!
Fei
@flyingxu
May 09 2016 07:33
@grokys do you have a quick workaround I can try?
Steven Kirk
@grokys
May 09 2016 07:49
i don't think there is one, but we can add the event - are you using the nightly nuget packages?
Steven Kirk
@grokys
May 09 2016 07:59
@kekekeks @jazzay i implemented the AppBuilder stuff on the appbuilder branch, could you take a look to see if it's what you were expecting? however i couldn't work out how this was supposed to fix the designer...
Matthijs ter Woord
@mterwoord
May 09 2016 07:59
wow, there's a perspex designer?? How usable is it? (not trying be negative here)
Does it support binding etc?
Steven Kirk
@grokys
May 09 2016 08:00
well it's pretty basic atm. and broken ;)
Matthijs ter Woord
@mterwoord
May 09 2016 08:00
visual designer? how about intellisense/coloring in the text editor for the xaml/paml/whatever files?
Steven Kirk
@grokys
May 09 2016 08:00
once we get it fixed, and do the rename we'll do a new release
yeah it has that, it's a VS plugin
Matthijs ter Woord
@mterwoord
May 09 2016 08:01
coo, does it have intellisense for bindings etc?
(ie, view model typing)
Steven Kirk
@grokys
May 09 2016 08:01
not currently, no
Matthijs ter Woord
@mterwoord
May 09 2016 08:01
note, i dont have any hands on experience with perspex, but interested in it quite a bit
Steven Kirk
@grokys
May 09 2016 08:01
it's something we'd like to add
sure :)
Matthijs ter Woord
@mterwoord
May 09 2016 08:01
awesome :)
Fei
@flyingxu
May 09 2016 09:03
@grokys If you can add the Closing event in the near future it will be great. I'm using Perspex by building it from source actually.
Matthijs ter Woord
@mterwoord
May 09 2016 09:04
Is an assembly-split planned as well?
Steven Kirk
@grokys
May 09 2016 11:07
@flyingxu ok will try to add it today!
@mterwoord assembly split?
Matthijs ter Woord
@mterwoord
May 09 2016 11:07
right now it seems all desktop targets are in 1 huge assembly
gtk, wpf, etc
Steven Kirk
@grokys
May 09 2016 11:08
no, they're in separate assemblies
also... wpf?
we don't target wpf
Matthijs ter Woord
@mterwoord
May 09 2016 11:09
ok, normal windows :)
hmm, it seemed to me that once i added the Perspex.Desktop nuget package to my project, everything suddenly was reference
d
Steven Kirk
@grokys
May 09 2016 11:09
ah you mean nuget packages, not assemblies
Matthijs ter Woord
@mterwoord
May 09 2016 11:09
hmm, guess so. sorry for confusion :)
Steven Kirk
@grokys
May 09 2016 11:10
yeah, we should probably do that too
Matthijs ter Woord
@mterwoord
May 09 2016 11:10
also, i know what a hassle nuget packaging is....
Steven Kirk
@grokys
May 09 2016 11:10
i didn't set all that up, so i don't really know!
Matthijs ter Woord
@mterwoord
May 09 2016 11:10
but i'd say most of the time apps will want to specifically use different logic for different platforms (ie, replace platform specific logic)
Jason Jarvis
@jazzay
May 09 2016 14:57
@grokys will add my comments shortly. fyi, I submitted a PR for some Skia improvements.
Darnell Williams
@Seeker1437
May 09 2016 16:10
Yep :D
Gutemberg Ribeiro
@galvesribeiro
May 09 2016 16:50
guys, who create IPlatformHandle ?
Darnell Williams
@Seeker1437
May 09 2016 16:52
Ooooooh
ITopLevel
Gutemberg Ribeiro
@galvesribeiro
May 09 2016 16:53
I don't see that on current skia implementation
Darnell Williams
@Seeker1437
May 09 2016 16:53
technically your create the IPlatformHandle In int you WindowImpl
Which should inherit ITopLevel.IPlatformHandle PlatformHandle {get;}
Gutemberg Ribeiro
@galvesribeiro
May 09 2016 16:54
the problem is
in order to create a Skia surface I have to provide some things
like image format, width, height, stride and the IntPtr for the buffer
that can change from device to device
and the method which creates that, receives just a IPlatformHandle
I think this interface too much tied to the win32 model
Darnell Williams
@Seeker1437
May 09 2016 16:56
Might be
But android and iOS ca use it too
what holds onto your FB?
Gutemberg Ribeiro
@galvesribeiro
May 09 2016 16:57
a class which has the FB Pointer and screen size, rotation, etc
Darnell Williams
@Seeker1437
May 09 2016 16:57
Whatever holds the FB can probably Implement IWindowImpl
Gutemberg Ribeiro
@galvesribeiro
May 09 2016 16:57
    public abstract class GenericFramebufferRenderer : IDisposable, IRenderer
    {
        private int _fd = -1;
        public IntPtr FBPointer { get; private set; }

        public int ScreenWidth { get; }

        public int ScreenHeight { get; }

        public virtual int CenterX { get; }

        public virtual int CenterY { get; }

        public int RotateDegrees { get; }

        public GenericFramebufferRenderer(string fbDeviceName, int width, int height, int fbSize, int rotateDegrees = 0)
        {
            if (string.IsNullOrWhiteSpace(fbDeviceName))
                throw new ArgumentNullException("fbDeviceName");

            if (width <= 0 || height <= 0 || fbSize <= 0)
                throw new ArgumentException($"Screen sizes must be set. Received w={width}, h={height}, fbSize={fbSize}");

            _fd = NativeOpen(fbDeviceName, 0x02);

            if (_fd < 0)
                throw new InvalidOperationException($"Unable to open framebuffer device {fbDeviceName}. Return code {_fd}.");

            ScreenHeight = height;
            ScreenWidth = width;
            CenterX = width / 2;
            CenterY = height / 2;
            RotateDegrees = rotateDegrees;

            FBPointer = NativeMmap(0, fbSize, MmapProts.PROT_READ | MmapProts.PROT_WRITE, MmapFlags.MAP_SHARED, _fd, 0);
        }

        public abstract void Draw(int x, int y, int width, int height, byte[] buffer);

        public void Dispose()
        {
            NativeClose(_fd);
        }

        #region Native
        private const string LIBC = "libc";

        [DllImport(LIBC, EntryPoint = "close")]
        private static extern int NativeClose(int fd);

        [DllImport(LIBC, EntryPoint = "open")]
        private static extern int NativeOpen([In()] [MarshalAs(UnmanagedType.LPStr)] string file, int oflag);

        [DllImport(LIBC, EntryPoint = "mmap")]
        private static extern IntPtr NativeMmap(int addr, [MarshalAs(UnmanagedType.SysUInt)] int len, MmapProts prot, MmapFlags flags, int fd, int offset);

        [Flags]
        private enum MmapFlags
        {
            MAP_SHARED = 1,
            MAP_PRIVATE = 2,
            MAP_TYPE = 15,
            MAP_FIXED = 16,
            MAP_FILE = 0,
            MAP_ANONYMOUS = 32,
            MAP_ANON = 32,
            MAP_GROWSDOWN = 256,
            MAP_DENYWRITE = 2048,
            MAP_EXECUTABLE = 4096,
            MAP_LOCKED = 8192,
            MAP_NORESERVE = 16384,
            MAP_POPULATE = 32768,
            MAP_NONBLOCK = 65536
        }

        [Flags]
        private enum MmapProts
        {
            PROT_READ = 1,
            PROT_WRITE = 2,
            PROT_EXEC = 4,
            PROT_NONE = 0,
            PROT_GROWSDOWN = 16777216,
            PROT_GROWSUP = 33554432
        }
        #endregion
    }
this is what I have
Darnell Williams
@Seeker1437
May 09 2016 16:58
kk bare with me really fast I might be able to actually help :D
Gutemberg Ribeiro
@galvesribeiro
May 09 2016 16:58
each devide we support, inherit from that class just to pass thru the ctor the device address like /dev/fb0 and its size
ok let me PM you
Steven Kirk
@grokys
May 09 2016 18:29
updated omnixaml to the latest and hopefully now we won't need to the assembly resolution hacks that were necessary before
(although the solution in one case is still a bit of a hack)
omnixaml's glass is now in a different repository so you'll need to do a git submodule init or update (not such which is necessary, guess i should learn...)
Wiesław Šoltés
@wieslawsoltes
May 09 2016 20:39
@grokys Please check my PR #532, the Glass was added as NuGet and as sources, Perspex NuGet package did not reference Glass nuget and this was causing exception when I've updated my app to latest Perspex
Steven Kirk
@grokys
May 09 2016 20:39
Ahh yes of course
Oh
But hold on, we include it by source
Wiesław Šoltés
@wieslawsoltes
May 09 2016 20:41
yes but Perspex.Markup.Xaml had reference to Glass dll
Steven Kirk
@grokys
May 09 2016 20:42
Hmm ok
I think that should now be removed
Instead of including the ref to the nuget
I think I tried including the nuget but it wasn't up to date and probably forgot to remove it
Wiesław Šoltés
@wieslawsoltes
May 09 2016 20:45
CI failed Failed to provision build worker virtual machine in a cloud - no active zones available. Please try restarting build later.
Steven Kirk
@grokys
May 09 2016 20:46
Arrgh. I'm not at my computer..
Let me try from my phone
Seemed to work
Wiesław Šoltés
@wieslawsoltes
May 09 2016 20:48
CI failed again :worried:
same error
Steven Kirk
@grokys
May 09 2016 21:12
Sounds like appveyor is having problems
Wiesław Šoltés
@wieslawsoltes
May 09 2016 21:12
yeah
Gutemberg Ribeiro
@galvesribeiro
May 09 2016 23:11
and the tests with perspex started :)