Skip to content

Commit

Permalink
fix most of the layout issues
Browse files Browse the repository at this point in the history
  • Loading branch information
chabad360 committed May 9, 2024
1 parent e48ff6f commit 235b378
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 43 deletions.
1 change: 1 addition & 0 deletions internal/driver/common/canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,7 @@ type RenderCacheNode struct {
// it may for instance point to a GL texture
// it should free all associated resources when released
// i.e. it should not simply be a texture reference integer
//lint:ignore U1000 this is supposed to be used?
painterData any
}

Expand Down
14 changes: 7 additions & 7 deletions internal/driver/software/canvas.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,13 +304,13 @@ func (c *SoftwareCanvas) Size() fyne.Size {
}

// canvasSize computes the needed canvas size for the given content size
func (c *SoftwareCanvas) canvasSize(contentSize fyne.Size) fyne.Size {
canvasSize := contentSize.Add(fyne.NewSize(0, 0))
if c.padded {
return canvasSize.Add(fyne.NewSquareSize(theme.Padding() * 2))
}
return canvasSize
}
// func (c *SoftwareCanvas) canvasSize(contentSize fyne.Size) fyne.Size {
// canvasSize := contentSize.Add(fyne.NewSize(0, 0))
// if c.padded {
// return canvasSize.Add(fyne.NewSquareSize(theme.Padding() * 2))
// }
// return canvasSize
// }

func (c *SoftwareCanvas) objectTrees() []fyne.CanvasObject {
trees := make([]fyne.CanvasObject, 0, len(c.Overlays().List())+1)
Expand Down
36 changes: 36 additions & 0 deletions internal/driver/software/device.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package software

import (
"runtime"

"fyne.io/fyne/v2"
)

type device struct{}

// Declare conformity with Device
var _ fyne.Device = (*device)(nil)

func (d *device) Orientation() fyne.DeviceOrientation {
return fyne.OrientationVertical
}

func (d *device) HasKeyboard() bool {
return false
}

func (d *device) SystemScale() float32 {
return d.SystemScaleForWindow(nil)
}

func (d *device) SystemScaleForWindow(fyne.Window) float32 {
return 1
}

func (d *device) Locale() fyne.Locale {
return "en"
}

func (*device) IsBrowser() bool {
return runtime.GOARCH == "js" || runtime.GOOS == "js"
}
7 changes: 7 additions & 0 deletions internal/driver/software/device_mobile.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build mobile

package software

func (d *device) IsMobile() bool {
return true
}
7 changes: 7 additions & 0 deletions internal/driver/software/device_other.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build !mobile

package software

func (d *device) IsMobile() bool {
return false
}
35 changes: 0 additions & 35 deletions internal/driver/software/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package software
import (
"fmt"
"image"
"runtime"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -37,40 +36,6 @@ type SoftwareDriver struct {
// Declare conformity with Driver
var _ fyne.Driver = (*SoftwareDriver)(nil)

type device struct {
}

// Declare conformity with Device
var _ fyne.Device = (*device)(nil)

func (d *device) Orientation() fyne.DeviceOrientation {
return fyne.OrientationVertical
}

func (d *device) HasKeyboard() bool {
return false
}

func (d *device) SystemScale() float32 {
return d.SystemScaleForWindow(nil)
}

func (d *device) SystemScaleForWindow(fyne.Window) float32 {
return 1
}

func (d *device) Locale() fyne.Locale {
return "en"
}

func (*device) IsBrowser() bool {
return runtime.GOARCH == "js" || runtime.GOOS == "js"
}

func (d *device) IsMobile() bool {
return true
}

// NewDriver sets up and registers a new dummy driver for test purpose
func NewDriver(painter func(image.Image, []image.Rectangle), events chan any) fyne.Driver {
drv := &SoftwareDriver{
Expand Down
2 changes: 1 addition & 1 deletion internal/painter/software/texture.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fyne.io/fyne/v2/internal/cache"
)

var noTexture = Texture(cache.NoTexture)
// var noTexture = Texture(cache.NoTexture)

// Texture represents a cached image texture
type Texture cache.TextureType
Expand Down

0 comments on commit 235b378

Please sign in to comment.