And removed the old test.

This commit is contained in:
Pietro Gagliardi 2018-09-02 09:46:08 -04:00
parent 731fa9c973
commit 7b7a2a7ef0
3 changed files with 0 additions and 471 deletions

View File

@ -1,155 +0,0 @@
// 12 december 2015
package ui
var page1 *Box
func makePage1(w *Window) {
var xbutton *Button
page1 = newVerticalBox()
entry := NewEntry()
page1.Append(entry, false)
spaced := NewCheckbox("Spaced")
spaced.OnToggled(func(*Checkbox) {
setSpaced(spaced.Checked())
})
label := NewLabel("Label")
hbox := newHorizontalBox()
getButton := NewButton("Get Window Text")
getButton.OnClicked(func(*Button) {
entry.SetText(w.Title())
})
setButton := NewButton("Set Window Text")
setButton.OnClicked(func(*Button) {
w.SetTitle(entry.Text())
})
hbox.Append(getButton, true)
hbox.Append(setButton, true)
page1.Append(hbox, false)
hbox = newHorizontalBox()
getButton = NewButton("Get Button Text")
xbutton = getButton
getButton.OnClicked(func(*Button) {
entry.SetText(xbutton.Text())
})
setButton = NewButton("Set Button Text")
setButton.OnClicked(func(*Button) {
xbutton.SetText(entry.Text())
})
hbox.Append(getButton, true)
hbox.Append(setButton, true)
page1.Append(hbox, false)
hbox = newHorizontalBox()
getButton = NewButton("Get Checkbox Text")
getButton.OnClicked(func(*Button) {
entry.SetText(spaced.Text())
})
setButton = NewButton("Set Checkbox Text")
setButton.OnClicked(func(*Button) {
spaced.SetText(entry.Text())
})
hbox.Append(getButton, true)
hbox.Append(setButton, true)
page1.Append(hbox, false)
hbox = newHorizontalBox()
getButton = NewButton("Get Label Text")
getButton.OnClicked(func(*Button) {
entry.SetText(label.Text())
})
setButton = NewButton("Set Label Text")
setButton.OnClicked(func(*Button) {
label.SetText(entry.Text())
})
hbox.Append(getButton, true)
hbox.Append(setButton, true)
page1.Append(hbox, false)
hbox = newHorizontalBox()
getButton = NewButton("Get Group Text")
getButton.OnClicked(func(*Button) {
entry.SetText(page2group.Title())
})
setButton = NewButton("Set Group Text")
setButton.OnClicked(func(*Button) {
page2group.SetTitle(entry.Text())
})
hbox.Append(getButton, true)
hbox.Append(setButton, true)
page1.Append(hbox, false)
hbox = newHorizontalBox()
hbox.Append(spaced, true)
getButton = NewButton("On")
getButton.OnClicked(func(*Button) {
spaced.SetChecked(true)
})
hbox.Append(getButton, false)
getButton = NewButton("Off")
getButton.OnClicked(func(*Button) {
spaced.SetChecked(false)
})
hbox.Append(getButton, false)
getButton = NewButton("Show")
getButton.OnClicked(func(*Button) {
// TODO
})
hbox.Append(getButton, false)
page1.Append(hbox, false)
testBox := newHorizontalBox()
ybutton := NewButton("Button")
testBox.Append(ybutton, true)
getButton = NewButton("Show")
getButton.OnClicked(func(*Button) {
ybutton.Show()
})
testBox.Append(getButton, false)
getButton = NewButton("Hide")
getButton.OnClicked(func(*Button) {
ybutton.Hide()
})
testBox.Append(getButton, false)
getButton = NewButton("Enable")
getButton.OnClicked(func(*Button) {
ybutton.Enable()
})
testBox.Append(getButton, false)
getButton = NewButton("Disable")
getButton.OnClicked(func(*Button) {
ybutton.Disable()
})
testBox.Append(getButton, false)
page1.Append(testBox, false)
hbox = newHorizontalBox()
getButton = NewButton("Show")
getButton.OnClicked(func(*Button) {
testBox.Show()
})
hbox.Append(getButton, false)
getButton = NewButton("Hide")
getButton.OnClicked(func(*Button) {
testBox.Hide()
})
hbox.Append(getButton, false)
getButton = NewButton("Enable")
getButton.OnClicked(func(*Button) {
testBox.Enable()
})
hbox.Append(getButton, false)
getButton = NewButton("Disable")
getButton.OnClicked(func(*Button) {
testBox.Disable()
})
hbox.Append(getButton, false)
page1.Append(hbox, false)
page1.Append(label, false)
}

