Element methods are now more consistent and have less bool flags
Still need to update most examples...
This commit is contained in:
@@ -13,23 +13,18 @@ func run () {
|
||||
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 256, 256))
|
||||
window.SetTitle("Text alignment")
|
||||
|
||||
container := elements.NewDocument()
|
||||
|
||||
left := elements.NewLabel(text, true)
|
||||
center := elements.NewLabel(text, true)
|
||||
right := elements.NewLabel(text, true)
|
||||
justify := elements.NewLabel(text, true)
|
||||
left := elements.NewLabelWrapped(text)
|
||||
center := elements.NewLabelWrapped(text)
|
||||
right := elements.NewLabelWrapped(text)
|
||||
justify := elements.NewLabelWrapped(text)
|
||||
|
||||
left.SetAlign(textdraw.AlignLeft)
|
||||
center.SetAlign(textdraw.AlignCenter)
|
||||
right.SetAlign(textdraw.AlignRight)
|
||||
justify.SetAlign(textdraw.AlignJustify)
|
||||
|
||||
container.Adopt(left, true)
|
||||
container.Adopt(center, true)
|
||||
container.Adopt(right, true)
|
||||
container.Adopt(justify, true)
|
||||
window.Adopt(elements.NewScroll(container, false, true))
|
||||
window.Adopt (elements.NewScroll (elements.ScrollVertical,
|
||||
elements.NewDocument(left, center, right, justify)))
|
||||
|
||||
window.OnClose(tomo.Stop)
|
||||
window.Show()
|
||||
|
||||
@@ -13,23 +13,15 @@ func run () {
|
||||
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 0, 0))
|
||||
window.SetTitle("Checkboxes")
|
||||
|
||||
container := elements.NewVBox(true, true)
|
||||
window.Adopt(container)
|
||||
|
||||
introText := elements.NewLabel (
|
||||
introText := elements.NewLabelWrapped (
|
||||
"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)
|
||||
"me to communicate.")
|
||||
introText.EmCollapse(0, 5)
|
||||
container.Adopt(introText, true)
|
||||
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 := elements.NewCheckbox("Enable vsync", false)
|
||||
vsync.OnToggle (func () {
|
||||
if vsync.Value() {
|
||||
@@ -40,12 +32,23 @@ func run () {
|
||||
"That doesn't do anything.")
|
||||
}
|
||||
})
|
||||
container.Adopt(vsync, false)
|
||||
|
||||
button := elements.NewButton("What")
|
||||
button.OnClick(tomo.Stop)
|
||||
container.Adopt(button, false)
|
||||
button.Focus()
|
||||
|
||||
box := elements.NewVBox(elements.SpaceBoth)
|
||||
box.AdoptExpand(introText)
|
||||
box.Adopt (
|
||||
elements.NewLine(),
|
||||
elements.NewCheckbox("Oh god", false),
|
||||
elements.NewCheckbox("Can you hear them", true),
|
||||
elements.NewCheckbox("They are in the walls", false),
|
||||
elements.NewCheckbox("They are coming for us", false),
|
||||
disabledCheckbox,
|
||||
vsync, button)
|
||||
window.Adopt(box)
|
||||
|
||||
button.Focus()
|
||||
window.OnClose(tomo.Stop)
|
||||
window.Show()
|
||||
}
|
||||
|
||||
@@ -25,9 +25,9 @@ func run () {
|
||||
window, _ := tomo.NewWindow(tomo.Bounds(0, 0, 256, 0))
|
||||
window.SetTitle("Clipboard")
|
||||
|
||||
container := elements.NewVBox(true, true)
|
||||
container := elements.NewVBox(elements.SpaceBoth)
|
||||
textInput := elements.NewTextBox("", "")
|
||||
controlRow := elements.NewHBox(false, true)
|
||||
controlRow := elements.NewHBox(elements.SpaceMargin)
|
||||
copyButton := elements.NewButton("Copy")
|
||||
copyButton.SetIcon(tomo.IconCopy)
|
||||
pasteButton := elements.NewButton("Paste")
|
||||
@@ -107,11 +107,11 @@ func run () {
|
||||
window.Paste(imageClipboardCallback, validImageTypes...)
|
||||
})
|
||||
|
||||
container.Adopt(textInput, true)
|
||||
controlRow.Adopt(copyButton, true)
|
||||
controlRow.Adopt(pasteButton, true)
|
||||
controlRow.Adopt(pasteImageButton, true)
|
||||
container.Adopt(controlRow, false)
|
||||
container.AdoptExpand(textInput)
|
||||
controlRow.AdoptExpand(copyButton)
|
||||
controlRow.AdoptExpand(pasteButton)
|
||||
controlRow.AdoptExpand(pasteImageButton)
|
||||
container.Adopt(controlRow)
|
||||
window.Adopt(container)
|
||||
|
||||
window.OnClose(tomo.Stop)
|
||||
@@ -121,13 +121,13 @@ func run () {
|
||||
func imageWindow (parent tomo.Window, image image.Image) {
|
||||
window, _ := parent.NewModal(tomo.Bounds(0, 0, 0, 0))
|
||||
window.SetTitle("Clipboard Image")
|
||||
container := containers.NewVBox(true, true)
|
||||
container := elements.NewVBox(elements.SpaceBoth)
|
||||
closeButton := elements.NewButton("Ok")
|
||||
closeButton.SetIcon(tomo.IconYes)
|
||||
closeButton.OnClick(window.Close)
|
||||
|
||||
container.Adopt(elements.NewImage(image), true)
|
||||
container.Adopt(closeButton, false)
|
||||
container.AdoptExpand(elements.NewImage(image))
|
||||
container.Adopt(closeButton)
|
||||
window.Adopt(container)
|
||||
window.Show()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user