Skip to content

Commit

Permalink
code cleanup for RectangularButtonView, added message to custom corne…
Browse files Browse the repository at this point in the history
…r button, see #454
  • Loading branch information
jbphet committed Mar 7, 2019
1 parent ccdea51 commit bc1edfa
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
18 changes: 9 additions & 9 deletions js/buttons/RectangularButtonView.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ define( function( require ) {
cornerRadius: 4,

// {number|null} corner-specific radii
// If null, the option is ignore.
// If null, the option is ignored.
// If non-null, it overrides cornerRadius for the associated corner of the button.
leftTopCornerRadius: null,
rightTopCornerRadius: null,
Expand Down Expand Up @@ -197,17 +197,17 @@ define( function( require ) {
/**
* Convenience function for creating the shape of the button, done to avoid code duplication
* @param {number} width
* @param {height} height
* @param {Object} options - RectangularButtonView options, containing values related to radii of button corners
* @param {number} height
* @param {Object} config - RectangularButtonView config, containing values related to radii of button corners
* @returns {Shape}
*/
function createButtonShape( width, height, options ) {
assert && assert( typeof options.cornerRadius === 'number', 'cornerRadius is required' );
function createButtonShape( width, height, config ) {
assert && assert( typeof config.cornerRadius === 'number', 'cornerRadius is required' );
return Shape.roundedRectangleWithRadii( 0, 0, width, height, {
topLeft: options.leftTopCornerRadius !== null ? options.leftTopCornerRadius : options.cornerRadius,
topRight: options.rightTopCornerRadius !== null ? options.rightTopCornerRadius : options.cornerRadius,
bottomLeft: options.leftBottomCornerRadius !== null ? options.leftBottomCornerRadius : options.cornerRadius,
bottomRight: options.rightBottomCornerRadius !== null ? options.rightBottomCornerRadius : options.cornerRadius
topLeft: config.leftTopCornerRadius !== null ? config.leftTopCornerRadius : config.cornerRadius,
topRight: config.rightTopCornerRadius !== null ? config.rightTopCornerRadius : config.cornerRadius,
bottomLeft: config.leftBottomCornerRadius !== null ? config.leftBottomCornerRadius : config.cornerRadius,
bottomRight: config.rightBottomCornerRadius !== null ? config.rightBottomCornerRadius : config.cornerRadius
} );
}

Expand Down
3 changes: 2 additions & 1 deletion js/demo/ButtonsScreenView.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ define( function( require ) {
leftTopCornerRadius: 20,
rightTopCornerRadius: 10,
rightBottomCornerRadius: 5,
leftBottomCornerRadius: 0
leftBottomCornerRadius: 0,
listener: function() { message( 'Custom corner button pressed' ); }
} );

var buttonD = new RoundPushButton( {
Expand Down

0 comments on commit bc1edfa

Please sign in to comment.