| // Copyright 2014 The Chromium Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| |
| module mojo.services.view_manager { |
| |
| struct INode { |
| uint32 parent_id; |
| uint32 node_id; |
| uint32 view_id; |
| }; |
| |
| // Functions that mutate the hierarchy take a |change_id|. |change_id| is an |
| // arbitrary value assigned by the client originating the change. It may be |
| // used by the client originating the change to later identify the change in |
| // an OnNodeHierarchyChanged callback. |change_id| is only passed to the client |
| // that originated the change; all other clients get a value of 0. |
| // |
| // Nodes are identified by a uint32. The upper 16 bits are the connection id, |
| // and the lower 16 the id assigned by the client. CreateNode() only takes a |
| // uint16 as the connection id of the originating connection is used. |
| // |
| // The root node is identified with a connection id of 0, and value of 1. |
| [Peer=IViewManagerClient] |
| interface IViewManager { |
| // Creates a new node with the specified id. It is up to the client to ensure |
| // the id is unique to the connection (the id need not be globally unique). |
| CreateNode(uint16 node_id) => (bool success); |
| |
| // Deletes a node. This does not recurse. Children are removed from the node |
| // before it is destroyed. |
| DeleteNode(uint32 node_id, uint32 change_id) => (bool success); |
| |
| // Reparents a node. See description above class for details of |change_id|. |
| AddNode(uint32 parent, uint32 child, uint32 change_id) => (bool success); |
| |
| // Removes a view from its current parent. See description above class for |
| // details of |change_id|. |
| RemoveNodeFromParent(uint32 node_id, uint32 change_id) => (bool success); |
| |
| // Returns the nodes comprising the tree starting at |node_id|. |node_id| is |
| // the first result in the return value, unless |node_id| is invalid, in which |
| // case an empty vector is returned. The nodes are visited using a depth first |
| // search (pre-order). |
| GetNodeTree(uint32 node_id) => (INode[] nodes); |
| |
| // Creates a new view with the specified id. It is up to the client to ensure |
| // the id is unique to the connection (the id need not be globally unique). |
| CreateView(uint16 view_id) => (bool success); |
| |
| // Deletes the view with the specified id. |
| DeleteView(uint32 view_id, uint32 change_id) => (bool success); |
| |
| // Sets the view a node is showing. |
| SetView(uint32 node_id, uint32 view_id, uint32 change_id) => (bool success); |
| }; |
| |
| [Peer=IViewManager] |
| interface IViewManagerClient { |
| // Invoked once the connection has been established. |connection_id| is the id |
| // used to uniquely identify the connection. |
| OnConnectionEstablished(uint16 connection_id); |
| |
| // Invoked when a change is done to the hierarchy. A value of 0 is used to |
| // identify a null node. For example, if the old_parent is NULL, 0 is |
| // supplied. See description above ViewManager for details on |change_id|. |
| OnNodeHierarchyChanged(uint32 node, |
| uint32 new_parent, |
| uint32 old_parent, |
| uint32 change_id); |
| |
| // Invoked when the view associated with a node is replaced by another view. |
| // 0 is used to identify a null view. |
| OnNodeViewReplaced(uint32 node, |
| uint32 new_view_id, |
| uint32 old_view_id, |
| uint32 change_id); |
| }; |
| |
| } |