summaryrefslogtreecommitdiff
path: root/area.go
diff options
context:
space:
mode:
Diffstat (limited to 'area.go')
-rw-r--r--area.go56
1 files changed, 19 insertions, 37 deletions
diff --git a/area.go b/area.go
index 2d4ae59..013cd6c 100644
--- a/area.go
+++ b/area.go
@@ -7,63 +7,45 @@ import _ "github.com/andlabs/ui/winmanifest"
import "github.com/davecgh/go-spew/spew"
-func makeSplashArea() *ui.Area {
+func makeSplashArea() *AreaHandler {
// make this button just to get the default font (but don't display the button)
// There should be another way to do this (?)
Data.fontButton = CreateFontButton("SplashFont", "DONE")
- makeAttributedString()
+ myAH.Attrstr = makeAttributedString()
Data.splashArea = ui.NewArea(myAH)
+ Data.MyArea = Data.splashArea
+ myAH.Area = Data.splashArea
// create a 'fake' button entry for the mouse clicks
var newmap ButtonMap
newmap.Action = "AREA"
+ newmap.AH = &myAH
newmap.A = Data.splashArea
- myAH.button = &newmap
+ myAH.Button = &newmap
Data.AllButtons = append(Data.AllButtons, newmap)
if (Data.Debug) {
spew.Dump(Data.splashArea)
log.Println("DEBUGGING", Data.Debug)
} else {
- log.Println("NOT DEBUGGING AREA mhAH.button =", myAH.button)
+ log.Println("NOT DEBUGGING AREA mhAH.Button =", myAH.Button)
}
- return Data.splashArea
+ return &myAH
}
-func appendWithAttributes(what string, attrs ...ui.Attribute) {
- start := len(Data.attrstr.String())
+func appendWithAttributes(newText *ui.AttributedString, what string, attrs ...ui.Attribute) {
+ start := len(newText.String())
end := start + len(what)
- Data.attrstr.AppendUnattributed(what)
+ newText.AppendUnattributed(what)
for _, a := range attrs {
- Data.attrstr.SetAttribute(a, start, end)
+ newText.SetAttribute(a, start, end)
}
}
-func makeAttributedString() {
- Data.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)
-
- Data.attrstr.AppendUnattributed("\n")
- Data.attrstr.AppendUnattributed("\n")
- appendWithAttributes("This control panel requires:\n")
- Data.attrstr.AppendUnattributed("\n")
- appendWithAttributes("IPv6\n")
- appendWithAttributes("Your hostname in DNS\n")
- Data.attrstr.AppendUnattributed("\n\n\n\n\n")
-
- appendWithAttributes("<click or press any key>\n", ui.TextSize(10))
-}
-
-func (ah areaHandler) Draw(a *ui.Area, p *ui.AreaDrawParams) {
+func (ah AreaHandler) Draw(a *ui.Area, p *ui.AreaDrawParams) {
tl := ui.DrawNewTextLayout(&ui.DrawTextLayoutParams{
- String: Data.attrstr,
+ String: myAH.Attrstr,
DefaultFont: Data.fontButton.Font(),
Width: p.AreaWidth,
Align: ui.DrawTextAlign(1),
@@ -72,7 +54,7 @@ func (ah areaHandler) Draw(a *ui.Area, p *ui.AreaDrawParams) {
defer tl.Free()
}
-func (ah areaHandler) MouseEvent(a *ui.Area, me *ui.AreaMouseEvent) {
+func (ah AreaHandler) MouseEvent(a *ui.Area, me *ui.AreaMouseEvent) {
if (Data.Debug) {
log.Println("GOT MouseEvent()")
spew.Dump(me)
@@ -84,19 +66,19 @@ func (ah areaHandler) MouseEvent(a *ui.Area, me *ui.AreaMouseEvent) {
log.Println("GOT MOUSE UP")
log.Println("GOT MOUSE UP")
log.Println("GOT MOUSE UP")
- mouseClick(myAH.button)
+ mouseClick(myAH.Button)
}
}
-func (ah areaHandler) MouseCrossed(a *ui.Area, left bool) {
+func (ah AreaHandler) MouseCrossed(a *ui.Area, left bool) {
log.Println("GOT MouseCrossed()")
}
-func (ah areaHandler) DragBroken(a *ui.Area) {
+func (ah AreaHandler) DragBroken(a *ui.Area) {
log.Println("GOT DragBroken()")
}
-func (ah areaHandler) KeyEvent(a *ui.Area, ke *ui.AreaKeyEvent) (handled bool) {
+func (ah AreaHandler) KeyEvent(a *ui.Area, ke *ui.AreaKeyEvent) (handled bool) {
log.Println("GOT KeyEvent()")
if (ke.Key == 10) {
log.Println("GOT ENTER")