| 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 device pixels. |
| 32 // Must be >= 0. |
| 33 int32 min_width; |
| 34 |
| 35 // The maximum width of the view in device pixels. |
| 36 // Must be >= |min_width|. |
| 37 int32 max_width; |
| 38 |
| 39 // The minimum height of the view in device pixels. |
| 40 // Must be >= 0. |
| 41 int32 min_height; |
| 42 |
| 43 // The maximum height of the view in device 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. |
| 55 struct ViewLayoutParams { |
| 56 // The size constraints for the child. |
| 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 |
| 61 // in relation to display density and zoom level. |
| 62 // Must be > 0. |
| 63 float device_pixel_ratio = 1.0; |
| 64 }; |
| 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 device pixels. |
| 72 mojo.Size size; |
| 73 }; |
| OLD | NEW |