Skip to content

Commit

Permalink
Merge branch 'master' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Aug 6, 2021
2 parents d633b99 + 2d4915c commit a0fff44
Show file tree
Hide file tree
Showing 22 changed files with 222 additions and 49 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github: [fyne-io, andydotxyz, toaster, okratitan]
github: [fyne-io, andydotxyz, toaster, okratitan, Jacalz]
31 changes: 30 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,42 @@ More detailed release notes can be found on the [releases page](https://github.c

### Added

### Updated
### Changed

* Focusable widgets are no longer focused on tap, add canvas.Focus(obj) in Tapped handler if required

### Fixed


## 2.0.4 - 6 August 2021

### Changed

* Disable Form labels when the element it applys to is disabled (#1530)
* Entry popup menu now fires shortcuts so extended widgets can intercept
* Update Android builds to SDK 30

### Fixed

* sendnotification show appID for name on windows (#1940)
* Fix accidental removal of windows builds during cross-compile
* Removing an item from a container did not update layout
* Update title bar on Windows 10 to match OS theme (#2184)
* Tapped triggered after Drag (#2235)
* Improved documentation and example code for file dialog (#2156)
* Preferences file gets unexpectedly cleared (#2241)
* Extra row dividers rendered on using SetColumnWidth to update a table (#2266)
* Fix resizing fullscreen issue
* Fullscreen changes my display resolution when showing a dialog (#1832)
* Entry validation does not work for empty field (#2179)
* Tab support for focus handling missing on mobile
* ScrollToBottom not always scrolling all the way when items added to container.Scroller
* Fixed scrollbar disappearing after changing content (#2303)
* Calling SetContent a second time with the same content will not show
* Drawing text can panic when Color is nil (#2347)
* Optimisations when drawing transparent rectangle or whitespace strings


## 2.0.3 - 30 April 2021

### Fixed
Expand Down
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,23 @@ More documentation is available at the [Fyne developer website](https://develope

You can find many example applications in the [examples repository](https://github.com/fyne-io/examples/).
Alternatively a list of applications using fyne can be found at [our website](https://apps.fyne.io/).

# Shipping the Fyne Toolkit

All Fyne apps will work without pre-installed libraries, this is one reason the apps are so portable.
However, if looking to support Fyne in a bigger way on your operating system then you can install some utilities that help to make a more complete experience.

## Additional apps

It is recommended that you install the following additional apps:

| app | go get | description |
| --- | ------ | ----------- |
| fyne_settings | `fyne.io/fyne/v2/cmd/fyne_settings` | A GUI for managing your global Fyne settings like theme and scaling |
| apps | `github.com/fyne-io/apps` | A graphical installer for the Fyne apps listed at https://apps.fyne.io |

These are optional applications but can help to create a more complete desktop experience.

## FyneDesk (Linux / BSD)

To go all the way with Fyne on your desktop / laptop computer you could install [FyneDesk](https://github.com/fyne-io/fynedesk) as well :)
3 changes: 3 additions & 0 deletions canvas/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ func (i *Image) Resize(s fyne.Size) {
if s == i.Size() {
return
}
if i.FillMode == ImageFillOriginal && i.size.Height > 2 { // don't refresh original scale images after first draw
return
}

i.baseObject.Resize(s)

Expand Down
6 changes: 5 additions & 1 deletion canvas/text.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ func (t *Text) Refresh() {

// NewText returns a new Text implementation
func NewText(text string, color color.Color) *Text {
size := float32(0)
if fyne.CurrentApp() != nil { // nil app possible if app not started
size = fyne.CurrentApp().Settings().Theme().Size("text") // manually name the size to avoid import loop
}
return &Text{
Color: color,
Text: text,
TextSize: fyne.CurrentApp().Settings().Theme().Size("text"), // manually name the size to avoid import loop
TextSize: size,
}
}
4 changes: 2 additions & 2 deletions cmd/fyne/internal/mobile/binres/binres.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ type ltoken struct {

// UnmarshalXML decodes an AndroidManifest.xml document returning type XML
// containing decoded resources.
func UnmarshalXML(r io.Reader, withIcon bool) (*XML, error) {
func UnmarshalXML(r io.Reader, withIcon bool, targetSDK int) (*XML, error) {
lr := &lineReader{r: r}
dec := xml.NewDecoder(lr)

Expand Down Expand Up @@ -273,7 +273,7 @@ func UnmarshalXML(r io.Reader, withIcon bool) (*XML, error) {
Space: androidSchema,
Local: "targetSdkVersion",
},
Value: "29",
Value: strconv.Itoa(targetSDK),
},
},
}
Expand Down
4 changes: 2 additions & 2 deletions cmd/fyne/internal/mobile/binres/binres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func TestEncode(t *testing.T) {
f, err := os.Open("testdata/bootstrap.xml")
r.NoError(err)

bx, err := UnmarshalXML(f, false)
bx, err := UnmarshalXML(f, false, 30)
r.NoError(err)

bin, err := ioutil.ReadFile("testdata/bootstrap.bin")
Expand Down Expand Up @@ -183,7 +183,7 @@ func TestRawValueByName(t *testing.T) {
f, err := os.Open("testdata/bootstrap.xml")
r.NoError(err)

bx, err := UnmarshalXML(f, false)
bx, err := UnmarshalXML(f, false, 30)
r.NoError(err)

pkgname, err := bx.RawValueByName("manifest", xml.Name{Local: "package"})
Expand Down
6 changes: 5 additions & 1 deletion cmd/fyne/internal/mobile/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ func runBuildImpl(cmd *command) (*packages.Package, error) {
}
return pkg, nil
}
nmpkgs, err = goAndroidBuild(pkg, buildBundleID, targetArchs, cmd.IconPath, cmd.AppName, cmd.Version, cmd.Build)
target := 30
if !buildRelease {
target = 29 // TODO once we have gomobile debug signing working for v2 android signs
}
nmpkgs, err = goAndroidBuild(pkg, buildBundleID, targetArchs, cmd.IconPath, cmd.AppName, cmd.Version, cmd.Build, target, buildRelease)
if err != nil {
return nil, err
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/fyne/internal/mobile/build_androidapp.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
)

func goAndroidBuild(pkg *packages.Package, bundleID string, androidArchs []string,
iconPath, appName, version string, build int) (map[string]bool, error) {
iconPath, appName, version string, build, target int, release bool) (map[string]bool, error) {
ndkRoot, err := ndkRoot()
if err != nil {
return nil, err
Expand Down Expand Up @@ -117,7 +117,7 @@ func goAndroidBuild(pkg *packages.Package, bundleID string, androidArchs []strin
if err != nil {
return nil, err
}
err = addAssets(apkw, manifestData, dir, iconPath)
err = addAssets(apkw, manifestData, dir, iconPath, target)
if err != nil {
return nil, err
}
Expand All @@ -134,7 +134,7 @@ func goAndroidBuild(pkg *packages.Package, bundleID string, androidArchs []strin
return nmpkgs[androidArchs[0]], nil
}

func addAssets(apkw *Writer, manifestData []byte, dir, iconPath string) error {
func addAssets(apkw *Writer, manifestData []byte, dir, iconPath string, target int) error {
// Add any assets.
var arsc struct {
iconPath string
Expand Down Expand Up @@ -186,7 +186,7 @@ func addAssets(apkw *Writer, manifestData []byte, dir, iconPath string) error {
}
}

bxml, err := binres.UnmarshalXML(bytes.NewReader(manifestData), arsc.iconPath != "")
bxml, err := binres.UnmarshalXML(bytes.NewReader(manifestData), arsc.iconPath != "", target)
if err != nil {
return err
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/fyne_demo/tutorials/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,9 @@ func makeFormTab(_ fyne.Window) fyne.CanvasObject {
password := widget.NewPasswordEntry()
password.SetPlaceHolder("Password")

disabled := widget.NewRadioGroup([]string{"Option 1", "Option 2"}, func(string) {})
disabled.Horizontal = true
disabled.Disable()
largeText := widget.NewMultiLineEntry()

form := &widget.Form{
Expand All @@ -344,6 +347,7 @@ func makeFormTab(_ fyne.Window) fyne.CanvasObject {
},
}
form.Append("Password", password)
form.Append("Disabled", disabled)
form.Append("Message", largeText)
return form
}
Expand Down
25 changes: 15 additions & 10 deletions internal/driver/glfw/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,10 @@ func (w *window) SetContent(content fyne.CanvasObject) {
}

w.canvas.SetContent(content)
// show new canvas element
if content != nil {
content.Show()
}
w.RescaleContext()
}

Expand Down Expand Up @@ -596,7 +600,6 @@ func (w *window) mouseMoved(viewport *glfw.Window, xpos float64, ypos float64) {
w.mousePos = fyne.NewPos(internal.UnscaleInt(w.canvas, int(xpos)), internal.UnscaleInt(w.canvas, int(ypos)))
mousePos := w.mousePos
mouseButton := w.mouseButton
mouseDragStarted := w.mouseDragStarted
mouseOver := w.mouseOver
w.mouseLock.Unlock()

Expand Down Expand Up @@ -631,7 +634,7 @@ func (w *window) mouseMoved(viewport *glfw.Window, xpos float64, ypos float64) {
}
}

if mouseButton != 0 && mouseButton != desktop.MouseButtonSecondary && !mouseDragStarted {
if w.mouseButton != 0 && w.mouseButton != desktop.MouseButtonSecondary && !w.mouseDragStarted {
obj, pos, _ := w.findObjectAtPositionMatching(w.canvas, previousPos, func(object fyne.CanvasObject) bool {
_, ok := object.(fyne.Draggable)
return ok
Expand Down Expand Up @@ -690,14 +693,16 @@ func (w *window) mouseMoved(viewport *glfw.Window, xpos float64, ypos float64) {
mouseDraggedOffset := w.mouseDraggedOffset
mouseDragPos := w.mouseDragPos
w.mouseLock.RUnlock()
if mouseDragged != nil && mouseButton > 0 && mouseButton != desktop.MouseButtonSecondary {
draggedObjDelta := mouseDraggedObjStart.Subtract(mouseDragged.(fyne.CanvasObject).Position())
ev := new(fyne.DragEvent)
ev.AbsolutePosition = mousePos
ev.Position = mousePos.Subtract(mouseDraggedOffset).Add(draggedObjDelta)
ev.Dragged = fyne.NewDelta(mousePos.X-mouseDragPos.X, mousePos.Y-mouseDragPos.Y)
wd := mouseDragged
w.QueueEvent(func() { wd.Dragged(ev) })
if w.mouseDragged != nil && w.mouseButton != desktop.MouseButtonSecondary {
if w.mouseButton > 0 {
draggedObjDelta := mouseDraggedObjStart.Subtract(mouseDragged.(fyne.CanvasObject).Position())
ev := new(fyne.DragEvent)
ev.AbsolutePosition = mousePos
ev.Position = mousePos.Subtract(mouseDraggedOffset).Add(draggedObjDelta)
ev.Dragged = fyne.NewDelta(mousePos.X-mouseDragPos.X, mousePos.Y-mouseDragPos.Y)
wd := mouseDragged
w.QueueEvent(func() { wd.Dragged(ev) })
}

w.mouseLock.Lock()
w.mouseDragStarted = true
Expand Down
38 changes: 38 additions & 0 deletions internal/driver/glfw/window_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,30 @@ func TestWindow_HandleDragging(t *testing.T) {
assert.Nil(t, d1.popDragEvent())
assert.Nil(t, d2.popDragEvent())

// no drag event on secondary mouseDown
w.mouseClicked(w.viewport, glfw.MouseButton2, glfw.Press, 0)
w.WaitForEvents()
assert.Nil(t, d1.popDragEvent())
assert.Nil(t, d2.popDragEvent())

// no drag start and no drag event with pressed secondary mouse button
w.mouseMoved(w.viewport, 8, 8)
w.WaitForEvents()
assert.Nil(t, d1.popDragEvent())
assert.Nil(t, d2.popDragEvent())

// no drag end event on secondary mouseUp
w.mouseClicked(w.viewport, glfw.MouseButton2, glfw.Release, 0)
w.WaitForEvents()
assert.Nil(t, d1.popDragEndEvent())
assert.Nil(t, d2.popDragEndEvent())

// no drag event in simple move
w.mouseMoved(w.viewport, 9, 9)
w.WaitForEvents()
assert.Nil(t, d1.popDragEvent())
assert.Nil(t, d2.popDragEvent())

// no drag event on mouseDown
w.mouseClicked(w.viewport, glfw.MouseButton1, glfw.Press, 0)
w.WaitForEvents()
Expand Down Expand Up @@ -1594,6 +1618,20 @@ func TestWindow_CloseInterception(t *testing.T) {
assert.True(t, onClosed) // Close is called if the interceptor is not set.
}

func TestWindow_SetContent_Twice(t *testing.T) {
w := createWindow("Test").(*window)

e1 := widget.NewLabel("1")
e2 := widget.NewLabel("2")

w.SetContent(e1)
assert.True(t, e1.Visible())
w.SetContent(e2)
assert.True(t, e2.Visible())
w.SetContent(e1)
assert.True(t, e1.Visible())
}

// This test makes our developer screens flash, let's not run it regularly...
//func TestWindow_Shortcut(t *testing.T) {
// w := createWindow("Test")
Expand Down
27 changes: 22 additions & 5 deletions internal/driver/gomobile/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,9 +197,9 @@ func (d *mobileDriver) Run() {
}
case key.Event:
if e.Direction == key.DirPress {
d.typeDownCanvas(c, e.Rune, e.Code)
d.typeDownCanvas(c, e.Rune, e.Code, e.Modifiers)
} else if e.Direction == key.DirRelease {
d.typeUpCanvas(c, e.Rune, e.Code)
d.typeUpCanvas(c, e.Rune, e.Code, e.Modifiers)
}
}
}
Expand Down Expand Up @@ -471,8 +471,26 @@ func runeToPrintable(r rune) rune {
return 0
}

func (d *mobileDriver) typeDownCanvas(canvas *mobileCanvas, r rune, code key.Code) {
func (d *mobileDriver) typeDownCanvas(canvas *mobileCanvas, r rune, code key.Code, mod key.Modifiers) {
keyName := keyToName(code)
switch keyName {
case fyne.KeyTab:
capture := false
if ent, ok := canvas.Focused().(fyne.Tabbable); ok {
capture = ent.AcceptsTab()
}
if !capture {
switch mod {
case 0:
canvas.FocusNext()
return
case key.ModShift:
canvas.FocusPrevious()
return
}
}
}

r = runeToPrintable(r)
keyEvent := &fyne.KeyEvent{Name: keyName}

Expand Down Expand Up @@ -501,8 +519,7 @@ func (d *mobileDriver) typeDownCanvas(canvas *mobileCanvas, r rune, code key.Cod
}
}

func (d *mobileDriver) typeUpCanvas(canvas *mobileCanvas, r rune, code key.Code) {

func (d *mobileDriver) typeUpCanvas(_ *mobileCanvas, _ rune, _ key.Code, _ key.Modifiers) {
}

func (d *mobileDriver) Device() fyne.Device {
Expand Down
6 changes: 5 additions & 1 deletion internal/painter/gl/draw.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gl

import (
"image/color"
"math"

"fyne.io/fyne/v2"
Expand Down Expand Up @@ -55,12 +56,15 @@ func (p *glPainter) drawGradient(o fyne.CanvasObject, texCreator func(fyne.Canva
}

func (p *glPainter) drawRectangle(rect *canvas.Rectangle, pos fyne.Position, frame fyne.Size) {
if (rect.FillColor == color.Transparent || rect.FillColor == nil) && (rect.StrokeColor == color.Transparent || rect.FillColor == nil || rect.StrokeWidth == 0) {
return
}
p.drawTextureWithDetails(rect, p.newGlRectTexture, pos, rect.Size(), frame, canvas.ImageFillStretch,
1.0, painter.VectorPad(rect))
}

func (p *glPainter) drawText(text *canvas.Text, pos fyne.Position, frame fyne.Size) {
if text.Text == "" {
if text.Text == "" || text.Text == " " {
return
}

Expand Down
Loading

0 comments on commit a0fff44

Please sign in to comment.