[BUG] submorphBounds is incorrect for TransformMorphs.

Doug Way dway at riskmetrics.com
Sat Mar 9 00:18:47 UTC 2002


Not having thought about this too hard, I tried something along the lines of what you suggested...

I copied the existing TransformMorph>>submorphBounds to privateSubmorphBounds, and then implemented:

TransformMorph>>submorphBounds
	^transform localBoundsToGlobal: (self privateSubmorphBounds ifNil: [^ nil])

However, this causes problems when scrolling down to the bottom of a pane, etc.  Apparently, some things still depend on submorphBounds being local.

Okay, after playing around I see that for most morphs, submorphBounds returns global coordinates, but only for TransformMorph, it returns local coordinates.  That does seem bad.  Maybe whatever relies on these local coordinates, should use a special accessor, like localSubmorphBounds or something.

- Doug Way
  dway at riskmetrics.com


Ned Konz wrote:
> 
> submorphBounds is defined in Morph as:
> 
> submorphBounds
>         "Private. Compute the actual full bounds of the receiver"
>         | box subBox |
>         submorphs do: [:m |
>                 (m visible) ifTrue: [
>                         subBox _ m fullBounds.
>                         box
>                                 ifNil:[box _ subBox copy]
>                                 ifNotNil:[box _ box quickMerge: subBox]]].
>         box ifNil:[^self bounds]. "e.g., having submorphs but not visible"
>         ^ box origin asIntegerPoint corner: box corner asIntegerPoint
> 
> However, for a TransformMorph, the submorphs aren't in the same coordinate
> system. So submorphBounds answers a Rectangle in the wrong coordinate system.
> 
> TransformMorph>>contentBounds has it right:
> 
> contentBounds
>         self hasSubmorphs ifTrue:
>                 [^ (transform localBoundsToGlobal: self submorphBounds) truncated].
>         ^ self fullBounds
> 
> Where this discrepancy is giving me a problem is with removeDropShadow, which
> eventually calls privateFullBounds, which calls submorphBounds and does a
> quickMerge with the outerBounds. And then results in fullBounds being set to
> a Rectangle in the wrong coordinate system.
> 
> It seems to me that submorphBounds should always answer a Rectangle in the
> same coordinate system as layoutBounds, outerBounds and clippingBounds.
> 
> I'm running into problems with my Connectors because of this and don't know
> quite how to proceed.
> 
> What's happening is that I have situations where (because of fullBounds
> getting set wrong) I can't select Connectors that have end adornments using a
> SelectionMorph. My Connector end adornments use TransformationMorphs for
> rotation.
> 
> --
> Ned Konz
> currently: Stanwood, WA
> email:     ned at bike-nomad.com
> homepage:  http://bike-nomad.com



More information about the Squeak-dev mailing list