'From Squeak3.2alpha of 3 October 2001 [latest update: #4563] on 29 November 2001 at 2:25 pm'! "Change Set: arrowDeltaEtc-sw Date: 29 November 2001 Author: Scott Wallace Allows the deltas applied via little green arrows on numeric readout tiles to be specified (formerly, the delta had always been one) -- and uses this to make the stepsize of the arrows for #scaleFactor be .1. Also makes the default float precision of #scaleFactor be such that one decimal place is always shown."! !Morph methodsFor: 'e-toy support' stamp: 'sw 11/29/2001 12:38'! defaultFloatPrecisionFor: aGetSelector "Answer a number indicating the default float precision to be used in a numeric readout for which the receiver provides the data. Individual morphs can override this. Showing fractional values for readouts of getCursor was in response to an explicit request from ack" (#(getCursor getNumericValue getNumberAtCursor getCursorWrapped getScaleFactor) includes: aGetSelector) ifTrue: [^ 0.01]. ^ 1! ! !CategoryViewer methodsFor: 'entries' stamp: 'sw 11/29/2001 13:15'! readoutFor: partName type: partType readOnly: readOnly getSelector: getSelector putSelector: putSelector "Answer a readout morph for the given part" | readout | readout _ (Vocabulary vocabularyForType: partType) updatingTileForTarget: scriptedPlayer partName: partName getter: getSelector setter: putSelector. "The below is a regrettable temporary expedient" (#(getScaleFactor "etc.") includes: getSelector) ifTrue: [readout setProperty: #arrowDelta toValue: 0.1. (readout findA: UpdatingStringMorph) floatPrecision: 0.1]. readout step. ^ readout! ! !Player methodsFor: 'slot getters/setters' stamp: 'sw 11/29/2001 14:07'! setScaleFactor: aNumber "Set the scale factor to be the given value" | aCostume | aCostume _ self costume. 1.0 = aNumber ifTrue: [0.0 = self getHeading ifTrue: [aCostume isFlexMorph ifTrue: [aCostume removeFlexShell]. ^ self]] ifFalse: [aCostume isFlexMorph ifFalse: [aCostume addFlexShell]]. costume scale: ((aNumber asFloat max: 0.1) min: 10.0)! ! !Player methodsFor: 'slots-user' stamp: 'sw 11/29/2001 14:12'! tearOffFancyWatcherFor: aGetter "Create 'Player3 heading = 43' as in independent entity. It keeps up with the truth, and may be edited to change the variable." | aWatcher aTile aLine aColor aTower precision ms slotMsg info isNumeric anInterface watcherWording | info _ self slotInfoForGetter: aGetter. info ifNotNil: [isNumeric _ info type == #Number. watcherWording _ Utilities inherentSelectorForGetter: aGetter] ifNil: [anInterface _Vocabulary eToyVocabulary methodInterfaceAt: aGetter ifAbsent: [nil]. isNumeric _ anInterface notNil and: [anInterface resultType == #Number]. watcherWording _ anInterface elementWording]. aColor _ Color r: 0.387 g: 0.581 b: 1.0. isNumeric ifTrue: [aTile _ NumericReadoutTile new typeColor: aColor]. aWatcher _ UpdatingStringMorph new. isNumeric ifTrue: [(precision _ self defaultFloatPrecisionFor: aGetter) ~= 1 ifTrue: [aWatcher floatPrecision: precision]]. aWatcher growable: true; getSelector: aGetter; putSelector: (info notNil ifTrue: [ScriptingSystem setterSelectorForGetter: aGetter] ifFalse: [anInterface companionSetterSelector]). aWatcher target: self. aTile addMorphBack: aWatcher. aTile addArrows. aTile setLiteralTo: (self perform: aGetter) width: 30. (#(getScaleFactor "etc.") includes: aGetter) ifTrue: [aTile setProperty: #arrowDelta toValue: 0.1. (aTile findA: UpdatingStringMorph) floatPrecision: 0.1]. Preferences universalTiles ifTrue: [ ms _ MessageSend receiver: self selector: aGetter asSymbol arguments: #(). slotMsg _ ms asTilesIn: self class globalNames: (self class officialClass ~~ CardPlayer). "For CardPlayers, use 'self'. For others, name it, and use its name." ms _ MessageSend receiver: 3 selector: #= asSymbol arguments: #(5). aLine _ ms asTilesIn: self class globalNames: false. aLine firstSubmorph delete. aLine addMorphFront: slotMsg. aLine lastSubmorph delete. aLine lastSubmorph delete. aLine color: aColor. aLine addMorphBack: aTile. aLine cellPositioning: #leftCenter] ifFalse: [ aLine _ AlignmentMorph newRow hResizing: #shrinkWrap; vResizing: #shrinkWrap; color: aColor. aLine layoutInset: -1. aLine borderWidth: 1; borderColor: aColor darker. aLine addMorphBack: (self tileReferringToSelf borderWidth: 0; typeColor: aColor; color: aColor; bePossessive). aLine addTransparentSpacerOfSize: (4@0). aTower _ AlignmentMorph newColumn color: aColor. aTower addTransparentSpacerOfSize: (0 @ 1). aTower addMorphBack: (StringMorph contents: watcherWording, ' = ' font: ScriptingSystem fontForTiles). aLine addMorphBack: aTower. aLine addMorphBack: aTile]. aWatcher step; fitContents. self currentHand attachMorph: aLine.! ! !TileMorph methodsFor: 'mouse handling' stamp: 'sw 11/29/2001 13:14'! arrowDelta "Answer the amount by which a number I display should increase at a time" ^ self valueOfProperty: #arrowDelta ifAbsent: [1]! ! !TileMorph methodsFor: 'mouse handling' stamp: 'sw 11/29/2001 12:29'! mouseStillDown: evt "See if arrows are being pressed and call arrowAction:..." | aPoint label | self flag: #arNote. "Fix 'significant' events below" upArrow ifNotNil: [aPoint _ evt cursorPoint. (label _ self labelMorph) ifNotNil: [label step. literal _ label valueFromContents]. (upArrow containsPoint: aPoint) ifTrue: [self abandonLabelFocus. self variableDelay: [self arrowAction: self arrowDelta]. ^ evt "hand noteSignificantEvent: evt"]. (downArrow containsPoint: aPoint) ifTrue: [self abandonLabelFocus. self variableDelay: [self arrowAction: self arrowDelta negated]. ^ evt "hand noteSignificantEvent: evt"]]. super mouseStillDown: evt. ! ! !NumericReadoutTile methodsFor: 'mouse' stamp: 'sw 11/29/2001 12:35'! mouseStillDown: evt "Copied from TileMorph mouseMove to use literal:width: rather than literal:." | p label | self flag: #arNote. "Fix 'significant' events below" upArrow ifNotNil: [p _ evt cursorPoint. self abandonLabelFocus. label _ self findA: UpdatingStringMorph. label ifNotNil: [label step. literal _ label valueFromContents]. (upArrow containsPoint: p) ifTrue: [self variableDelay: [self literal: (self numericValue + self arrowDelta)]. ^ evt "hand noteSignificantEvent: evt"]. (downArrow containsPoint: p) ifTrue: [self variableDelay: [self literal: (self numericValue - self arrowDelta)]. ^ evt "hand noteSignificantEvent: evt"]]. super mouseStillDown: evt. ! ! NumericReadoutTile removeSelector: #arrowAction:!