[Cuis-dev] custom morph with fixed size

Mark Volkmann r.mark.volkmann at gmail.com
Mon Aug 12 16:53:16 PDT 2024


On Mon, Aug 12, 2024 at 6:38 PM <ken.dickey at whidbey.com> wrote:

> On 2024-08-12 15:13, Mark Volkmann via Cuis-dev wrote:
>
> > See the attached screenshot. Hard as I try, I haven't been able to
> > figure out why the two red squares are different sizes. They are
> > instances of a custom morph named PlaceholderMorph.
>
> PlaceHolderMorph inherits from PlacedMorph, which supplies a default
> LayoutSpec which scales to the space available.
>
> vvv===vvv
> layoutSpec
>         "Layout specific. Return the layout spec describing where the
>         receiver should appear in a proportional layout"
>
>         layoutSpec ifNotNil: [ :ls | ^ ls ].
>         layoutSpec := LayoutSpec useAll.
>         layoutSpec morph: self.
>
>         ^ layoutSpec
> ^^^===^^^
>
> Resizing the outer, containing LayoutMorph demonstrates this.
>
> The LabelMorphs and PluggableButtonMorphs have default LayoutSpecs which
> use the original morphExtent, so they are not scaled.
>
> Using UI-MetaProperties to view the LayoutSpecs of various morphs and
> play with their properties, then dynamically resizing the containing
> LayoutMorph should sharpen your intuitions about what to expect.
>

That helps! Now I have to decide how to address this.
The only reason I chose to make my PlaceholderMorph be a subclass of
PlacedMorph instead of BoxedMorph is that
with PlacedMorph the canvas passed to drawOn: is a VectorCanvas and
with BoxedMorph the canvas passed to drawOn: is a HybridCanvas.
I want to use the polyLine: method in VectorCanvas.

Is there a way I can configure my custom morph so that if it is a subclass
of BoxedMorph, I can get a VectorCanvas in drawTo: ?

Is it a better option to modify the layoutSpec in the initialize method so
it keeps a fixed size?

-- 
R. Mark Volkmann
Object Computing, Inc.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20240812/6b859529/attachment.htm>


More information about the Cuis-dev mailing list