All examples work

This commit is contained in:
Sasha Koshka 2023-05-03 15:23:42 -04:00
parent cc03440125
commit 8d6deb3456
14 changed files with 112 additions and 58 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 300 B

After

Width:  |  Height:  |  Size: 350 B

View File

@ -92,7 +92,7 @@ func init () {
atlasCol(2, artist.I(1))
atlasCol(3, artist.I(1))
atlasCol(4, artist.I(1))
atlasCol(5, artist.I(2))
atlasCol(5, artist.I(3))
atlasCol(6, artist.I(1))
// set up small icons
@ -236,6 +236,7 @@ func (Default) Color (id tomo.Color, state tomo.State, c tomo.Case) color.RGBA {
func (Default) Padding (id tomo.Pattern, c tomo.Case) artist.Inset {
switch id {
case tomo.PatternGutter: return artist.I(0)
case tomo.PatternLine: return artist.I(1)
default: return artist.I(6)
}
}

View File

@ -17,7 +17,6 @@ var validImageTypes = []data.Mime {
data.M("image", "jpeg"),
}
func main () {
nasin.Run(Application { })
}

View File

@ -4,21 +4,25 @@ import "os"
import "image"
import _ "image/png"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/nasin"
import "git.tebibyte.media/sashakoshka/tomo/elements"
func main () {
tomo.Run(run)
nasin.Run(Application { })
}
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 383, 360))
type Application struct { }
func (Application) Init () error {
window, err := nasin.NewWindow(tomo.Bounds(0, 0, 383, 360))
if err != nil { return err }
window.SetTitle("Document Container")
file, err := os.Open("assets/banner.png")
if err != nil { panic(err.Error()); return }
if err != nil { return err }
logo, _, err := image.Decode(file)
file.Close()
if err != nil { panic(err.Error()); return }
if err != nil { return err }
document := elements.NewDocument()
document.Adopt (
@ -55,6 +59,7 @@ func run () {
}
window.Adopt(elements.NewScroll(elements.ScrollVertical, document))
window.OnClose(tomo.Stop)
window.OnClose(nasin.Stop)
window.Show()
return nil
}

View File

@ -3,18 +3,23 @@ package main
import "os"
import "path/filepath"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/nasin"
import "git.tebibyte.media/sashakoshka/tomo/elements"
func main () {
tomo.Run(run)
nasin.Run(Application { })
}
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 384, 384))
type Application struct { }
func (Application) Init () error {
window, err := nasin.NewWindow(tomo.Bounds(0, 0, 384, 384))
if err != nil { return err }
window.SetTitle("File browser")
container := elements.NewVBox(elements.SpaceBoth)
window.Adopt(container)
homeDir, _ := os.UserHomeDir()
homeDir, err := os.UserHomeDir()
if err != nil { return err }
controlBar := elements.NewHBox(elements.SpaceNone)
backButton := elements.NewButton("Back")
@ -77,6 +82,7 @@ func run () {
elements.NewScroll(elements.ScrollVertical, directoryView))
container.Adopt(statusBar)
window.OnClose(tomo.Stop)
window.OnClose(nasin.Stop)
window.Show()
return nil
}

View File

