Re-organized module structure
This commit is contained in:
@@ -2,7 +2,7 @@ package main
|
||||
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/textdraw"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
|
||||
@@ -19,10 +19,10 @@ func run () {
|
||||
scrollContainer.Adopt(container)
|
||||
window.Adopt(scrollContainer)
|
||||
|
||||
left := basicElements.NewLabel(text, true)
|
||||
center := basicElements.NewLabel(text, true)
|
||||
right := basicElements.NewLabel(text, true)
|
||||
justify := basicElements.NewLabel(text, true)
|
||||
left := elements.NewLabel(text, true)
|
||||
center := elements.NewLabel(text, true)
|
||||
right := elements.NewLabel(text, true)
|
||||
justify := elements.NewLabel(text, true)
|
||||
|
||||
left.SetAlign(textdraw.AlignLeft)
|
||||
center.SetAlign(textdraw.AlignCenter)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
import "git.tebibyte.media/sashakoshka/ezprof/ez"
|
||||
|
||||
@@ -12,7 +12,7 @@ func main () {
|
||||
func run () {
|
||||
window, _ := tomo.NewWindow(2, 2)
|
||||
window.SetTitle("example button")
|
||||
button := basicElements.NewButton("hello tomo!")
|
||||
button := elements.NewButton("hello tomo!")
|
||||
button.OnClick (func () {
|
||||
// when we set the button's text to something longer, the window
|
||||
// will automatically resize to accomodate it.
|
||||
|
||||
@@ -2,8 +2,8 @@ package main
|
||||
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/popups"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
|
||||
@@ -15,34 +15,35 @@ func run () {
|
||||
window, _ := tomo.NewWindow(2, 2)
|
||||
window.SetTitle("Checkboxes")
|
||||
|
||||
container := containers.NewContainer(basicLayouts.Vertical { true, true })
|
||||
container := containers.NewContainer(layouts.Vertical { true, true })
|
||||
window.Adopt(container)
|
||||
|
||||
introText := basicElements.NewLabel (
|
||||
introText := elements.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)
|
||||
introText.EmCollapse(0, 5)
|
||||
container.Adopt(introText, true)
|
||||
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)
|
||||
container.Adopt(elements.NewSpacer(true), false)
|
||||
container.Adopt(elements.NewCheckbox("Oh god", false), false)
|
||||
container.Adopt(elements.NewCheckbox("Can you hear them", true), false)
|
||||
container.Adopt(elements.NewCheckbox("They are in the walls", false), false)
|
||||
container.Adopt(elements.NewCheckbox("They are coming for us", false), false)
|
||||
disabledCheckbox := elements.NewCheckbox("We are but their helpless prey", false)
|
||||
disabledCheckbox.SetEnabled(false)
|
||||
container.Adopt(disabledCheckbox, false)
|
||||
vsync := basicElements.NewCheckbox("Enable vsync", false)
|
||||
vsync := elements.NewCheckbox("Enable vsync", false)
|
||||
vsync.OnToggle (func () {
|
||||
if vsync.Value() {
|
||||
popups.NewDialog (
|
||||
popups.DialogKindInfo,
|
||||
window,
|
||||
"Ha!",
|
||||
"That doesn't do anything.")
|
||||
}
|
||||
})
|
||||
container.Adopt(vsync, false)
|
||||
button := basicElements.NewButton("What")
|
||||
button := elements.NewButton("What")
|
||||
button.OnClick(tomo.Stop)
|
||||
container.Adopt(button, false)
|
||||
button.Focus()
|
||||
|
||||
@@ -9,8 +9,8 @@ import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/data"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/theme"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/popups"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
|
||||
@@ -28,14 +28,14 @@ func run () {
|
||||
window, _ := tomo.NewWindow(256, 2)
|
||||
window.SetTitle("Clipboard")
|
||||
|
||||
container := containers.NewContainer(basicLayouts.Vertical { true, true })
|
||||
textInput := basicElements.NewTextBox("", "")
|
||||
controlRow := containers.NewContainer(basicLayouts.Horizontal { true, false })
|
||||
copyButton := basicElements.NewButton("Copy")
|
||||
container := containers.NewContainer(layouts.Vertical { true, true })
|
||||
textInput := elements.NewTextBox("", "")
|
||||
controlRow := containers.NewContainer(layouts.Horizontal { true, false })
|
||||
copyButton := elements.NewButton("Copy")
|
||||
copyButton.SetIcon(theme.IconCopy)
|
||||
pasteButton := basicElements.NewButton("Paste")
|
||||
pasteButton := elements.NewButton("Paste")
|
||||
pasteButton.SetIcon(theme.IconPaste)
|
||||
pasteImageButton := basicElements.NewButton("Image")
|
||||
pasteImageButton := elements.NewButton("Image")
|
||||
pasteImageButton.SetIcon(theme.IconPictures)
|
||||
|
||||
imageClipboardCallback := func (clipboard data.Data, err error) {
|
||||
@@ -124,12 +124,12 @@ func run () {
|
||||
func imageWindow (image image.Image) {
|
||||
window, _ := tomo.NewWindow(2, 2)
|
||||
window.SetTitle("Clipboard Image")
|
||||
container := containers.NewContainer(basicLayouts.Vertical { true, true })
|
||||
closeButton := basicElements.NewButton("Ok")
|
||||
container := containers.NewContainer(layouts.Vertical { true, true })
|
||||
closeButton := elements.NewButton("Ok")
|
||||
closeButton.SetIcon(theme.IconYes)
|
||||
closeButton.OnClick(window.Close)
|
||||
|
||||
container.Adopt(basicElements.NewImage(image), true)
|
||||
container.Adopt(elements.NewImage(image), true)
|
||||
container.Adopt(closeButton, false)
|
||||
window.Adopt(container)
|
||||
window.Show()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
|
||||
@@ -14,14 +14,14 @@ func run () {
|
||||
window, _ := tomo.NewWindow(2, 2)
|
||||
window.SetTitle("dialog")
|
||||
|
||||
container := containers.NewContainer(basicLayouts.Dialog { true, true })
|
||||
container := containers.NewContainer(layouts.Dialog { true, true })
|
||||
window.Adopt(container)
|
||||
|
||||
container.Adopt(basicElements.NewLabel("you will explode", false), true)
|
||||
cancel := basicElements.NewButton("Cancel")
|
||||
container.Adopt(elements.NewLabel("you will explode", false), true)
|
||||
cancel := elements.NewButton("Cancel")
|
||||
cancel.SetEnabled(false)
|
||||
container.Adopt(cancel, false)
|
||||
okButton := basicElements.NewButton("OK")
|
||||
okButton := elements.NewButton("OK")
|
||||
container.Adopt(okButton, false)
|
||||
okButton.Focus()
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@ import "os"
|
||||
import "image"
|
||||
import _ "image/png"
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
|
||||
@@ -26,34 +26,34 @@ func run () {
|
||||
scrollContainer := containers.NewScrollContainer(false, true)
|
||||
document := containers.NewDocumentContainer()
|
||||
|
||||
document.Adopt (basicElements.NewLabel (
|
||||
document.Adopt (elements.NewLabel (
|
||||
"A document container is a vertically stacked container " +
|
||||
"capable of properly laying out flexible elements such as " +
|
||||
"text-wrapped labels. You can also include normal elements " +
|
||||
"like:", true))
|
||||
document.Adopt (basicElements.NewButton (
|
||||
document.Adopt (elements.NewButton (
|
||||
"Buttons,"))
|
||||
document.Adopt (basicElements.NewCheckbox (
|
||||
document.Adopt (elements.NewCheckbox (
|
||||
"Checkboxes,", true))
|
||||
document.Adopt(basicElements.NewTextBox("", "And text boxes."))
|
||||
document.Adopt (basicElements.NewSpacer(true))
|
||||
document.Adopt (basicElements.NewLabel (
|
||||
document.Adopt(elements.NewTextBox("", "And text boxes."))
|
||||
document.Adopt (elements.NewSpacer(true))
|
||||
document.Adopt (elements.NewLabel (
|
||||
"Document containers are meant to be placed inside of a " +
|
||||
"ScrollContainer, like this one.", true))
|
||||
document.Adopt (basicElements.NewLabel (
|
||||
document.Adopt (elements.NewLabel (
|
||||
"You could use document containers to do things like display various " +
|
||||
"forms of hypertext (like HTML, gemtext, markdown, etc.), " +
|
||||
"lay out a settings menu with descriptive label text between " +
|
||||
"control groups like in iOS, or list comment or chat histories.", true))
|
||||
document.Adopt(basicElements.NewImage(logo))
|
||||
document.Adopt (basicElements.NewLabel (
|
||||
document.Adopt(elements.NewImage(logo))
|
||||
document.Adopt (elements.NewLabel (
|
||||
"Oh, you're a switch? Then name all of these switches:", true))
|
||||
for i := 0; i < 3; i ++ {
|
||||
switchContainer := containers.NewContainer (basicLayouts.Horizontal {
|
||||
switchContainer := containers.NewContainer (layouts.Horizontal {
|
||||
Gap: true,
|
||||
})
|
||||
for i := 0; i < 10; i ++ {
|
||||
switchContainer.Adopt(basicElements.NewSwitch("", false), true)
|
||||
switchContainer.Adopt(elements.NewSwitch("", false), true)
|
||||
}
|
||||
document.Adopt(switchContainer)
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import "os"
|
||||
import "path/filepath"
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/theme"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/file"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ package main
|
||||
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/flow"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
|
||||
@@ -14,21 +14,21 @@ func main () {
|
||||
func run () {
|
||||
window, _ := tomo.NewWindow(192, 192)
|
||||
window.SetTitle("adventure")
|
||||
container := containers.NewContainer(basicLayouts.Vertical { true, true })
|
||||
container := containers.NewContainer(layouts.Vertical { true, true })
|
||||
window.Adopt(container)
|
||||
|
||||
var world flow.Flow
|
||||
world.Transition = container.DisownAll
|
||||
world.Stages = map [string] func () {
|
||||
"start": func () {
|
||||
label := basicElements.NewLabel (
|
||||
label := elements.NewLabel (
|
||||
"you are standing next to a river.", true)
|
||||
|
||||
button0 := basicElements.NewButton("go in the river")
|
||||
button0 := elements.NewButton("go in the river")
|
||||
button0.OnClick(world.SwitchFunc("wet"))
|
||||
button1 := basicElements.NewButton("walk along the river")
|
||||
button1 := elements.NewButton("walk along the river")
|
||||
button1.OnClick(world.SwitchFunc("house"))
|
||||
button2 := basicElements.NewButton("turn around")
|
||||
button2 := elements.NewButton("turn around")
|
||||
button2.OnClick(world.SwitchFunc("bear"))
|
||||
|
||||
container.Warp ( func () {
|
||||
@@ -40,13 +40,13 @@ func run () {
|
||||
})
|
||||
},
|
||||
"wet": func () {
|
||||
label := basicElements.NewLabel (
|
||||
label := elements.NewLabel (
|
||||
"you get completely soaked.\n" +
|
||||
"you die of hypothermia.", true)
|
||||
|
||||
button0 := basicElements.NewButton("try again")
|
||||
button0 := elements.NewButton("try again")
|
||||
button0.OnClick(world.SwitchFunc("start"))
|
||||
button1 := basicElements.NewButton("exit")
|
||||
button1 := elements.NewButton("exit")
|
||||
button1.OnClick(tomo.Stop)
|
||||
|
||||
container.Warp (func () {
|
||||
@@ -57,13 +57,13 @@ func run () {
|
||||
})
|
||||
},
|
||||
"house": func () {
|
||||
label := basicElements.NewLabel (
|
||||
label := elements.NewLabel (
|
||||
"you are standing in front of a delapidated " +
|
||||
"house.", true)
|
||||
|
||||
button1 := basicElements.NewButton("go inside")
|
||||
button1 := elements.NewButton("go inside")
|
||||
button1.OnClick(world.SwitchFunc("inside"))
|
||||
button0 := basicElements.NewButton("turn back")
|
||||
button0 := elements.NewButton("turn back")
|
||||
button0.OnClick(world.SwitchFunc("start"))
|
||||
|
||||
container.Warp (func () {
|
||||
@@ -74,14 +74,14 @@ func run () {
|
||||
})
|
||||
},
|
||||
"inside": func () {
|
||||
label := basicElements.NewLabel (
|
||||
label := elements.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 := basicElements.NewButton("go back outside")
|
||||
button0 := elements.NewButton("go back outside")
|
||||
button0.OnClick(world.SwitchFunc("house"))
|
||||
|
||||
container.Warp (func () {
|
||||
@@ -91,13 +91,13 @@ func run () {
|
||||
})
|
||||
},
|
||||
"bear": func () {
|
||||
label := basicElements.NewLabel (
|
||||
label := elements.NewLabel (
|
||||
"you come face to face with a bear.\n" +
|
||||
"it eats you (it was hungry).", true)
|
||||
|
||||
button0 := basicElements.NewButton("try again")
|
||||
button0 := elements.NewButton("try again")
|
||||
button0.OnClick(world.SwitchFunc("start"))
|
||||
button1 := basicElements.NewButton("exit")
|
||||
button1 := elements.NewButton("exit")
|
||||
button1.OnClick(tomo.Stop)
|
||||
|
||||
container.Warp (func () {
|
||||
|
||||
@@ -3,9 +3,9 @@ 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/elements"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/fun"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
|
||||
@@ -17,12 +17,12 @@ func main () {
|
||||
func run () {
|
||||
window, _ := tomo.NewWindow(200, 216)
|
||||
window.SetTitle("Clock")
|
||||
container := containers.NewContainer(basicLayouts.Vertical { true, true })
|
||||
container := containers.NewContainer(layouts.Vertical { true, true })
|
||||
window.Adopt(container)
|
||||
|
||||
clock := fun.NewAnalogClock(time.Now())
|
||||
container.Adopt(clock, true)
|
||||
label := basicElements.NewLabel(formatTime(), false)
|
||||
label := elements.NewLabel(formatTime(), false)
|
||||
container.Adopt(label, false)
|
||||
|
||||
window.OnClose(tomo.Stop)
|
||||
@@ -34,7 +34,7 @@ func formatTime () (timeString string) {
|
||||
return time.Now().Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
func tick (label *basicElements.Label, clock *fun.AnalogClock) {
|
||||
func tick (label *elements.Label, clock *fun.AnalogClock) {
|
||||
for {
|
||||
tomo.Do (func () {
|
||||
label.SetText(formatTime())
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
|
||||
@@ -14,12 +14,12 @@ func run () {
|
||||
window, _ := tomo.NewWindow(360, 2)
|
||||
window.SetTitle("horizontal stack")
|
||||
|
||||
container := containers.NewContainer(basicLayouts.Horizontal { true, true })
|
||||
container := containers.NewContainer(layouts.Horizontal { true, true })
|
||||
window.Adopt(container)
|
||||
|
||||
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)
|
||||
container.Adopt(elements.NewLabel("this is sample text", true), true)
|
||||
container.Adopt(elements.NewLabel("this is sample text", true), true)
|
||||
container.Adopt(elements.NewLabel("this is sample text", true), true)
|
||||
|
||||
window.OnClose(tomo.Stop)
|
||||
window.Show()
|
||||
|
||||
@@ -2,8 +2,8 @@ package main
|
||||
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/theme"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
|
||||
@@ -15,16 +15,16 @@ func run () {
|
||||
window, _ := tomo.NewWindow(360, 2)
|
||||
window.SetTitle("Icons")
|
||||
|
||||
container := containers.NewContainer(basicLayouts.Vertical { true, true })
|
||||
container := containers.NewContainer(layouts.Vertical { true, true })
|
||||
window.Adopt(container)
|
||||
|
||||
container.Adopt(basicElements.NewLabel("Just some of the wonderful icons we have:", false), false)
|
||||
container.Adopt(basicElements.NewSpacer(true), false)
|
||||
container.Adopt(elements.NewLabel("Just some of the wonderful icons we have:", false), false)
|
||||
container.Adopt(elements.NewSpacer(true), false)
|
||||
container.Adopt(icons(theme.IconHome, theme.IconRepositories), true)
|
||||
container.Adopt(icons(theme.IconFile, theme.IconCD), true)
|
||||
container.Adopt(icons(theme.IconOpen, theme.IconRemoveBookmark), true)
|
||||
|
||||
closeButton := basicElements.NewButton("Ok")
|
||||
closeButton := elements.NewButton("Ok")
|
||||
closeButton.SetIcon(theme.IconYes)
|
||||
closeButton.ShowText(false)
|
||||
closeButton.OnClick(tomo.Stop)
|
||||
@@ -35,9 +35,9 @@ func run () {
|
||||
}
|
||||
|
||||
func icons (min, max theme.Icon) (container *containers.Container) {
|
||||
container = containers.NewContainer(basicLayouts.Horizontal { true, false })
|
||||
container = containers.NewContainer(layouts.Horizontal { true, false })
|
||||
for index := min; index <= max; index ++ {
|
||||
container.Adopt(basicElements.NewIcon(index, theme.IconSizeSmall), true)
|
||||
container.Adopt(elements.NewIcon(index, theme.IconSizeSmall), true)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ import _ "image/png"
|
||||
import "github.com/jezek/xgbutil/gopher"
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/popups"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
|
||||
@@ -21,20 +21,20 @@ func run () {
|
||||
window.SetTitle("Tomo Logo")
|
||||
|
||||
file, err := os.Open("assets/banner.png")
|
||||
if err != nil { fatalError(err); return }
|
||||
if err != nil { fatalError(window, err); return }
|
||||
logo, _, err := image.Decode(file)
|
||||
file.Close()
|
||||
if err != nil { fatalError(err); return }
|
||||
if err != nil { fatalError(window, err); return }
|
||||
|
||||
container := containers.NewContainer(basicLayouts.Vertical { true, true })
|
||||
logoImage := basicElements.NewImage(logo)
|
||||
button := basicElements.NewButton("Show me a gopher instead")
|
||||
container := containers.NewContainer(layouts.Vertical { true, true })
|
||||
logoImage := elements.NewImage(logo)
|
||||
button := elements.NewButton("Show me a gopher instead")
|
||||
button.OnClick (func () { container.Warp (func () {
|
||||
container.DisownAll()
|
||||
gopher, _, err :=
|
||||
image.Decode(bytes.NewReader(gopher.GopherPng()))
|
||||
if err != nil { fatalError(err); return }
|
||||
container.Adopt(basicElements.NewImage(gopher),true)
|
||||
if err != nil { fatalError(window, err); return }
|
||||
container.Adopt(elements.NewImage(gopher),true)
|
||||
}) })
|
||||
|
||||
container.Adopt(logoImage, true)
|
||||
@@ -47,9 +47,10 @@ func run () {
|
||||
window.Show()
|
||||
}
|
||||
|
||||
func fatalError (err error) {
|
||||
func fatalError (window tomo.Window, err error) {
|
||||
popups.NewDialog (
|
||||
popups.DialogKindError,
|
||||
window,
|
||||
"Error",
|
||||
err.Error(),
|
||||
popups.Button {
|
||||
@@ -57,3 +58,4 @@ func fatalError (err error) {
|
||||
OnPress: tomo.Stop,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@ package main
|
||||
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/popups"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
|
||||
@@ -14,20 +14,21 @@ func main () {
|
||||
func run () {
|
||||
window, _ := tomo.NewWindow(2, 2)
|
||||
window.SetTitle("Enter Details")
|
||||
container := containers.NewContainer(basicLayouts.Vertical { true, true })
|
||||
container := containers.NewContainer(layouts.Vertical { true, true })
|
||||
window.Adopt(container)
|
||||
|
||||
// create inputs
|
||||
firstName := basicElements.NewTextBox("First name", "")
|
||||
lastName := basicElements.NewTextBox("Last name", "")
|
||||
fingerLength := basicElements.NewTextBox("Length of fingers", "")
|
||||
button := basicElements.NewButton("Ok")
|
||||
firstName := elements.NewTextBox("First name", "")
|
||||
lastName := elements.NewTextBox("Last name", "")
|
||||
fingerLength := elements.NewTextBox("Length of fingers", "")
|
||||
button := elements.NewButton("Ok")
|
||||
|
||||
button.SetEnabled(false)
|
||||
button.OnClick (func () {
|
||||
// create a dialog displaying the results
|
||||
popups.NewDialog (
|
||||
popups.DialogKindInfo,
|
||||
window,
|
||||
"Profile",
|
||||
firstName.Value() + " " + lastName.Value() +
|
||||
"'s fingers\nmeasure in at " + fingerLength.Value() +
|
||||
@@ -46,11 +47,11 @@ func run () {
|
||||
fingerLength.OnChange(check)
|
||||
|
||||
// add elements to container
|
||||
container.Adopt(basicElements.NewLabel("Choose your words carefully.", false), true)
|
||||
container.Adopt(elements.NewLabel("Choose your words carefully.", false), true)
|
||||
container.Adopt(firstName, false)
|
||||
container.Adopt(lastName, false)
|
||||
container.Adopt(fingerLength, false)
|
||||
container.Adopt(basicElements.NewSpacer(true), false)
|
||||
container.Adopt(elements.NewSpacer(true), false)
|
||||
container.Adopt(button, false)
|
||||
|
||||
window.OnClose(tomo.Stop)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package main
|
||||
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
|
||||
func main () {
|
||||
@@ -11,7 +11,7 @@ func main () {
|
||||
func run () {
|
||||
window, _ := tomo.NewWindow(480, 360)
|
||||
window.SetTitle("example label")
|
||||
window.Adopt(basicElements.NewLabel(text, true))
|
||||
window.Adopt(elements.NewLabel(text, true))
|
||||
window.OnClose(tomo.Stop)
|
||||
window.Show()
|
||||
}
|
||||
|
||||
@@ -2,9 +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/elements/containers"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
@@ -17,11 +16,11 @@ func run () {
|
||||
window, _ := tomo.NewWindow(300, 2)
|
||||
window.SetTitle("List Sidebar")
|
||||
|
||||
container := containers.NewContainer(basicLayouts.Horizontal { true, true })
|
||||
container := containers.NewContainer(layouts.Horizontal { true, true })
|
||||
window.Adopt(container)
|
||||
|
||||
var currentPage elements.Element
|
||||
turnPage := func (newPage elements.Element) {
|
||||
var currentPage tomo.Element
|
||||
turnPage := func (newPage tomo.Element) {
|
||||
container.Warp (func () {
|
||||
if currentPage != nil {
|
||||
container.Disown(currentPage)
|
||||
@@ -31,29 +30,29 @@ func run () {
|
||||
})
|
||||
}
|
||||
|
||||
intro := basicElements.NewLabel (
|
||||
intro := elements.NewLabel (
|
||||
"The List element can be easily used as a sidebar. " +
|
||||
"Click on entries to flip pages!", true)
|
||||
button := basicElements.NewButton("I do nothing!")
|
||||
button := elements.NewButton("I do nothing!")
|
||||
button.OnClick (func () {
|
||||
popups.NewDialog(popups.DialogKindInfo, "", "Sike!")
|
||||
popups.NewDialog(popups.DialogKindInfo, window, "", "Sike!")
|
||||
})
|
||||
mouse := testing.NewMouse()
|
||||
input := basicElements.NewTextBox("Write some text", "")
|
||||
form := containers.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)
|
||||
input := elements.NewTextBox("Write some text", "")
|
||||
form := containers.NewContainer(layouts.Vertical { true, false})
|
||||
form.Adopt(elements.NewLabel("I have:", false), false)
|
||||
form.Adopt(elements.NewSpacer(true), false)
|
||||
form.Adopt(elements.NewCheckbox("Skin", true), false)
|
||||
form.Adopt(elements.NewCheckbox("Blood", false), false)
|
||||
form.Adopt(elements.NewCheckbox("Bone", false), false)
|
||||
art := testing.NewArtist()
|
||||
|
||||
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) }),
|
||||
basicElements.NewListEntry("art", func () { turnPage(art) }))
|
||||
list := elements.NewList (
|
||||
elements.NewListEntry("button", func () { turnPage(button) }),
|
||||
elements.NewListEntry("mouse", func () { turnPage(mouse) }),
|
||||
elements.NewListEntry("input", func () { turnPage(input) }),
|
||||
elements.NewListEntry("form", func () { turnPage(form) }),
|
||||
elements.NewListEntry("art", func () { turnPage(art) }))
|
||||
list.OnNoEntrySelected(func () { turnPage (intro) })
|
||||
list.Collapse(96, 0)
|
||||
|
||||
|
||||
@@ -2,9 +2,8 @@ package main
|
||||
|
||||
import "fmt"
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
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/backends/all"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
|
||||
@@ -16,8 +15,8 @@ func run () {
|
||||
window, _ := tomo.NewWindow(256, 256)
|
||||
window.SetTitle("Main")
|
||||
|
||||
container := containers.NewContainer(basicLayouts.Vertical { true, true })
|
||||
container.Adopt(basicElements.NewLabel("Main window", false), true)
|
||||
container := containers.NewContainer(layouts.Vertical { true, true })
|
||||
container.Adopt(elements.NewLabel("Main window", false), true)
|
||||
window.Adopt(container)
|
||||
|
||||
window.OnClose(tomo.Stop)
|
||||
@@ -29,12 +28,12 @@ func run () {
|
||||
createPanel(window, 3)
|
||||
}
|
||||
|
||||
func createPanel (parent elements.MainWindow, id int) {
|
||||
func createPanel (parent tomo.MainWindow, id int) {
|
||||
window, _ := parent.NewPanel(2, 2)
|
||||
title := fmt.Sprint("Panel #", id)
|
||||
window.SetTitle(title)
|
||||
container := containers.NewContainer(basicLayouts.Vertical { true, true })
|
||||
container.Adopt(basicElements.NewLabel(title, false), true)
|
||||
container := containers.NewContainer(layouts.Vertical { true, true })
|
||||
container.Adopt(elements.NewLabel(title, false), true)
|
||||
window.Adopt(container)
|
||||
window.Show()
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@ import "errors"
|
||||
import "github.com/faiface/beep"
|
||||
import "github.com/faiface/beep/speaker"
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/fun"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/fun/music"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
@@ -34,27 +34,27 @@ func main () {
|
||||
func run () {
|
||||
window, _ := tomo.NewWindow(2, 2)
|
||||
window.SetTitle("Piano")
|
||||
container := containers.NewContainer(basicLayouts.Vertical { true, true })
|
||||
controlBar := containers.NewContainer(basicLayouts.Horizontal { true, false })
|
||||
container := containers.NewContainer(layouts.Vertical { true, true })
|
||||
controlBar := containers.NewContainer(layouts.Horizontal { true, false })
|
||||
|
||||
waveformColumn := containers.NewContainer(basicLayouts.Vertical { true, false })
|
||||
waveformList := basicElements.NewList (
|
||||
basicElements.NewListEntry("Sine", func(){ waveform = 0 }),
|
||||
basicElements.NewListEntry("Triangle", func(){ waveform = 3 }),
|
||||
basicElements.NewListEntry("Square", func(){ waveform = 1 }),
|
||||
basicElements.NewListEntry("Saw", func(){ waveform = 2 }),
|
||||
basicElements.NewListEntry("Supersaw", func(){ waveform = 4 }),
|
||||
waveformColumn := containers.NewContainer(layouts.Vertical { true, false })
|
||||
waveformList := elements.NewList (
|
||||
elements.NewListEntry("Sine", func(){ waveform = 0 }),
|
||||
elements.NewListEntry("Triangle", func(){ waveform = 3 }),
|
||||
elements.NewListEntry("Square", func(){ waveform = 1 }),
|
||||
elements.NewListEntry("Saw", func(){ waveform = 2 }),
|
||||
elements.NewListEntry("Supersaw", func(){ waveform = 4 }),
|
||||
)
|
||||
waveformList.OnNoEntrySelected (func(){waveformList.Select(0)})
|
||||
waveformList.Select(0)
|
||||
|
||||
adsrColumn := containers.NewContainer(basicLayouts.Vertical { true, false })
|
||||
adsrGroup := containers.NewContainer(basicLayouts.Horizontal { true, false })
|
||||
attackSlider := basicElements.NewLerpSlider(0, 3 * time.Second, adsr.Attack, true)
|
||||
decaySlider := basicElements.NewLerpSlider(0, 3 * time.Second, adsr.Decay, true)
|
||||
sustainSlider := basicElements.NewSlider(adsr.Sustain, true)
|
||||
releaseSlider := basicElements.NewLerpSlider(0, 3 * time.Second, adsr.Release, true)
|
||||
gainSlider := basicElements.NewSlider(math.Sqrt(gain), false)
|
||||
adsrColumn := containers.NewContainer(layouts.Vertical { true, false })
|
||||
adsrGroup := containers.NewContainer(layouts.Horizontal { true, false })
|
||||
attackSlider := elements.NewLerpSlider(0, 3 * time.Second, adsr.Attack, true)
|
||||
decaySlider := elements.NewLerpSlider(0, 3 * time.Second, adsr.Decay, true)
|
||||
sustainSlider := elements.NewSlider(adsr.Sustain, true)
|
||||
releaseSlider := elements.NewLerpSlider(0, 3 * time.Second, adsr.Release, true)
|
||||
gainSlider := elements.NewSlider(math.Sqrt(gain), false)
|
||||
|
||||
attackSlider.OnRelease (func () {
|
||||
adsr.Attack = attackSlider.Value()
|
||||
@@ -72,7 +72,7 @@ func run () {
|
||||
gain = math.Pow(gainSlider.Value(), 2)
|
||||
})
|
||||
|
||||
patchColumn := containers.NewContainer(basicLayouts.Vertical { true, false })
|
||||
patchColumn := containers.NewContainer(layouts.Vertical { true, false })
|
||||
patch := func (w int, a, d time.Duration, s float64, r time.Duration) func () {
|
||||
return func () {
|
||||
waveform = w
|
||||
@@ -89,22 +89,22 @@ func run () {
|
||||
releaseSlider.SetValue(adsr.Release)
|
||||
}
|
||||
}
|
||||
patchList := basicElements.NewList (
|
||||
basicElements.NewListEntry ("Bones", patch (
|
||||
patchList := elements.NewList (
|
||||
elements.NewListEntry ("Bones", patch (
|
||||
0, 0, 100, 0.0, 0)),
|
||||
basicElements.NewListEntry ("Staccato", patch (
|
||||
elements.NewListEntry ("Staccato", patch (
|
||||
4, 70, 500, 0, 0)),
|
||||
basicElements.NewListEntry ("Sustain", patch (
|
||||
elements.NewListEntry ("Sustain", patch (
|
||||
4, 70, 200, 0.8, 500)),
|
||||
basicElements.NewListEntry ("Upright", patch (
|
||||
elements.NewListEntry ("Upright", patch (
|
||||
1, 0, 500, 0.4, 70)),
|
||||
basicElements.NewListEntry ("Space Pad", patch (
|
||||
elements.NewListEntry ("Space Pad", patch (
|
||||
4, 1500, 0, 1.0, 3000)),
|
||||
basicElements.NewListEntry ("Popcorn", patch (
|
||||
elements.NewListEntry ("Popcorn", patch (
|
||||
2, 0, 40, 0.0, 0)),
|
||||
basicElements.NewListEntry ("Racer", patch (
|
||||
elements.NewListEntry ("Racer", patch (
|
||||
3, 70, 0, 0.7, 400)),
|
||||
basicElements.NewListEntry ("Reverse", patch (
|
||||
elements.NewListEntry ("Reverse", patch (
|
||||
2, 3000, 60, 0, 0)),
|
||||
)
|
||||
patchList.Collapse(0, 32)
|
||||
@@ -121,19 +121,19 @@ func run () {
|
||||
window.Adopt(container)
|
||||
|
||||
controlBar.Adopt(patchColumn, true)
|
||||
patchColumn.Adopt(basicElements.NewLabel("Presets", false), false)
|
||||
patchColumn.Adopt(elements.NewLabel("Presets", false), false)
|
||||
patchColumn.Adopt(patchScrollBox, true)
|
||||
patchScrollBox.Adopt(patchList)
|
||||
|
||||
controlBar.Adopt(basicElements.NewSpacer(true), false)
|
||||
controlBar.Adopt(elements.NewSpacer(true), false)
|
||||
|
||||
controlBar.Adopt(waveformColumn, false)
|
||||
waveformColumn.Adopt(basicElements.NewLabel("Waveform", false), false)
|
||||
waveformColumn.Adopt(elements.NewLabel("Waveform", false), false)
|
||||
waveformColumn.Adopt(waveformList, true)
|
||||
|
||||
controlBar.Adopt(basicElements.NewSpacer(true), false)
|
||||
controlBar.Adopt(elements.NewSpacer(true), false)
|
||||
|
||||
adsrColumn.Adopt(basicElements.NewLabel("ADSR", false), false)
|
||||
adsrColumn.Adopt(elements.NewLabel("ADSR", false), false)
|
||||
adsrGroup.Adopt(attackSlider, false)
|
||||
adsrGroup.Adopt(decaySlider, false)
|
||||
adsrGroup.Adopt(sustainSlider, false)
|
||||
|
||||
@@ -2,8 +2,8 @@ package main
|
||||
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/popups"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
|
||||
@@ -15,12 +15,12 @@ func run () {
|
||||
window, _ := tomo.NewWindow(2, 2)
|
||||
window.SetTitle("Dialog Boxes")
|
||||
|
||||
container := containers.NewContainer(basicLayouts.Vertical { true, true })
|
||||
container := containers.NewContainer(layouts.Vertical { true, true })
|
||||
window.Adopt(container)
|
||||
|
||||
container.Adopt(basicElements.NewLabel("Try out different dialogs:", false), true)
|
||||
container.Adopt(elements.NewLabel("Try out different dialogs:", false), true)
|
||||
|
||||
infoButton := basicElements.NewButton("popups.DialogKindInfo")
|
||||
infoButton := elements.NewButton("popups.DialogKindInfo")
|
||||
infoButton.OnClick (func () {
|
||||
popups.NewDialog (
|
||||
popups.DialogKindInfo,
|
||||
@@ -31,7 +31,7 @@ func run () {
|
||||
container.Adopt(infoButton, false)
|
||||
infoButton.Focus()
|
||||
|
||||
questionButton := basicElements.NewButton("popups.DialogKindQuestion")
|
||||
questionButton := elements.NewButton("popups.DialogKindQuestion")
|
||||
questionButton.OnClick (func () {
|
||||
popups.NewDialog (
|
||||
popups.DialogKindQuestion,
|
||||
@@ -44,7 +44,7 @@ func run () {
|
||||
})
|
||||
container.Adopt(questionButton, false)
|
||||
|
||||
warningButton := basicElements.NewButton("popups.DialogKindWarning")
|
||||
warningButton := elements.NewButton("popups.DialogKindWarning")
|
||||
warningButton.OnClick (func () {
|
||||
popups.NewDialog (
|
||||
popups.DialogKindWarning,
|
||||
@@ -54,7 +54,7 @@ func run () {
|
||||
})
|
||||
container.Adopt(warningButton, false)
|
||||
|
||||
errorButton := basicElements.NewButton("popups.DialogKindError")
|
||||
errorButton := elements.NewButton("popups.DialogKindError")
|
||||
errorButton.OnClick (func () {
|
||||
popups.NewDialog (
|
||||
popups.DialogKindError,
|
||||
@@ -64,7 +64,7 @@ func run () {
|
||||
})
|
||||
container.Adopt(errorButton, false)
|
||||
|
||||
cancelButton := basicElements.NewButton("No thank you.")
|
||||
cancelButton := elements.NewButton("No thank you.")
|
||||
cancelButton.OnClick(tomo.Stop)
|
||||
container.Adopt(cancelButton, false)
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ package main
|
||||
import "time"
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/popups"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
|
||||
@@ -15,23 +15,23 @@ func main () {
|
||||
func run () {
|
||||
window, _ := tomo.NewWindow(2, 2)
|
||||
window.SetTitle("Approaching")
|
||||
container := containers.NewContainer(basicLayouts.Vertical { true, true })
|
||||
container := containers.NewContainer(layouts.Vertical { true, true })
|
||||
window.Adopt(container)
|
||||
|
||||
container.Adopt (basicElements.NewLabel (
|
||||
container.Adopt (elements.NewLabel (
|
||||
"Rapidly approaching your location...", false), false)
|
||||
bar := basicElements.NewProgressBar(0)
|
||||
bar := elements.NewProgressBar(0)
|
||||
container.Adopt(bar, false)
|
||||
button := basicElements.NewButton("Stop")
|
||||
button := elements.NewButton("Stop")
|
||||
button.SetEnabled(false)
|
||||
container.Adopt(button, false)
|
||||
|
||||
window.OnClose(tomo.Stop)
|
||||
window.Show()
|
||||
go fill(bar)
|
||||
go fill(window, bar)
|
||||
}
|
||||
|
||||
func fill (bar *basicElements.ProgressBar) {
|
||||
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 () {
|
||||
@@ -41,6 +41,7 @@ func fill (bar *basicElements.ProgressBar) {
|
||||
tomo.Do (func () {
|
||||
popups.NewDialog (
|
||||
popups.DialogKindInfo,
|
||||
window,
|
||||
"I am here",
|
||||
"Don't look outside your window.")
|
||||
})
|
||||
|
||||
@@ -5,8 +5,8 @@ import _ "embed"
|
||||
import _ "image/png"
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/popups"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
|
||||
@@ -21,7 +21,7 @@ func run () {
|
||||
window, _ := tomo.NewWindow(640, 480)
|
||||
window.SetTitle("Raycaster")
|
||||
|
||||
container := containers.NewContainer(basicLayouts.Vertical { false, false })
|
||||
container := containers.NewContainer(layouts.Vertical { false, false })
|
||||
window.Adopt(container)
|
||||
|
||||
wallTexture, _ := TextureFrom(bytes.NewReader(wallTextureBytes))
|
||||
@@ -48,13 +48,13 @@ func run () {
|
||||
wallTexture,
|
||||
})
|
||||
|
||||
topBar := containers.NewContainer(basicLayouts.Horizontal { true, true })
|
||||
staminaBar := basicElements.NewProgressBar(game.Stamina())
|
||||
healthBar := basicElements.NewProgressBar(game.Health())
|
||||
topBar := containers.NewContainer(layouts.Horizontal { true, true })
|
||||
staminaBar := elements.NewProgressBar(game.Stamina())
|
||||
healthBar := elements.NewProgressBar(game.Health())
|
||||
|
||||
topBar.Adopt(basicElements.NewLabel("Stamina:", false), false)
|
||||
topBar.Adopt(elements.NewLabel("Stamina:", false), false)
|
||||
topBar.Adopt(staminaBar, true)
|
||||
topBar.Adopt(basicElements.NewLabel("Health:", false), false)
|
||||
topBar.Adopt(elements.NewLabel("Health:", false), false)
|
||||
topBar.Adopt(healthBar, true)
|
||||
container.Adopt(topBar, false)
|
||||
container.Adopt(game, true)
|
||||
@@ -69,6 +69,7 @@ func run () {
|
||||
|
||||
popups.NewDialog (
|
||||
popups.DialogKindInfo,
|
||||
window,
|
||||
"Welcome to the backrooms",
|
||||
"You've no-clipped into the backrooms!\n" +
|
||||
"Move with WASD, and look with the arrow keys.\n" +
|
||||
|
||||
@@ -2,8 +2,8 @@ package main
|
||||
|
||||
import "image"
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
|
||||
@@ -14,39 +14,39 @@ func main () {
|
||||
func run () {
|
||||
window, _ := tomo.NewWindow(360, 240)
|
||||
window.SetTitle("Scroll")
|
||||
container := containers.NewContainer(basicLayouts.Vertical { true, true })
|
||||
container := containers.NewContainer(layouts.Vertical { true, true })
|
||||
window.Adopt(container)
|
||||
|
||||
textBox := basicElements.NewTextBox("", copypasta)
|
||||
textBox := elements.NewTextBox("", copypasta)
|
||||
scrollContainer := containers.NewScrollContainer(true, false)
|
||||
|
||||
disconnectedContainer := containers.NewContainer (basicLayouts.Horizontal {
|
||||
disconnectedContainer := containers.NewContainer (layouts.Horizontal {
|
||||
Gap: true,
|
||||
})
|
||||
list := basicElements.NewList (
|
||||
basicElements.NewListEntry("This is list item 0", nil),
|
||||
basicElements.NewListEntry("This is list item 1", nil),
|
||||
basicElements.NewListEntry("This is list item 2", nil),
|
||||
basicElements.NewListEntry("This is list item 3", nil),
|
||||
basicElements.NewListEntry("This is list item 4", nil),
|
||||
basicElements.NewListEntry("This is list item 5", nil),
|
||||
basicElements.NewListEntry("This is list item 6", nil),
|
||||
basicElements.NewListEntry("This is list item 7", nil),
|
||||
basicElements.NewListEntry("This is list item 8", nil),
|
||||
basicElements.NewListEntry("This is list item 9", nil),
|
||||
basicElements.NewListEntry("This is list item 10", nil),
|
||||
basicElements.NewListEntry("This is list item 11", nil),
|
||||
basicElements.NewListEntry("This is list item 12", nil),
|
||||
basicElements.NewListEntry("This is list item 13", nil),
|
||||
basicElements.NewListEntry("This is list item 14", nil),
|
||||
basicElements.NewListEntry("This is list item 15", nil),
|
||||
basicElements.NewListEntry("This is list item 16", nil),
|
||||
basicElements.NewListEntry("This is list item 17", nil),
|
||||
basicElements.NewListEntry("This is list item 18", nil),
|
||||
basicElements.NewListEntry("This is list item 19", nil),
|
||||
basicElements.NewListEntry("This is list item 20", nil))
|
||||
list := elements.NewList (
|
||||
elements.NewListEntry("This is list item 0", nil),
|
||||
elements.NewListEntry("This is list item 1", nil),
|
||||
elements.NewListEntry("This is list item 2", nil),
|
||||
elements.NewListEntry("This is list item 3", nil),
|
||||
elements.NewListEntry("This is list item 4", nil),
|
||||
elements.NewListEntry("This is list item 5", nil),
|
||||
elements.NewListEntry("This is list item 6", nil),
|
||||
elements.NewListEntry("This is list item 7", nil),
|
||||
elements.NewListEntry("This is list item 8", nil),
|
||||
elements.NewListEntry("This is list item 9", nil),
|
||||
elements.NewListEntry("This is list item 10", nil),
|
||||
elements.NewListEntry("This is list item 11", nil),
|
||||
elements.NewListEntry("This is list item 12", nil),
|
||||
elements.NewListEntry("This is list item 13", nil),
|
||||
elements.NewListEntry("This is list item 14", nil),
|
||||
elements.NewListEntry("This is list item 15", nil),
|
||||
elements.NewListEntry("This is list item 16", nil),
|
||||
elements.NewListEntry("This is list item 17", nil),
|
||||
elements.NewListEntry("This is list item 18", nil),
|
||||
elements.NewListEntry("This is list item 19", nil),
|
||||
elements.NewListEntry("This is list item 20", nil))
|
||||
list.Collapse(0, 32)
|
||||
scrollBar := basicElements.NewScrollBar(true)
|
||||
scrollBar := elements.NewScrollBar(true)
|
||||
list.OnScrollBoundsChange (func () {
|
||||
scrollBar.SetBounds (
|
||||
list.ScrollContentBounds(),
|
||||
@@ -57,10 +57,10 @@ func run () {
|
||||
})
|
||||
|
||||
scrollContainer.Adopt(textBox)
|
||||
container.Adopt(basicElements.NewLabel("A ScrollContainer:", false), false)
|
||||
container.Adopt(elements.NewLabel("A ScrollContainer:", false), false)
|
||||
container.Adopt(scrollContainer, false)
|
||||
disconnectedContainer.Adopt(list, false)
|
||||
disconnectedContainer.Adopt (basicElements.NewLabel (
|
||||
disconnectedContainer.Adopt (elements.NewLabel (
|
||||
"Notice how the scroll bar to the right can be used to " +
|
||||
"control the list, despite not even touching it. It is " +
|
||||
"indeed a thing you can do. It is also terrible UI design so " +
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
|
||||
@@ -14,14 +14,14 @@ func run () {
|
||||
window, _ := tomo.NewWindow(2, 2)
|
||||
window.SetTitle("Spaced Out")
|
||||
|
||||
container := containers.NewContainer(basicLayouts.Vertical { true, true })
|
||||
container := containers.NewContainer(layouts.Vertical { true, true })
|
||||
window.Adopt(container)
|
||||
|
||||
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)
|
||||
container.Adopt (elements.NewLabel("This is at the top", false), false)
|
||||
container.Adopt (elements.NewSpacer(true), false)
|
||||
container.Adopt (elements.NewLabel("This is in the middle", false), false)
|
||||
container.Adopt (elements.NewSpacer(false), true)
|
||||
container.Adopt (elements.NewLabel("This is at the bottom", false), false)
|
||||
|
||||
window.OnClose(tomo.Stop)
|
||||
window.Show()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
|
||||
@@ -14,12 +14,12 @@ func run () {
|
||||
window, _ := tomo.NewWindow(2, 2)
|
||||
window.SetTitle("Switches")
|
||||
|
||||
container := containers.NewContainer(basicLayouts.Vertical { true, true })
|
||||
container := containers.NewContainer(layouts.Vertical { true, true })
|
||||
window.Adopt(container)
|
||||
|
||||
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)
|
||||
container.Adopt(elements.NewSwitch("hahahah", false), false)
|
||||
container.Adopt(elements.NewSwitch("hehehehheheh", false), false)
|
||||
container.Adopt(elements.NewSwitch("you can flick da swicth", false), false)
|
||||
|
||||
window.OnClose(tomo.Stop)
|
||||
window.Show()
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package main
|
||||
|
||||
import "git.tebibyte.media/sashakoshka/tomo"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/basic"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/layouts"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/testing"
|
||||
import "git.tebibyte.media/sashakoshka/tomo/elements/containers"
|
||||
import _ "git.tebibyte.media/sashakoshka/tomo/backends/all"
|
||||
@@ -15,15 +15,15 @@ func run () {
|
||||
window, _ := tomo.NewWindow(128, 128)
|
||||
window.SetTitle("vertical stack")
|
||||
|
||||
container := containers.NewContainer(basicLayouts.Vertical { true, true })
|
||||
container := containers.NewContainer(layouts.Vertical { true, true })
|
||||
window.Adopt(container)
|
||||
|
||||
label := basicElements.NewLabel("it is a label hehe", true)
|
||||
button := basicElements.NewButton("drawing pad")
|
||||
okButton := basicElements.NewButton("OK")
|
||||
label := elements.NewLabel("it is a label hehe", true)
|
||||
button := elements.NewButton("drawing pad")
|
||||
okButton := elements.NewButton("OK")
|
||||
button.OnClick (func () {
|
||||
container.DisownAll()
|
||||
container.Adopt(basicElements.NewLabel("Draw here:", false), false)
|
||||
container.Adopt(elements.NewLabel("Draw here:", false), false)
|
||||
container.Adopt(testing.NewMouse(), true)
|
||||
container.Adopt(okButton, false)
|
||||
okButton.Focus()
|
||||
|
||||
Reference in New Issue
Block a user