forked from fyne-io/fyne
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow setting custom Layout paddings
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]
- Loading branch information
1 parent
e05c0a5
commit 00ea032
Showing
21 changed files
with
228 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package layout | ||
|
||
import "fyne.io/fyne/v2/theme" | ||
|
||
type BaseLayout struct { | ||
paddingFn func() (float32, float32, float32, float32) | ||
} | ||
|
||
func (b *BaseLayout) SetPaddingFn(fn func() (float32, float32, float32, float32)) { | ||
b.paddingFn = fn | ||
} | ||
|
||
func (b *BaseLayout) GetPaddings() (float32, float32, float32, float32) { | ||
if b.paddingFn == nil { | ||
padding := theme.Padding() | ||
return padding, padding, padding, padding | ||
} | ||
return b.paddingFn() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.