View File

@ -1,187 +0,0 @@
// 12 december 2015
package ui
var page2group *Group
var (
movingLabel *Label
movingBoxes [2]*Box
movingCurrent int
)
func moveLabel(*Button) {
from := movingCurrent
to := 0
if from == 0 {
to = 1
}
movingBoxes[from].Delete(0)
movingBoxes[to].Append(movingLabel, false)
movingCurrent = to
}
var moveBack bool
const (
moveOutText = "Move Page 1 Out"
moveBackText = "Move Page 1 Back"
)
func movePage1(b *Button) {
if moveBack {
mainbox.Delete(1)
mainTab.InsertAt("Page 1", 0, page1)
b.SetText(moveOutText)
moveBack = false
return
}
mainTab.Delete(0)
mainbox.Append(page1, true)
b.SetText(moveBackText)
moveBack = true
}
func makePage2() *Box {
page2 := newVerticalBox()
group := newGroup("Moving Label")
page2group = group
page2.Append(group, false)
vbox := newVerticalBox()
group.SetChild(vbox)
hbox := newHorizontalBox()
button := NewButton("Move the Label!")
button.OnClicked(moveLabel)
hbox.Append(button, true)
hbox.Append(NewLabel(""), true)
vbox.Append(hbox, false)
hbox = newHorizontalBox()
movingBoxes[0] = newVerticalBox()
hbox.Append(movingBoxes[0], true)
movingBoxes[1] = newVerticalBox()
hbox.Append(movingBoxes[1], true)
vbox.Append(hbox, false)
movingCurrent = 0
movingLabel = NewLabel("This label moves!")
movingBoxes[movingCurrent].Append(movingLabel, false)
hbox = newHorizontalBox()
button = NewButton(moveOutText)
button.OnClicked(movePage1)
hbox.Append(button, false)
page2.Append(hbox, false)
moveBack = false
hbox = newHorizontalBox()
hbox.Append(NewLabel("Label Alignment Test"), false)
button = NewButton("Open Menued Window")
button.OnClicked(func(*Button) {
w := NewWindow("Another Window", 100, 100, true)
b := NewVerticalBox()
b.Append(NewEntry(), false)
b.Append(NewButton("Button"), false)
b.SetPadded(true)
w.SetChild(b)
w.SetMargined(true)
w.Show()
})
hbox.Append(button, false)
button = NewButton("Open Menuless Window")
button.OnClicked(func(*Button) {
w := NewWindow("Another Window", 100, 100, true)
//TODO w.SetChild(makePage6())
w.SetMargined(true)
w.Show()
})
hbox.Append(button, false)
button = NewButton("Disabled Menued")
button.OnClicked(func(*Button) {
w := NewWindow("Another Window", 100, 100, true)
w.Disable()
w.Show()
})
hbox.Append(button, false)
button = NewButton("Disabled Menuless")
button.OnClicked(func(*Button) {
w := NewWindow("Another Window", 100, 100, false)
w.Disable()
w.Show()
})
hbox.Append(button, false)
page2.Append(hbox, false)
nestedBox := newHorizontalBox()
innerhbox := newHorizontalBox()
innerhbox.Append(NewButton("These"), false)
button = NewButton("buttons")
button.Disable()
innerhbox.Append(button, false)
nestedBox.Append(innerhbox, false)
innerhbox = newHorizontalBox()
innerhbox.Append(NewButton("are"), false)
innerhbox2 := newHorizontalBox()
button = NewButton("in")
button.Disable()
innerhbox2.Append(button, false)
innerhbox.Append(innerhbox2, false)
nestedBox.Append(innerhbox, false)
innerhbox = newHorizontalBox()
innerhbox2 = newHorizontalBox()
innerhbox2.Append(NewButton("nested"), false)
innerhbox3 := newHorizontalBox()
button = NewButton("boxes")
button.Disable()
innerhbox3.Append(button, false)
innerhbox2.Append(innerhbox3, false)
innerhbox.Append(innerhbox2, false)
nestedBox.Append(innerhbox, false)
page2.Append(nestedBox, false)
hbox = newHorizontalBox()
button = NewButton("Enable Nested Box")
button.OnClicked(func(*Button) {
nestedBox.Enable()
})
hbox.Append(button, false)
button = NewButton("Disable Nested Box")
button.OnClicked(func(*Button) {
nestedBox.Disable()
})
hbox.Append(button, false)
page2.Append(hbox, false)
disabledTab := newTab()
disabledTab.Append("Disabled", NewButton("Button"));
disabledTab.Append("Tab", NewLabel("Label"));
disabledTab.Disable()
page2.Append(disabledTab, true)
entry := NewEntry()
readonly := NewEntry()
entry.OnChanged(func(*Entry) {
readonly.SetText(entry.Text())
})
readonly.SetText("If you can see this, uiEntryReadOnly() isn't working properly.")
readonly.SetReadOnly(true)
if readonly.ReadOnly() {
readonly.SetText("")
}
page2.Append(entry, false)
page2.Append(readonly, false)
hbox = newHorizontalBox()
button = NewButton("Show Button 2")
button2 := NewButton("Button 2")
button.OnClicked(func(*Button) {
button2.Show()
})
button2.Hide()
hbox.Append(button, true)
hbox.Append(button2, false)
page2.Append(hbox, false)
return page2
}

