These are chat archives for AvaloniaUI/Avalonia

31st
Oct 2016
Darnell Williams
@Seeker1437
Oct 31 2016 00:27
Well... fixing the designer suspension and the error were projects can be null would be nice to have
Can they be cherrypicked in or something?
Steven Kirk
@grokys
Oct 31 2016 09:26
@Seeker1437 where are they?
Darnell Williams
@Seeker1437
Oct 31 2016 09:39
They are in that pr, AvaloniaUI/AvaloniaVS#35
Steven Kirk
@grokys
Oct 31 2016 09:40
could you create a PR with the changes cherry picked in?
Darnell Williams
@Seeker1437
Oct 31 2016 09:41
Sure
danwalmsley
@danwalmsley
Oct 31 2016 11:06
@grokys
perhaps a question with an obvious answer
but can I assume that in the visual tree
everything is of type Visual?
so where as logical tree might contain a string
in the visual tree it would at least be a TextBlock
?
Steven Kirk
@grokys
Oct 31 2016 11:13
everything is of type IVisual yes
but the local differs from WPF too in that respect because everything there is of type ILogical
there's no "string in the logical tree" concept because that wouldn't work with our styling system as that works on the local tree
danwalmsley
@danwalmsley
Oct 31 2016 11:14
I'm working with @Seeker1437 on docking
and we are trying to make the dock collapse when there is an item in it that is invisible
and then restore when the reverse happens
should we be subscribing to the visibility property, or assume that the size would measure 0 when not visible?
Steven Kirk
@grokys
Oct 31 2016 11:17
hmm well they are slightly different things: a DesiredSize of 0 can be caused by an invisible control, or a control with no content
so it depends if you want to collapse on both those conditions
danwalmsley
@danwalmsley
Oct 31 2016 11:19
Id have to think
and I guess if we want it to only collapse with visibility then we need to check the IsVisible
when we measure
to distinguish between those 2 states
ok 1 more question
Steven Kirk
@grokys
Oct 31 2016 11:20
https://github.com/AvaloniaUI/Avalonia/blob/master/src/Avalonia.Layout/Layoutable.cs#L446 that's the logic for measuring and visibility if that helps
danwalmsley
@danwalmsley
Oct 31 2016 11:20
thanks
so contentcontrol
its content property is of type oject
so it can take anything
When that gets set it must be transformed to ILogical and IVisual where in code does this happen?
it's refactored out into a mixin as it's needed in more than one base class
danwalmsley
@danwalmsley
Oct 31 2016 11:25
ok thanks I think that should get me going
Steven Kirk
@grokys
Oct 31 2016 11:27
basically, it looks for the presenter in the control template, and listens for changes to the presenter's Child and updates the ContentControl.LogicalChildren based on that
danwalmsley
@danwalmsley
Oct 31 2016 11:28
@grokys perhaps we can get a fix for #791 into next release?
it can be reproduced in control catalog, have you seen this one before?
I might be able to look at it tonight
Steven Kirk
@grokys
Oct 31 2016 11:32
oh i thought i fixed something similar a while ago. obviously not
Darnell Williams
@Seeker1437
Oct 31 2016 11:38
Ah I see this is pretty cool, @grokys can younalso take a look at Mabiavalon/DocnNC#7 ?
Lol Mabiavalon/DockNC#7
Steven Kirk
@grokys
Oct 31 2016 12:13
what did you want me to take a look at in particular?
Darnell Williams
@Seeker1437
Oct 31 2016 12:17
Oh sorry in my response I linked to my attempt at tackling the visibility though it doesn't listen for changes atm xD
Here: Mabiavalon/DockNC@7be7154
Id have to fix what we talked regarding not being in the logical tree some reason, also I csn dry this code up a bit
But I wasnt sure how to go about listening for changes
danwalmsley
@danwalmsley
Oct 31 2016 12:20
@Seeker1437 listening for which changes?
visibility?
Darnell Williams
@Seeker1437
Oct 31 2016 12:23
Yes
danwalmsley
@danwalmsley
Oct 31 2016 12:24
here is an example in the PR I sent you!
Darnell Williams
@Seeker1437
Oct 31 2016 12:30
Oh I totally misread this before, this is good!
danwalmsley
@danwalmsley
Oct 31 2016 12:35
the PR was WIP i.e. unfinished, but I thought it would give you a clue how to finish off,
so I think to finish it
you need to find the IVisual from the visual tree rather than casting to IVisual
and also restore the gridlength when visibility is restored
danwalmsley
@danwalmsley
Oct 31 2016 20:15
@grokys I'm trying to write a unit test for virtualization...
public void Filtering_Multiple_Times_Between_Renders_Should_Generate_Valid_Containers()
            {
                var file = File.OpenText("Presenters\\testdata.txt");
                var data = new List<string>();

                while(!file.EndOfStream)
                {
                    data.Add(file.ReadLine());
                }

                var target = CreateObservableCollectionTarget(data);

                target.ApplyTemplate();
                target.Measure(new Size(100, 100));
                target.Arrange(new Rect(0, 0, 100, 100));

                var expected = data.Take(10);
                var items = (ObservableCollection<string>)target.Items;
                var actual = target.Panel.Children.Select(x => x.DataContext).ToList();

                Assert.Equal(expected, actual);

                expected = Enumerable.Range(0, 6).Select(x => $"Item {x}").ToList();
                target.Items = expected;

                actual = target.Panel.Children.Select(x => x.DataContext).ToList();
                Assert.Equal(expected, actual);
            }
