Morphic questions

Ned Konz ned at squeakland.org
Wed Dec 22 05:02:01 UTC 2004


On Sunday 19 December 2004 7:51 pm, Michael Latta wrote:

> 1) The current Morphs seem to use BitBlt.  Is there an effort to use
> Baloon?  Can I build my own morphs using Baloon?  I would like
> anti-aliased morphs.

You can certainly use Balloon. Connectors2 and the CurveMorph stuff I did for 
Squeakland uses Balloon.

The incantation is something like:

drawOn: aCanvas
 aCanvas asBalloonCanvas ...

Balloon has a couple of bugs in rendering, though; there is some flattening of 
ellipses, and flaws in line thickness at joints in some cases. And there's an 
off-by-one bug that may cause other graphics to be slightly overwritten in 
some cases.

> 2) What is the relative speed of BitBlt vs. Baloon vs. OpenGL?  Does
> Baloon use the hardware on Windows or Mac OS/X?

Balloon does not use hardware acceleration. It's slower than BitBlt. OpenGL is 
being used by Croquet, but that's different.

> 3) Does the polygon morph deal with dragging line segments or other
> means to allow user control of line routing?

Yes. You can do a shift-click to bring up handles. However, in some cases 
(like for lines (non-closed PMs) you may want to use Connectors2 instead.

> 4) Can I control the layering of morphs?

Yes, more or less.The answer to this has two parts:

* You can control the layering of a morph vs. its submorphs by overriding 
drawing methods.

By default a morph is drawn first, followed by its submorphs. If that's not 
what you want you can change it.

* You can control the Z-order of your morph with respect to other submorphs of 
its parent by where it is added to the submorphs array. This can be 
controlled in several ways:

-- you can provide a morphicLayerNumber, so that when your morph is added to a 
parent it gets put in front of morphs with lower morphicLayerNumbers.
-- if you need a "topmost" morph, you can periodically arrange it to be the 
topmost within its parent (typically in the step method).

Connectors2 uses both of these methods in different places.

> 5) The squeak books at Amazon looked old (3.4 or so).  Is there a
> current reference that covers Morphic as it exists now?

Not that I know of, but Morphic itself hasn't changed much since then. There 
may be some new classes or subtle changes, but pretty much everything is the 
same. There have been slight changes in add/remove morph protocols, and maybe 
in the top-level Morphic event loop since 3.4, but I don't think there's been 
many changes that would affect the typical Morphic programmer.

> 6) Can I anchor a morph to the outside of another morph, or only inside
> another morph?

Sure. You can have a morph move itself dynamically to wherever it wants.It 
could follow an unrelated morph around if it wanted to (this is how the 
endpoints of Connectors work).

If you mean to do this statically, by layout, outside a parent, the answer is 
still yes. (That is, if you're talking about a submorph appearing outside the 
bounds of its parent).

However, the parent morph can't use a layout policy that would move the 
submorphs (so TableLayout is out). It may be possible to use a 
ProportionalLayout to do this (using negative offsets); I haven't tried it. 
Certainly you can do this using no LayoutPolicy.

> If I want handles on a morph, do I need to place a 
> parent morph to hold the handles and the morph being edited?

No; there's always the World to use as a parent. However, it may be more 
convenient to use a (possibly invisible) parent morph to handle the user 
interaction and to own the handles. That gives you a logical place to manage 
the handles.

If you haven't already, you might want to read the paper about "Magic Lenses" 
in user interface design. The gist of this is that one can make UI objects 
that can be dragged or otherwise placed over other UI objects and then can 
modify appearance and user interaction, since they're in between the user and 
the underlying objects. This is a useful idiom for managing handles within a 
tool. Whether the lens itself is visible doesn't really matter, in my 
opinion.

-- 
Ned Konz
http://bike-nomad.com/squeak/



More information about the Squeak-dev mailing list