The root of our logical tree is denoted by `IStyleRoot` for historical reasons: before #1594, styling was defined in `Avalonia.Styling` but the logical tree was defined in `Avalonia.Controls`. The styling system needed a root but because it was lower-level than the logical tree it had to define its own root type which was then repurposed for use by the logical tree.
Since #1594 the logical tree is defined in `Avalonia.Styling` as well so we might as well call `IStyleRoot` what it is: the logical tree root.
There were two problems:
- There were two root controls (`TestScroller` and `TestRoot`)
- The root control needs to have a fixed size otherwise it will grow because `LayoutManager` passes `MaxClientSize` to its measure (which may be different to the initial measure that we were using to set its size).
`VisualBrush`es need to get delegated back to the renderer for
rendering, so added an `IVisualBrushRenderer` interface which is
implemented by the renderers, and pass this when creating drawing
contexts. Only currently implemented/tested for D2D and
`ImmediateRenderer`.
There are still a few bugs around scrollbar behavior, and maybe Grid. To
see them, add a long item in the middle of VirtualizationTest's items,
resize the window to require a scrollbar and scroll up and down.
Rather than repainting whenever, this adds a render loop which is called
N times per second. IRenderQueueManager and ITopLevelRenderer have been
removed, replaced by IRenderer.
@donandren correctly identified a problem with the `ItemsPresenter` but
he put the tests in the `ListBox` tests. Moved them to the correct
place. Also tweak formatting in `ItemContainerGenerator.InsertSpace`.
When a virtualized list was scrolled to the bottom and then the list was
measured with a size larger than needed to fit all items (in this case
we use infinity) then the virtualizer tries to go backwards to add items
at the top of the currently visible items by setting `step = -1`;
however it didn't check whether the current index was < 0.
Fixes#589.
Don't add virtualized items before the virtualizing panel is attached to
the visual tree, as bindings etc won't be set and so measurement will
produce 0,0 causing all items to be materialized.