OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 [DartPackage="mojo_services"] | 5 [DartPackage="mojo_services"] |
6 module mojo.gfx.composition; | 6 module mojo.gfx.composition; |
7 | 7 |
8 import "mojo/services/geometry/interfaces/geometry.mojom"; | 8 import "mojo/services/geometry/interfaces/geometry.mojom"; |
9 import "mojo/services/gfx/composition/interfaces/scene_token.mojom"; | 9 import "mojo/services/gfx/composition/interfaces/scene_token.mojom"; |
10 | 10 |
11 // Indicates that hit testing is not needed for a given node. | 11 // Determines how a node behaves during hit testing. |
12 const uint32 kHitIdNone = 0; | 12 // |
| 13 // See |Node| for more details of the hit testing traversal process. |
| 14 struct HitTestBehavior { |
| 15 // The visibility specifies how a node itself is hit and its effect on |
| 16 // the hit testing traversal. |
| 17 enum Visibility { |
| 18 // The node can be hit and prevents other targets visually behind the |
| 19 // node from being hit. This is the default. |
| 20 // |
| 21 // Opaque targets are useful for UI elements like buttons which cover and |
| 22 // block interaction with content visually behind them. |
| 23 OPAQUE, |
13 | 24 |
14 // Provides information about the point of intersection of a hit test with | 25 // The node can be hit and allows other targets visually behind the node |
15 // a node in a scene graph. | 26 // to also be hit. |
16 struct Hit { | 27 // |
17 // The scene token of the scene which was hit. | 28 // Translucent targets are useful for UI elements like dimissed drawers |
18 SceneToken scene_token; | 29 // which may not obscure content visually behind them but which do need |
| 30 // to intercept gestures in that area (perhaps to reveal themselves). |
| 31 TRANSLUCENT, |
19 | 32 |
20 // The version of the scene which was consulted as part of evaluating the | 33 // The node cannot be hit. |
21 // hit test. | 34 // |
22 uint32 scene_version; | 35 // Invisible targets are useful for explicitly suppressing hit testing |
| 36 // for a node and its children when combined with the |prune| flag. |
| 37 INVISIBLE, |
| 38 }; |
23 | 39 |
24 // The node id of the node which was hit. | 40 // Specifies the visibility of the node for hit testing purposes. |
25 uint32 node_id; | 41 // The default is opaque. |
| 42 Visibility visibility = Visibility.OPAQUE; |
26 | 43 |
27 // The hit test id of the node which was hit. | 44 // When set to true, prevents a node's children from being hit tested. |
28 uint32 hit_id; | 45 bool prune = false; |
29 | 46 |
30 // The coordinates of the hit within the node's content space. | 47 // The rectangle within the node's content space to test for hits. |
31 mojo.Point intersection; | 48 // If null, the node's entire clip region is tested for hits. |
32 }; | 49 // |
33 | 50 // TODO(jeffbrown): Support more complex hit test regions and masks. |
34 // The result of a hit test operation. | 51 mojo.Rect? hit_rect; |
35 struct HitTestResult { | |
36 // A sorted list of hits in dispatch order from the top-most hit node | |
37 // to the nodes underneath it and containing it, or an empty array if none. | |
38 // Omits nodes for which the hit_id was |kHitIdNone|. | |
39 array<Hit> hits; | |
40 }; | 52 }; |
41 | 53 |
42 // A hit testing service for scene graphs. | 54 // A hit testing service for scene graphs. |
43 interface HitTester { | 55 interface HitTester { |
44 // Performs a hit test on the specified point. | 56 // Performs a hit test on the specified point. |
45 // | 57 // |
46 // TODO(jeffbrown): Specify a timestamp to allow for hit-tests of geometry | 58 // TODO(jeffbrown): Specify a presentation timestamp to allow for |
47 // as it appeared in the recent past. | 59 // hit-tests of geometry as it appeared to the user in the recent past. |
48 HitTest(mojo.Point point) => (HitTestResult result); | 60 HitTest(mojo.Point point) => (HitTestResult result); |
49 }; | 61 }; |
| 62 |
| 63 // The result of a hit test operation. |
| 64 // |
| 65 // Hit test results form a hit tree with information about the nodes which |
| 66 // were hit and the scenes which contain them. The structure of the hit |
| 67 // tree reflects the path that the scene graph was traversed during the |
| 68 // hit test. |
| 69 // |
| 70 // To walk the hit nodes in dispatch order, perform a post-order traversal |
| 71 // of the hit tree starting at |root| and processing children before their |
| 72 // parents. |
| 73 struct HitTestResult { |
| 74 // A tree of hits beginning at the root scene, or null if nothing was hit. |
| 75 SceneHit? root; |
| 76 }; |
| 77 |
| 78 // An element in a hit tree. |
| 79 // This either contains a reference to another scene which contains hits or |
| 80 // to a specific node within the containing scene which was hit. |
| 81 union Hit { |
| 82 SceneHit scene; |
| 83 NodeHit node; |
| 84 }; |
| 85 |
| 86 // Describes a collection of hits within a scene. |
| 87 struct SceneHit { |
| 88 // The scene token of the scene which contains hits. |
| 89 SceneToken scene_token; |
| 90 |
| 91 // The version of the scene which was consulted at the time the hit test |
| 92 // was performed. |
| 93 uint32 scene_version; |
| 94 |
| 95 // The array of hits within this scene, in dispatch order. |
| 96 // This list always contains at least one entry. |
| 97 array<Hit> hits; |
| 98 }; |
| 99 |
| 100 // Describes the point of intersection of a hit test with a node. |
| 101 struct NodeHit { |
| 102 // The node id of the node which was hit. |
| 103 uint32 node_id; |
| 104 |
| 105 // The coordinates of the hit within the node's content space. |
| 106 mojo.Point intersection; |
| 107 }; |
OLD | NEW |