1 module fluid.container; 2 3 import fluid.node; 4 import fluid.tree; 5 import fluid.input; 6 import fluid.actions; 7 import fluid.backend; 8 9 10 @safe: 11 12 13 /// A interface for nodes that contain and control other nodes. 14 /// 15 /// See_Also: https://git.samerion.com/Samerion/Fluid/issues/14 16 interface FluidContainer { 17 18 /// Scroll towards the given children node. This should change the parent's properties (without affecting the child) 19 /// so that the child enters the viewport, or becomes as close to it as possible. 20 /// Params: 21 /// child = Node to scroll towards. Must be a direct child of this node. 22 /// viewport = Size of the current viewport. The parent should 23 /// parentBox = This node's current padding box. 24 /// childBox = The child's current padding box. 25 /// Returns: 26 /// Estimated new padding box for the child. 27 /// See_Also: 28 /// `fluid.actions.scrollIntoView` for recursive scrolling via `TreeAction`. 29 Rectangle shallowScrollTo(Node child, Vector2 viewport, Rectangle parentBox, Rectangle childBox); 30 31 /// Set focus on the first available focusable node in this tree. 32 final void focusChild() { 33 34 asNode.focusRecurseChildren(); 35 36 } 37 38 final inout(Node) asNode() inout { 39 40 import std.format; 41 42 auto node = cast(inout Node) this; 43 44 assert(node, format!"%s : FluidContainer must inherit from a Node"(typeid(this))); 45 46 return node; 47 48 } 49 50 private final LayoutTree* getTree() 51 out (r; r !is null, "Container needs a resize to associate with a tree") 52 do { 53 54 return asNode.tree; 55 56 } 57 58 }