<commit_before>// Copyright 2014-2019, University of Colorado Boulder

/**
 * Horizontal bar placed above something that can be expanded/collapsed.
 *
 * @author <NAME> (PixelZoom, Inc.)
 */
define( require => {
  'use strict';

  // modules
  const ExpandCollapseButton = require( 'SUN/ExpandCollapseButton' );
  const inherit = require( 'PHET_CORE/inherit' );
  const merge = require( 'PHET_CORE/merge' );
  const Node = require( 'SCENERY/nodes/Node' );
  const Rectangle = require( 'SCENERY/nodes/Rectangle' );
  const Shape = require( 'KITE/Shape' );
  const sun = require( 'SUN/sun' );
  const Tandem = require( 'TANDEM/Tandem' );

  /**
   * @param {Node} titleNode
   * @param {Property.<boolean>} expandedProperty
   * @param {Object} [options]
   * @constructor
   */
  function ExpandCollapseBar( titleNode, expandedProperty, options ) {

    options = merge( {
      buttonLength: 15,
      minWidth: 1, // minimum width of the bar
      minHeight: 1, // minimum height of the bar
      cornerRadius: 6,
      xMargin: 10,
      yMargin: 8,
      xSpacing: 10,
      barFill: 'white',
      barStroke: 'black',
      barLineWidth: 1,
      tandem: Tandem.REQUIRED
    }, options );

    Node.call( this );

    // expand/collapse button
    const button = new ExpandCollapseButton( expandedProperty, {
      sideLength: options.buttonLength,
      tandem: options.tandem.createTandem( 'button' )
    } );
    button.touchArea = Shape.bounds( button.localBounds.dilatedXY( 10, 10 ) );

    // bar
    const barWidth = Math.max( options.minWidth, titleNode.width + button.width + options.xSpacing + ( 2 * options.xMargin ) );
    const barHeight = Math.max( options.minHeight, Math.max( titleNode.height, button.height ) + ( 2 * options.yMargin ) );
    const barNode = new Rectangle( 0, 0, barWidth, barHeight, options.cornerRadius, options.cornerRadius, {
      fill: options.barFill,
      stroke: options.barStroke,
      lineWidth: options.barLineWidth
    } );

    // rendering order
    this.addChild( barNode );
    this.addChild( titleNode );
    this.addChild( button );

    // layout
    titleNode.left = barNode.left + options.xMargin;
    titleNode.centerY = barNode.centerY;
    button.right = barNode.right - options.xMargin;
    button.centerY = barNode.centerY;
  }

  sun.register( 'ExpandCollapseBar', ExpandCollapseBar );

  return inherit( Node, ExpandCollapseBar );
} );<commit_msg>ExpandCollapseBar fix, instrument in ph-scale, https://github.com/phetsims/sun/issues/562, https://github.com/phetsims/ph-scale/issues/98<commit_after>// Copyright 2014-2019, University of Colorado Boulder

/**
 * Horizontal bar placed above something that can be expanded/collapsed.
 *
 * @author <NAME> (PixelZoom, Inc.)
 */
define( require => {
  'use strict';

  // modules
  const ExpandCollapseButton = require( 'SUN/ExpandCollapseButton' );
  const inherit = require( 'PHET_CORE/inherit' );
  const merge = require( 'PHET_CORE/merge' );
  const Node = require( 'SCENERY/nodes/Node' );
  const Rectangle = require( 'SCENERY/nodes/Rectangle' );
  const Shape = require( 'KITE/Shape' );
  const sun = require( 'SUN/sun' );
  const Tandem = require( 'TANDEM/Tandem' );

  /**
   * @param {Node} titleNode
   * @param {Property.<boolean>} expandedProperty
   * @param {Object} [options]
   * @constructor
   */
  function ExpandCollapseBar( titleNode, expandedProperty, options ) {

    options = merge( {
      buttonLength: 15,
      minWidth: 1, // minimum width of the bar
      minHeight: 1, // minimum height of the bar
      cornerRadius: 6,
      xMargin: 10,
      yMargin: 8,
      xSpacing: 10,
      barFill: 'white',
      barStroke: 'black',
      barLineWidth: 1,
      tandem: Tandem.REQUIRED
    }, options );

    Node.call( this );

    // expand/collapse button
    const button = new ExpandCollapseButton( expandedProperty, {
      sideLength: options.buttonLength,
      tandem: options.tandem.createTandem( 'button' )
    } );
    button.touchArea = Shape.bounds( button.localBounds.dilatedXY( 10, 10 ) );

    // bar
    const barWidth = Math.max( options.minWidth, titleNode.width + button.width + options.xSpacing + ( 2 * options.xMargin ) );
    const barHeight = Math.max( options.minHeight, Math.max( titleNode.height, button.height ) + ( 2 * options.yMargin ) );
    const barNode = new Rectangle( 0, 0, barWidth, barHeight, options.cornerRadius, options.cornerRadius, {
      fill: options.barFill,
      stroke: options.barStroke,
      lineWidth: options.barLineWidth
    } );

    // rendering order
    this.addChild( barNode );
    this.addChild( titleNode );
    this.addChild( button );

    // layout
    titleNode.left = barNode.left + options.xMargin;
    titleNode.centerY = barNode.centerY;
    button.right = barNode.right - options.xMargin;
    button.centerY = barNode.centerY;

    this.mutate( options );
  }

  sun.register( 'ExpandCollapseBar', ExpandCollapseBar );

  return inherit( Node, ExpandCollapseBar );
} );
{'fraction_non_alphanumeric': 0.12622917920931165, 'fraction_numerical': 0.011840256873369457, 'mean_word_length': 3.132669983416252, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '1842111', 'n_tokens_mistral': 1655, 'n_tokens_neox': 1561, 'n_words': 382}