Scrolling a PasteUpMorph
Ned Konz
ned at bike-nomad.com
Thu Aug 12 06:35:24 UTC 2004
On Wednesday 11 August 2004 8:12 pm, Rodrigo Gonçalves wrote:
> I'm developing a Project subclass which will need to have its main area
> scrollable. I've been trying to make its the Project "world" (a
> PasteUpMorph) scrollable with the TwoWayScrollPane without success.
>
> Any ideas on how could that be done?
If you look at my Connectors package, you'll see a Morph with a scrollable
pasteup morph. But it isn't a world.
I believe that the range of the arguments given to some of the BitBlt routines
is limited to a SmallInteger (and very possibly more limited than that); make
sure that that isn't a problem.
For a really quick way to scroll a world, you can just move all of its morphs
by the same amount.
You could also subclass PasteUpMorph and override drawSubmorphsOn:. This way
you could also add scaling. Or, equivalently, you could answer a translated
Canvas when asked for your canvas to draw the world on.
However, there may be code that assumes that the origin of the World is at 0 at 0
and that the World's extent is the same as the Display.
I'd try just translating all the morphs first. Turn on deferred updates while
doing the moves.
I've attached a quick demo of a JoystickMorph moving a World's submorphs.
--
Ned Konz
http://bike-nomad.com
-------------- next part --------------
'From Squeak3.7gamma of ''17 July 2004'' [latest update: #5976] on 11 August 2004 at 11:34:36 pm'!
JoystickMorph subclass: #WorldShifter
instanceVariableNames: 'lastPosition'
classVariableNames: ''
poolDictionaries: ''
category: 'Demo'!
!WorldShifter commentStamp: '<historical>' prior: 0!
A quickie demo of how one might scroll a World.!
!WorldShifter methodsFor: 'initialization' stamp: 'nk 8/11/2004 23:33'!
initialize
super initialize.
xScale _ 10.0.
yScale _ 10.0.
radiusScale _ 1.0.
lastAngle _ 0.0.
autoCenter _ false.
lastPosition _ 0 at 0.! !
!WorldShifter methodsFor: 'stepping and presenter' stamp: 'nk 8/11/2004 23:33'!
step
| currentPosition delta morphsToMove |
self owner isNil
ifTrue: [^ self].
currentPosition := self leftRight @ self upDown negated.
delta := currentPosition - lastPosition.
delta isZero
ifFalse: [morphsToMove := self owner submorphs
reject: [:m | m == self
or: [m isFlapOrTab]].
morphsToMove
do: [:m | m
position: (m position translateBy: delta)]].
lastPosition := currentPosition! !
More information about the Squeak-dev
mailing list
|