95 Commits

Author SHA1 Message Date
Eric Seidel
19766c05de Merge pull request #878 from eseidelGoogle/grid
Add basic Grid widget and test RenderGrid
2015-08-27 15:55:39 -07:00
Hixie
a6e6b93b14 Allow parents of RenderObjects that have layout callbacks to depend on those objects' sizes.
Previously, if you used a layout callback, you could not have a parent
that did parentUsesSize, or if you did, you had to be marked
sizedByParent. With this patch, we allow the parent to depend on your
layout, even if you modify your child list during your layout using a
layout callback, by checking that the parent is still actively being
laid out in this scenario.
2015-08-27 15:26:57 -07:00
Adam Barth
45f2c58987 Add PointerRouter
This patch is the first step towards implementing gestures. The pointer router
allows the gesture detectors to hook in at the end of the pointer event
propagation chain.

Related to #145
2015-08-27 15:02:35 -07:00
Eric Seidel
b58f850e63 Add a Widget wrapper around Grid and test RenderGrid
@abarth
2015-08-27 14:52:19 -07:00
Hixie
e6f34f8666 Abstract out syncChildren().
The core of MultiChildRenderObjectWrapper.syncRenderObject() could
apply to any subclass that uses a flat child list, so this abstracts
it out into the superclass.

(Also, instead of requiring the callbacks of RenderBlockViewport to
constrain their results, we just constrain it for them. Makes things a
bit easier for users of that class.)
2015-08-26 16:56:25 -07:00
Ian Hickson
7a4bdc7f2a Merge pull request #870 from Hixie/RenderBlockViewport
Generalise RenderBlockViewport so that it can be used by a Widget that knows its children's dimensions.
2015-08-26 15:16:43 -07:00
Hixie
b1468cb2ea ShrinkWrapHeight widget
- add debugDescribeSettings to a few classes that were missing it
- fix some minor bugs in RenderShrinkWrapWidth and ShrinkWrapWidth
- introduce RenderShrinkWrapHeight and ShrinkWrapHeight
2015-08-26 15:07:53 -07:00
Hixie
04a8fe8e6b Generalise RenderBlockViewport so that it can be used by a Widget that knows its children's dimensions. 2015-08-26 14:25:53 -07:00
Eric Seidel
b122969624 Add support for RenderGrid
I'll write the Widget wrapper in the next CL, including adding
support for padding at the Widget layer.

