2019-05-17 15:07:45 -05:00
package main
// import "time"
2019-05-17 15:19:46 -05:00
import "log"
2019-05-17 15:07:45 -05:00
// 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 ) {
2019-05-17 15:19:46 -05:00
log . Println ( "GOT MouseEvent()" )
spew . Dump ( me )
2019-05-17 15:07:45 -05:00
}
func ( areaHandler ) MouseCrossed ( a * ui . Area , left bool ) {
2019-05-17 15:19:46 -05:00
log . Println ( "GOT MouseCrossed()" )
2019-05-17 15:07:45 -05:00
}
func ( areaHandler ) DragBroken ( a * ui . Area ) {
2019-05-17 15:19:46 -05:00
log . Println ( "GOT DragBroken()" )
2019-05-17 15:07:45 -05:00
}
func ( areaHandler ) KeyEvent ( a * ui . Area , ke * ui . AreaKeyEvent ) ( handled bool ) {
2019-05-17 15:19:46 -05:00
log . Println ( "GOT KeyEvent()" )
spew . Dump ( ke )
2019-05-17 15:07:45 -05:00
return false
}