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

Box layout with custom padding #1031

Closed
ababo opened this issue May 23, 2020 · 7 comments · Fixed by #4825
Closed

Box layout with custom padding #1031

ababo opened this issue May 23, 2020 · 7 comments · Fixed by #4825

Comments

@ababo
Copy link

ababo commented May 23, 2020

Currently I implement a canvas object for rich text which will use a very limited subset of HTML for styling. And I struggle with the horizontal box layout, since it uses a theme padding, but I don't need any padding. Is there a way to reuse existing layout with no padding without changing the theme globally? Thanks in advance.

@ababo ababo changed the title Layout with custom padding Box layout with custom padding May 23, 2020
@andydotxyz
Copy link
Member

The default layouts use theme padding, just like the standard widgets use theme colours.
You can easily pass a custom layout into NewContainerWithLayout, https://fyne.io/develop/tutorials/custom-layout .

@ababo
Copy link
Author

ababo commented May 24, 2020

So I had to replicate the box layout code with a couple changed lines to support custom (zero) padding. It would be nice to support NewVBoxWithPadding() and NewHBoxWithPadding() functions for the existing box layout having really minimal changes. If I'll create a PR would you accept that?

@andydotxyz
Copy link
Member

The box widgets are designed for laying out other widgets in a consistent manner.
Your work sounds closer to a custom widget - that would normally provide it's own layout anyhow.

@ababo
Copy link
Author

ababo commented May 24, 2020

Oh, I meant layouts, not the widgets, i.e. NewVBoxLayoutWithPadding() and NewHBoxLayoutWithPadding().

@andydotxyz
Copy link
Member

I think that it's probably still the same case - you are working on what should probably be a widget so adding customisation to standard components to support that doesn't make sense to the core API. At some point we should complete the more advanced layout options (like #4) that make "anything possible" but the simple layout API should probably always use the theme like widgets

@andydotxyz
Copy link
Member

I am going to close this as won't fix because you are building a widget and most widgets have custom layouts. If you still think that generic layouts should have custom padding it probably would need to be added to them all.

adamantike added a commit to adamantike/fyne that referenced this issue 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]
adamantike added a commit to adamantike/fyne that referenced this issue 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 added a commit to adamantike/fyne that referenced this issue 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
@dweymouth
Copy link
Contributor

Added on develop for Fyne 2.5

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 a pull request may close this issue.

3 participants