Skip to content

Commit

Permalink
Simplify background with new SimpleRenderer
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Oct 15, 2023
1 parent 2d4de82 commit 46aed46
Showing 1 changed file with 1 addition and 33 deletions.
34 changes: 1 addition & 33 deletions internal/ui/background.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package ui

import (
"image/color"
"os"

"fyne.io/fyne/v2"
"fyne.io/fyne/v2/canvas"
"fyne.io/fyne/v2/container"
"fyne.io/fyne/v2/theme"
"fyne.io/fyne/v2/widget"

"fyshos.com/fynedesk"
Expand All @@ -17,41 +15,12 @@ import (
type background struct {
widget.BaseWidget

objects []fyne.CanvasObject
wallpaper *fyne.Container
}

func (b *background) CreateRenderer() fyne.WidgetRenderer {
c := container.NewStack(b.loadModules()...)
return &backgroundRenderer{b: b, c: c}
}

type backgroundRenderer struct {
b *background
c *fyne.Container
}

func (b *backgroundRenderer) Layout(s fyne.Size) {
b.c.Layout.Layout(b.c.Objects, s)
}

func (b *backgroundRenderer) MinSize() fyne.Size {
return b.c.Layout.MinSize(b.c.Objects)
}

func (b *backgroundRenderer) Refresh() {
b.c.Objects = b.b.objects
}

func (b *backgroundRenderer) BackgroundColor() color.Color {
return theme.BackgroundColor()
}

func (b *backgroundRenderer) Objects() []fyne.CanvasObject {
return b.c.Objects
}

func (b *backgroundRenderer) Destroy() {
return widget.NewSimpleRenderer(c)
}

func (b *background) loadModules() []fyne.CanvasObject {
Expand All @@ -68,7 +37,6 @@ func (b *background) loadModules() []fyne.CanvasObject {
}
}

b.objects = objects
return objects
}

Expand Down

0 comments on commit 46aed46

Please sign in to comment.