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.
This commit is contained in:
ZacharyZhang-NY committed 2026-10-12 13:13:44 -04:00
1 parent d60d53ef90
commit 7800003418
39 files changed
+4120 -2

No files matched your search

+52
View File
@@ -0,0 +1,52 @@
package desk
import (
"log/slog"
"unicode/utf8"
"github.com/egoist/mygo/ui"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/input"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/navigation"
"git.zacharyzhang.com/ZacharyZhang-NY/8bitMyGoUI/pixel"
)
type NotepadOptions struct {
// Width is in dots, zero 240; Lines zero means 6.
Width, Lines int
Disabled bool
}
type NotepadResult struct {
Element *ui.Element
// Saved is FILE, SAVE chosen this frame.
Changed, Saved bool
}
// Notepad is a text area under FILE and EDIT menus.
func Notepad(c *ui.Context, text string, value *string, o NotepadOptions) NotepadResult {
k := pixel.K(c)
w, lines := pixel.Or("Notepad Width", o.Width, 240), pixel.Or("Notepad Lines", o.Lines, 6)
var res NotepadResult
res.Element = ui.Column(c).Width(k.D(w)).Gap(k.D(2)).Role(ui.RoleGroup).Label(text).Children(func() {
m := navigation.MenuBar(c, k.Msg("menu_bar"), []navigation.Menu{
{Title: k.Msg("file_menu"), Items: []navigation.MenuItem{{Label: k.Msg("new_file")}, {Label: k.Msg("save")}}},
{Title: k.Msg("edit_menu"), Items: []navigation.MenuItem{{Label: k.Msg("time_date")}}},
}, navigation.MenuBarOptions{Disabled: o.Disabled})
switch [2]int{m.Menu, m.Item} {
case [2]int{0, 0}:
*value, res.Changed = "", true
case [2]int{0, 1}:
res.Saved = true
case [2]int{1, 0}:
// As old Notepad's F5: the time and date, typed in.
*value, res.Changed = *value+k.Now().Format("15:04 2006-01-02"), true
}
f := input.TextArea(c, text, value, input.TextAreaOptions{Width: w, Lines: lines, Disabled: o.Disabled})
res.Changed = res.Changed || f.Changed
})
if res.Changed || res.Saved {
slog.Debug("8bit: notepad", "label", text, "runes", utf8.RuneCountInString(*value), "saved", res.Saved)
}
return res
}