Class: SC.SplitView


Extends SC.View.

SC.SplitView arranges multiple views side-by-side or on top of each other.

By default, SC.SplitView sets size and position properties on the child views, leaving it up to the child view to adjust itself. For good default behavior, mix SC.SplitChild into your child views.

SplitView can resize its children to fit (the default behavior), or resize itself to fit its children--allowing you to build column- based file browsers and the like. As one child (a divider, most likely) is moved, SplitView can move additional children to get them out of the way.

Setting Up SplitViews

You can set up a split view like any other view in SproutCore:

SplitView.design({
  childViews: ['leftPanel', 'rightPanel'],

  leftPanel: SC.View.design(SC.SplitChild, {
    minimumSize: 200
  }),

  rightPanel: SC.View.design(SC.SplitChild, {
    // it is usually the right panel you want to resize
    // as the SplitView resizes:
    autoResizeStyle: SC.RESIZE_AUTOMATIC
  })
})

Dividers

Dividers are automatically added between every child view.

You can specify what dividers to create in two ways:

As far as SplitView is concerned, dividers are actually just ordinary child views. They usually have an autoResizeStyle of SC.FIXED_SIZE, and usually mixin SC.SplitThumb to relay mouse and touch events to the SplitView. To prevent adding dividers between dividers and views or dividers and dividers, SC.SplitView marks all dividers with an isSplitDivider property.

If you do not want to use split dividers at all, or wish to set them up manually in your childViews array, set splitDividerView to null.

Defined in: split.js

Field Summary

Instance Methods

Field Detail

Read Only
childViews Array
Default value:
['topLeftView', 'bottomRightView']
See:
SC.View#childViews
Read Only
classNames Array
Default value:
['sc-split-view']
See:
SC.View#classNames
Read Only
isSplitView Boolean
Used by the splitView computed property to find the nearest SplitView.
Default value:
true
layoutDirection LayoutDirection

Determines whether the SplitView should lay out its children horizontally or vertically.

Possible values:

  • SC.LAYOUT_HORIZONTAL: side-by-side
  • SC.LAYOUT_VERTICAL: on top of each other
Default value:
SC.LAYOUT_HORIZONTAL
needsTiling

Whether the SplitView needs to be re-laid out. You can change this by calling scheduleTiling.

shouldResizeChildrenToFit Boolean

Determines whether the SplitView should attempt to resize its child views to fit within the SplitView's own frame (the default).

If NO, the SplitView will decide its own size based on its children.

Default value:
true
splitChildCursorStyle String

The cursor of the child view currently being dragged (if any). This allows the cursor to be used even if the user drags "too far", past the child's own boundaries.

Default value:
null
splitDividerView SC.View

The class of view to create for the divider views. Override this to use a subclass of SC.SplitDividerView, or to implment your own.

Default value:
SC.SplitDividerView

Instance Method Detail

adjustPositionForChild(child, position)

Attempts to adjust the position of a child view, such as a divider.

The implementation for this may be overridden in the delegate method splitViewAdjustPositionForChild.

You may use this method to automatically collapse the view by setting the view's position to the position of the next or previous view (accessible via the child's nextView and previousView properties and the getPositionForChild method).

Parameters:
child SC.View
The child to move.
position Number
The position to move the child to.
Returns:
Number
The position to which the child was actually moved.
createChildViews()
didAddChild()
didRemoveChild()
getPositionForChild(child)

Returns the position within the split view for a child view, such as a divider. This position is not necessarily identical to the view's actual layout 'left' or 'right'; that position could be offset--for instance, to give a larger grab area to the divider.

The implementation for this is in the delegate method splitViewGetPositionForChild.

Parameters:
child SC.View
The child whose position to find.
Returns:
Number
The position.
scheduleTiling()
Schedules a retile of the SplitView.
splitViewAdjustPositionForChild(splitView, child, position)

Attempts to move a single child from its current position to a desired position.

You may override the behavior on a delegate.

Parameters:
splitView SC.SplitView
The splitView whose child should be moved.
child SC.View
The child which should be moved.
position Number
The position to attempt to move the child to.
Returns:
Number
The final position of the child.
splitViewConstrainSizeForChild(splitView, child, position)

Returns the nearest valid size to a proposed size for a child view. By default, constrains the size to the range specified by the child's minimumSize and maximumSize properties, and returns 0 if the child has canCollapse set and the size is less than the child's collapseAtSize.

You may override this in a delegate.

Parameters:
splitView SC.SplitView
The SplitView which owns the child.
child SC.View
The child.
position Number
The proposed size for the child.
Returns:
Number
splitViewDividerBetween(splitView, view1, view2)

Returns a view instance to be used as a divider between two other views, or null if no divider should be used.

The value of the 'splitDividerView' property will be instantiated. The default value of this property is 'SC.SplitDividerView'. If the value is null or undefined, null will be returned, and the SplitView will not automatically create dividers.

You may override this method in a delegate.

Parameters:
splitView SC.SplitView
The split view that is hte parent of the two views.
view1 SC.View
The first view.
view2 SC.View
The second view.
Returns:
SC.View
The view instance to use as a divider.
splitViewGetPositionForChild(splitView, child)

Returns the current position for the specified child.

You may override this in a delegate.

Parameters:
splitView SC.SplitView
The SplitView which owns the child.
child SC.View
The child.
Returns:
Number
splitViewGetSizeForChild(splitView, child)

Returns the current size for the specified child.

You may override this in a delegate.

Parameters:
splitView SC.SplitView
The SplitView which owns the child.
child SC.View
The child.
Returns:
Number
splitViewLayoutChildren(splitView)

Lays out the children one next to each other or one on top of the other, based on their sizes. It returns the total size.

You may override this method in a delegate.

Parameters:
splitView SC.SplitView
The SplitView whose children need layout.
Returns:
Number
The total size of all the SplitView's children.
splitViewResizeChildrenToFit(splitView, contentSize)

Attempts to resize the child views of the split view to fit in the SplitView's frame. So it may proportionally adjust the child views, the current size of the SplitView's content is passed.

You may override this method in a delegate.

Parameters:
splitView SC.SplitView
The SC.SplitView whose children should be resized.
contentSize Number
The current not-yet-resized size of the SplitView's content.
splitViewSetPositionForChild(splitView, child, position)

Sets the position for the specified child.

You may override this in a delegate.

Parameters:
splitView SC.SplitView
The SplitView which owns the child.
child SC.View
The child.
position Number
The position to move the child to.
splitViewSetSizeForChild(splitView, child, position)

Sets the size for the specified child.

You may override this in a delegate.

Parameters:
splitView SC.SplitView
The SplitView which owns the child.
child SC.View
The child.
position Number
The size to give the child.
splitViewShouldResizeChildToFit(splitView, child)

Determines whether the SplitView should attempt to resize the specified child view when the SplitView's size changes.

You may override this method in a delegate.

Parameters:
splitView SC.SplitView
The SplitView that owns the child.
child SC.View
The child view.
Returns:
Boolean
tileIfNeeded()
Documentation generated by JsDoc Toolkit 2.4.0 on Wed Apr 08 2015 10:02:21 GMT-0600 (CST)