-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Adding a blur graphical primitive and use it under modal popups & dialogs #5849
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
Open
andydotxyz
wants to merge
13
commits into
fyne-io:develop
Choose a base branch
from
andydotxyz:feature/blur
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7fbfc2b
Support getting subimage of a window capture
andydotxyz f46350c
Add the canvas.Blur graphics primitive
andydotxyz 84c61f4
Use blur under modal dialogs by a themable amount
andydotxyz 5f6bf68
Fixup compile after merge for ES shader
andydotxyz 9ecfb39
Better compatibility with other compilers
andydotxyz f685cbd
Add missing test in dialog package
andydotxyz e333351
Add missing windows method
andydotxyz 4c43069
Update to not use deprecated theme
andydotxyz ac53e3a
Cache kernel computation
andydotxyz 8ecabdf
don't allocate pixel slice for drawBlur
dweymouth c5fb5ff
format for lint
dweymouth ff2db57
Fix paste mistake
andydotxyz 126f7c4
Avoid moving if not required
andydotxyz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,56 @@ | ||
| package canvas | ||
|
|
||
| import "fyne.io/fyne/v2" | ||
|
|
||
| // Declare conformity with CanvasObject interface | ||
| var _ fyne.CanvasObject = (*Blur)(nil) | ||
|
|
||
| // Blur creates a rectangular blur region on the output. | ||
| // All objects drawn under this will be blurred, any above will not be affected. | ||
| // | ||
| // Since: 2.7 | ||
| type Blur struct { | ||
| baseObject | ||
|
|
||
| // Radius refers to how far from a pixel should be used to calculate the blur. | ||
| // It must be greater than 0 but no more than 50. | ||
| Radius float32 | ||
| } | ||
|
|
||
| // Hide will set this blur to not be visible | ||
| func (b *Blur) Hide() { | ||
| b.baseObject.Hide() | ||
|
|
||
| repaint(b) | ||
| } | ||
|
|
||
| // Move the blur to a new position, relative to its parent / canvas | ||
| func (b *Blur) Move(pos fyne.Position) { | ||
| if b.Position() == pos { | ||
| return | ||
| } | ||
| b.baseObject.Move(pos) | ||
|
|
||
| repaint(b) | ||
| } | ||
|
|
||
| // Refresh causes this blur to be redrawn with its configured state. | ||
| func (b *Blur) Refresh() { | ||
| Refresh(b) | ||
| } | ||
|
|
||
| // Resize on a blur updates the new size of this object. | ||
| func (b *Blur) Resize(s fyne.Size) { | ||
| if s == b.Size() { | ||
| return | ||
| } | ||
|
|
||
| b.baseObject.Resize(s) | ||
| } | ||
|
|
||
| // NewBlur returns a new Blur instance | ||
| func NewBlur(radius float32) *Blur { | ||
| return &Blur{ | ||
| Radius: radius, | ||
| } | ||
| } | ||
This file contains hidden or 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,26 @@ | ||
| package canvas_test | ||
|
|
||
| import ( | ||
| "testing" | ||
|
|
||
| "fyne.io/fyne/v2" | ||
| "fyne.io/fyne/v2/canvas" | ||
| "fyne.io/fyne/v2/container" | ||
| "fyne.io/fyne/v2/test" | ||
| ) | ||
|
|
||
| func TestBlur(t *testing.T) { | ||
| test.NewTempApp(t) | ||
| bg := canvas.NewImageFromFile("testdata/Utah_teapot.png") | ||
| b1 := canvas.NewBlur(35) | ||
| w := test.NewTempWindow(t, container.NewWithoutLayout(bg, b1)) | ||
| w.SetPadded(false) | ||
| size := fyne.NewSize(300, 243) | ||
| bg.Resize(size) | ||
| w.Resize(size) | ||
|
|
||
| b1.Move(fyne.NewPos(120, 110)) | ||
| b1.Resize(fyne.NewSize(140, 100)) | ||
|
|
||
| test.AssertRendersToImage(t, "blur.png", w.Canvas()) | ||
| } |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.