module Webglimpse { export function newTimelineLayout ( axisHeight ) { return { updatePrefSize : function ( parentPrefSize , children ) { var topAxis = null ; var bottomAxis = null ; var center = null ; for ( var c = 0 ; c < children . length ; c ++ ) { var child = children [ c ] ; switch ( child . layoutArg ) { case Side . TOP : if ( hasval ( topAxis ) ) throw new Error ( 'Timeline-layout can have at most one top-axis pane' ) ; topAxis = child ; break ; case Side . BOTTOM : if ( hasval ( bottomAxis ) ) throw new Error ( 'Timeline-layout can have at most one bottom-axis pane' ) ; bottomAxis = child ; break ; default : if ( hasval ( center ) ) throw new Error ( 'Timeline-layout can have at most one center pane' ) ; center = child ; break ; } } var hSum = 0 ; if ( hasval ( topAxis ) ) { hSum += axisHeight ; } if ( hasval ( bottomAxis ) ) { hSum += axisHeight ; } if ( hasval ( center ) ) { if ( hasval ( center . prefSize . h ) ) { hSum += center . prefSize . h ; } else { hSum = null ; } } parentPrefSize . w = null ; parentPrefSize . h = hSum ; } , updateChildViewports : function ( children , parentViewport ) { var topAxis = null ; var bottomAxis = null ; var center = null ; for ( var c = 0 ; c < children . length ; c ++ ) { var child = children [ c ] ; switch ( child . layoutArg ) { case Side . TOP : if ( hasval ( topAxis ) ) throw new Error ( 'Timeline-layout can have at most one top-axis pane' ) ; topAxis = child ; break ; case Side . BOTTOM : if ( hasval ( bottomAxis ) ) throw new Error ( 'Timeline-layout can have at most one bottom-axis pane' ) ; bottomAxis = child ; break ; default : if ( hasval ( center ) ) throw new Error ( 'Timeline-layout can have at most one center pane' ) ; center = child ; break ; } } if ( hasval ( topAxis ) ) { topAxis . viewport . setRect ( parentViewport . i , parentViewport . jEnd - axisHeight , parentViewport . w , axisHeight ) ; } if ( hasval ( bottomAxis ) ) { var jBottomMax = ( hasval ( topAxis ) ? topAxis . viewport . j : parentViewport . jEnd ) - axisHeight ; bottomAxis . viewport . setRect ( parentViewport . i , Math . min ( jBottomMax , parentViewport . j ) , parentViewport . w , axisHeight ) ; } if ( hasval ( center ) ) { var jCenterEnd = ( hasval ( topAxis ) ? topAxis . viewport . jStart : parentViewport . jEnd ) ; var jCenterStart = ( hasval ( bottomAxis ) ? bottomAxis . viewport . jEnd : parentViewport . jStart ) ; center . viewport . setEdges ( parentViewport . iStart , parentViewport . iEnd , jCenterStart , jCenterEnd ) ; } } } ; } }