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:
Set
splitDividerView
to change the default divider view class to use.Override
splitViewDividerBetween
(splitView, view1, view2), either in your subclass ofSC.SplitView
or in a delegate, and return the divider view instance that should go between the two views.
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
- childViews
- classNames
- isSplitView
- layoutDirection
- needsTiling
- shouldResizeChildrenToFit
- splitChildCursorStyle
- splitDividerView
- Fields borrowed from SC.View:
- acceptsFirstResponder, acceptsMultitouch, ariaHidden, ariaRole, attributeBindings, autoMixins, backgroundColor, childViewLayout, childViewLayoutOptions, childViewsNeedLayout, classNameBindings, concatenatedProperties, createdByParent, designMode, displayProperties, enabledState, firstKeyView, hasLayout, hasTouch, hasVisibility, isBuildingIn, isBuildingOut, isChildViewLayoutLive, isEnabled, isFixedHeight, isFixedPosition, isFixedSize, isFixedWidth, isKeyResponder, isTextSelectable, isView, isVisible, lastKeyView, layerLocationNeedsUpdate, layerNeedsUpdate, layout, modeAdjust, nextKeyView, page, pane, parentView, previousKeyView, renderDelegateName, shouldInheritCursor, shouldInheritEnabled, tagName, themeName, toolTip, touchBoundary, transitionAdjust, transitionAdjustOptions, transitionHide, transitionHideOptions, transitionIn, transitionInOptions, transitionOut, transitionOutOptions, transitionShow, transitionShowOptions, useStaticLayout
- Fields borrowed from SC.Responder:
- hasFirstResponder, isFirstResponder, responderContext
- Fields borrowed from SC.Object:
- isDestroyed, isObject, nextProperty, object, property, target, toInvalidate
- Fields borrowed from SC.Observable:
- isObservable
Instance Methods
- adjustPositionForChild(child, position)
- createChildViews()
- didAddChild()
- didRemoveChild()
- getPositionForChild(child)
- scheduleTiling()
- splitViewAdjustPositionForChild(splitView, child, position)
- splitViewConstrainSizeForChild(splitView, child, position)
- splitViewDividerBetween(splitView, view1, view2)
- splitViewGetPositionForChild(splitView, child)
- splitViewGetSizeForChild(splitView, child)
- splitViewLayoutChildren(splitView)
- splitViewResizeChildrenToFit(splitView, contentSize)
- splitViewSetPositionForChild(splitView, child, position)
- splitViewSetSizeForChild(splitView, child, position)
- splitViewShouldResizeChildToFit(splitView, child)
- tileIfNeeded()
Field Detail
- Default value:
- ['topLeftView', 'bottomRightView']
- See:
- SC.View#childViews
- Default value:
- ['sc-split-view']
- See:
- SC.View#classNames
- Default value:
- true
Determines whether the SplitView should lay out its children horizontally or vertically.
Possible values:
SC.LAYOUT_HORIZONTAL
: side-by-sideSC.LAYOUT_VERTICAL
: on top of each other
- Default value:
- SC.LAYOUT_HORIZONTAL
Whether the SplitView needs to be re-laid out. You can change this by
calling scheduleTiling
.
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
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
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
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.
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.
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.
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
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.
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
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
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.
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.
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.
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.
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