@Hixie
2015-08-26 13:52:30 -07:00
Ian Hickson
bdc77e868c Merge pull request #863 from Hixie/mixed-viewport-changes
Make RenderBlockViewport shrink-wrap its children in the main axis direction
2015-08-26 13:43:55 -07:00
Ian Hickson
f5fdc1cf1b Merge pull request #852 from Hixie/sizing-docs
Update the documentation on sizing, make another assert point to it.
2015-08-26 13:25:17 -07:00
Hixie
301d0d3774 Make RenderBlockViewport shrink-wrap its children in the main axis direction. 2015-08-26 13:19:04 -07:00
Andrew Wilson
6215abec4d Change generic value names to be more descriptive for assert tracing. 2015-08-26 12:22:38 -07:00
Hixie
a951bf685e Update the documentation on sizing, make another assert point to it.
This hopefully explains things well enough that it fixes #846, after a manner.
2015-08-26 10:10:56 -07:00
Hixie
ce28a7176e Replace Flex to Row and Column in tests and examples.
This still leaves Flex and FlexDirection available. At some point once
people have transitioned to Row/Column we should rename Flex to _Flex
and stop reexporting FlexDirection from basic.dart.
2015-08-26 09:05:14 -07:00
Adam Barth
4923f0cd08 Merge pull request #813 from abarth/device_pixel_ratio
Don't freeze devicePixelRatio at startup
2015-08-25 14:55:01 -07:00
Adam Barth
1883d06aef Fix build
I removed these functions by mistake in my previous patch.
2015-08-25 14:10:32 -07:00
Adam Barth
a733e91b7b Don't freeze devicePixelRatio at startup
When we start, we might not have initialized the devicePixelRatio value. The
value will be initialized by the time we paint, so now we update the value
every time we paint.
2015-08-25 14:06:53 -07:00
Adam Barth
0e4ac8c12b Use sky.SceneBuilder to upload Layer tree to C++
We still use SkPicture as our rasterization backend, but now we're uploading
our layer tree to C++. A future patch will push the layer tree deeper into the
system and we'll eventually switch backends.
2015-08-25 13:41:37 -07:00
Hans Muller
aaeaed9be8 done 2015-08-25 09:41:28 -07:00
Hixie
14f3f58cd9 Make Flex shrink-wrap when unconstrained. 2015-08-24 17:34:44 -07:00
Hixie
d99641dd85 Better exception handling for rendering library.
- Catch exceptions closer to the source.
- Factor out exception printing code.
- Have widget library hand the rendering library some context when syncing RenderObjectWrappers to aid with debugging.
- Fix a bug in flex.dart whereby _overflow was compared when null.
2015-08-24 15:13:04 -07:00
Hans Muller
a61f0f5021 RenderObject.flushLayout should loop until _nodesNeedingLayout is empty 2015-08-24 12:49:41 -07:00
Hixie
d81ec90c5f Reimplement 'stretch' for flexible items correctly.
Fixes #698 to actually work.
Also, adds some debugging aids around Flex.
And a test to check this fix.
2015-08-21 16:47:44 -07:00
Hixie
dda253bb29 Reorder bootstrapping code in rendering/ for slightly cleaner code. 2015-08-20 15:31:10 -07:00
Adam Barth
de966121c8 Merge pull request #714 from abarth/stack_squish
Stack squishes positioned elements near the edge
2015-08-20 11:25:35 -07:00
Adam Barth
077e75e87b Remove RenderView.paintFrame
We now use the repaint system to do all the painting. During initialization, we
set up a root layer that applies the device pixel ratio.

Fixes #706
2015-08-20 11:24:33 -07:00
Adam Barth
f7aa83238f Stack squishes positioned elements near the edge
When laying out positioned children inside a stack, we should give them
unbounded constraints because if they draw outside of the stack, we'll just
clip them.
2015-08-20 11:15:15 -07:00
Adam Barth
8a3285b6c5 Split up paintChildWithPaint into paintChildWithOpacity and paintChildWithColorFilter
The compositor backends we're planning to use can't handle a general-purpose
paint layer and instead need lower-level operations.

Fixes #707
2015-08-20 10:28:23 -07:00
Hixie
654fc7346e Improvements for Layers logic
- Introduce some new Layer classes.
- Introduce paintChildWith* methods.
- Convert paint() methods to use paintChildWith* where appropriate.
- Fix paintBounds logic in Layer world.
- Introduce Layer.replaceWith(), so that it's clearer what's going on.
- Make RenderObjects have a ContainerLayer, not a PictureLayer.
- Introduce a PaintingContext.replacingLayer() constructor to highlight
  where we are creating a layer just to replace an older one.
- Rename some layer-related methods and fields for clarity:
   requiresCompositing -> hasLayer
   hasCompositedDescendant -> needsCompositing
   updateCompositing -> updateCompositingBits
   _needsCompositingUpdate -> _needsCompositingBitsUpdate
   markNeedsCompositingUpdate -> markNeedsCompositingBitsUpdate
- After updating compositing bits, if we find that the bit changed, we
  now call markNeedsPaint().
- Reorder markNeedsPaint() logic for clarity.
- Make flushPaint() start at the deepest node.
- Make _compositeChild() avoid repainting children with hasLayer that
  aren't dirty, instead it just reuses their existing layer.
