Skip to content

Commit 3887888

Browse files
authored
Merge branch 'develop' into dynamic-cache-clean
2 parents a5e0b99 + f7fbad7 commit 3887888

File tree

314 files changed

+4287
-1622
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

314 files changed

+4287
-1622
lines changed

.github/workflows/mobile_tests.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ jobs:
2626
- name: Get dependencies
2727
run: |
2828
sudo apt-get update
29-
sudo apt-get install --no-install-recommends clang lld libegl1-mesa-dev libgles2-mesa-dev libx11-dev xorg-dev
29+
sudo apt-get install --no-install-recommends clang lld libegl1-mesa-dev libgles2-mesa-dev libx11-dev xorg-dev fonts-noto-cjk
30+
31+
- name: Set environment variable LANG
32+
run: echo "LANG=en_US.UTF-8" >> $GITHUB_ENV
3033

3134
- name: Tests
3235
run: xvfb-run go test -race -tags mobile,ci,migrated_fynedo ./...

.github/workflows/platform_tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ jobs:
3030
- name: Get dependencies
3131
run: |
3232
sudo apt-get update
33-
sudo apt-get install --no-install-recommends bc clang lld libgl1-mesa-dev libwayland-dev libx11-dev libxkbcommon-dev xorg-dev xvfb language-pack-en
33+
sudo apt-get install --no-install-recommends bc clang lld libgl1-mesa-dev libwayland-dev libx11-dev libxkbcommon-dev xorg-dev xvfb language-pack-en fonts-noto-cjk
3434
echo "CC=clang" >> "$GITHUB_ENV"
3535
echo "CGO_LDFLAGS=-fuse-ld=lld" >> "$GITHUB_ENV"
3636
if: ${{ runner.os == 'Linux' }}
3737

3838
- name: Set environment variable LANG
39-
run: export LANG=en_EN.UTF-8
39+
run: echo "LANG=en_US.UTF-8" >> $GITHUB_ENV
4040
if: ${{ runner.os == 'Linux' }}
4141

4242
- name: Tests

.github/workflows/static_analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
sudo apt-get install --no-install-recommends clang lld libegl1-mesa-dev libgl1-mesa-dev libgles2-mesa-dev libx11-dev xorg-dev xvfb language-pack-en
2525
2626
- name: Set environment variable LANG
27-
run: export LANG=en_EN.UTF-8
27+
run: echo "LANG=en_US.UTF-8" >> $GITHUB_ENV
2828

2929
- name: Install analysis tools
3030
run: |

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ After importing a new module, run the following command before compiling the cod
3232

3333
To run a showcase of the features of Fyne execute the following:
3434

35-
go install fyne.io/fyne/v2/cmd/fyne_demo@latest
36-
fyne_demo
35+
go install fyne.io/demo@latest
36+
demo
3737

3838
And you should see something like this (after you click a few buttons):
3939

app/meta_development.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ func checkLocalMetadata() {
3939
if err == nil {
4040
meta.Icon = metadata.ScaleIcon(res, 512)
4141
}
42+
} else { // Icon.png fallback
43+
res, err := fyne.LoadResourceFromPath("Icon.png")
44+
if err == nil {
45+
meta.Icon = metadata.ScaleIcon(res, 512)
46+
}
4247
}
4348

4449
meta.Release = false

canvas/arbitrary_polygon.go

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
package canvas
2+
3+
import (
4+
"image/color"
5+
6+
"fyne.io/fyne/v2"
7+
)
8+
9+
// Declare conformity with CanvasObject interface
10+
var _ fyne.CanvasObject = (*ArbitraryPolygon)(nil)
11+
12+
// ArbitraryPolygon describes a colored arbitrary polygon primitive in a Fyne canvas.
13+
// The polygon is defined by a list of vertex positions in clockwise order, specified in absolute coordinates
14+
// relative to the object (top-left is (0,0), bottom-right is (width,height)).
15+
// Each corner can have an individually specified rounding radius.
16+
//
17+
// Since: 2.8
18+
type ArbitraryPolygon struct {
19+
baseObject
20+
21+
Points []fyne.Position // Vertices in coordinates relative to the object. If NormalizedPoints is true, these are (0.0 to 1.0), otherwise absolute.
22+
NormalizedPoints bool // True if Points are specified in normalized coordinates (0.0 to 1.0) relative to the object's size.
23+
CornerRadii []float32 // Per-corner rounding radius, must match len(Points); missing entries default to 0
24+
FillColor color.Color // The polygon fill color
25+
StrokeColor color.Color // The polygon stroke color
26+
StrokeWidth float32 // The stroke width of the polygon
27+
}
28+
29+
// Hide will set this arbitrary polygon to not be visible
30+
func (r *ArbitraryPolygon) Hide() {
31+
r.baseObject.Hide()
32+
33+
repaint(r)
34+
}
35+
36+
// Move the arbitrary polygon to a new position, relative to its parent / canvas
37+
func (r *ArbitraryPolygon) Move(pos fyne.Position) {
38+
if r.Position() == pos {
39+
return
40+
}
41+
42+
r.baseObject.Move(pos)
43+
44+
repaint(r)
45+
}
46+
47+
// Refresh causes this arbitrary polygon to be redrawn with its configured state.
48+
func (r *ArbitraryPolygon) Refresh() {
49+
Refresh(r)
50+
}
51+
52+
// Resize on an arbitrary polygon updates the new size of this object.
53+
func (r *ArbitraryPolygon) Resize(s fyne.Size) {
54+
if s == r.Size() {
55+
return
56+
}
57+
58+
r.baseObject.Resize(s)
59+
60+
Refresh(r)
61+
}
62+
63+
// NewArbitraryPolygon returns a new ArbitraryPolygon instance
64+
func NewArbitraryPolygon(points []fyne.Position, fill color.Color) *ArbitraryPolygon {
65+
return &ArbitraryPolygon{
66+
Points: points,
67+
FillColor: fill,
68+
}
69+
}

