Files
8bitMyGoUI/files/kinds.go
T
ZacharyZhang-NY 552b073e81 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.
2026-10-12 09:27:26 -04:00

115 lines
1.9 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package files
import (
"fmt"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
)
// Kind is what a file holds; it picks the icon.
type Kind int
const (
Folder Kind = iota
Text
Image
Audio
Code
Archive
)
type kindArt struct {
msg string
art *pixel.Sprite
}
// kinds name each Kind's message and 12×12 page (S7).
var kinds = []kindArt{
{"folder", pixel.MustSprite(`
............
............
.eeee.......
.eyyye......
.eyyyyeeeee.
.eyyyyyyyye.
.eeeeeeeeee.
.elllyyyyye.
.eyyyyyyyye.
.eyyyyyyyye.
.eeeeeeeeee.
............`)},
{"text_file", pixel.MustSprite(`
.eeeeeee....
.elllllee...
.elnnnlese..
.elllllesse.
.ellllleeee.
.elllllllle.
.elnnnnnnle.
.elllllllle.
.elnnnnnnle.
.elllllllle.
.elnnnnllle.
.eeeeeeeeee.`)},
{"image_file", pixel.MustSprite(`
.eeeeeee....
.elllllee...
.elllllese..
.elllllesse.
.ellllleeee.
.elllllllle.
.elccccyyle.
.elccgcccle.
.elcgggcgle.
.elggggggle.
.elllllllle.
.eeeeeeeeee.`)},
{"audio_file", pixel.MustSprite(`
.eeeeeee....
.elllllee...
.elllllese..
.elllllesse.
.ellllleeee.
.ellllmmlle.
.ellllmlmle.
.ellllmllle.
.ellmmmllle.
.elmmmmllle.
.ellmmlllle.
.eeeeeeeeee.`)},
{"code_file", pixel.MustSprite(`
.eeeeeee....
.elllllee...
.elllllese..
.elllllesse.
.ellllleeee.
.elllllllle.
.ellcllclle.
.elcllllcle.
.ecllllllce.
.elcllllcle.
.ellcllclle.
.eeeeeeeeee.`)},
{"archive_file", pixel.MustSprite(`
.eeeeeee....
.ellselee...
.elleslese..
.ellselesse.
.ellesleeee.
.ellselllle.
.elllllllle.
.elyyyyllle.
.elyeeyllle.
.elyyyyllle.
.elllllllle.
.eeeeeeeeee.`)},
}
// look returns kind's message and art; unknown kinds panic.
func look(kind Kind) kindArt {
if kind < 0 || int(kind) >= len(kinds) {
panic(fmt.Sprintf("files: unknown kind %d", kind))
}
return kinds[kind]
}