Skip to content

Commit

Permalink
Merge branch 'develop' into moredeprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
andydotxyz committed Jan 15, 2021
2 parents 12cf8bb + 11b7968 commit 67e0c78
Show file tree
Hide file tree
Showing 271 changed files with 622 additions and 753 deletions.
7 changes: 2 additions & 5 deletions cmd/fyne_settings/settings/appearance.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func newColorButton(n string, c color.Color, s *Settings) *colorButton {
}

func (c *colorButton) CreateRenderer() fyne.WidgetRenderer {
r := canvas.NewRectangle(color.Transparent)
r := canvas.NewRectangle(c.color)
r.StrokeWidth = 5

if c.name == c.s.fyneSettings.PrimaryColor {
Expand Down Expand Up @@ -230,14 +230,11 @@ func (c *colorRenderer) Refresh() {
} else {
c.rect.StrokeColor = color.Transparent
}
c.rect.FillColor = c.c.color

c.rect.Refresh()
}

func (c *colorRenderer) BackgroundColor() color.Color {
return c.c.color
}

func (c *colorRenderer) Objects() []fyne.CanvasObject {
return c.objs
}
Expand Down
44 changes: 21 additions & 23 deletions container/split.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package container

import (
"image/color"

"fyne.io/fyne"
"fyne.io/fyne/canvas"
"fyne.io/fyne/driver/desktop"
Expand Down Expand Up @@ -82,10 +80,6 @@ type splitContainerRenderer struct {
objects []fyne.CanvasObject
}

func (r *splitContainerRenderer) BackgroundColor() color.Color {
return theme.BackgroundColor()
}

func (r *splitContainerRenderer) Destroy() {
}

Expand Down Expand Up @@ -202,11 +196,13 @@ func newDivider(split *Split) *divider {
// CreateRenderer is a private method to Fyne which links this widget to its renderer
func (d *divider) CreateRenderer() fyne.WidgetRenderer {
d.ExtendBaseWidget(d)
r := canvas.NewRectangle(theme.ForegroundColor())
background := canvas.NewRectangle(theme.ShadowColor())
foreground := canvas.NewRectangle(theme.ForegroundColor())
return &dividerRenderer{
divider: d,
rectangle: r,
objects: []fyne.CanvasObject{r},
divider: d,
background: background,
foreground: foreground,
objects: []fyne.CanvasObject{background, foreground},
}
}

Expand Down Expand Up @@ -257,22 +253,17 @@ func (d *divider) MouseOut() {
var _ fyne.WidgetRenderer = (*dividerRenderer)(nil)

type dividerRenderer struct {
divider *divider
rectangle *canvas.Rectangle
objects []fyne.CanvasObject
}

func (r *dividerRenderer) BackgroundColor() color.Color {
if r.divider.hovered {
return theme.HoverColor()
}
return theme.ShadowColor()
divider *divider
background *canvas.Rectangle
foreground *canvas.Rectangle
objects []fyne.CanvasObject
}

func (r *dividerRenderer) Destroy() {
}

func (r *dividerRenderer) Layout(size fyne.Size) {
r.background.Resize(size)
var x, y, w, h float32
if r.divider.split.Horizontal {
x = (dividerThickness() - handleThickness()) / 2
Expand All @@ -285,8 +276,8 @@ func (r *dividerRenderer) Layout(size fyne.Size) {
w = handleLength()
h = handleThickness()
}
r.rectangle.Move(fyne.NewPos(x, y))
r.rectangle.Resize(fyne.NewSize(w, h))
r.foreground.Move(fyne.NewPos(x, y))
r.foreground.Resize(fyne.NewSize(w, h))
}

func (r *dividerRenderer) MinSize() fyne.Size {
Expand All @@ -301,7 +292,14 @@ func (r *dividerRenderer) Objects() []fyne.CanvasObject {
}

func (r *dividerRenderer) Refresh() {
r.rectangle.FillColor = theme.ForegroundColor()
if r.divider.hovered {
r.background.FillColor = theme.HoverColor()
} else {
r.background.FillColor = theme.ShadowColor()
}
r.background.Refresh()
r.foreground.FillColor = theme.ForegroundColor()
r.foreground.Refresh()
r.Layout(r.divider.Size())
}

Expand Down
36 changes: 23 additions & 13 deletions dialog/fileitem.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dialog

import (
"image/color"
"path/filepath"

"fyne.io/fyne"
Expand Down Expand Up @@ -32,11 +31,19 @@ func (i *fileDialogItem) Tapped(_ *fyne.PointEvent) {
}

func (i *fileDialogItem) CreateRenderer() fyne.WidgetRenderer {
background := canvas.NewRectangle(theme.PrimaryColor())
background.Hide()
text := widget.NewLabelWithStyle(i.name, fyne.TextAlignCenter, fyne.TextStyle{})
text.Wrapping = fyne.TextTruncate
icon := widget.NewFileIcon(i.location)

return &fileItemRenderer{item: i, icon: icon, text: text, objects: []fyne.CanvasObject{icon, text}}
return &fileItemRenderer{
item: i,
background: background,
icon: icon,
text: text,
objects: []fyne.CanvasObject{background, icon, text},
}
}

func fileName(path fyne.URI) (name string) {
Expand Down Expand Up @@ -72,34 +79,37 @@ func (f *fileDialog) newFileItem(location fyne.URI, dir bool) *fileDialogItem {
type fileItemRenderer struct {
item *fileDialogItem

icon *widget.FileIcon
text *widget.Label
objects []fyne.CanvasObject
background *canvas.Rectangle
icon *widget.FileIcon
text *widget.Label
objects []fyne.CanvasObject
}

func (s fileItemRenderer) Layout(size fyne.Size) {
s.background.Resize(size)

iconAlign := (size.Width - fileIconSize) / 2
s.icon.Resize(fyne.NewSize(fileIconSize, fileIconSize))
s.icon.Move(fyne.NewPos(iconAlign, 0))

s.text.Resize(fyne.NewSize(size.Width, fileTextSize))
s.text.Move(fyne.NewPos(0, fileIconSize+theme.Padding()))
s.text.Move(fyne.NewPos(0, size.Height-fileTextSize-theme.Padding()*2))
}

func (s fileItemRenderer) MinSize() fyne.Size {
return fyne.NewSize(fileIconSize, fileIconSize+fileTextSize+theme.Padding())
}

func (s fileItemRenderer) Refresh() {
s.icon.SetSelected(s.item.isCurrent)
canvas.Refresh(s.item)
}

func (s fileItemRenderer) BackgroundColor() color.Color {
if s.item.isCurrent {
return theme.PrimaryColor()
s.background.FillColor = theme.PrimaryColor()
s.background.Show()
} else {
s.background.Hide()
}
return theme.BackgroundColor()
s.background.Refresh()
s.icon.SetSelected(s.item.isCurrent)
canvas.Refresh(s.item)
}

func (s fileItemRenderer) Objects() []fyne.CanvasObject {
Expand Down
Binary file modified dialog/testdata/color/channel_layout_foobar_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/color/channel_layout_foobar_50.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/color/dialog_expanded_theme_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/color/dialog_expanded_theme_ugly.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/color/dialog_recents_theme_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/color/dialog_simple_recents_theme_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/color/dialog_simple_theme_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/color/dialog_theme_default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/color/picker_layout_advanced.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified dialog/testdata/dialog-custom-default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified driver/software/testdata/canvas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified driver/software/testdata/label_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions internal/driver/glfw/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ func Test_gLDriver_AbsolutePositionForObject(t *testing.T) {
repaintWindow(w.(*window))
// accessing the menu bar's actual CanvasObjects isn't straight forward
// 0 is the shadow
// 1 is the menu bar’s background
// 2 is the container holding the items
mbarCont := cache.Renderer(movl.(fyne.Widget)).Objects()[2].(*fyne.Container)
// 1 is the menu bar’s underlay
// 2 is the menu bar's background
// 3 is the container holding the items
mbarCont := cache.Renderer(movl.(fyne.Widget)).Objects()[3].(*fyne.Container)
m2 := mbarCont.Objects[1]

tests := map[string]struct {
Expand Down
Loading

0 comments on commit 67e0c78

Please sign in to comment.