- Made RenderView reuse the RenderObject layer instead of having its own.
- Made RenderView have hasLayer set to true.
- Add various asserts and comments.
2015-08-20 08:57:22 -07:00
Hixie
2c44ed0f01 Implement 'stretch' for flexible items. 2015-08-19 13:28:28 -07:00
Adam Barth
8f0efd54ff Add the ability to draw a foreground box decoration
This feature lets you create effects similar to the "outline" property in CSS.
2015-08-19 09:36:40 -07:00
Adam Barth
dea3a0922c Add package:sky/rendering.dart
Similar to widgets.dart, rendering.dart exports the entire rendering layer.
Also, update the examples to use rendering.dart and widgets.dart. Also clean up
some exports so that the examples have more sensible imports.
2015-08-18 21:39:51 -07:00
Adam Barth
50bfdedbf4 Split box.dart into many files
Sadly, box.dart has grown much longer than 1000 lines. This patch splits it up
into several files based on the class hierarchy. Fortunately, many of these
classes are loosely coupled to each other.
2015-08-18 20:55:32 -07:00
Adam Barth
5b40e03129 RenderImage should handle the case of a null image
When given a null image, RenderImage should be as small as possible (isntead of
being NaNxNaN).

Also, plumb ImageFit and ImageRepeat through the various image widgets.
2015-08-18 20:05:52 -07:00
Adam Barth
6cc103cf07 Borders on Containers shouldn't overlap the content
This CL inflates the padding of Container to account for the borders so that
the borders are allocated space in the layout and don't draw behind the
Container's child.
2015-08-18 16:10:40 -07:00
Adam Barth
b7421fcbf1 Improve RenderImage constraint solving
We now fold the width and height properties into the constraints and try to
find a size for the image that perserves the image's intrinsict aspect ratio
while fitting within the given constraints.
2015-08-18 15:23:04 -07:00
Adam Barth
0ad2c11cc6 Apply ImageFit and ImageRepeat to RenderImage
These properties should apply to foreground images as well as background
images. Also, rename these types from BackgroundFit and BackgroundRepeat
because they apply to things other than backgrounds.
2015-08-18 11:11:31 -07:00
Hixie
e4ac518908 Port clipping to the new layer world.
- Add Canvas.getSaveCount()
- Make RenderClipRect call context.paintChildWithClip instead of doing the clipping itself
- Make ClipLayer take a Rect instead of a Size
- Make PaintingContext.canvas read-only
- Add PaintingContext.paintChildWithClip()
- Minor rearrangings of code and style tweaks
2015-08-18 08:34:42 -07:00
Adam Barth
ac0ec3221b Add support for drag-and-drop
Widgets that want to receive drops should include a DropTarget in their build.
Currently there's no widget for initiating a drag. Components can use the
DragController directly. In the future, we'll probably want to add a Draggable
that knows how to do some of this work automatically.

Fixes #612
2015-08-17 14:06:19 -07:00
Collin Jackson
779f5743e5 Refactor of text rendering into painting layer 2015-08-14 13:30:56 -07:00
Adam Barth
d291fcaecd Merge pull request #620 from abarth/compositing_update
Add a compositing update phase
2015-08-14 11:09:28 -07:00
Adam Barth
e17aa1b63a Add a compositing update phase
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.
2015-08-14 10:47:39 -07:00
Adam Barth
e0f14e3719 Add debug painting for layer borders
This patch makes it easier to debug layerization issues.
2015-08-14 10:46:53 -07:00
Adam Barth
86da2f9bf4 Separate the notions of offset and size in compositing
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.
2015-08-14 09:49:38 -07:00
Adam Barth
53884a37de Generalize _cleanRelayoutSubtreeRootChildren into visitChildren
This generalization will let us implement other alogorithims that need to walk
the RenderObject tree.
2015-08-14 09:37:19 -07:00
Adam Barth
bf260f98e3 Add a compositing step to the lifecycle
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.
2015-08-13 16:31:45 -07:00
Adam Barth
7cba729110 Switch painting over to using PictureLayer
Currently we have a single PictureLayer that everyone draws into. A future
patch will teach the system to use multiple PictureLayers.
2015-08-13 14:24:29 -07:00
Adam Barth
be8454073a Rename createsNewDisplayList to requiresCompositing
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.
2015-08-13 12:43:39 -07:00
Adam Barth
c80603cf0e Add PaintingContext which has-a sky.Canvas instead of is-a sky.Canvas
We'll need this for compositing because we need to switch out the sky.Canvas
when we switch compositing layers.
2015-08-13 10:18:33 -07:00