<commit_before>////////////////////////////////////////////////////////////////////////////////
//
//  ADOBE SYSTEMS INCORPORATED
//  Copyright 2011 Adobe Systems Incorporated
//  All Rights Reserved.
//
//  NOTICE: Adobe permits you to use, modify, and distribute this file
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////
package spark.layouts
{	
import flash.events.Event;
import flash.geom.Point;
import flash.geom.Rectangle;

import mx.core.ILayoutElement;
import mx.core.mx_internal;

import spark.components.supportClasses.GroupBase;
import spark.core.NavigationUnit;

use namespace mx_internal;

[ExcludeClass]

/**
 *  Custom wrapping layout for the SpinnerList
 */ 
public class VerticalSpinnerLayout extends VerticalLayout
{
	public function VerticalSpinnerLayout()
	{
		super();
	}
	
	//--------------------------------------------------------------------------
	//
	//  Variables
	//
	//--------------------------------------------------------------------------
	
	private function get totalHeight():Number
	{
		return Math.ceil(target.numElements * rowHeight);
	}
	
	// If true, then when the layout encounters a disabled element, it will scroll past it
	// in ascending index order. If false, then it will scroll in the descending index order
	mx_internal var autoScrollAscending:Boolean = true;
	
	mx_internal static const FORCE_NO_WRAP_ELEMENTS_CHANGE:String = "forceNoWrapElementsChange";
	
	//--------------------------------------------------------------------------
	//
	//  Properties
	//
	//--------------------------------------------------------------------------
	
	//----------------------------------
	//  requestedWrapElements
	//----------------------------------
	
	private var _requestedWrapElements:Boolean = true;
	
	/**
	 *  This is the suggested value for wrapElements. However, the layout might not honor this value
	 *  if there are too few elements to display in the viewable area. 
	 * 
	 *  @default true
	 */
	public function get requestedWrapElements():Boolean
	{
		return _requestedWrapElements;
	}
	
	public function set requestedWrapElements(value:Boolean):void
	{
		if (value == _requestedWrapElements)
			return;
		
		_requestedWrapElements = value;
		target.invalidateSize();
		target.invalidateDisplayList();
	}
	
	/**
	 *  If true, the layout has forced wrapElements to be false
	 */ 
	public var forceNoWrapElements:Boolean = false;
	
	//----------------------------------
	//  wrapElements
	//----------------------------------
	
	/**
	 *  When true, scrolling past the last element will scroll to the first element. 
	 * 
	 *  @default true
	 */
	public function get wrapElements():Boolean
	{
		if (forceNoWrapElements)
			return false;
		else
			return requestedWrapElements;
	}
	
	//--------------------------------------------------------------------------
	//
	//  Overridden methods
	//
	//--------------------------------------------------------------------------
		
	override public function measure():void
	{					
		var preferredWidth:Number = 0;  // max of the elt preferred widths
		
		var element:ILayoutElement;
		
		var iter:LayoutIterator = new LayoutIterator(target);
		
		if (useVirtualLayout)
		{
			if (typicalLayoutElement)
				preferredWidth = typicalLayoutElement.getPreferredBoundsWidth();
		}
		else
		{
			while (iter.visitedElementCount < target.numElements)
			{
				element = iter.nextWrappedElement();
				
				if (element)
				{
					// Get the largest width
					preferredWidth = Math.max(Math.ceil(element.getPreferredBoundsWidth()), preferredWidth);
				}
			}
		}
		
		var rowsToMeasure:int = getRowsToMeasure(target.numElements);
		
		// Calculate the height by multiplying the number of elements time the row height
		target.measuredHeight = Math.ceil(rowsToMeasure * rowHeight);
		target.measuredWidth = preferredWidth;
	}
	
    override public function updateDisplayList(width:Number, height:Number):void
    {
        var element:ILayoutElement;
        var numElements:int = target.numElements;
        
        var oldForceNoWrapElements:Boolean = forceNoWrapElements;
        
        // If there are fewer elements than will fit, we need to set wrapElements = false
        if (requestedWrapElements && (height > numElements * rowHeight))
            forceNoWrapElements = true;
        else
            forceNoWrapElements = false;
        
        if (forceNoWrapElements != oldForceNoWrapElements)
            dispatchEvent(new Event(FORCE_NO_WRAP_ELEMENTS_CHANGE));
        
        var scrollPosition:Number = wrapElements ? 
            normalizeScrollPosition(verticalScrollPosition) : 
            verticalScrollPosition;
		
		// TODO (jszeto) Modify LayoutIterator to not require seeding w/ index - 1
        var itemIndex:int = -1;
        var yPos:Number = 0;
        var numVisibleElements:int = -1;
        
        // Translate the vsp to the item index
        if (wrapElements)
        {<commit_msg>Transferred from the Adobe Open Source Subversion Repository<commit_after>////////////////////////////////////////////////////////////////////////////////
//
//  ADOBE SYSTEMS INCORPORATED
//  Copyright 2011 Adobe Systems Incorporated
//  All Rights Reserved.
//
//  NOTICE: Adobe permits you to use, modify, and distribute this file
//  in accordance with the terms of the license agreement accompanying it.
//
////////////////////////////////////////////////////////////////////////////////
package spark.layouts
{	
import flash.events.Event;
import flash.geom.Point;
import flash.geom.Rectangle;

import mx.core.ILayoutElement;
import mx.core.mx_internal;

import spark.components.supportClasses.GroupBase;
import spark.core.NavigationUnit;

use namespace mx_internal;

[ExcludeClass]

/**
 *  Custom wrapping layout for the SpinnerList
 */ 
public class VerticalSpinnerLayout extends VerticalLayout
{
	public function VerticalSpinnerLayout()
	{
		super();
	}
	
	//--------------------------------------------------------------------------
	//
	//  Variables
	//
	//--------------------------------------------------------------------------
	
	private function get totalHeight():Number
	{
		return Math.ceil(target.numElements * rowHeight);
	}
	
	// If true, then when the layout encounters a disabled element, it will scroll past it
	// in ascending index order. If false, then it will scroll in the descending index order
	mx_internal var autoScrollAscending:Boolean = true;
	
	mx_internal static const FORCE_NO_WRAP_ELEMENTS_CHANGE:String = "forceNoWrapElementsChange";
	
	//--------------------------------------------------------------------------
	//
	//  Properties
	//
	//--------------------------------------------------------------------------
	
	//----------------------------------
	//  requestedWrapElements
	//----------------------------------
	
	private var _requestedWrapElements:Boolean = true;
	
	/**
	 *  This is the suggested value for wrapElements. However, the layout might not honor this value
	 *  if there are too few elements to display in the viewable area. 
	 * 
	 *  @default true
	 */
	public function get requestedWrapElements():Boolean
	{
		return _requestedWrapElements;
	}
	
	public function set requestedWrapElements(value:Boolean):void
	{
		if (value == _requestedWrapElements)
			return;
		
		_requestedWrapElements = value;
		target.invalidateSize();
		target.invalidateDisplayList();
	}
	
	/**
	 *  If true, the layout has forced wrapElements to be false
	 */ 
	public var forceNoWrapElements:Boolean = false;
	
	//----------------------------------
	//  wrapElements
	//----------------------------------
	
	/**
	 *  When true, scrolling past the last element will scroll to the first element. 
	 * 
	 *  @default true
	 */
	public function get wrapElements():Boolean
	{
		if (forceNoWrapElements)
			return false;
		else
			return requestedWrapElements;
	}
	
	//--------------------------------------------------------------------------
	//
	//  Overridden methods
	//
	//--------------------------------------------------------------------------
		
	override public function measure():void
	{					
		var preferredWidth:Number = 0;  // max of the elt preferred widths
		
		var element:ILayoutElement;
		
		var iter:LayoutIterator = new LayoutIterator(target);
		
		if (useVirtualLayout)
		{
			if (typicalLayoutElement)
				preferredWidth = typicalLayoutElement.getPreferredBoundsWidth();
		}
		else
		{
			while (iter.visitedElementCount < target.numElements)
			{
				element = iter.nextWrappedElement();
				
				if (element)
				{
					// Get the largest width
					preferredWidth = Math.max(Math.ceil(element.getPreferredBoundsWidth()), preferredWidth);
				}
			}
		}
		
		var rowsToMeasure:int = getRowsToMeasure(target.numElements);
		
		// Calculate the height by multiplying the number of elements time the row height
		target.measuredHeight = Math.ceil(rowsToMeasure * Math.max(5, rowHeight));
		target.measuredWidth = preferredWidth;
	}
	
    override public function updateDisplayList(width:Number, height:Number):void
    {
        var element:ILayoutElement;
        var numElements:int = target.numElements;
        
        var oldForceNoWrapElements:Boolean = forceNoWrapElements;
        
        // If there are fewer elements than will fit, we need to set wrapElements = false
        if (requestedWrapElements && (height > numElements * rowHeight))
            forceNoWrapElements = true;
        else
            forceNoWrapElements = false;
        
        if (forceNoWrapElements != oldForceNoWrapElements)
            dispatchEvent(new Event(FORCE_NO_WRAP_ELEMENTS_CHANGE));
        
        var scrollPosition:Number = wrapElements ? 
            normalizeScrollPosition(verticalScrollPosition) : 
            verticalScrollPosition;
		
		// TODO (jszeto) Modify LayoutIterator to not require seeding w/ index - 1
        var itemIndex:int = -1;
        var yPos:Number = 0;
        var numVisibleElements:int = -1;
        
        // Translate the vsp to the item index
        if (wrapElements)
        {
{'fraction_non_alphanumeric': 0.21718471589784202, 'fraction_numerical': 0.0018808156800633538, 'mean_word_length': 1.7801320858558063, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7663317', 'n_tokens_mistral': 2750, 'n_tokens_neox': 2420, 'n_words': 706}