Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(696)

Side by Side Diff: sky/sdk/lib/rendering/README.md

Issue 1189343002: Start fleshing out the rendering/README.md (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/sdk/lib/base/README.md ('k') | sky/sdk/lib/widgets/README.md » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 This directory introduces a layout and painting system built on the 1 Sky Rendering
2 Sky APIs. It depends on Dart primitives, ../base/*, ../mojo/*, and 2 =============
3 ../animation/*. 3
4 The Sky render tree is a low-level layout and painting system based on a
5 retained tree of objects that inherit from [`RenderObject`](object.dart). Most
6 developers using Sky will not need to interact directly with the rendering tree.
7 Instead, most developers should use [Sky widgets](../widgets/README.md), which
8 are built using the render tree.
9
10 Base Model
11 ----------
12
13 The base class for every node in the render tree is
14 [`RenderObject`](object.dart), which defines the base layout model. The base
15 layout mode is extremely general and can accomodate a large number of more
16 concrete layout models that can co-exist in the same tree. For example, the base
17 model does not commit to a fixed number of dimensions or even a cartesian
18 coordinate system. In this way, a single render tree can contain render objects
19 operating in three-dimensional space together with other render objects
20 operating in two-dimensional space, e.g., on the face of a cube in the three-
21 dimensional space. Moreover, the two-dimensional layout might be partially
22 computed in cartesian coordinates and partially computed in polar coordinates.
23 These distinct models can interact during layout, for example determining the
24 size of the cube by the height of a block of text on the cube's face.
25
26 Not entirely free-wheeling, the base model does impose some structure on the
27 render tree:
28
29 * Subclasses of `RenderObject` must implement a `performLayout` function that
30 takes as input a `constraints` object provided by its parent. `RenderObject`
31 has no opinion about the structure of this object and different layout models
32 use different types of constraints. However, whatever type they choose must
33 implement `operator==` in such a way that `performLayout` produces the same
34 output for two `constraints` objects that are `operator==`.
35
36 * Implementations of `performLayout` are expected to call `layout` on their
37 children. When calling `layout`, a `RenderObject` must use the
38 `parentUsesSize` parameter to declare whether its `performLayout` function
39 depends on information read from the child. If the parent doesn't declare
40 that it uses the child's size, the edge from the parent to the child becomes
41 a _relayout boundary_, which means the child (and its subtree) might undergo
42 layout without the parent undergoing layout.
43
44 * Subclasses of `RenderObject` must implement a `paint` function that draws a
45 visual representation of the object onto an `RenderObjectDisplayList`. If
46 the `RenderObject` has children, the `RenderObject` is responsible for
47 painting its children using the `paintChild` function.
48
49 * Subclasses of `RenderObject` must call `adoptChild` whenever they add a
50 child. Similarly, they must call `dropChild` whenever they remove a child.
51
52 * Most subclasses of `RenderObject` will implement a `hitTest` function that
53 lets clients query the render tree for objects that intersect with a given
54 user input location. `RenderObject` itself does not impose a particular
55 type signature on `hitTest`, but most implementations will take an argument
56 of type `HitTestResult` (or, more likely, a model-specific subclass of
57 `HitTestResult`) as well as an object that describes the location at which
58 the user provided input (e.g., a `Point` for a two-dimensional cartesian
59 model).
60
61 * Finally, subclasses of `RenderObject` can override the default, do-nothing
62 implemenations of `handleEvent` and `rotate` to respond to user input and
63 screen rotation, respectively.
64
65 The base model also provides two mixins for common child models:
66
67 * `RenderObjectWithChildMixin` is useful for subclasses of `RenderObject` that
68 have a unique child.
69
70 * `ContainerRenderObjectMixin` is useful for subclasses of `RenderObject` that
71 have a child list.
72
73 Subclasses of `RenderObject` are not required to use either of these child
74 models and are free to invent novel child models for their specific use cases.
75
76 Parent Data
77 -----------
78
79
80 Box Model
81 ---------
82
83
84 Bespoke Models
85 --------------
86
87
88 Dependencies
89 ------------
90
91 * [`package:sky/base`](../base)
92 * [`package:sky/mojo`](../mojo)
93 * [`package:sky/animation`](../mojo)
OLDNEW
« no previous file with comments | « sky/sdk/lib/base/README.md ('k') | sky/sdk/lib/widgets/README.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698