after first Assert.Equal
I want to update the target.Items
so far so good
how can I trigger a re-render
so that I can test the results have updated?
Steven Kirk
@grokys
Oct 31 2016 20:16
a render?
danwalmsley
@danwalmsley
Oct 31 2016 20:16
like update to ui
target.arrange?
so all the containers get recycled and now reflect what would be on the ui
if there was one
Steven Kirk
@grokys
Oct 31 2016 20:17
ok, sorry, i've not got the code in front of me
don't all the other tests do that though?
danwalmsley
@danwalmsley
Oct 31 2016 20:18
they all do it once I guess.
but I'm not sure which line does it
I suspect
target.Measure(new Size(100, 100));
                target.Arrange(new Rect(0, 0, 100, 100));
???
Steven Kirk
@grokys
Oct 31 2016 20:18
yep, that represents a layout pass, so that should do it
danwalmsley
@danwalmsley
Oct 31 2016 20:19
ok thanks!! :)
hopefully will be able to catch the bug iv seen
danwalmsley
@danwalmsley
Oct 31 2016 21:10
@grokys I'm finding that during my unit test
var layoutManager = LayoutManager.Instance;
layout manager is null?
is there are way to create it?
oh I found
using (UnitTestApplication.Start(TestServices.RealLayoutManager))
Steven Kirk
@grokys
Oct 31 2016 21:31
Yep that limits the scope of the service
So each test is isolated from the services of others
danwalmsley
@danwalmsley
Oct 31 2016 21:31
ok
im struggling a bit, getting the listbox to move to selected item in the test
I couldn't find another test that actually did that either
are you at your machine?
Steven Kirk
@grokys
Oct 31 2016 21:36
Not right now but I probably can be in 30 mins or so
danwalmsley
@danwalmsley
Oct 31 2016 21:36
ok well no rush like
I will push my current test to a WIP pr
so you can see when you are ready
Steven Kirk
@grokys
Oct 31 2016 21:36
You should be able to set the offset
Look for other tests that set offset
danwalmsley
@danwalmsley
Oct 31 2016 21:37
iv seen the ones that do that
but was hoping to exactly represent my intellisense code
to hopefully pick up the bug
maybe I can calculate offset anyway
should be roughly equivalent
will check that
:)
Steven Kirk
@grokys
Oct 31 2016 21:38
The offset in a virtualized list should just be the index of the first item
danwalmsley
@danwalmsley
Oct 31 2016 21:39
ok sounds pretty easy then ;)
Steven Kirk
@grokys
Oct 31 2016 21:53
ok, i'm at my computer now
danwalmsley
@danwalmsley
Oct 31 2016 21:54
ok can you see #792
I know the test is a mess at the momen
just trying to get it to do what I need first
I tried setting the offset
but the panels children don't get updated
here I set offset...
Steven Kirk
@grokys
Oct 31 2016 22:12
ah ok, just got chance to look.
so you're testing ListBox itself, i thought you were testing ItemsPresenter
danwalmsley
@danwalmsley
Oct 31 2016 22:12
I was at first
Steven Kirk
@grokys
Oct 31 2016 22:13
ListBox is more difficult to test because its interactions are all via the presenter
danwalmsley
@danwalmsley
Oct 31 2016 22:13
but I couldn't find out how to ...
set SelectedItem
the Presenter doesn't have SelectedItem
as far as I could tell
I just had a feeling it was important, because that's what causes my intellisense box to scroll to the suggestion
but perhaps it just needs to set the offset on the Presenter
and its equivalent
I can quickly move it back to being a presenter test
Steven Kirk
@grokys
Oct 31 2016 22:16
no it's ok, just need to work out what's happening
danwalmsley
@danwalmsley
Oct 31 2016 22:16
ok
I think you can tell what im trying to test right?
that after scroll in a very long list, where I keep changing the data to a subset
the first item actually represents the first item in the data
because the issue im having is the first item often displays textblock for an old container
Steven Kirk
@grokys
Oct 31 2016 22:19
ok, this works
                text = target.Presenter.Panel.Children
                    .OfType<ListBoxItem>()
                    .Select(x => x.Content)
                    .Cast<string>()
                    .ToList();
