--- a/Label.st Sun May 15 17:41:51 2016 +0200
+++ b/Label.st Sun May 15 17:50:56 2016 +0200
@@ -1453,9 +1453,93 @@
labelChannel removeDependent:self.
labelChannel := nil.
].
+ self stopAnimation.
super release
! !
+!Label methodsFor:'label animation'!
+
+animationDelay
+ ^ 100 milliseconds
+!
+
+animationDelayTopOrBottom
+ ^ 3 seconds
+!
+
+doAnimate
+ "by slow scrolling the label, ensure that the label's text is readable.
+ (stops when the cursor enters)"
+
+ |offset animator atTop atBottom|
+
+ (animator := self objectAttributeAt:#animator) isNil ifTrue:[^ self "I have been stopped"].
+ drawableId isNil ifTrue:[^ self].
+
+ offset := self objectAttributeAt:#animatorOffset.
+ atTop := (offset == 0).
+ atBottom := (offset - self font ascent + labelHeight) > self height .
+
+ atBottom ifTrue:[
+ "/ after a longer delay, start again from top
+ self objectAttributeAt:#animatorOffset put:0.
+ Processor addTimedBlock:animator after:(self animationDelayTopOrBottom).
+ ^ self.
+ ].
+
+ labelOriginY := offset negated.
+ offset := offset + 1.
+ self objectAttributeAt:#animatorOffset put:offset.
+ self invalidate.
+
+ Processor addTimedBlock:animator
+ after:(atTop
+ ifTrue:[self animationDelayTopOrBottom]
+ ifFalse:[self animationDelay]).
+!
+
+startAnimation
+ "start an animator, which ensures that the label's text is visible
+ (slow scroll which stops when the cursor enters)"
+
+ |animator|
+
+ self stopAnimation.
+ animator := [ self doAnimate ].
+ self objectAttributeAt:#animatorOffset put:0.
+ self objectAttributeAt:#animator put:animator.
+ Processor addTimedBlock:animator after:(self animationDelay)
+
+ "
+ |l|
+ l := Label new.
+ l height:30.
+ l sizeFixed:true.
+ l label:'Line1
+Line2
+Line3
+Line4'.
+ l openAndWait.
+ Delay waitForSeconds:10.
+ l startAnimation.
+ Delay waitForSeconds:10.
+ l stopAnimation.
+ "
+!
+
+stopAnimation
+ |animator|
+
+ (animator := (self objectAttributeAt:#animator) notNil) ifTrue:[
+ self objectAttributeAt:#animator put:nil.
+ Processor removeTimedBlock:animator.
+
+ "/ ensure that things are in their normal state again
+ self computeLabelOrigin.
+ self invalidate.
+ ].
+! !
+
!Label methodsFor:'menu'!
copyLabelText