@ -1,14 +1,18 @@
package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/nasin"
import "git.tebibyte.media/sashakoshka/tomo/elements"
func main () {
tomo.Run(run)
nasin.Run(Application { })
}
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 360, 0))
type Application struct { }
func (Application) Init () error {
window, err := nasin.NewWindow(tomo.Bounds(0, 0, 360, 0))
if err != nil { return err }
window.SetTitle("Icons")
container := elements.NewVBox(elements.SpaceBoth)
@ -25,11 +29,12 @@ func run () {
closeButton := elements.NewButton("Yes verynice")
closeButton.SetIcon(tomo.IconYes)
closeButton.OnClick(tomo.Stop)
closeButton.OnClick(window.Close)
container.Adopt(closeButton)
window.OnClose(tomo.Stop)
window.OnClose(nasin.Stop)
window.Show()
return nil
}
func icons (min, max tomo.Icon) (container *elements.Box) {

View File

@ -6,22 +6,25 @@ import "bytes"
import _ "image/png"
import "github.com/jezek/xgbutil/gopher"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/nasin"
import "git.tebibyte.media/sashakoshka/tomo/popups"
import "git.tebibyte.media/sashakoshka/tomo/elements"
func main () {
tomo.Run(run)
nasin.Run(Application { })
}
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 0, 0))
type Application struct { }
func (Application) Init () error {
window, _ := nasin.NewWindow(tomo.Bounds(0, 0, 0, 0))
window.SetTitle("Tomo Logo")
file, err := os.Open("assets/banner.png")
if err != nil { fatalError(window, err); return }
if err != nil { return err }
logo, _, err := image.Decode(file)
file.Close()
if err != nil { fatalError(window, err); return }
if err != nil { return err }
container := elements.NewVBox(elements.SpaceBoth)
logoImage := elements.NewImage(logo)
@ -41,8 +44,9 @@ func run () {
button.Focus()
window.OnClose(tomo.Stop)
window.OnClose(nasin.Stop)
window.Show()
return nil
}
func fatalError (window tomo.Window, err error) {
@ -53,7 +57,7 @@ func fatalError (window tomo.Window, err error) {
err.Error(),
popups.Button {
Name: "OK",
OnPress: tomo.Stop,
OnPress: nasin.Stop,
})
}

View File

@ -6,11 +6,14 @@ import "git.tebibyte.media/sashakoshka/tomo/popups"
import "git.tebibyte.media/sashakoshka/tomo/elements"
func main () {
tomo.Run(run)
nasin.Run(Application { })
}
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 0, 0))
type Application struct { }
func (Application) Init () error {
window, err := nasin.NewWindow(tomo.Bounds(0, 0, 0, 0))
if err != nil { return err }
window.SetTitle("Enter Details")
container := elements.NewVBox(elements.SpaceBoth)
window.Adopt(container)
@ -59,6 +62,7 @@ func run () {
elements.NewLabel("Purpose:"),
purpose,
elements.NewLine(), button)
window.OnClose(tomo.Stop)
window.OnClose(nasin.Stop)
window.Show()
return nil
}

View File

@ -1,18 +1,23 @@
package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/nasin"
import "git.tebibyte.media/sashakoshka/tomo/elements"
func main () {
tomo.Run(run)
nasin.Run(Application { })
}
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 480, 360))
type Application struct { }
func (Application) Init () error {
window, err := nasin.NewWindow(tomo.Bounds(0, 0, 480, 360))
if err != nil { return err }
window.SetTitle("example label")
window.Adopt(elements.NewLabelWrapped(text))
window.OnClose(tomo.Stop)
window.OnClose(nasin.Stop)
window.Show()
return nil
}
const text = "Resize the window to see the text wrap:\n\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Fermentum et sollicitudin ac orci phasellus egestas tellus rutrum. Aliquam vestibulum morbi blandit cursus risus at ultrices mi. Gravida dictum fusce ut placerat. Cursus metus aliquam eleifend mi in nulla posuere. Sit amet nulla facilisi morbi tempus iaculis urna id. Amet volutpat consequat mauris nunc congue nisi vitae. Varius duis at consectetur lorem donec massa sapien faucibus et. Vitae elementum curabitur vitae nunc sed velit dignissim. In hac habitasse platea dictumst quisque sagittis purus. Enim nulla aliquet porttitor lacus luctus accumsan tortor. Lectus magna fringilla urna porttitor rhoncus dolor purus non.\n\nNon pulvinar neque laoreet suspendisse. Viverra adipiscing at in tellus integer. Vulputate dignissim suspendisse in est ante. Purus in mollis nunc sed id semper. In est ante in nibh mauris cursus. Risus pretium quam vulputate dignissim suspendisse in est. Blandit aliquam etiam erat velit scelerisque in dictum. Lectus quam id leo in. Odio tempor orci dapibus ultrices in iaculis. Pharetra sit amet aliquam id. Elit ut aliquam purus sit. Egestas dui id ornare arcu odio ut sem nulla pharetra. Massa tempor nec feugiat nisl pretium fusce id. Dui accumsan sit amet nulla facilisi morbi. A lacus vestibulum sed arcu non odio euismod. Nam libero justo laoreet sit amet cursus. Mattis rhoncus urna neque viverra justo nec. Mauris augue neque gravida in fermentum et sollicitudin ac. Vulputate mi sit amet mauris. Ut sem nulla pharetra diam sit amet."

View File

