[Newbies] Modifying world size?

Bert Freudenberg bert at freudenbergs.de
Tue Dec 28 10:27:58 UTC 2010


On 27.12.2010, at 19:55, Casey Ransberger wrote:

> I'd like to have worlds that are bigger than the screen, wherein the user can scroll about using a floating desktop pager, a la Self's demo snapshot.
> 
> I've tried changing e.g., the height of the world, but it seems to snap right back. Anyone know what's doing that?

It's in the Morphic main loop. See doOneCycleNowFor: which sends checkForNewScreenSize which sends displaySizeChanged to the current project which sends restoreMorphicDisplay to the World which sets its extent.

There are two ways to make a "virtual screen". Either a low-level one where you actually use a larger Display than the physical Squeak window size. Or you leave Display alone and do it in Morphic, making the World scrollable.

The first alternative is more general because it works in both MVC and Morphic. Also, there still are places in Morphic that directly reference Display and Sensor (fast window frame dragging, for example). 

Andreas implemented this for Etoys. We use a virtual screen with a fixed 1200 at 900 resolution and scale it to the actual window size. That way projects can easily be shared. Just download Etoys and resize its window to see.

The beef is in class OLPCVirtualScreen. Changing it from scaling to panning should be quite straightforward.

The only drawback is that with the current implementation we actually have two Display bitmaps - one of the actual screen size plus one for the full virtual display. Making the latter store only the visible portion of the Display requires a bit more work (we did not need that because the whole world is always visible).

Actually, since you do not need scaling, a single bitmap of the screen size would suffice. If I were to implement this, I'd subclass DisplayScreen and add a virtual size and offset. Every BitBlt operation would need to use that offset.

Have fun :)

- Bert -




More information about the Beginners mailing list