AmbidextrousList, can have its scrollbar on the left or right side.
In fact, it can be swapped while the user is dragging it... git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@463 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -0,0 +1,58 @@
|
|||||||
|
package com.threerings.flex {
|
||||||
|
|
||||||
|
import mx.controls.List;
|
||||||
|
|
||||||
|
import mx.core.EdgeMetrics;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A list that can be configured with the vertical scrollbar on the left or right side.
|
||||||
|
*/
|
||||||
|
public class AmbidextrousList extends List
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Get whether the scrollbar is on the left side.
|
||||||
|
*/
|
||||||
|
public function get scrollBarOnLeft () :Boolean
|
||||||
|
{
|
||||||
|
return _scrollLeft;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets whether to place the scrollbar on the left or right side.
|
||||||
|
*/
|
||||||
|
public function set scrollBarOnLeft (scrollLeft :Boolean) :void
|
||||||
|
{
|
||||||
|
_scrollLeft = scrollLeft;
|
||||||
|
|
||||||
|
scrollAreaChanged = true;
|
||||||
|
invalidateDisplayList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @inheritDoc */
|
||||||
|
override public function get viewMetrics () :EdgeMetrics
|
||||||
|
{
|
||||||
|
var em :EdgeMetrics = super.viewMetrics;
|
||||||
|
|
||||||
|
if (_scrollLeft && verticalScrollBar && verticalScrollBar.visible) {
|
||||||
|
em.right -= verticalScrollBar.minWidth;
|
||||||
|
em.left += verticalScrollBar.minWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
return em;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @inheritDoc */
|
||||||
|
override protected function updateDisplayList (uw :Number, uh :Number) :void
|
||||||
|
{
|
||||||
|
super.updateDisplayList(uw, uh);
|
||||||
|
|
||||||
|
if (_scrollLeft) {
|
||||||
|
var vm :EdgeMetrics = viewMetrics;
|
||||||
|
verticalScrollBar.move(vm.left - verticalScrollBar.minWidth, vm.top);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Do we want to have the scrollbar on the left? */
|
||||||
|
protected var _scrollLeft :Boolean;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user