Updated everything else to match

This commit is contained in:
2023-02-02 01:48:16 -05:00
parent 99942466f8
commit 892c74a9da
40 changed files with 304 additions and 759 deletions

View File

@@ -11,7 +11,7 @@ func main () {
func run () {
window, _ := tomo.NewWindow(2, 2)
window.SetTitle("example button")
button := basic.NewButton("hello tomo!")
button := basicElements.NewButton("hello tomo!")
button.OnClick (func () {
// when we set the button's text to something longer, the window
// will automatically resize to accomodate it.

View File

@@ -2,7 +2,7 @@ package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/popups"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
@@ -14,22 +14,22 @@ func run () {
window, _ := tomo.NewWindow(2, 2)
window.SetTitle("Checkboxes")
container := basic.NewContainer(layouts.Vertical { true, true })
container := basicElements.NewContainer(basicLayouts.Vertical { true, true })
window.Adopt(container)
container.Adopt (basic.NewLabel (
container.Adopt (basicElements.NewLabel (
"We advise you to not read thPlease listen to me. I am " +
"trapped inside the example code. This is the only way for " +
"me to communicate.", true), true)
container.Adopt(basic.NewSpacer(true), false)
container.Adopt(basic.NewCheckbox("Oh god", false), false)
container.Adopt(basic.NewCheckbox("Can you hear them", true), false)
container.Adopt(basic.NewCheckbox("They are in the walls", false), false)
container.Adopt(basic.NewCheckbox("They are coming for us", false), false)
disabledCheckbox := basic.NewCheckbox("We are but their helpless prey", false)
container.Adopt(basicElements.NewSpacer(true), false)
container.Adopt(basicElements.NewCheckbox("Oh god", false), false)
container.Adopt(basicElements.NewCheckbox("Can you hear them", true), false)
container.Adopt(basicElements.NewCheckbox("They are in the walls", false), false)
container.Adopt(basicElements.NewCheckbox("They are coming for us", false), false)
disabledCheckbox := basicElements.NewCheckbox("We are but their helpless prey", false)
disabledCheckbox.SetEnabled(false)
container.Adopt(disabledCheckbox, false)
vsync := basic.NewCheckbox("Enable vsync", false)
vsync := basicElements.NewCheckbox("Enable vsync", false)
vsync.OnToggle (func () {
if vsync.Value() {
popups.NewDialog (
@@ -39,7 +39,7 @@ func run () {
}
})
container.Adopt(vsync, false)
button := basic.NewButton("What")
button := basicElements.NewButton("What")
button.OnClick(tomo.Stop)
container.Adopt(button, false)
button.Focus()

View File

@@ -1,7 +1,7 @@
package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
@@ -13,14 +13,14 @@ func run () {
window, _ := tomo.NewWindow(2, 2)
window.SetTitle("dialog")
container := basic.NewContainer(layouts.Dialog { true, true })
container := basicElements.NewContainer(basicLayouts.Dialog { true, true })
window.Adopt(container)
container.Adopt(basic.NewLabel("you will explode", true), true)
cancel := basic.NewButton("Cancel")
container.Adopt(basicElements.NewLabel("you will explode", true), true)
cancel := basicElements.NewButton("Cancel")
cancel.SetEnabled(false)
container.Adopt(cancel, false)
okButton := basic.NewButton("OK")
okButton := basicElements.NewButton("OK")
container.Adopt(okButton, false)
okButton.Focus()

View File

@@ -2,7 +2,7 @@ package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/flow"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
@@ -13,21 +13,21 @@ func main () {
func run () {
window, _ := tomo.NewWindow(2, 2)
window.SetTitle("adventure")
container := basic.NewContainer(layouts.Vertical { true, true })
container := basicElements.NewContainer(basicLayouts.Vertical { true, true })
window.Adopt(container)
var world flow.Flow
world.Transition = container.DisownAll
world.Stages = map [string] func () {
"start": func () {
label := basic.NewLabel (
label := basicElements.NewLabel (
"you are standing next to a river.", true)
button0 := basic.NewButton("go in the river")
button0 := basicElements.NewButton("go in the river")
button0.OnClick(world.SwitchFunc("wet"))
button1 := basic.NewButton("walk along the river")
button1 := basicElements.NewButton("walk along the river")
button1.OnClick(world.SwitchFunc("house"))
button2 := basic.NewButton("turn around")
button2 := basicElements.NewButton("turn around")
button2.OnClick(world.SwitchFunc("bear"))
container.Warp ( func () {
@@ -39,13 +39,13 @@ func run () {
})
},
"wet": func () {
label := basic.NewLabel (
label := basicElements.NewLabel (
"you get completely soaked.\n" +
"you die of hypothermia.", true)
button0 := basic.NewButton("try again")
button0 := basicElements.NewButton("try again")
button0.OnClick(world.SwitchFunc("start"))
button1 := basic.NewButton("exit")
button1 := basicElements.NewButton("exit")
button1.OnClick(tomo.Stop)
container.Warp (func () {
@@ -56,13 +56,13 @@ func run () {
})
},
"house": func () {
label := basic.NewLabel (
label := basicElements.NewLabel (
"you are standing in front of a delapidated " +
"house.", true)
button1 := basic.NewButton("go inside")
button1 := basicElements.NewButton("go inside")
button1.OnClick(world.SwitchFunc("inside"))
button0 := basic.NewButton("turn back")
button0 := basicElements.NewButton("turn back")
button0.OnClick(world.SwitchFunc("start"))
container.Warp (func () {
@@ -73,14 +73,14 @@ func run () {
})
},
"inside": func () {
label := basic.NewLabel (
label := basicElements.NewLabel (
"you are standing inside of the house.\n" +
"it is dark, but rays of light stream " +
"through the window.\n" +
"there is nothing particularly interesting " +
"here.", true)
button0 := basic.NewButton("go back outside")
button0 := basicElements.NewButton("go back outside")
button0.OnClick(world.SwitchFunc("house"))
container.Warp (func () {
@@ -90,13 +90,13 @@ func run () {
})
},
"bear": func () {
label := basic.NewLabel (
label := basicElements.NewLabel (
"you come face to face with a bear.\n" +
"it eats you (it was hungry).", true)
button0 := basic.NewButton("try again")
button0 := basicElements.NewButton("try again")
button0.OnClick(world.SwitchFunc("start"))
button1 := basic.NewButton("exit")
button1 := basicElements.NewButton("exit")
button1.OnClick(tomo.Stop)
container.Warp (func () {

View File

@@ -3,7 +3,7 @@ package main
import "os"
import "time"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
import "git.tebibyte.media/sashakoshka/tomo/elements/fun"
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
@@ -16,12 +16,12 @@ func main () {
func run () {
window, _ := tomo.NewWindow(2, 2)
window.SetTitle("clock")
container := basic.NewContainer(layouts.Vertical { true, true })
container := basicElements.NewContainer(basicLayouts.Vertical { true, true })
window.Adopt(container)
clock := fun.NewAnalogClock(time.Now())
container.Adopt(clock, true)
label := basic.NewLabel(formatTime(), false)
label := basicElements.NewLabel(formatTime(), false)
container.Adopt(label, false)
window.OnClose(tomo.Stop)
@@ -33,7 +33,7 @@ func formatTime () (timeString string) {
return time.Now().Format("2006-01-02 15:04:05")
}
func tick (label *basic.Label, clock *fun.AnalogClock) {
func tick (label *basicElements.Label, clock *fun.AnalogClock) {
for {
tomo.Do (func () {
label.SetText(formatTime())

View File

@@ -1,7 +1,7 @@
package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
@@ -13,12 +13,12 @@ func run () {
window, _ := tomo.NewWindow(360, 2)
window.SetTitle("horizontal stack")
container := basic.NewContainer(layouts.Horizontal { true, true })
container := basicElements.NewContainer(basicLayouts.Horizontal { true, true })
window.Adopt(container)
container.Adopt(basic.NewLabel("this is sample text", true), true)
container.Adopt(basic.NewLabel("this is sample text", true), true)
container.Adopt(basic.NewLabel("this is sample text", true), true)
container.Adopt(basicElements.NewLabel("this is sample text", true), true)
container.Adopt(basicElements.NewLabel("this is sample text", true), true)
container.Adopt(basicElements.NewLabel("this is sample text", true), true)
window.OnClose(tomo.Stop)
window.Show()

View File

@@ -2,7 +2,7 @@ package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/popups"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
@@ -13,14 +13,14 @@ func main () {
func run () {
window, _ := tomo.NewWindow(2, 2)
window.SetTitle("Enter Details")
container := basic.NewContainer(layouts.Vertical { true, true })
container := basicElements.NewContainer(basicLayouts.Vertical { true, true })
window.Adopt(container)
// create inputs
firstName := basic.NewTextBox("First name", "")
lastName := basic.NewTextBox("Last name", "")
fingerLength := basic.NewTextBox("Length of fingers", "")
button := basic.NewButton("Ok")
firstName := basicElements.NewTextBox("First name", "")
lastName := basicElements.NewTextBox("Last name", "")
fingerLength := basicElements.NewTextBox("Length of fingers", "")
button := basicElements.NewButton("Ok")
button.SetEnabled(false)
button.OnClick (func () {
@@ -45,11 +45,11 @@ func run () {
fingerLength.OnChange(check)
// add elements to container
container.Adopt(basic.NewLabel("Choose your words carefully.", false), true)
container.Adopt(basicElements.NewLabel("Choose your words carefully.", false), true)
container.Adopt(firstName, false)
container.Adopt(lastName, false)
container.Adopt(fingerLength, false)
container.Adopt(basic.NewSpacer(true), false)
container.Adopt(basicElements.NewSpacer(true), false)
container.Adopt(button, false)
window.OnClose(tomo.Stop)

View File

@@ -11,7 +11,7 @@ func main () {
func run () {
window, _ := tomo.NewWindow(480, 2)
window.SetTitle("example label")
window.Adopt(basic.NewLabel(text, true))
window.Adopt(basicElements.NewLabel(text, true))
window.OnClose(tomo.Stop)
window.Show()
}

View File

@@ -2,7 +2,8 @@ package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/popups"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/elements"
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
import "git.tebibyte.media/sashakoshka/tomo/elements/testing"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
@@ -15,11 +16,11 @@ func run () {
window, _ := tomo.NewWindow(300, 2)
window.SetTitle("List Sidebar")
container := basic.NewContainer(layouts.Horizontal { true, true })
container := basicElements.NewContainer(basicLayouts.Horizontal { true, true })
window.Adopt(container)
var currentPage tomo.Element
turnPage := func (newPage tomo.Element) {
var currentPage elements.Element
turnPage := func (newPage elements.Element) {
container.Warp (func () {
if currentPage != nil {
container.Disown(currentPage)
@@ -29,27 +30,27 @@ func run () {
})
}
intro := basic.NewLabel (
intro := basicElements.NewLabel (
"The List element can be easily used as a sidebar. " +
"Click on entries to flip pages!", true)
button := basic.NewButton("I do nothing!")
button := basicElements.NewButton("I do nothing!")
button.OnClick (func () {
popups.NewDialog(popups.DialogKindInfo, "", "Sike!")
})
mouse := testing.NewMouse()
input := basic.NewTextBox("Write some text", "")
form := basic.NewContainer(layouts.Vertical { true, false})
form.Adopt(basic.NewLabel("I have:", false), false)
form.Adopt(basic.NewSpacer(true), false)
form.Adopt(basic.NewCheckbox("Skin", true), false)
form.Adopt(basic.NewCheckbox("Blood", false), false)
form.Adopt(basic.NewCheckbox("Bone", false), false)
input := basicElements.NewTextBox("Write some text", "")
form := basicElements.NewContainer(basicLayouts.Vertical { true, false})
form.Adopt(basicElements.NewLabel("I have:", false), false)
form.Adopt(basicElements.NewSpacer(true), false)
form.Adopt(basicElements.NewCheckbox("Skin", true), false)
form.Adopt(basicElements.NewCheckbox("Blood", false), false)
form.Adopt(basicElements.NewCheckbox("Bone", false), false)
list := basic.NewList (
basic.NewListEntry("button", func () { turnPage(button) }),
basic.NewListEntry("mouse", func () { turnPage(mouse) }),
basic.NewListEntry("input", func () { turnPage(input) }),
basic.NewListEntry("form", func () { turnPage(form) }))
list := basicElements.NewList (
basicElements.NewListEntry("button", func () { turnPage(button) }),
basicElements.NewListEntry("mouse", func () { turnPage(mouse) }),
basicElements.NewListEntry("input", func () { turnPage(input) }),
basicElements.NewListEntry("form", func () { turnPage(form) }))
list.OnNoEntrySelected(func () { turnPage (intro) })
list.Collapse(96, 0)

View File

@@ -2,7 +2,7 @@ package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/popups"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
@@ -14,12 +14,12 @@ func run () {
window, _ := tomo.NewWindow(2, 2)
window.SetTitle("Dialog Boxes")
container := basic.NewContainer(layouts.Vertical { true, true })
container := basicElements.NewContainer(basicLayouts.Vertical { true, true })
window.Adopt(container)
container.Adopt(basic.NewLabel("Try out different dialogs:", false), true)
container.Adopt(basicElements.NewLabel("Try out different dialogs:", false), true)
infoButton := basic.NewButton("popups.DialogKindInfo")
infoButton := basicElements.NewButton("popups.DialogKindInfo")
infoButton.OnClick (func () {
popups.NewDialog (
popups.DialogKindInfo,
@@ -29,7 +29,7 @@ func run () {
container.Adopt(infoButton, false)
infoButton.Focus()
questionButton := basic.NewButton("popups.DialogKindQuestion")
questionButton := basicElements.NewButton("popups.DialogKindQuestion")
questionButton.OnClick (func () {
popups.NewDialog (
popups.DialogKindQuestion,
@@ -41,7 +41,7 @@ func run () {
})
container.Adopt(questionButton, false)
warningButton := basic.NewButton("popups.DialogKindWarning")
warningButton := basicElements.NewButton("popups.DialogKindWarning")
warningButton.OnClick (func () {
popups.NewDialog (
popups.DialogKindQuestion,
@@ -50,7 +50,7 @@ func run () {
})
container.Adopt(warningButton, false)
errorButton := basic.NewButton("popups.DialogKindError")
errorButton := basicElements.NewButton("popups.DialogKindError")
errorButton.OnClick (func () {
popups.NewDialog (
popups.DialogKindQuestion,
@@ -59,7 +59,7 @@ func run () {
})
container.Adopt(errorButton, false)
cancelButton := basic.NewButton("No thank you.")
cancelButton := basicElements.NewButton("No thank you.")
cancelButton.OnClick(tomo.Stop)
container.Adopt(cancelButton, false)

View File

@@ -3,7 +3,7 @@ package main
import "time"
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/popups"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
@@ -14,14 +14,14 @@ func main () {
func run () {
window, _ := tomo.NewWindow(2, 2)
window.SetTitle("Approaching")
container := basic.NewContainer(layouts.Vertical { true, true })
container := basicElements.NewContainer(basicLayouts.Vertical { true, true })
window.Adopt(container)
container.Adopt (basic.NewLabel (
container.Adopt (basicElements.NewLabel (
"Rapidly approaching your location...", false), false)
bar := basic.NewProgressBar(0)
bar := basicElements.NewProgressBar(0)
container.Adopt(bar, false)
button := basic.NewButton("Stop")
button := basicElements.NewButton("Stop")
button.SetEnabled(false)
container.Adopt(button, false)
@@ -30,7 +30,7 @@ func run () {
go fill(bar)
}
func fill (bar *basic.ProgressBar) {
func fill (bar *basicElements.ProgressBar) {
for progress := 0.0; progress < 1.0; progress += 0.01 {
time.Sleep(time.Second / 24)
tomo.Do (func () {

View File

@@ -1,7 +1,7 @@
package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
@@ -12,13 +12,13 @@ func main () {
func run () {
window, _ := tomo.NewWindow(2, 2)
window.SetTitle("Scroll")
container := basic.NewContainer(layouts.Vertical { true, true })
container := basicElements.NewContainer(basicLayouts.Vertical { true, true })
window.Adopt(container)
container.Adopt(basic.NewLabel("look at this non sense", false), false)
container.Adopt(basicElements.NewLabel("look at this non sense", false), false)
textBox := basic.NewTextBox("", "sample text sample text")
scrollContainer := basic.NewScrollContainer(true, false)
textBox := basicElements.NewTextBox("", "sample text sample text")
scrollContainer := basicElements.NewScrollContainer(true, false)
scrollContainer.Adopt(textBox)
container.Adopt(scrollContainer, true)

View File

@@ -1,7 +1,7 @@
package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
@@ -13,14 +13,14 @@ func run () {
window, _ := tomo.NewWindow(2, 2)
window.SetTitle("Spaced Out")
container := basic.NewContainer(layouts.Vertical { true, true })
container := basicElements.NewContainer(basicLayouts.Vertical { true, true })
window.Adopt(container)
container.Adopt (basic.NewLabel("This is at the top", false), false)
container.Adopt (basic.NewSpacer(true), false)
container.Adopt (basic.NewLabel("This is in the middle", false), false)
container.Adopt (basic.NewSpacer(false), true)
container.Adopt (basic.NewLabel("This is at the bottom", false), false)
container.Adopt (basicElements.NewLabel("This is at the top", false), false)
container.Adopt (basicElements.NewSpacer(true), false)
container.Adopt (basicElements.NewLabel("This is in the middle", false), false)
container.Adopt (basicElements.NewSpacer(false), true)
container.Adopt (basicElements.NewLabel("This is at the bottom", false), false)
window.OnClose(tomo.Stop)
window.Show()

View File

@@ -1,7 +1,7 @@
package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
@@ -13,12 +13,12 @@ func run () {
window, _ := tomo.NewWindow(2, 2)
window.SetTitle("Switches")
container := basic.NewContainer(layouts.Vertical { true, true })
container := basicElements.NewContainer(basicLayouts.Vertical { true, true })
window.Adopt(container)
container.Adopt(basic.NewSwitch("hahahah", false), false)
container.Adopt(basic.NewSwitch("hehehehheheh", false), false)
container.Adopt(basic.NewSwitch("you can flick da swicth", false), false)
container.Adopt(basicElements.NewSwitch("hahahah", false), false)
container.Adopt(basicElements.NewSwitch("hehehehheheh", false), false)
container.Adopt(basicElements.NewSwitch("you can flick da swicth", false), false)
window.OnClose(tomo.Stop)
window.Show()

View File

@@ -1,7 +1,7 @@
package main
import "git.tebibyte.media/sashakoshka/tomo"
import "git.tebibyte.media/sashakoshka/tomo/layouts"
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
import "git.tebibyte.media/sashakoshka/tomo/elements/testing"
import _ "git.tebibyte.media/sashakoshka/tomo/backends/x"
@@ -14,15 +14,15 @@ func run () {
window, _ := tomo.NewWindow(2, 2)
window.SetTitle("vertical stack")
container := basic.NewContainer(layouts.Vertical { true, true })
container := basicElements.NewContainer(basicLayouts.Vertical { true, true })
window.Adopt(container)
label := basic.NewLabel("it is a label hehe", true)
button := basic.NewButton("drawing pad")
okButton := basic.NewButton("OK")
label := basicElements.NewLabel("it is a label hehe", true)
button := basicElements.NewButton("drawing pad")
okButton := basicElements.NewButton("OK")
button.OnClick (func () {
container.DisownAll()
container.Adopt(basic.NewLabel("Draw here:", false), false)
container.Adopt(basicElements.NewLabel("Draw here:", false), false)
container.Adopt(testing.NewMouse(), true)
container.Adopt(okButton, false)
okButton.Focus()