Files
8bitMyGoUI/desk/desktop.go
T
ZacharyZhang-NY 7800003418 Add desk components 466-485 and icon.Bomb
Twenty pieces of a retro desktop: Desktop, DesktopIcon, Taskbar,
StartMenu, AppWindow, Calculator, Notepad, Minesweeper, ControlPanel,
TrayIcons, ShutdownScreen, BootScreen, Screensaver, Snake, Dock,
RunDialog, DiskDefrag, WallpaperPicker, ClipboardPanel and LockScreen.

The calculator really adds up and calls division by zero GAME OVER;
Minesweeper and Snake are playable, first click always safe; START
cascades its submenus without moving the rows already open; windows
drag by whole dots; the screensaver's logo changes color at each wall
and sparkles in a corner; the defragmenter is oddly soothing. Clocks
that step back hold at zero, and typed or copied text never reaches
the log.

icon.Bomb is the new 12x12 mine.
2026-10-12 13:13:44 -04:00

25 lines
813 B
Go

package desk
import (
"github.com/egoist/mygo/ui"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
)
type DesktopOptions struct {
Wallpaper Wallpaper
// Width and Height are dots; zeros mean 320 by 200.
Width, Height int
}
// Desktop lays icons down a dithered wallpaper, column by column.
func Desktop(c *ui.Context, text string, o DesktopOptions, icons func()) *ui.Element {
k := pixel.K(c)
o.Wallpaper.name(k)
w, h := pixel.Or("Desktop Width", o.Width, 320), pixel.Or("Desktop Height", o.Height, 200)
return ui.Column(c).Size(k.D(w), k.D(h)).Wrap().AlignContent(ui.Start).Padding(k.D(4)).Gap(k.D(2)).Clip().
FocusGroup(ui.Horizontal | ui.Vertical).Role(ui.RoleGroup).Label(text).Draw(func(p *ui.Painter, r ui.Rect) {
paper(k.Canvas(p, r), 0, 0, w, h, o.Wallpaper)
}).Children(icons)
}