seperate the area code into it's own file
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
81dabbe53d
commit
9a49f56147
|
@ -1,3 +1,5 @@
|
|||
*.swp
|
||||
|
||||
cloud-control-panel
|
||||
example-gui/example-gui
|
||||
example-systray/example-systray
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
package main
|
||||
|
||||
// import "time"
|
||||
// import "log"
|
||||
// import "fmt"
|
||||
// import "runtime"
|
||||
|
||||
import "github.com/andlabs/ui"
|
||||
import _ "github.com/andlabs/ui/winmanifest"
|
||||
|
||||
import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
var fontButton *ui.FontButton
|
||||
var attrstr *ui.AttributedString
|
||||
var splashArea *ui.Area
|
||||
|
||||
func makeSplashArea() *ui.Area {
|
||||
fontButton = ui.NewFontButton()
|
||||
fontButton.OnChanged(func(*ui.FontButton) {
|
||||
spew.Dump(fontButton.Font())
|
||||
// SplashArea.QueueRedrawAll()
|
||||
})
|
||||
|
||||
spew.Dump(fontButton.Font())
|
||||
|
||||
makeAttributedString()
|
||||
splashArea = ui.NewArea(areaHandler{})
|
||||
|
||||
spew.Dump(splashArea)
|
||||
return splashArea
|
||||
}
|
||||
|
||||
func appendWithAttributes(what string, attrs ...ui.Attribute) {
|
||||
start := len(attrstr.String())
|
||||
end := start + len(what)
|
||||
attrstr.AppendUnattributed(what)
|
||||
for _, a := range attrs {
|
||||
attrstr.SetAttribute(a, start, end)
|
||||
}
|
||||
}
|
||||
|
||||
func makeAttributedString() {
|
||||
attrstr = ui.NewAttributedString("")
|
||||
|
||||
appendWithAttributes("Welcome to the Cloud Control Panel\n", ui.TextSize(16), ui.TextColor{0.0, 0.0, 0.8, .8}) // "RGBT"
|
||||
|
||||
appendWithAttributes("(alpha)\n\n", ui.TextSize(10))
|
||||
|
||||
appendWithAttributes("This control panel was designed to be an interface to your 'private' cloud. ", ui.TextWeightBold)
|
||||
appendWithAttributes("The concept of a private cloud means that you can use a providers system, or, seemlessly, use your own hardware in your own datacenter. ", ui.TextWeightBold)
|
||||
|
||||
attrstr.AppendUnattributed("\n")
|
||||
attrstr.AppendUnattributed("\n")
|
||||
appendWithAttributes("This control panel requires:\n")
|
||||
attrstr.AppendUnattributed("\n")
|
||||
appendWithAttributes("IPv6\n")
|
||||
appendWithAttributes("Your hostname in DNS\n")
|
||||
}
|
||||
|
||||
type areaHandler struct{}
|
||||
|
||||
func (areaHandler) Draw(a *ui.Area, p *ui.AreaDrawParams) {
|
||||
tl := ui.DrawNewTextLayout(&ui.DrawTextLayoutParams{
|
||||
String: attrstr,
|
||||
DefaultFont: fontButton.Font(),
|
||||
Width: p.AreaWidth,
|
||||
Align: ui.DrawTextAlign(1),
|
||||
})
|
||||
defer tl.Free()
|
||||
p.Context.Text(tl, 0, 0)
|
||||
}
|
||||
|
||||
func (areaHandler) MouseEvent(a *ui.Area, me *ui.AreaMouseEvent) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (areaHandler) MouseCrossed(a *ui.Area, left bool) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (areaHandler) DragBroken(a *ui.Area) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (areaHandler) KeyEvent(a *ui.Area, ke *ui.AreaKeyEvent) (handled bool) {
|
||||
// reject all keys
|
||||
return false
|
||||
}
|
|
@ -8,14 +8,10 @@ import "runtime"
|
|||
import "github.com/andlabs/ui"
|
||||
import _ "github.com/andlabs/ui/winmanifest"
|
||||
|
||||
import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
var fontButton *ui.FontButton
|
||||
var attrstr *ui.AttributedString
|
||||
var SplashArea *ui.Area
|
||||
// import "github.com/davecgh/go-spew/spew"
|
||||
|
||||
func showSplash() {
|
||||
splashWin := ui.NewWindow("Splash Screen", 640, 480, false)
|
||||
splashWin := ui.NewWindow("", 640, 480, false)
|
||||
splashWin.OnClosing(func(*ui.Window) bool {
|
||||
ui.Quit()
|
||||
return true
|
||||
|
@ -25,38 +21,18 @@ func showSplash() {
|
|||
return true
|
||||
})
|
||||
|
||||
hbox := ui.NewHorizontalBox()
|
||||
hbox.SetPadded(true)
|
||||
splashWin.SetChild(hbox)
|
||||
vbox = ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
splashWin.SetChild(vbox)
|
||||
splashWin.SetMargined(true)
|
||||
|
||||
// This displays the window
|
||||
splashWin.Show()
|
||||
|
||||
vbox = ui.NewVerticalBox()
|
||||
vbox.SetPadded(true)
|
||||
|
||||
hbox.Append(vbox, true)
|
||||
|
||||
fontButton = ui.NewFontButton()
|
||||
fontButton.OnChanged(func(*ui.FontButton) {
|
||||
spew.Dump(fontButton.Font())
|
||||
// SplashArea.QueueRedrawAll()
|
||||
})
|
||||
// vbox.Append(fontButton, true)
|
||||
|
||||
spew.Dump(fontButton.Font())
|
||||
|
||||
ahbox := ui.NewHorizontalBox()
|
||||
ahbox.SetPadded(true)
|
||||
vbox.Append(ahbox, true)
|
||||
|
||||
makeAttributedString()
|
||||
SplashArea = ui.NewArea(areaHandler{})
|
||||
myArea := makeSplashArea()
|
||||
|
||||
spew.Dump(attrstr)
|
||||
spew.Dump(SplashArea)
|
||||
ahbox.Append(SplashArea, true)
|
||||
vbox.Append(myArea, true)
|
||||
|
||||
if runtime.GOOS == "linux" {
|
||||
vbox.Append(ui.NewLabel("OS: Linux"), false)
|
||||
|
@ -76,60 +52,3 @@ func showSplash() {
|
|||
})
|
||||
vbox.Append(okButton, false)
|
||||
}
|
||||
|
||||
func appendWithAttributes(what string, attrs ...ui.Attribute) {
|
||||
start := len(attrstr.String())
|
||||
end := start + len(what)
|
||||
attrstr.AppendUnattributed(what)
|
||||
for _, a := range attrs {
|
||||
attrstr.SetAttribute(a, start, end)
|
||||
}
|
||||
}
|
||||
|
||||
func makeAttributedString() {
|
||||
attrstr = ui.NewAttributedString("")
|
||||
|
||||
appendWithAttributes("Welcome to the Cloud Control Panel\n", ui.TextSize(16), ui.TextColor{0.0, 0.0, 0.8, .8}) // "RGBT"
|
||||
|
||||
appendWithAttributes("(alpha)\n\n", ui.TextSize(10))
|
||||
|
||||
appendWithAttributes("This control panel was designed to be an interface to your 'private' cloud. ", ui.TextWeightBold)
|
||||
appendWithAttributes("The concept of a private cloud means that you can use a providers system, or, seemlessly, use your own hardware in your own datacenter. ", ui.TextWeightBold)
|
||||
|
||||
attrstr.AppendUnattributed("\n")
|
||||
attrstr.AppendUnattributed("\n")
|
||||
appendWithAttributes("This control panel requires:\n")
|
||||
attrstr.AppendUnattributed("\n")
|
||||
appendWithAttributes("IPv6\n")
|
||||
appendWithAttributes("Your hostname in DNS\n")
|
||||
}
|
||||
|
||||
type areaHandler struct{}
|
||||
|
||||
func (areaHandler) Draw(a *ui.Area, p *ui.AreaDrawParams) {
|
||||
tl := ui.DrawNewTextLayout(&ui.DrawTextLayoutParams{
|
||||
String: attrstr,
|
||||
DefaultFont: fontButton.Font(),
|
||||
Width: p.AreaWidth,
|
||||
Align: ui.DrawTextAlign(1),
|
||||
})
|
||||
defer tl.Free()
|
||||
p.Context.Text(tl, 0, 0)
|
||||
}
|
||||
|
||||
func (areaHandler) MouseEvent(a *ui.Area, me *ui.AreaMouseEvent) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (areaHandler) MouseCrossed(a *ui.Area, left bool) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (areaHandler) DragBroken(a *ui.Area) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
func (areaHandler) KeyEvent(a *ui.Area, ke *ui.AreaKeyEvent) (handled bool) {
|
||||
// reject all keys
|
||||
return false
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue