We need to compute whether a RenderObject has a composited descendant so that
we can decide whether to use canvas.saveLayer or to create a new composited
layer while walking down the tree during painting.
The compositing update walks the tree from the root only to places where the
tree's structure has been mutated. In the common case during an animation loop,
we won't need to visit any render object beyond the root.
Separating these notions makes them easier to work with because offset is
relative to the parent layer whereas size is intrinsic to the layer itself.
This patch fixes the underpainting bugs when compositing the stocks example.
Now we have the ability to draw multiple PictureLayers. We still squash all the
pictures together into a single SkPicture for simplicity. In the future, we'll
submit them to C++ separately and composite them on the GPU thread.
This patch prepares for introducing the compositing system by repurposing the
relevant parts of the createsNewDisplayList system. This patch also removes the
no-longer-relevant parts of that system.
Previously we were doing the bounds testing for hit tests in the parent, but
that doesn't work if the child paints at a location other than 0.0, 0.0. Now we
do the bounds check in the child. This also simplifies Scaffold's hit testing.
Fixes#558
Now that we get sky.Image callbacks synchronously, we were actually figuring in
the width and height of images the second time the drawer opened in the Stocks
app. That exposed a bug in our RenderImage layout code whereby it would ignore
the _width and _height properties when the image was non-null.
Added a ScrollListener listener to Scrollable. The ScrollListener runs each time the Scrollable's scrollOffset changes. This can be used to keep overlay widgets in sync with a Scrollable below them.
Removed the Scrollable ScrollClient API. It was no longer used and was clumsy to use as a ScrollListener.
Added global function findScrollableAncestor() to scrollable.dart.
Added examples/widgets/overlay_geometry.dart. The app's Scaffold is contained by a Stack. The Stack is used to display green overlay "Markers" at the corners of the most recently selected list item and where the corresponding tap occurred. The app uses widget.localToGlobal() to compute the global overlay positions of the markers. The ScrollListener is used to keep the markers' positions up to date.
Using ImageResource solves two problems:
1) Listeners can be notified synchronously when the sky.Image is already
available. This change removes flash of 0x0 layout when moving an
already-cached image around in the render tree.
2) In the future, when we support animated images, we can notify listeners
multiple times whenever a new image is available.
This patch simplifies the SkPicture we generate for Skia. Instead of drawing
everything into a nested SkPicture, we now draw everything into the top-level
picture, which requires us to apply the device scale factor in Dart.
- Inline -> Pargraph. This class is actually a box, not an inline. It's really
a wrapper for RenderParagraph, so Paragraph is the normal name.
- InlineBase -> RenderInline. The name we used in C++ for the base class of
all inlines was RenderInline, which removes the ugly "Base" suffix.
- InlineText -> RenderText. Aligns this name with C++.
- InlineStyle -> RenderStyled. Matches the foregoing pattern.
Now ScrollableBlock can combine a horizontally scrolling viewport with a
horizontal block.
Also rename ViewportScrollDirection to just ScrollDirection for less verbosity.
This ensures we don't run into discontinuities when reversing an
animation halfway through. I refactored AnimationValue to have knowledge
of the reverse curves and intervals.
This refactors Checkbox to own a RenderObject similar to how Switch was
refactored in https://github.com/domokit/sky_engine/pull/376 and
extracts common functionality for toggleable renderers into a base
class. Switch and Checkbox's render objects derive from this base
class to add their own custom painting and theming logic.
This introduces the notion of event disposition and allows event
targets (widgets and render objects) to consume events that should not
be processed further. This is needed by the Switch component in the
Drawer in the stocks example. The Switch is embedded in a DrawerItem.
The Switch handles the gesture tap event to toggle its state and should
handle pointer events to allow swiping and draw its own radial
reaction. The DrawerItem also handles gesture taps to allow toggling
the switch value when tapping anywhere on the drawer and to draw its
own ink splash. When tapping on the switch, both the switch's render
object and the DrawerItem's listener are in the event dispatch path.
The Switch needs to signal in some fashion that it consumed the event
so the DrawerItem does not also try to toggle the switch's state.
We were applying the style to the RenderInline but we actually needed to apply
it to the RenderParagraph. The lineHeight property had the same problem.
When embedded by the view_manager, sometimes we receive pointerup or
pointercancel events without having received a cooresponding pointerdown event.
The underlying issue is that the view_manager doesn't capture on pointerdown
and instead performs a new hit test for every pointer event. We should fix that
in view_manager, but, in the meantime, this patch makes us not crash in this
scenario.
Fixes#339
Rather than using a microtask to schedule component build functions, instead
use the scheduler. We now tread building just like layout and painting as a
visual update.
If your constraints are tight when you get laid out, you don't get a
relayout subtree root.
If you don't have a relayout subtree root, and you get marked dirty,
you go through layoutWithoutResize() rather than layout(), so we don't
get a parentUsesSize.
If you're not dirty and your constraints didn't change, layout() skips
your layout.
So then if your initial layout had parentUsesSize:true, and then you
got marked dirty directly, you would set your size with
parentCanUseSize=false, and then later if your parent tried to lay you
out then read your size, it would crash because your size wasn't set
up to allow you to get your size.
The fix is to actually remember the last setting of parentUsesSize,
even in the case of the constraints being tight and you later being
marked as needing layout directly.
This change makes it easier to defined only the width or the height of an image
and let the other value be filled in from the image's intrinsic aspect ratio.
Fixes#175