Add files components 406-420; Tree opens to a known choice
Fifteen file components: FileExplorer, FileGrid, FileIcon, PathBar, MemoryCard, DiskUsage, UploadQueue, Trash, RecentFiles, FilePreview, ArchiveViewer, FileDetails, SharePanel, SyncStatus and QuotaMeter. FileIcon draws six kinds as hand-placed 12x12 pages and a folder. The browsers build on data.Tree, List, GridView and Table; ArchiveViewer owns its sort and keeps the caller's index on its entry. UploadQueue keys rows by name so focus stays on its row. SharePanel never logs the link. SyncStatus turns its arrows on Busy steps, so syncing moves under Reduce Motion. data.Tree now opens the closed branches above a chosen path it knows, so a caller's starting path survives the first frame.
This commit is contained in:
30 files changed
+2416
-2
No files matched your search
@@ -0,0 +1,66 @@
|
||||
package files_test
|
||||
|
||||
import (
|
||||
"image"
|
||||
"testing"
|
||||
|
||||
"github.com/egoist/mygo/ui"
|
||||
|
||||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/files"
|
||||
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/icon"
|
||||
)
|
||||
|
||||
// offPalette counts dots no palette color matches.
|
||||
func offPalette(img *image.RGBA) int {
|
||||
b := img.Bounds()
|
||||
return count(img, 0, 0, b.Dx()/2, b.Dy()/2, none)
|
||||
}
|
||||
|
||||
func TestFilesStayOnThePaletteWhenOff(t *testing.T) {
|
||||
list := []files.File{{Name: "A.TXT", Kind: files.Text, Size: 1, Modified: newWorld().clk.t}}
|
||||
builds := map[string]func(c *ui.Context, off bool){
|
||||
"explorer": func(c *ui.Context, off bool) {
|
||||
p, f := "0/0/0", 0
|
||||
files.FileExplorer(c, "X", drive, &p, &f, files.FileExplorerOptions{Disabled: off})
|
||||
},
|
||||
"grid": func(c *ui.Context, off bool) {
|
||||
i := 0
|
||||
files.FileGrid(c, "X", list, &i, files.FileGridOptions{Disabled: off})
|
||||
},
|
||||
"path": func(c *ui.Context, off bool) {
|
||||
files.PathBar(c, "X", []string{"C:", "A"}, files.PathBarOptions{Disabled: off})
|
||||
},
|
||||
"card": func(c *ui.Context, off bool) {
|
||||
i := 0
|
||||
files.MemoryCard(c, "X", []files.Save{{Title: "A", Icon: icon.Sword}}, &i, files.MemoryCardOptions{Disabled: off})
|
||||
},
|
||||
"uploads": func(c *ui.Context, off bool) {
|
||||
files.UploadQueue(c, "X", []files.Upload{{Name: "A", Sent: 1, Size: 2}}, files.UploadQueueOptions{Disabled: off})
|
||||
},
|
||||
"trash": func(c *ui.Context, off bool) {
|
||||
files.Trash(c, "X", 2, files.TrashOptions{Disabled: off})
|
||||
},
|
||||
"recent": func(c *ui.Context, off bool) {
|
||||
i := 0
|
||||
files.RecentFiles(c, "X", list, &i, files.RecentFilesOptions{Disabled: off})
|
||||
},
|
||||
"archive": func(c *ui.Context, off bool) {
|
||||
i := 0
|
||||
files.ArchiveViewer(c, "X", []files.Entry{{Path: "A", Size: 2, Packed: 1}}, &i, files.ArchiveViewerOptions{Disabled: off})
|
||||
},
|
||||
"share": func(c *ui.Context, off bool) {
|
||||
a := files.CanView
|
||||
files.SharePanel(c, "X", "https://x.example", &a, files.SharePanelOptions{Disabled: off})
|
||||
},
|
||||
}
|
||||
for name, build := range builds {
|
||||
for _, inert := range []bool{false, true} {
|
||||
wd := newWorld()
|
||||
wd.inert = inert
|
||||
tt := view(700, 400, wd, func(c *ui.Context) { build(c, !inert) })
|
||||
if n := offPalette(tt.Image()); n != 0 {
|
||||
t.Errorf("%s, inert %v: %d pixels off the palette", name, inert, n)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user