View File

@ -1,129 +0,0 @@
// 11 december 2015
package ui
import (
"flag"
"testing"
)
var (
nomenus = flag.Bool("nomenus", false, "No menus")
startspaced = flag.Bool("startspaced", false, "Start with spacing")
swaphv = flag.Bool("swaphv", false, "Swap horizontal and vertical boxes")
)
var mainbox *Box
var mainTab *Tab
func xmain() {
if !*nomenus {
// TODO
}
w := newWindow("Main Window", 320, 240, true)
w.OnClosing(func(*Window) bool {
Quit()
return true
})
OnShouldQuit(func() bool {
// TODO
return true
})
mainbox = newHorizontalBox()
w.SetChild(mainbox)
outerTab := newTab()
mainbox.Append(outerTab, true)
mainTab = newTab()
outerTab.Append("Original", mainTab)
makePage1(w)
mainTab.Append("Page 1", page1)
mainTab.Append("Page 2", makePage2())
// TODO
if *startspaced {
setSpaced(true)
}
w.Show()
}
func TestIt(t *testing.T) {
err := Main(xmain)
if err != nil {
t.Fatal(err)
}
}
var (
spwindows []*Window
sptabs []*Tab
spgroups []*Group
spboxes []*Box
)
func newWindow(title string, width int, height int, hasMenubar bool) *Window {
w := NewWindow(title, width, height, hasMenubar)
spwindows = append(spwindows, w)
return w
}
func newTab() *Tab {
t := NewTab()
sptabs = append(sptabs, t)
return t
}
func newGroup(title string) *Group {
g := NewGroup(title)
spgroups = append(spgroups, g)
return g
}
func newHorizontalBox() *Box {
var b *Box
if *swaphv {
b = NewVerticalBox()
} else {
b = NewHorizontalBox()
}
spboxes = append(spboxes, b)
return b
}
func newVerticalBox() *Box {
var b *Box
if *swaphv {
b = NewHorizontalBox()
} else {
b = NewVerticalBox()
}
spboxes = append(spboxes, b)
return b
}
func setSpaced(spaced bool) {
for _, w := range spwindows {
w.SetMargined(spaced)
}
for _, t := range sptabs {
for i := 0; i < t.NumPages(); i++ {
t.SetMargined(i, spaced)
}
}
for _, g := range spgroups {
g.SetMargined(spaced)
}
for _, b := range spboxes {
b.SetPadded(spaced)
}
}