Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow setting custom Layout paddings #4813

Conversation

adamantike
Copy link
Contributor

Description:

Introduce a LayoutOption concept, and allow setting custom paddings for a Layout. The BaseLayout struct implements the default paddings retrieval, to reduce the amount of changes required by project maintainers to comply with the new interface methods.

This change uses the Option pattern in case other customizations can be added to Layouts in the future, without changing the public API.

Main motivation for this change has been Supersonic needing to copy the entire Vbox/Hbox implementation, just to add custom paddings [1]. Also related to feature request #1031.

[1] https://github.com/dweymouth/supersonic/blob/02d4082f3dae4d1d54a4384489785a5984a7a7de/ui/layouts/hboxcustompadding.go

Checklist:

  • Tests included.
  • Lint and formatter run with no errors.
  • Tests all pass.

Where applicable:

  • Public APIs match existing style and have Since: line.
  • Any breaking changes have a deprecation path or have been discussed.

@adamantike adamantike changed the base branch from master to develop April 27, 2024 21:00
@adamantike adamantike changed the title Feat/allow custom paddings for layouts feat: Allow setting custom Layout paddings Apr 27, 2024
Introduce a `LayoutOption` concept, and allow setting custom paddings
for a Layout. The `BaseLayout` struct implements the default paddings
retrieval, to reduce the amount of changes required by project
maintainers to comply with the new interface methods.

This change uses the Option pattern in case other customizations can be
added to Layouts in the future, without changing the public API.

Main motivation for this change has been Supersonic needing to copy the
entire Vbox/Hbox implementation, just to add custom paddings [1]. Also
related to feature request fyne-io#1031.

[1] https://github.com/dweymouth/supersonic/blob/02d4082f3dae4d1d54a4384489785a5984a7a7de/ui/layouts/hboxcustompadding.go
@adamantike adamantike force-pushed the feat/allow-custom-paddings-for-layouts branch from 41ea0c7 to 748a8c5 Compare April 27, 2024 21:10
Copy link
Member

@andydotxyz andydotxyz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this may want to close in preference to #4823 and #4825 along with others I expect.

@@ -8,4 +8,10 @@ type Layout interface {
// MinSize calculates the smallest size that will fit the listed
// CanvasObjects using this Layout algorithm.
MinSize(objects []CanvasObject) Size
// GetPaddings returns the top, bottom, left and right paddings used
// by this layout.
GetPaddings() (float32, float32, float32, float32)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just FYI such an addition to a published interface is a breaking change.

Anyhow this topic has been discussed a lot and you can see replacement PRs coming in that take a less-sweeping change that can be adopted more easily.
Hopefully this resolves the use-case we missed?

@adamantike
Copy link
Contributor Author

This is indeed solved by the linked PRs, thank you!

@adamantike adamantike closed this May 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants