stickers icon indicating copy to clipboard operation
stickers copied to clipboard

GetContentWidth ignores padding

Open jon4hz opened this issue 2 years ago • 2 comments

Hi, I noticed that the GetContentWidth method ignores the padding of the cells style. Is this intended?

If not the getExtraWidth method should be changed from: https://github.com/76creates/stickers/blob/d6bf5dc8ab6b58b882cb887ad4367249f8684fce/flexBoxCell.go#L117-L119

To:

func (r *FlexBoxCell) getExtraWidth() int { 
 	return r.style.GetHorizontalFrameSize()
} 

Same for GetContentHeight()

jon4hz avatar Feb 03 '23 23:02 jon4hz

Opened PR #16 implementing the fix specified here.

I'm not familiar with the internals, but I note there are identical getContentHeight(), getContentWidth(), getExtraHeight(), and getExtraWidth() methods in row.go, column.go, flexbox.go, and horizontal_flexbox.go, and so I presume these ought to have to same fix applied? If so, perhaps they should be refactored with a base type for the sake of DRY principles?

Omnikron13 avatar Jun 21 '24 10:06 Omnikron13

Im not sure what are we trying to achieve with this, getContentWidth is used to determine the total width of the "outer" cell, I don't see how padding affects this as its "inner" part of the cell. Maybe the function name is misleading, and it used to be exported thus the user might have been using it for something that is not originally intended for.

I might be getting this wrong, if so please provide a working example to show the unwanted behaviour. @jon4hz

As far as making things DRY, I will look deeper into this, everything could be a child of Cell is the first thing that comes to my mind, but will need to check it out in more detail.

76creates avatar Jul 02 '24 17:07 76creates