[Cuis-dev] BoxedMorph padding

Bernhard Pieber bernhard at pieber.com
Thu Sep 5 12:51:52 PDT 2024


Hi Ken,

This looks promising!

I started my test with doing this in a workspace:

labelMorph := LabelMorph new
	borderWidth: 2;
	borderColor: Color red;
	color: Color cyan;
	padding: 0.

imageMorph := ImageMorph new
	borderWidth: 2;
	borderColor: Color red;
	padding: 0.

layoutMorph := LayoutMorph newColumn
	borderWidth: 2;
	borderColor: Color yellow;
	padding: 0;
	useEdgeSpace: false;
	separation: 0;
	addMorph: labelMorph;
	addMorph: imageMorph;
	scaleBy: 3;
	openInWorld.

Then I did this:

labelMorph padding: 3; morphExtent: labelMorph minimumExtent.
layoutMorph morphExtent: layoutMorph minimumExtent.

imageMorph padding: 3; morphExtent: imageMorph minimumExtent.
layoutMorph morphExtent: layoutMorph minimumExtent.

Padding is applied to both morphs. Great! The same amount of padding looks smaller in the imageMorph, though.

Then I gave the layoutMorph a padding:

layoutMorph padding: 3; morphExtent: layoutMorph minimumExtent.

The padding seems to be applied just on the top. I would have expected it on all four sides.

Then I reset the padding to zero and set the separation to 3:

layoutMorph padding: 0; morphExtent: layoutMorph minimumExtent.
layoutMorph separation: 3; morphExtent: layoutMorph minimumExtent.

The separation is applied between labelMorph and the imageMorph as expected. In addition it is on the left, right and bottom edges, which should not be the case.

I think the method BoxedMorph>>#interiorOrigin can be simplified:

interiorOrigin

	"Answer point inset from borderWidth and Padding"
	| x y |
	x := self borderWidth + self padding x.
	y := self borderWidth + self padding y.
	^x @ y

One other use case: The hardcoded PluggableScrollPane>>xtraBorder could be replaced by padding.

Thanks for working on this!

Cheers,
Bernhard


> Am 04.09.2024 um 23:02 schrieb ken.dickey--- via Cuis-dev <cuis-dev at lists.cuis.st>:
> 
> Greetings,
> 
> Attached is a fileIn for adding padding to BoxedMorphs.
> 
> Padding is really just a property for now -- simulated iVar but no
> change to BoxedMorph instance shape.
> 
> You can use a morph menu to get an inspector to make visible the
> borderWidth and add padding (an integer or point).
> 
> Current code should run unchanged.
> 
> Updated drawing with padding in:
>   LayoutMorph
>   ImageMorph
>   InnerTextMorph
>   LabelMorph
>   TextParagraphMorph
> 
> Note that #minimumExtent: now includes both borderWidth and padding.
> 
> The question is: is it worthwhile to add #padding to BoxedMorph, or
> should we just add to LayoutMorph?
> 
> Anyway, please play around with padding, let me know of breakage, and
> are there additional Morphs where drawOn: updates would be useful?
> 
> Other features?
> 
> Thanks for feedback,
> -KenD--
> Cuis-dev mailing list
> Cuis-dev at lists.cuis.st
> https://lists.cuis.st/mailman/listinfo/cuis-dev
> <6672-CuisCore-Padding-2024Sep03-15h04m-KenD.002.cs.st>




More information about the Cuis-dev mailing list