'From Pharo2.0a of ''18 April 2012'' [Latest update: #20112] on 4 July 2012 at 7:19:59 pm'! Morph subclass: #ASZoomerMorph instanceVariableNames: 'basicExtent maxZoom currentAnimation currentZoom targetZoom animStartZoom svg surface svgExtent svgZoom animCenter' classVariableNames: '' poolDictionaries: '' category: 'Athens-SVG'! !ASZoomerMorph methodsFor: 'as yet unclassified' stamp: 'IgorStasenko 6/10/2012 14:52'! animateZoomTo: zoomLevel targetZoom := zoomLevel. animStartZoom := currentZoom. currentAnimation := ASAnimation new subject: self. currentAnimation stopCondition: [:anim | anim duration >= self maxAnimationDuration ]. currentAnimation stepAction: [:anim | | duration | duration := (anim duration min: self maxAnimationDuration) / self maxAnimationDuration asFloat. self setZoom: animStartZoom * (1-duration) + (targetZoom * duration). ]. currentAnimation finishAction: [:anim | self stopStepping. self setZoom: targetZoom. currentAnimation := nil. ]. currentAnimation start. self startStepping! ! !ASZoomerMorph methodsFor: 'as yet unclassified' stamp: 'IgorStasenko 6/10/2012 15:14'! drawDropShadowOn: aCanvas ! ! !ASZoomerMorph methodsFor: 'as yet unclassified' stamp: 'IgorStasenko 6/10/2012 14:36'! drawOn: aCanvas svg ifNotNil: [ surface drawDuring: [:canvas | surface clear. canvas pathTransform restoreAfter: [ canvas pathTransform scaleBy: (currentZoom * svgZoom) asFloat. svg renderOn: canvas. ] ]. aCanvas translucentImage: surface asForm at: self innerBounds origin ] ifNil: [ super drawOn: aCanvas. ]! ! !ASZoomerMorph methodsFor: 'as yet unclassified' stamp: 'IgorStasenko 6/10/2012 14:52'! extent: pos super extent: pos. animCenter := self bounds center. ! ! !ASZoomerMorph methodsFor: 'as yet unclassified' stamp: 'IgorStasenko 6/10/2012 15:17'! handlesDropShadowInHand "Answer whether the receiver will handle drop shadow drawing when picked up in the hand." ^ true! ! !ASZoomerMorph methodsFor: 'as yet unclassified' stamp: 'IgorStasenko 6/10/2012 11:11'! handlesMouseOver: evt ^ true! ! !ASZoomerMorph methodsFor: 'as yet unclassified' stamp: 'IgorStasenko 6/10/2012 12:50'! initialize super initialize. currentZoom := 1. basicExtent := self extent.! ! !ASZoomerMorph methodsFor: 'as yet unclassified' stamp: 'IgorStasenko 6/10/2012 14:49'! justDroppedInto: aMorph event: anEvent super justDroppedInto: aMorph event: anEvent. animCenter := self bounds center.! ! !ASZoomerMorph methodsFor: 'as yet unclassified' stamp: 'IgorStasenko 6/10/2012 14:54'! maxAnimationDuration ^ 100! ! !ASZoomerMorph methodsFor: 'as yet unclassified' stamp: 'IgorStasenko 6/10/2012 14:09'! maxZoom ^ maxZoom ifNil: [ maxZoom := 2 ]! ! !ASZoomerMorph methodsFor: 'as yet unclassified' stamp: 'IgorStasenko 6/10/2012 14:10'! maxZoom: aValue maxZoom := aValue max: 1 ! ! !ASZoomerMorph methodsFor: 'as yet unclassified' stamp: 'IgorStasenko 6/10/2012 15:04'! mouseEnter: evt self comeToFront. self animateZoomTo: self maxZoom! ! !ASZoomerMorph methodsFor: 'as yet unclassified' stamp: 'IgorStasenko 6/10/2012 11:14'! mouseLeave: evt self animateZoomTo: 1! ! !ASZoomerMorph methodsFor: 'as yet unclassified' stamp: 'IgorStasenko 6/10/2012 14:51'! position: pos super position: pos. animCenter := self bounds center. ! ! !ASZoomerMorph methodsFor: 'as yet unclassified' stamp: 'IgorStasenko 6/10/2012 13:59'! screenDPI ^ 96 "just a guess "! ! !ASZoomerMorph methodsFor: 'as yet unclassified' stamp: 'IgorStasenko 6/10/2012 14:50'! setZoom: aZoom | newExtent oldCenter | currentZoom := aZoom. newExtent := basicExtent * aZoom. oldCenter := animCenter. self bounds: (animCenter - (newExtent /2) extent: newExtent). animCenter := oldCenter. self changed! ! !ASZoomerMorph methodsFor: 'as yet unclassified' stamp: 'IgorStasenko 6/10/2012 11:44'! step currentAnimation ifNotNil: [ currentAnimation step ]! ! !ASZoomerMorph methodsFor: 'as yet unclassified' stamp: 'IgorStasenko 6/10/2012 12:01'! stepTime ^ 20! ! !ASZoomerMorph methodsFor: 'as yet unclassified' stamp: 'IgorStasenko 6/10/2012 14:28'! svg: anSVG ^ self svg: anSVG zoom: 1! ! !ASZoomerMorph methodsFor: 'as yet unclassified' stamp: 'IgorStasenko 6/10/2012 14:37'! svg: anSVG zoom: anSvgZoom | w h | svg := anSVG. svg isString ifTrue: [ svg := AthensSVGConverter fromFile: svg ]. svgExtent := self extent. svg width ifNotNil: [ w := svg width valueForDPI: self screenDPI. h := svg height valueForDPI: self screenDPI. svgExtent := (w@h) * anSvgZoom + (2@2). svgZoom := anSvgZoom. ] ifNil: [ svgExtent := self extent. svgZoom := 1. ]. surface := AthensCairoSurface extent: (svgExtent * self maxZoom + (1@1)) asIntegerPoint. basicExtent := svgExtent. self extent: svgExtent. currentZoom := 1. self changed! ! !ASZoomerMorph methodsFor: 'as yet unclassified' stamp: 'IgorStasenko 6/10/2012 14:48'! wantsToBeDroppedInto: aMorph ^ aMorph isWorldMorph! !