Skip to content

Commit

Permalink
Merge branch 'release/v1.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Dec 24, 2019
2 parents a359961 + 3398cb7 commit 196202c
Show file tree
Hide file tree
Showing 17 changed files with 194 additions and 79 deletions.
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@
This file lists the main changes with each version of the Fyne toolkit.
More detailed release notes can be found on the [releases page](https://github.com/fyne-io/fyne/releases).

## 1.2.1 - Under development

### Added

* Add TouchDown, TouchUp and TouchCancel API in driver/mobile for device specific events
* Add support for adding and removing tabs from a tab container (#444)

### Fixed

* Issues when settings changes may not be monitored (#576)
* Layout of hidden tab container contents on mobile (#578)
* Mobile apps would not quit when Quit() was called (#580)
* Shadows disappeared when theme changes (#589)
* iOS apps could stop rendering after many refreshes (#584)
* Fyne package could fail on Windows (#586)
* Horizontal only scroll container may not refresh using scroll wheel


## 1.2 - 12 December 2019

### Added
Expand Down
2 changes: 2 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ type App interface {

// Calling Quit on the application will cause the application to exit
// cleanly, closing all open windows.
// This should be used with caution, many platforms discourage exiting an application
// from within the code and some mobile systems do not allow it.
Quit()

// Driver returns the driver that is rendering this application.
Expand Down
9 changes: 7 additions & 2 deletions cmd/fyne/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,15 @@ func (b *builder) build() error {
goos = runtime.GOOS
}

cmd := exec.Command("go", "build", b.srcdir)
var cmd *exec.Cmd
if goos == "windows" {
cmd = exec.Command("go", "build", "-ldflags", "-H=windowsgui", ".")
} else {
cmd = exec.Command("go", "build", ".")
}
cmd.Dir = b.srcdir
env := os.Environ()
env = append(env, "GOOS=", goos)
env = append(env, "GOOS="+goos)
cmd.Env = env

out, err := cmd.CombinedOutput()
Expand Down
12 changes: 5 additions & 7 deletions cmd/fyne_demo/screens/widget.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,12 @@ func makeScrollTab() fyne.CanvasObject {
}))
}

scroll := widget.NewScrollContainer(list)
scroll.Resize(fyne.NewSize(200, 300))
horiz := widget.NewScrollContainer(list)
vert := widget.NewScrollContainer(list2)

scroll2 := widget.NewScrollContainer(list2)
scroll2.Resize(fyne.NewSize(200, 100))

return fyne.NewContainerWithLayout(layout.NewGridLayout(1), scroll, scroll2)
scrolls := fyne.NewContainerWithLayout(layout.NewBorderLayout(horiz, nil, nil, nil),
horiz, vert)
return fyne.NewContainerWithLayout(layout.NewAdaptiveGridLayout(2), scrolls, makeScrollBothTab())
}

func makeScrollBothTab() fyne.CanvasObject {
Expand Down Expand Up @@ -151,7 +150,6 @@ func WidgetScreen() fyne.CanvasObject {
widget.NewTabItem("Progress", makeProgressTab()),
widget.NewTabItem("Form", makeFormTab()),
widget.NewTabItem("Scroll", makeScrollTab()),
widget.NewTabItem("Full Scroll", makeScrollBothTab()),
),
)
}
40 changes: 23 additions & 17 deletions internal/driver/gomobile/driver.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package gomobile

import (
"fmt"
"runtime"
"strconv"
"time"
Expand All @@ -26,6 +27,7 @@ const tapSecondaryDelay = 300 * time.Millisecond

type mobileDriver struct {
app app.App
quit bool
glctx gl.Context

windows []fyne.Window
Expand Down Expand Up @@ -70,7 +72,7 @@ func (d *mobileDriver) CanvasForObject(fyne.CanvasObject) fyne.Canvas {
return nil
}

// TODO figure out how we handle multiple windows...
// TODO don't just assume it refers to the topmost window
return d.currentWindow().Canvas()
}

Expand All @@ -94,14 +96,13 @@ func (d *mobileDriver) Quit() {
return
}

// TODO? often mobile apps should not allow this...
d.app.Send(lifecycle.Event{From: lifecycle.StageAlive, To: lifecycle.StageDead, DrawContext: nil})
// TODO should this be disabled for iOS?
d.quit = true
}

func (d *mobileDriver) Run() {
app.Main(func(a app.App) {
d.app = a
quit := false

var currentSize size.Event
for e := range a.Events() {
Expand All @@ -123,7 +124,7 @@ func (d *mobileDriver) Run() {
d.glctx = nil
}
if e.Crosses(lifecycle.StageAlive) == lifecycle.CrossOff {
quit = true
d.quit = true
}
case size.Event:
currentSize = e
Expand All @@ -136,9 +137,17 @@ func (d *mobileDriver) Run() {
canvas.painter.Init() // we cannot init until the context is set above
}

d.freeDirtyTextures(canvas)
d.paintWindow(current, currentSize)
a.Publish()
if d.freeDirtyTextures(canvas) {
d.paintWindow(current, currentSize)
a.Publish()

err := d.glctx.GetError()
if err != 0 {
fyne.LogError(fmt.Sprintf("OpenGL Error: %d", err), nil)
}
}

time.Sleep(time.Millisecond * 10)
a.Send(paint.Event{})
case touch.Event:
switch e.Type {
Expand All @@ -157,17 +166,14 @@ func (d *mobileDriver) Run() {
}
}

if quit {
if d.quit {
break
}
}
})
}

func (d *mobileDriver) onStart() {
for _, win := range d.AllWindows() {
win.Canvas().(*mobileCanvas).painter.Init() // we cannot init until the context is set above
}
}

func (d *mobileDriver) onStop() {
Expand Down Expand Up @@ -422,17 +428,19 @@ func (d *mobileDriver) typeUpCanvas(canvas *mobileCanvas, r rune, code key.Code)

}

func (d *mobileDriver) freeDirtyTextures(canvas *mobileCanvas) {
func (d *mobileDriver) freeDirtyTextures(canvas *mobileCanvas) bool {
freed := false
for {
select {
case object := <-canvas.refreshQueue:
freed = true
freeWalked := func(obj fyne.CanvasObject, _ fyne.Position, _ fyne.Position, _ fyne.Size) bool {
canvas.painter.Free(obj)
return false
}
driver.WalkCompleteObjectTree(object, freeWalked, nil)
default:
return
return freed
}
}
}
Expand All @@ -448,7 +456,5 @@ func (d *mobileDriver) Device() fyne.Device {
// NewGoMobileDriver sets up a new Driver instance implemented using the Go
// Mobile extension and OpenGL bindings.
func NewGoMobileDriver() fyne.Driver {
driver := new(mobileDriver)

return driver
return new(mobileDriver)
}
5 changes: 2 additions & 3 deletions internal/painter/gl/gl_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@ import (

"fyne.io/fyne"
"fyne.io/fyne/canvas"
"fyne.io/fyne/internal/cache"
"fyne.io/fyne/internal/painter"
"fyne.io/fyne/theme"
"fyne.io/fyne/widget"

"github.com/goki/freetype"
"github.com/goki/freetype/truetype"
"github.com/srwiley/rasterx"
Expand Down Expand Up @@ -84,7 +83,7 @@ func (p *glPainter) newGlLineTexture(obj fyne.CanvasObject) Texture {
func (p *glPainter) newGlRectTexture(rect fyne.CanvasObject) Texture {
col := theme.BackgroundColor()
if wid, ok := rect.(fyne.Widget); ok {
widCol := widget.Renderer(wid).BackgroundColor()
widCol := cache.Renderer(wid).BackgroundColor()
if widCol != nil {
col = widCol
}
Expand Down
2 changes: 1 addition & 1 deletion internal/painter/gl/gl_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ func glInit() {
}

gl.Disable(gl.DEPTH_TEST)
gl.Enable(gl.BLEND)
}

func compileShader(source string, shaderType uint32) (uint32, error) {
Expand Down Expand Up @@ -198,7 +199,6 @@ func (p *glPainter) glFreeBuffer(vbo Buffer) {
}

func (p *glPainter) glDrawTexture(texture Texture, alpha float32) {
gl.Enable(gl.BLEND)
// here we have to choose between blending the image alpha or fading it...
// TODO find a way to support both
if alpha != 1.0 {
Expand Down
2 changes: 1 addition & 1 deletion internal/painter/gl/gl_es.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ func glInit() {
}

gl.Disable(gl.DEPTH_TEST)
gl.Enable(gl.BLEND)
}

func compileShader(source string, shaderType uint32) (uint32, error) {
Expand Down Expand Up @@ -199,7 +200,6 @@ func (p *glPainter) glFreeBuffer(vbo Buffer) {
}

func (p *glPainter) glDrawTexture(texture Texture, alpha float32) {
gl.Enable(gl.BLEND)
// here we have to choose between blending the image alpha or fading it...
// TODO find a way to support both
if alpha != 1.0 {
Expand Down
6 changes: 5 additions & 1 deletion internal/painter/gl/gl_gomobile.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ const (

func (p *glPainter) Init() {
p.glctx().Disable(gl.DEPTH_TEST)
p.glctx().Enable(gl.BLEND)
sharedBuffer = p.glctx().CreateBuffer()

vertexShader, err := p.compileShader(vertexShaderSource, gl.VERTEX_SHADER)
Expand Down Expand Up @@ -179,9 +180,12 @@ func (p *glPainter) glCreateBuffer(points []float32) Buffer {
return Buffer(sharedBuffer)
}

func (p *glPainter) glFreeBuffer(_ Buffer) {
// we don't free a shared buffer!
}

func (p *glPainter) glDrawTexture(texture Texture, alpha float32) {
ctx := p.glctx()
ctx.Enable(gl.BLEND)

// here we have to choose between blending the image alpha or fading it...
// TODO find a way to support both
Expand Down
12 changes: 0 additions & 12 deletions internal/painter/gl/gl_gomobile_ios.go

This file was deleted.

7 changes: 0 additions & 7 deletions internal/painter/gl/gl_gomobile_other.go

This file was deleted.

8 changes: 6 additions & 2 deletions widget/button.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
type buttonRenderer struct {
icon *canvas.Image
label *canvas.Text
shadow fyne.CanvasObject
shadow *shadow

objects []fyne.CanvasObject
button *Button
Expand Down Expand Up @@ -125,6 +125,10 @@ func (b *buttonRenderer) Refresh() {
b.icon.Hide()
}

if b.shadow != nil {
b.shadow.depth = theme.Padding() / 2
}

b.Layout(b.button.Size())
canvas.Refresh(b.button)
}
Expand Down Expand Up @@ -206,7 +210,7 @@ func (b *Button) CreateRenderer() fyne.WidgetRenderer {
objects := []fyne.CanvasObject{
text,
}
var shadow fyne.CanvasObject
var shadow *shadow
if !b.HideShadow {
shadow = newShadow(shadowAround, theme.Padding()/2)
objects = append(objects, shadow)
Expand Down
14 changes: 10 additions & 4 deletions widget/scroller.go
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ type scrollContainerRenderer struct {
scroll *ScrollContainer
vertArea *scrollBarArea
horizArea *scrollBarArea
leftShadow, rightShadow fyne.CanvasObject
topShadow, bottomShadow fyne.CanvasObject
leftShadow, rightShadow *shadow
topShadow, bottomShadow *shadow

objects []fyne.CanvasObject
}
Expand Down Expand Up @@ -265,14 +265,19 @@ func (r *scrollContainerRenderer) Layout(size fyne.Size) {
}

func (r *scrollContainerRenderer) MinSize() fyne.Size {
return fyne.NewSize(25, 25) // TODO consider the smallest useful scroll view?
return fyne.NewSize(32, 32) // TODO consider the smallest useful scroll view?
}

func (r *scrollContainerRenderer) Objects() []fyne.CanvasObject {
return r.objects
}

func (r *scrollContainerRenderer) Refresh() {
r.leftShadow.depth = theme.Padding() * 2
r.rightShadow.depth = theme.Padding() * 2
r.topShadow.depth = theme.Padding() * 2
r.bottomShadow.depth = theme.Padding() * 2

r.Layout(r.scroll.Size())
}

Expand Down Expand Up @@ -315,7 +320,8 @@ func (r *scrollContainerRenderer) updatePosition() {
Renderer(r.vertArea).Layout(r.scroll.size)
Renderer(r.horizArea).Layout(r.scroll.size)

canvas.Refresh(r.vertArea) // this is required to force the canvas to update, we have no "Redraw()"
canvas.Refresh(r.vertArea) // this is required to force the canvas to update, we have no "Redraw()"
canvas.Refresh(r.horizArea) // this is required like above but if we are horizontal
}

// ScrollContainer defines a container that is smaller than the Content.
Expand Down
Loading

0 comments on commit 196202c

Please sign in to comment.