'From etoys4.0 of 9 October 2008 [latest update: #2251] on 21 August 2009 at 11:19:10 am'! "Change Set: PianoKeyboardMorph Date: 15 March 2009 Author: Karl Ramberg Makes the piano keyboard about twice as big"! !PianoKeyboardMorph methodsFor: 'simple keyboard' stamp: 'kfr 3/15/2009 23:01'! buildKeyboard | wtWid bkWid keyRect octavePt nWhite nBlack keyHeight | self removeAllMorphs. wtWid _16. bkWid _ 10. keyHeight _ 75. self extent: 10@10. 1 to: nOctaves+1 do: [:i | i <= nOctaves ifTrue: [nWhite _ 7. nBlack _ 5] ifFalse: [nWhite _ 1. nBlack _ 0 "High C"]. octavePt _ self innerBounds topLeft + ((7*wtWid*(i-1)-1)@-1). 1 to: nWhite do: [:j | keyRect _ octavePt + (j-1*wtWid@0) extent: (wtWid+1)@keyHeight. self addMorph: ((RectangleMorph newBounds: keyRect color: whiteKeyColor) borderWidth: 1; on: #mouseDown send: #mouseDownPitch:event:noteMorph: to: self withValue: i-1*12 + (#(1 3 5 6 8 10 12) at: j))]. 1 to: nBlack do: [:j | keyRect _ octavePt + ((#(12 28 58 75 92) at: j)@1) extent: bkWid@(keyHeight * 0.618). self addMorph: ((Morph newBounds: keyRect color: blackKeyColor) on: #mouseDown send: #mouseDownPitch:event:noteMorph: to: self withValue: i-1*12 + (#(2 4 7 9 11) at: j))]]. self submorphsDo: [:m | m on: #mouseMove send: #mouseMovePitch:event:noteMorph: to: self; on: #mouseUp send: #mouseUpPitch:event:noteMorph: to: self; on: #mouseEnterDragging send: #mouseDownPitch:event:noteMorph: to: self; on: #mouseLeaveDragging send: #mouseUpPitch:event:noteMorph: to: self]. self extent: (self fullBounds extent + borderWidth - 1)! !