Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 [DartPackage="mojo_services"] | |
| 6 module mojo.ui; | |
| 7 | |
| 8 import "mojo/services/geometry/interfaces/geometry.mojom"; | |
| 9 import "mojo/services/surfaces/interfaces/surface_id.mojom"; | |
| 10 | |
| 11 // Box constraints for layout. | |
| 12 // | |
| 13 // A box constraint allows a parent view to determine the size of its child | |
| 14 // by constraining its width and height. Each dimension is considered | |
| 15 // independently. If a constraint only admits a single value in one or both | |
| 16 // dimensions (because the minimum and maximum values are equal) then it is | |
| 17 // said to be "tight" in those dimension. | |
| 18 // | |
| 19 // A |Size| respects this constraint if, and only if, all of the following | |
| 20 // relations hold: | |
| 21 // | |
| 22 // size.width >= constraints.min_width | |
| 23 // size.width <= constraints.max_width | |
| 24 // size.height >= constraints.min_height | |
| 25 // size.height <= constraints.max_height | |
| 26 // | |
| 27 // The view manager validates all constraints before delivering them to a | |
| 28 // child view; it will close its connection if the parent view supplies | |
| 29 // constraints which are ill-formed. | |
| 30 struct BoxConstraints { | |
| 31 // The minimum width of the view in pixels. | |
| 32 // Must be >= 0. | |
|
jamesr
2015/10/26 19:35:38
we could express this constraint in the type syste
jeffbrown
2015/10/27 01:49:07
We could. I was debating whether to use uint32 or
| |
| 33 int32 min_width; | |
| 34 | |
| 35 // The maximum width of the view in pixels. | |
| 36 // Must be >= |min_width|. | |
|
jamesr
2015/10/26 19:35:38
we don't have a way to validate on this automatica
jeffbrown
2015/10/27 01:49:07
True, which is why it's documented. The implement
| |
| 37 int32 max_width; | |
| 38 | |
| 39 // The minimum height of the view in pixels. | |
| 40 // Must be >= 0. | |
| 41 int32 min_height; | |
| 42 | |
| 43 // The maximum height of the view in pixels. | |
| 44 // Must be >= |min_height|. | |
| 45 int32 max_height; | |
| 46 }; | |
| 47 | |
| 48 // Layout parameters provided by a parent view to one of its children. | |
| 49 // | |
| 50 // TODO(jeffbrown): We will eventually need to pass a bunch more information | |
| 51 // such as theme colors, virtual light sources for shadows, elevation, and | |
| 52 // more. It is unclear whether we'll want to put that information here | |
| 53 // or somewhere else but it may be convenient to stash it here because we | |
| 54 // will already have an invalidation mechanism in place. | |
|
abarth-chromium
2015/10/24 05:09:30
The way we handle this issue in Flutter is that we
jeffbrown
2015/10/27 01:49:07
Hmm. This bears further consideration. We may ne
| |
| 55 struct ViewLayoutParams { | |
| 56 // The size constraints for the child in pixels. | |
|
jamesr
2015/10/26 19:35:38
"in pixels" is ambiguous - what sort of pixels?
jeffbrown
2015/10/27 01:49:07
Logical pixels. I'll clarify the docs.
| |
| 57 mojo.ui.BoxConstraints constraints; | |
| 58 | |
| 59 // The ratio between the size of one display device pixel to the size | |
| 60 // of one logical pixel, assuming pixels are square. This value changes | |
|
jamesr
2015/10/26 19:35:38
what uses logical pixels and what uses device pixe
jeffbrown
2015/10/27 01:49:06
Everything here uses integer device pixels. The a
| |
| 61 // in relation to display density and zoom level. | |
| 62 // Must be > 0. | |
| 63 float device_pixel_ratio = 1.0; | |
|
jamesr
2015/10/26 19:35:38
seems a bit odd to have this be a constraint on a
jeffbrown
2015/10/27 01:49:07
It's not a constraint. It's a parameter that's ne
| |
| 64 }; | |
|
abarth-chromium
2015/10/24 05:09:30
We'll probably need a bunch more metrics about the
jeffbrown
2015/10/27 01:49:07
I don't think views should care about the overall
| |
| 65 | |
| 66 // Layout information for a view. | |
| 67 struct ViewLayoutInfo { | |
| 68 // The view's surface ID for composition by the parent. | |
| 69 mojo.SurfaceId surface_id; | |
| 70 | |
| 71 // The actual size of the view in pixels, or null if not provided. | |
| 72 // This information must always be returned by a view during OnLayout() | |
| 73 // but will only be provided to the parent upon request. | |
| 74 mojo.Size? size; | |
| 75 }; | |
| OLD | NEW |