Karl Ramberg uploaded a new version of MorphicExtras to project The Trunk:
http://source.squeak.org/trunk/MorphicExtras-kfr.234.mcz ==================== Summary ==================== Name: MorphicExtras-kfr.234 Author: kfr Time: 1 May 2018, 12:17:55.1564 pm UUID: daa73559-d68f-7c4d-a1a3-2a3ad97af5bc Ancestors: MorphicExtras-kfr.233 Adds menu button to EnvelopeEditorMorph. Fixes the layout of the morph a little. Changes lable of ScorePlayerMorph menu button to Menu =============== Diff against MorphicExtras-kfr.233 =============== Item was removed: - ----- Method: EnvelopeEditorMorph>>addControls (in category 'construction') ----- - addControls - | chooser | - chooser := PopUpChoiceMorph new extent: 110@14; - contentsClipped: 'Editing: ' , envelope name; - target: self; - actionSelector: #chooseFrom:envelopeItem:; - getItemsSelector: #curveChoices. - chooser arguments: (Array with: chooser). - self addMorph: chooser. - chooser align: chooser bounds topLeft with: graphArea bounds bottomLeft + (0@5). - - chooser := PopUpChoiceMorph new extent: 130@14; - contentsClipped: 'Timbre: ' , soundName; - target: self; - actionSelector: #chooseFrom:soundItem:; - getItemsSelector: #soundChoices. - chooser arguments: (Array with: chooser). - self addMorph: chooser. - chooser align: chooser bounds topRight with: graphArea bounds bottomRight + (-50@5). - ! Item was removed: - ----- Method: EnvelopeEditorMorph>>addCustomMenuItems:hand: (in category 'menu') ----- - addCustomMenuItems: menu hand: aHandMorph - super addCustomMenuItems: menu hand: aHandMorph. - menu addLine. - envelope updateSelector = #ratio: ifTrue: - [menu add: 'choose denominator...' translated action: #chooseDenominator:]. - menu add: 'adjust scale...' translated action: #adjustScale:. - SoundPlayer isReverbOn - ifTrue: [menu add: 'turn reverb off' translated target: SoundPlayer selector: #stopReverb] - ifFalse: [menu add: 'turn reverb on' translated target: SoundPlayer selector: #startReverb]. - menu addLine. - menu add: 'get sound from lib' translated action: #chooseSound:. - menu add: 'put sound in lib' translated action: #saveSound:. - menu add: 'read sound from disk...' translated action: #readFromDisk:. - menu add: 'save sound on disk...' translated action: #saveToDisk:. - menu add: 'save library on disk...' translated action: #saveLibToDisk:. - ! Item was changed: ----- Method: EnvelopeEditorMorph>>buildGraphAreaIn: (in category 'construction') ----- buildGraphAreaIn: frame | r y | graphArea := RectangleMorph + newBounds: ((frame left + 15) @ (frame top + 15) + corner: (frame right+1) @ (frame bottom - 70)) - newBounds: ((frame left + 40) @ (frame top + 40) - corner: (frame right+1) @ (frame bottom - 60)) color: Color lightGreen lighter lighter. graphArea borderWidth: 1. self addMorph: graphArea. (envelope updateSelector = #pitch: and: [envelope scale <= 2.0]) ifTrue: ["Show half-steps" r := graphArea innerBounds. 0.0 to: 1.0 by: 1.0/12.0/envelope scale do: [:val | y := self yFromValue: val. graphArea addMorph: ((RectangleMorph newBounds: (r left@y extent: r width@1) color: Color veryLightGray) borderWidth: 0)]]. (envelope updateSelector = #ratio: and: [denominator ~= 9999]) ifTrue: ["Show denominator gridding" r := graphArea innerBounds. (0.0 to: 1.0 by: 1.0/denominator/envelope scale) do: [:v | y := self yFromValue: v. graphArea addMorph: ((RectangleMorph newBounds: (r left@y extent: r width@1) color: Color veryLightGray) borderWidth: 0)]]. ! Item was changed: ----- Method: EnvelopeEditorMorph>>buildScalesIn: (in category 'editing') ----- buildScalesIn: frame | env | env := envelope. pixPerTick := graphArea width // (self maxTime//10) max: 1. "hminortick := ( 1 + ( self maxTime // 800 ) ) * 10. hmajortick := ( 1 + ( self maxTime // 800 ) ) * 100." hScale := (Morph newBounds: ((graphArea left)@(frame top) corner: (self xFromMs: self maxTime)@(graphArea top - 1))) color: Color lightGreen. " hScale := (ScaleMorph newBounds: ((graphArea left)@(frame top) corner: (self xFromMs: self maxTime)@(graphArea top - 1))) start: 0 stop: self maxTime minorTick: hminortick minorTickLength: 3 majorTick: hmajortick majorTickLength: 10 caption: 'milliseconds' tickPrintBlock: [:v | v printString]. " self addMorph: hScale. vScale := (Morph newBounds: (0@0 extent: (graphArea height)@(graphArea left - frame left))) color: Color lightGreen. "vScale := ScaleMorph newBounds: (0@0 extent: (graphArea height)@(graphArea left - frame left))." "env name = 'pitch' ifTrue: [env scale >= 2.0 ifTrue: [vScale start: 0 stop: env scale minorTick: env scale / 24 minorTickLength: 3 majorTick: env scale / 2.0 majorTickLength: 10 caption: 'pitch (octaves)' tickPrintBlock: [:v | (v-(env scale/2)) asInteger printString]] ifFalse: [vScale start: 0 stop: env scale minorTick: 1.0/48.0 minorTickLength: 3 majorTick: 1.0/12.0 majorTickLength: 10 caption: 'pitch (half-steps)' tickPrintBlock: [:v | (v-(env scale/2)*12) rounded printString]]] ifFalse: [ env name = 'random pitch:' ifTrue: [ vScale start: 0.9 stop: 1.1 minorTick: 0.2 / 50.0 minorTickLength: 3 majorTick: 0.2 / 5.0 majorTickLength: 10 caption: env name tickPrintBlock: [:v | v printString]] ifFalse: [ vScale start: 0 stop: env scale minorTick: env scale / 50.0 minorTickLength: 3 majorTick: env scale / 5.0 majorTickLength: 10 caption: env name tickPrintBlock: [:v | v printString]]. ]." vScale := TransformationMorph new asFlexOf: vScale. vScale angle: Float pi / 2.0. self addMorph: vScale. + vScale position: (frame left + 1)@(graphArea top-1) - (3@1). - vScale position: (frame left)@(graphArea top-1) - (3@1). ! Item was changed: ----- Method: EnvelopeEditorMorph>>buildView (in category 'construction') ----- buildView | frame | self color: Color lightGreen. self removeAllMorphs. frame := self innerBounds. self buildGraphAreaIn: frame. self buildScalesIn: frame. self addHandlesIn: frame. self addCurves. line addHandles. + self addMorph: self makeControls. - self addControls. self addKeyboard! Item was added: + ----- Method: EnvelopeEditorMorph>>invokeMenu (in category 'menu') ----- + invokeMenu + "Invoke a menu of additonal functions for this ScorePlayer." + | menu | + menu := MenuMorph new defaultTarget: self. + + envelope updateSelector = #ratio: ifTrue: + [menu add: 'choose denominator...' translated action: #chooseDenominator:]. + menu add: 'adjust scale...' translated action: #adjustScale:. + SoundPlayer isReverbOn + ifTrue: [menu add: 'turn reverb off' translated target: SoundPlayer selector: #stopReverb] + ifFalse: [menu add: 'turn reverb on' translated target: SoundPlayer selector: #startReverb]. + menu addLine. + menu add: 'get sound from lib' translated action: #chooseSound:. + menu add: 'put sound in lib' translated action: #saveSound:. + menu add: 'read sound from disk...' translated action: #readFromDisk:. + menu add: 'save sound on disk...' translated action: #saveToDisk:. + menu add: 'save library on disk...' translated action: #saveLibToDisk:. + menu popUpInWorld: self world! Item was added: + ----- Method: EnvelopeEditorMorph>>makeControls (in category 'construction') ----- + makeControls + | chooser button row | + row := AlignmentMorph newRow color: color; borderWidth: 0. + row align: row bounds topLeft with: graphArea bounds bottomLeft + (0@5). + button := SimpleButtonMorph new target: self; borderColor: Color black; + borderWidth: 2; color: color. + row addMorphBack: (button label: 'Menu' translated; actWhen: #buttonDown; + actionSelector: #invokeMenu). + row addMorphBack: (Morph new extent:10@1; color: Color transparent). + chooser := PopUpChoiceMorph new extent: 120@14; + contentsClipped: 'Editing: ' , envelope name; + target: self; + actionSelector: #chooseFrom:envelopeItem:; + getItemsSelector: #curveChoices. + chooser arguments: (Array with: chooser). + row addMorphBack: chooser. + + chooser := PopUpChoiceMorph new extent: 130@14; + contentsClipped: 'Timbre: ' , soundName; + target: self; + actionSelector: #chooseFrom:soundItem:; + getItemsSelector: #soundChoices. + chooser arguments: (Array with: chooser). + row addMorphBack: chooser. + + ^row! Item was changed: ----- Method: ScorePlayerMorph>>makeControls (in category 'layout') ----- makeControls | bb r reverbSwitch repeatSwitch | r := AlignmentMorph newRow. r color: color; borderWidth: 0; layoutInset: 0. r hResizing: #shrinkWrap; vResizing: #shrinkWrap; extent: 5@5. bb := SimpleButtonMorph new target: self; borderColor: #raised; borderWidth: 2; color: color. + r addMorphBack: (bb label: 'Menu' translated; actWhen: #buttonDown; - r addMorphBack: (bb label: '<>'; actWhen: #buttonDown; actionSelector: #invokeMenu). bb := SimpleButtonMorph new target: self; borderColor: #raised; borderWidth: 2; color: color. r addMorphBack: (bb label: 'Piano Roll' translated; actionSelector: #makePianoRoll). bb := SimpleButtonMorph new target: self; borderColor: #raised; borderWidth: 2; color: color. r addMorphBack: (bb label: 'Rewind' translated; actionSelector: #rewind). bb := SimpleButtonMorph new target: scorePlayer; borderColor: #raised; borderWidth: 2; color: color. r addMorphBack: (bb label: 'Play' translated; actionSelector: #resumePlaying). bb := SimpleButtonMorph new target: scorePlayer; borderColor: #raised; borderWidth: 2; color: color. r addMorphBack: (bb label: 'Pause' translated; actionSelector: #pause). reverbSwitch := SimpleSwitchMorph new offColor: color; onColor: (Color r: 1.0 g: 0.6 b: 0.6); borderWidth: 2; label: 'Reverb Disable' translated; actionSelector: #disableReverb:; target: scorePlayer; setSwitchState: SoundPlayer isReverbOn not. r addMorphBack: reverbSwitch. scorePlayer ifNotNil: [repeatSwitch := SimpleSwitchMorph new offColor: color; onColor: (Color r: 1.0 g: 0.6 b: 0.6); borderWidth: 2; label: 'Repeat' translated; actionSelector: #repeat:; target: scorePlayer; setSwitchState: scorePlayer repeat. r addMorphBack: repeatSwitch]. ^ r ! |
Free forum by Nabble | Edit this page |