you were getting caught by the same thing as @Seeker1437 : AvaloniaUI/Avalonia#787
if you want to use x.Presenter.Child you need to call UpdateChild on the ListBoxItem.Presenter for the moment
until #787 gets fixed
danwalmsley
@danwalmsley
Oct 31 2016 22:21
ok sure
right let me see if I can get this test to fail ...
although perhaps that could be the bug that im seeing
if update child hadn't been called
Steven Kirk
@grokys
Oct 31 2016 22:23
yeah it could be that UpdateChild isn't getting called, so yeah you should probably do what you were doing, but first loop through the items, casting the presenter to ContentPresenter and calling UpdateChild
but that's not really testing the same thing
as UpdateChild will be called by the measure on the actual app
danwalmsley
@danwalmsley
Oct 31 2016 22:24
but not in the test?
Steven Kirk
@grokys
Oct 31 2016 22:24
no, because that only happens on a rooted logical tree
danwalmsley
@danwalmsley
Oct 31 2016 22:25
ok
Steven Kirk
@grokys
Oct 31 2016 22:25
you can do that in a test though
danwalmsley
@danwalmsley
Oct 31 2016 22:25
looks like I will need to
to make it an equivalent test
Steven Kirk
@grokys
Oct 31 2016 22:25
just put the ListBox under a TestRoot using TestRoot.Child
danwalmsley
@danwalmsley
Oct 31 2016 22:25
ok cheers
Steven Kirk
@grokys
Oct 31 2016 22:26
and then call LayoutManager.Instance.ExecuteLayoutPass instead of doing the measure/arrange yourself
let me find a test that does that
that uses a Window instead of a TestRoot
you but other than that it's pretty much it
you can use a window if you like too but just be sure to register the correct services using UnitTestApplication.Start(TestServices.StyledWindow)
danwalmsley
@danwalmsley
Oct 31 2016 22:32
ok thanks