Skip to content

Commit

Permalink
Update scroll position when user changes directory
Browse files Browse the repository at this point in the history
Fixes #800
  • Loading branch information
andydotxyz committed Apr 2, 2020
1 parent 16e4f16 commit c0544ef
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions dialog/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type fileDialog struct {
open *widget.Button
breadcrumb *widget.Box
files *fyne.Container
fileScroll *widget.ScrollContainer
parent fyne.Window

win *widget.PopUp
Expand Down Expand Up @@ -102,15 +103,15 @@ func (f *fileDialog) makeUI() fyne.CanvasObject {
f.files = fyne.NewContainerWithLayout(layout.NewFixedGridLayout(fyne.NewSize(fileIconCellWidth,
fileIconSize+theme.Padding()+fileTextSize)),
)
fileScroll := widget.NewScrollContainer(f.files)
f.fileScroll = widget.NewScrollContainer(f.files)
verticalExtra := int(float64(fileIconSize) * 0.25)
fileScroll.SetMinSize(fyne.NewSize(fileIconCellWidth*2+theme.Padding(),
f.fileScroll.SetMinSize(fyne.NewSize(fileIconCellWidth*2+theme.Padding(),
(fileIconSize+fileTextSize)+theme.Padding()*2+verticalExtra))

f.breadcrumb = widget.NewHBox()
scrollBread := widget.NewScrollContainer(f.breadcrumb)
body := fyne.NewContainerWithLayout(layout.NewBorderLayout(scrollBread, nil, nil, nil),
scrollBread, fileScroll)
scrollBread, f.fileScroll)
header := widget.NewLabelWithStyle(label+" File", fyne.TextAlignLeading, fyne.TextStyle{Bold: true})
favourites := widget.NewGroup("Favourites", f.loadFavourites()...)
return fyne.NewContainerWithLayout(layout.NewBorderLayout(header, footer, favourites, nil),
Expand Down Expand Up @@ -164,6 +165,8 @@ func (f *fileDialog) refreshDir(dir string) {

f.files.Objects = icons
f.files.Refresh()
f.fileScroll.Offset = fyne.NewPos(0, 0)
f.fileScroll.Refresh()
}

func (f *fileDialog) setDirectory(dir string) {
Expand Down

0 comments on commit c0544ef

Please sign in to comment.