@ -1,16 +1,21 @@
package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/nasin"
import "git.tebibyte.media/sashakoshka/tomo/popups"
import "git.tebibyte.media/sashakoshka/tomo/ability"
import "git.tebibyte.media/sashakoshka/tomo/elements"
import "git.tebibyte.media/sashakoshka/tomo/elements/testing"
func main () {
tomo.Run(run)
nasin.Run(Application { })
}
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 300, 0))
type Application struct { }
func (Application) Init () error {
window, err := nasin.NewWindow(tomo.Bounds(0, 0, 300, 0))
if err != nil { return err }
window.SetTitle("List Sidebar")
container := elements.NewHBox(elements.SpaceBoth)
@ -43,7 +48,7 @@ func run () {
elements.NewCheckbox("Bone", false))
art := testing.NewArtist()
makePage := func (name string, callback func ()) tomo.Selectable {
makePage := func (name string, callback func ()) ability.Selectable {
cell := elements.NewCell(elements.NewLabel(name))
cell.OnSelectionChange (func () {
if cell.Selected() { callback() }
@ -62,6 +67,7 @@ func run () {
container.Adopt(list)
turnPage(intro)
window.OnClose(tomo.Stop)
window.OnClose(nasin.Stop)
window.Show()
return nil
}

View File

@ -3,14 +3,18 @@ package main
import "fmt"
import "image"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/nasin"
import "git.tebibyte.media/sashakoshka/tomo/elements"
func main () {
tomo.Run(run)
nasin.Run(Application { })
}
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(200, 200, 256, 256))
type Application struct { }
func (Application) Init () error {
window, err := nasin.NewWindow(tomo.Bounds(200, 200, 256, 256))
if err != nil { return err }
window.SetTitle("Main")
container := elements.NewVBox (
@ -18,13 +22,14 @@ func run () {
elements.NewLabel("Main window"))
window.Adopt(container)
window.OnClose(tomo.Stop)
window.OnClose(nasin.Stop)
window.Show()
createPanel(window, 0, tomo.Bounds(-64, 20, 0, 0))
createPanel(window, 1, tomo.Bounds(200, 20, 0, 0))
createPanel(window, 2, tomo.Bounds(-64, 180, 0, 0))
createPanel(window, 3, tomo.Bounds(200, 180, 0, 0))
return nil
}
func createPanel (parent tomo.MainWindow, id int, bounds image.Rectangle) {

View File

@ -1,16 +1,19 @@
package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/nasin"
import "git.tebibyte.media/sashakoshka/tomo/popups"
import "git.tebibyte.media/sashakoshka/tomo/elements"
func main () {
tomo.Run(run)
nasin.Run(Application { })
}
func run () {
window, err := tomo.NewWindow(tomo.Bounds(0, 0, 0, 0))
if err != nil { panic(err.Error()) }
type Application struct { }
func (Application) Init () error {
window, err := nasin.NewWindow(tomo.Bounds(0, 0, 0, 0))
if err != nil { return err }
window.SetTitle("Dialog Boxes")
container := elements.NewVBox(elements.SpaceBoth)
@ -75,9 +78,10 @@ func run () {
container.Adopt(menuButton)
cancelButton := elements.NewButton("No thank you.")
cancelButton.OnClick(tomo.Stop)
cancelButton.OnClick(nasin.Stop)
container.Adopt(cancelButton)
window.OnClose(tomo.Stop)
window.OnClose(nasin.Stop)
window.Show()
return nil
}

View File

@ -2,15 +2,19 @@ package main
import "time"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/nasin"
import "git.tebibyte.media/sashakoshka/tomo/popups"
import "git.tebibyte.media/sashakoshka/tomo/elements"
func main () {
tomo.Run(run)
nasin.Run(Application { })
}
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 0, 0))
type Application struct { }
func (Application) Init () error {
window, err := nasin.NewWindow(tomo.Bounds(0, 0, 0, 0))
if err != nil { return err }
window.SetTitle("Approaching")
container := elements.NewVBox(elements.SpaceBoth)
window.Adopt(container)
@ -22,19 +26,20 @@ func run () {
button.SetEnabled(false)
container.Adopt(button)
window.OnClose(tomo.Stop)
window.OnClose(nasin.Stop)
window.Show()
go fill(window, bar)
return nil
}
func fill (window tomo.Window, bar *elements.ProgressBar) {
for progress := 0.0; progress < 1.0; progress += 0.01 {
time.Sleep(time.Second / 24)
tomo.Do (func () {
nasin.Do (func () {
bar.SetProgress(progress)
})
}
tomo.Do (func () {
nasin.Do (func () {
popups.NewDialog (
popups.DialogKindInfo,
window,

View File

@ -1,14 +1,18 @@
package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/nasin"
import "git.tebibyte.media/sashakoshka/tomo/elements"
func main () {
tomo.Run(run)
nasin.Run(Application { })
}
func run () {
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 0, 0))
type Application struct { }
func (Application) Init () error {
window, err := nasin.NewWindow(tomo.Bounds(0, 0, 0, 0))
if err != nil { return err }
window.SetTitle("Spaced Out")
container := elements.NewVBox (
@ -20,6 +24,7 @@ func run () {
container.Adopt(elements.NewLabel("This is at the bottom"))
window.Adopt(container)
window.OnClose(tomo.Stop)
window.OnClose(nasin.Stop)
window.Show()
return nil
}