[Cuis-dev] How do I "pack" morphs?

H. Hirzel hannes.hirzel at gmail.com
Wed Mar 26 15:59:44 PDT 2025


Hi

I have a question related to the 'scaling morphs' discussion.

Scaling a form and then opening it as an image morph works fine, see 
[1a],[1b] and attachment '2025-03-25_scaling_a_form.gif' with example 
image '20250326_coffee.jpg'.

However if I add an image morph to a layout morph the layout morph does 
not "shrink" to the necessary size given by the submorphs and I did also 
not find which message I need to send to the layout morph or which 
LayoutSpec to add to the submorphs. [2] and attachment 
'2025-03-25_Adding_an_image_morph_to_a_layout'.

What am I missing here, maybe it is something obvious?

Additional question: what is the first argument of the #shrink:by: 
message for?

Kind regards

Hannes

-----------------------------

"[1a] no scaling of Form object"

  aForm := Form fromFileEntry: '20250326_coffee.jpg' asFileEntry.


  imageMorph := ImageMorph newWith: aForm.
  imageMorph
     borderWidth: 20;
     borderColor: Color white;
     scaleBy: 0.2;
     padding: 0.

imageMorph openInWorld


"[1b] scaling of Form object"

  aForm := Form fromFileEntry: '20250326_coffee.jpg' asFileEntry.


aForm := aForm shrink: aForm boundingBox by: 1.5.

  imageMorph := ImageMorph newWith: aForm.
  imageMorph
     borderWidth: 20;
     borderColor: Color black;
     scaleBy: 0.2;
     padding: 0.

imageMorph openInWorld


[2] Adding a LabelMorph and an ImageMorph object to a LayoutMorph object.

labelMorph := LabelMorph new
    contents: 'coffee';
    color: Color red;
    padding: 0.


  aForm := Form fromFileEntry: '20250326_coffee.jpg' asFileEntry.

aForm := aForm shrink: aForm boundingBox by: 1.5.

  imageMorph := ImageMorph newWith: aForm.
  imageMorph
     borderWidth: 20;
     borderColor: Color black;
     scaleBy: 0.2;
     padding: 0.

  layoutMorph := LayoutMorph newColumn
      borderWidth: 2;
      borderColor: Color yellow;
      padding: 0;
      separation: 0;
      addMorph: labelMorph;
      addMorph: imageMorph;
      "morphExtent: 300 at 300;"
      openInWorld

"changing the morph extent seems to have any effect on the morphExtent 
of the layoutMorph."
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 20250326_coffee.jpg
Type: image/jpeg
Size: 183339 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250326/bd015a5f/attachment-0001.jpg>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2025-03-25_scaling_a_form.gif
Type: image/gif
Size: 97673 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250326/bd015a5f/attachment-0002.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 2025-03-25_Adding_an_image_morph_to_a_layout.gif
Type: image/gif
Size: 34738 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20250326/bd015a5f/attachment-0003.gif>


More information about the Cuis-dev mailing list