//  Copyright 2002-2014, University of Colorado Boulder

/**
 * Defines the appearance of the radio buttons, see RadioButtonGroup.js
 *
 * @author Sam Reid (PhET Interactive Simulations)
 * @author Aaron Davis (PhET Interactive Simulations)
 */
define( function( require ) {
  'use strict';

  // modules
  var Color = require( 'SCENERY/util/Color' );

  // constants
  var DISABLED_OPACITY = 0.3;

  /**
   * Strategy for buttons that look flat, i.e. no shading or highlighting, but
   * that change color on mouseover, press, etc.
   *
   * @param {Node} button
   * @param {Property} interactionStateProperty
   * @param {Object} [options]
   * @constructor
   */
  var defaultRadioButtonsAppearance = function( button, interactionStateProperty, options ) {

    // Set up variables needed to create the various fills and strokes
    var baseColor = Color.toColor( options.baseColor );
    var disabledBaseColor = Color.toColor( options.disabledBaseColor );
    var deselectedStroke = Color.toColor( options.deselectedStroke );

    // Create the fills and strokes used for various button states
    var disabledStroke = disabledBaseColor.colorUtilsDarker( 0.4 );
    var overStroke = deselectedStroke.colorUtilsDarker( 0.4 );
    var overFill = baseColor.colorUtilsBrighter( 0.4 );

    interactionStateProperty.link( function( state ) {
      switch( state ) {

        // deselected
        case 'idle':
          button.fill = baseColor;
          button.stroke = options.deselectedStroke;
          button.lineWidth = options.deselectedLineWidth;
          button.opacity = options.deselectedButtonOpacity;
          break;

        // mouseover for deselected buttons
        case 'over':
          button.fill = ( options.overFill ) ? options.overFill : overFill;
          button.stroke = ( options.overStroke ) ? options.overStroke : overStroke;
          button.lineWidth = ( options.overLineWidth ) ? options.overLineWidth : options.deselectedLineWidth;
          button.opacity = options.overButtonOpacity;
          break;

        // selected
        case 'pressed':
          button.fill = baseColor;
          button.stroke = options.selectedStroke;
          button.lineWidth = options.selectedLineWidth;
          button.opacity = options.selectedButtonOpacity;
          break;

        // disabled and deselected
        case 'disabled':
          button.fill = disabledBaseColor;
          button.stroke = disabledStroke;
          button.lineWidth = options.deselectedLineWidth;
          button.opacity = options.deselectedOpacity;
          break;

        // disabled and selected
        case 'disabled-pressed':
          button.fill = disabledBaseColor;
          button.stroke = disabledStroke;
          button.lineWidth = options.selectedLineWidth;
          button.opacity = options.selectedOpacity;
          break;
      }
    } );
  };

  var contentAppearanceStrategy = function( content, interactionStateProperty, options ) {

    // The button is not the parent of the content, therefore it is necessary to set the opacity on
    // the content separately if you wish to do so.
    interactionStateProperty.link( function( state ) {
      if ( content !== null ) {
        switch( state ) {

          // deselected
          case 'idle':
            content.opacity = options.deselectedContentOpacity;
            break;

          // mouseover for deselected buttons
          case 'over':
            content.opacity = options.overContentOpacity;
            break;

          // selected
          case 'pressed':
            content.opacity = options.selectedContentOpacity;
            break;

          // disabled and deselected
          case 'disabled':
            content.opacity = DISABLED_OPACITY;
            break;

          // disabled and selected
          case 'disabled-pressed':
            content.opacity = DISABLED_OPACITY;
            break;
        }
      }
    } );
  };

  return {
    defaultRadioButtonsAppearance: defaultRadioButtonsAppearance,
    contentAppearanceStrategy: contentAppearanceStrategy
  };

} );
@@ -2868,16 +2868,295 @@
 ;%0A  %7D;%0A%0A
+  /**%0A   * Strategy for changing the button content opacity for each of the different states:%0A   * mouseover, selected, deselected, and disabled%0A   *%0A   * @param %7BNode%7D button%0A   * @param %7BProperty%7D interactionStateProperty%0A   * @param %7BObject%7D %5Boptions%5D%0A   * @constructor%0A   */%0A
   var co
@@ -3230,32 +3230,32 @@
 ty, options ) %7B%0A
-
 %0A    // The butt
@@ -3339,16 +3339,16 @@
 city on%0A
+
     // t
@@ -3372,30 +3372,8 @@
 tely
- if you wish to do so.
 %0A   

add JSDoc to RBGA contentAppearanceStrategy, see #134