canvas/arbitrary_polygon_test.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package canvas_test
2+
3+
import (
4+
"image/color"
5+
"testing"
6+
7+
"fyne.io/fyne/v2"
8+
"fyne.io/fyne/v2/canvas"
9+
"fyne.io/fyne/v2/test"
10+
"github.com/stretchr/testify/assert"
11+
)
12+
13+
func TestArbitraryPolygon_NewAndDefaults(t *testing.T) {
14+
points := []fyne.Position{
15+
{X: 0, Y: 0},
16+
{X: 100, Y: 0},
17+
{X: 100, Y: 100},
18+
}
19+
fill := color.White
20+
p := canvas.NewArbitraryPolygon(points, fill)
21+
22+
assert.Equal(t, points, p.Points)
23+
assert.Equal(t, fill, p.FillColor)
24+
assert.Nil(t, p.StrokeColor)
25+
assert.Equal(t, float32(0), p.StrokeWidth)
26+
}
27+
28+
func TestArbitraryPolygon_Properties(t *testing.T) {
29+
p := canvas.NewArbitraryPolygon(nil, color.Black)
30+
p.StrokeWidth = 2.0
31+
p.StrokeColor = color.NRGBA{R: 255, G: 0, B: 0, A: 255}
32+
p.CornerRadii = []float32{5, 10, 5}
33+
34+
assert.Equal(t, float32(2.0), p.StrokeWidth)
35+
assert.Equal(t, color.NRGBA{R: 255, G: 0, B: 0, A: 255}, p.StrokeColor)
36+
assert.Equal(t, []float32{5, 10, 5}, p.CornerRadii)
37+
}
38+
39+
func TestArbitraryPolygon_RendersToMarkup(t *testing.T) {
40+
points := []fyne.Position{
41+
{X: 0, Y: 0},
42+
{X: 10, Y: 0},
43+
{X: 10, Y: 10},
44+
}
45+
p := canvas.NewArbitraryPolygon(points, color.White)
46+
p.Resize(fyne.NewSize(10, 10))
47+
48+
test.AssertObjectRendersToMarkup(t, "arbitrary_polygon.xml", p)
49+
}

canvas/blur.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package canvas
2+
3+
import "fyne.io/fyne/v2"
4+
5+
// Declare conformity with CanvasObject interface
6+
var _ fyne.CanvasObject = (*Blur)(nil)
7+
8+
// Blur creates a rectangular blur region on the output.
9+
// All objects drawn under this will be blurred, any above will not be affected.
10+
//
11+
// Since: 2.7
12+
type Blur struct {
13+
baseObject
14+
15+
// Radius refers to how far from a point should be used to calculate the blur.
16+
// It must be greater than 0 but no more than 50.
17+
Radius float32
18+
}
19+
20+
// Hide will set this blur to not be visible
21+
func (b *Blur) Hide() {
22+
b.baseObject.Hide()
23+
24+
repaint(b)
25+
}
26+
27+
// Move the blur to a new position, relative to its parent / canvas
28+
func (b *Blur) Move(pos fyne.Position) {
29+
if b.Position() == pos {
30+
return
31+
}
32+
b.baseObject.Move(pos)
33+
34+
repaint(b)
35+
}
36+
37+
// Refresh causes this blur to be redrawn with its configured state.
38+
func (b *Blur) Refresh() {
39+
Refresh(b)
40+
}
41+
42+
// Resize on a blur updates the new size of this object.
43+
func (b *Blur) Resize(s fyne.Size) {
44+
if s == b.Size() {
45+
return
46+
}
47+
48+
b.baseObject.Resize(s)
49+
}
50+
51+
// NewBlur returns a new Blur instance
52+
func NewBlur(radius float32) *Blur {
53+
return &Blur{
54+
Radius: radius,
55+
}
56+
}

canvas/blur_test.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
package canvas_test
2+
3+
import (
4+
"testing"
5+
6+
"fyne.io/fyne/v2"
7+
"fyne.io/fyne/v2/canvas"
8+
"fyne.io/fyne/v2/container"
9+
"fyne.io/fyne/v2/test"
10+
)
11+
12+
func TestBlur(t *testing.T) {
13+
test.NewTempApp(t)
14+
bg := canvas.NewImageFromFile("testdata/Utah_teapot.png")
15+
b1 := canvas.NewBlur(35)
16+
w := test.NewTempWindow(t, container.NewWithoutLayout(bg, b1))
17+
w.SetPadded(false)
18+
size := fyne.NewSize(300, 243)
19+
bg.Resize(size)
20+
w.Resize(size)
21+
22+
b1.Move(fyne.NewPos(120, 110))
23+
b1.Resize(fyne.NewSize(140, 100))
24+
25+
test.AssertRendersToImage(t, "blur.png", w.Canvas())
26+
}

canvas/canvas.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ const (
1313
// This constant represents the maximum possible corner radius, resulting in a circular appearance.
1414
// Since: 2.7
1515
RadiusMaximum float32 = math.MaxFloat32
16+
17+
// ArbitraryPolygonVerticesMaximum defines the maximum number of vertices supported by the arbitrary polygon
18+
// Since: 2.8
19+
ArbitraryPolygonVerticesMaximum = 16
1620
)
1721

1822
// Refresh instructs the containing canvas to refresh the specified obj.

0 commit comments

Comments
 (0)