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

/**
 * Check box.
 *
 * @author <NAME> (PixelZoom, Inc.)
 */
define( function( require ) {
  'use strict';

  // imports
  var ButtonListener = require( 'SCENERY/input/ButtonListener' );
  var FontAwesomeNode = require( 'SUN/FontAwesomeNode' );
  var inherit = require( 'PHET_CORE/inherit' );
  var Node = require( 'SCENERY/nodes/Node' );
  var Rectangle = require( 'SCENERY/nodes/Rectangle' );

  /**
   * @param {Node} content
   * @param {Property<Boolean>} property
   * @constructor
   * @param options
   */
  function CheckBox( content, property, options ) {
    var checkBox = this;
    options = _.extend(
      {
        spacing: 5,
        boxScale: 0.6,
        cursor: 'pointer',
        checkBoxColor: 'black'
      }, options );

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

    var x = options.boxScale / 0.75;

    //Make the background white.  Until we are creating our own shapes, just put a white rectangle behind the font awesome check box icons
    var whiteBackground = new Rectangle( 0, -25 * x, 25 * x, 25 * x, 5 * x, 5 * x, {fill: 'white'} );

    var checkedNode = new FontAwesomeNode( 'check', { scale: options.boxScale, fill: options.checkBoxColor } );
    var uncheckedNode = new FontAwesomeNode( 'check_empty', { scale: options.boxScale, fill: options.checkBoxColor } );

    thisNode.addChild( whiteBackground );
    thisNode.addChild( checkedNode );
    thisNode.addChild( uncheckedNode );
    thisNode.addChild( content );

    content.left = checkedNode.right + options.spacing;
    content.centerY = checkedNode.centerY;

    // put a rectangle on top of everything to prevent dead zones which clicking
    thisNode.addChild( new Rectangle( thisNode.left, thisNode.top, thisNode.width, thisNode.height ) );

    // interactivity
    thisNode.addInputListener( new ButtonListener( {
      fire: function() {
        property.value = !property.value;
      }
    } ) );

    // sync with property
    property.link( function( checked ) {
      checkedNode.visible = checked;
      uncheckedNode.visible = !checked;
    } );
<commit_msg>use touchArea instead of a Rectangle overlay, and allow optional padding<commit_after>// Copyright 2002-2013, University of Colorado Boulder

/**
 * Check box.
 *
 * @author <NAME> (PixelZoom, Inc.)
 */
define( function( require ) {
  'use strict';

  // imports
  var ButtonListener = require( 'SCENERY/input/ButtonListener' );
  var FontAwesomeNode = require( 'SUN/FontAwesomeNode' );
  var inherit = require( 'PHET_CORE/inherit' );
  var Node = require( 'SCENERY/nodes/Node' );
  var Rectangle = require( 'SCENERY/nodes/Rectangle' );
  var Shape = require( 'KITE/Shape' );

  /**
   * @param {Node} content
   * @param {Property<Boolean>} property
   * @constructor
   * @param options
   */
  function CheckBox( content, property, options ) {
    var checkBox = this;
    options = _.extend(
      {
        spacing: 5,
        boxScale: 0.6,
        cursor: 'pointer',
        checkBoxColor: 'black',

        //TODO: Should these default to something larger?
        touchAreaTopPadding: 0,
        touchAreaBottomPadding: 0,
        touchAreaLeftPadding: 0,
        touchAreaRightPadding: 0
      }, options );

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

    var x = options.boxScale / 0.75;

    //Make the background white.  Until we are creating our own shapes, just put a white rectangle behind the font awesome check box icons
    var whiteBackground = new Rectangle( 0, -25 * x, 25 * x, 25 * x, 5 * x, 5 * x, {fill: 'white'} );

    var checkedNode = new FontAwesomeNode( 'check', { scale: options.boxScale, fill: options.checkBoxColor } );
    var uncheckedNode = new FontAwesomeNode( 'check_empty', { scale: options.boxScale, fill: options.checkBoxColor } );

    thisNode.addChild( whiteBackground );
    thisNode.addChild( checkedNode );
    thisNode.addChild( uncheckedNode );
    thisNode.addChild( content );

    content.left = checkedNode.right + options.spacing;
    content.centerY = checkedNode.centerY;

    // put a rectangle on top of everything to prevent dead zones which clicking
    thisNode.mouseArea = thisNode.touchArea = Shape.rectangle( thisNode.left - options.touchAreaLeftPadding, thisNode.top - options.touchAreaTopPadding, thisNode.width + options.touchAreaLeftPadding + options.touchAreaRightPadding, thisNode.height + options.touchAreaTopPadding + options.touchAreaBottomPadding );

    // interactivity
    thisNode.addInputListener( new ButtonListener( {
      fire: function() {
        property.value = !property.value;
      }
    } ) );

    // sync with property
    property.link( function( checked ) {
      checkedNode.visible = checked;
      uncheckedNode.visible = !checked;
    } );

{'fraction_non_alphanumeric': 0.1147985806720935, 'fraction_numerical': 0.010436234606553955, 'mean_word_length': 3.0782978723404257, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '453617', 'n_tokens_mistral': 1474, 'n_tokens_neox': 1389, 'n_words': 405}