<commit_before>// Copyright 2013-2015, University of Colorado Boulder

/**
 * A default slider track, currently intended for use only in HSlider.
 *
 * HSliderTrack is composed of two rectangles, one for the enabled section of the
 * track and one for the disabled section.  The enabled track rectangle sits on top of the disabled track so that
 * the enabled range can be any desired sub range of the full slider range.
 *
 * @author <NAME> (PixelZoom, Inc.)
 * @author <NAME> (PhET Interactive Simulations)
 * @author <NAME> (PhET Interactive Simulations)
 */
define( function( require ) {
  'use strict';

  // modules
  var Dimension2 = require( 'DOT/Dimension2' );
  var inherit = require( 'PHET_CORE/inherit' );
  var Node = require( 'SCENERY/nodes/Node' );
  var Property = require( 'AXON/Property' );
  var Rectangle = require( 'SCENERY/nodes/Rectangle' );
  var sun = require( 'SUN/sun' );
  var Tandem = require( 'TANDEM/Tandem' );
  var SimpleDragHandler = require( 'SCENERY/input/SimpleDragHandler' );

  // phet-io modules
  var THSliderTrack = require( 'SUN/THSliderTrack' );

  /**
   * @param {Property.<number>} valueProperty
   * @param {function} valueToPosition - linear function that maps property value to position along the track
   * @param {function} snapToValue - function to snap to a value if slider should snap to a value on drag end
   * @param {Object} [options]
   * @constructor
   */
  function HSliderTrack( valueProperty, valueToPosition, snapToValue, options ) {

    var self = this;
    Node.call( this );

    options = _.extend( {
      size: new Dimension2( 100, 5 ),
      fillEnabled: 'white',
      fillDisabled: 'gray',
      stroke: 'black',
      lineWidth: 1,
      cornerRadius: 0,
      enabledProperty: new Property( true ), // is the track enabled?
      startDrag: function() {}, // called when a drag sequence starts
      endDrag: function() {}, // called when a drag sequence ends
      snapValue: null, // if specified, slider will snap to this value on end drag
      constrainValue: function( value ) { return value; }, // called before valueProperty is set

      // phet-io
      tandem: Tandem.tandemRequired()

    }, options );

    // @private
    this.size = options.size;
    this.enabledProperty = options.enabledProperty;

    // @public
    this.valueToPosition = valueToPosition;
    this.snapValue = options.snapValue;

    // @private
    this.disabledTrack = new Rectangle( 0, 0, this.size.width, this.size.height, {
      fill: options.fillDisabled,
      stroke: options.stroke,
      lineWidth: options.lineWidth,
      cornerRadius: options.cornerRadius,
      cursor: 'default'
    } );
    this.addChild( this.disabledTrack );

    // @private<commit_msg>improve documentation for HSliderTrack enabledRectangle and disabledRectangle, see #308<commit_after>// Copyright 2013-2015, University of Colorado Boulder

/**
 * A default slider track, currently intended for use only in HSlider.
 *
 * HSliderTrack is composed of two rectangles, one for the enabled section of the track and one for the disabled
 * section.  The enabled track rectangle sits on top of the disabled track so that the enabled range can be any
 * desired sub range of the full slider range.
 *
 * @author <NAME> (PixelZoom, Inc.)
 * @author <NAME> (PhET Interactive Simulations)
 * @author <NAME> (PhET Interactive Simulations)
 */
define( function( require ) {
  'use strict';

  // modules
  var Dimension2 = require( 'DOT/Dimension2' );
  var inherit = require( 'PHET_CORE/inherit' );
  var Node = require( 'SCENERY/nodes/Node' );
  var Property = require( 'AXON/Property' );
  var Rectangle = require( 'SCENERY/nodes/Rectangle' );
  var sun = require( 'SUN/sun' );
  var Tandem = require( 'TANDEM/Tandem' );
  var SimpleDragHandler = require( 'SCENERY/input/SimpleDragHandler' );

  // phet-io modules
  var THSliderTrack = require( 'SUN/THSliderTrack' );

  /**
   * @param {Property.<number>} valueProperty
   * @param {function} valueToPosition - linear function that maps property value to position along the track
   * @param {function} snapToValue - function to snap to a value if slider should snap to a value on drag end
   * @param {Object} [options]
   * @constructor
   */
  function HSliderTrack( valueProperty, valueToPosition, snapToValue, options ) {

    var self = this;
    Node.call( this );

    options = _.extend( {
      size: new Dimension2( 100, 5 ),
      fillEnabled: 'white',
      fillDisabled: 'gray',
      stroke: 'black',
      lineWidth: 1,
      cornerRadius: 0,
      enabledProperty: new Property( true ), // is the track enabled?
      startDrag: function() {}, // called when a drag sequence starts
      endDrag: function() {}, // called when a drag sequence ends
      snapValue: null, // if specified, slider will snap to this value on end drag
      constrainValue: function( value ) { return value; }, // called before valueProperty is set

      // phet-io
      tandem: Tandem.tandemRequired()

    }, options );

    // @private
    this.size = options.size;
    this.enabledProperty = options.enabledProperty;

    // @public
    this.valueToPosition = valueToPosition;
    this.snapValue = options.snapValue;

    // @private - Represents the disabled range of the slider, always visible and always the full range
    // of the slider so that when the enabled range changes we see the enabled sub-range on top of the
    // full range of the slider.
    this.disabledTrack = new Rectangle( 0, 0, this.size.width, this.size.height, {
      fill: options.fillDisabled,
      stroke: options.stroke,
      lineWidth: options.lineWidth,
      cornerRadius: options.cornerRadius,
      cursor: 'default'
    } );
    this.addChild( this.disabledTrack );

    // @private - Will change size depending on the enabled range of the slider.  On top so that we can see
    // the enabled sub-range of the slider.
{'fraction_non_alphanumeric': 0.10362343379613952, 'fraction_numerical': 0.006942092786996275, 'mean_word_length': 3.1657263751763045, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '187670', 'n_tokens_mistral': 1727, 'n_tokens_neox': 1656, 'n_words': 615}