2019-05-22 20:35:00 -05:00
package gui
import "log"
import "github.com/andlabs/ui"
import _ "github.com/andlabs/ui/winmanifest"
import "github.com/davecgh/go-spew/spew"
2019-05-26 14:05:23 -05:00
func makeSplashArea ( ) * ui . Area {
2019-05-22 20:35:00 -05:00
// make this button just to get the default font (but don't display the button)
// There should be another way to do this (?)
2019-05-26 14:40:07 -05:00
Data . fontButton = CreateFontButton ( "SplashFont" , "DONE" )
2019-05-22 20:35:00 -05:00
makeAttributedString ( )
2019-05-26 00:07:37 -05:00
splashArea := ui . NewArea ( myAH )
// create a 'fake' button entry for the mouse clicks
var newmap ButtonMap
newmap . Action = "AREA"
newmap . A = splashArea
myAH . button = & newmap
Data . AllButtons = append ( Data . AllButtons , newmap )
Data . splashArea = splashArea
2019-05-22 20:35:00 -05:00
2019-05-23 15:13:42 -05:00
if ( Data . Debug ) {
spew . Dump ( Data . splashArea )
log . Println ( "DEBUGGING" , Data . Debug )
} else {
2019-05-26 00:07:37 -05:00
log . Println ( "NOT DEBUGGING AREA mhAH.button =" , myAH . button )
log . Println ( "NOT DEBUGGING AREA mhAH.button =" , myAH . button )
log . Println ( "NOT DEBUGGING AREA mhAH.button =" , myAH . button )
2019-05-23 15:13:42 -05:00
}
2019-05-22 21:11:43 -05:00
return Data . splashArea
2019-05-22 20:35:00 -05:00
}
func appendWithAttributes ( what string , attrs ... ui . Attribute ) {
2019-05-22 21:11:43 -05:00
start := len ( Data . attrstr . String ( ) )
2019-05-22 20:35:00 -05:00
end := start + len ( what )
2019-05-22 21:11:43 -05:00
Data . attrstr . AppendUnattributed ( what )
2019-05-22 20:35:00 -05:00
for _ , a := range attrs {
2019-05-22 21:11:43 -05:00
Data . attrstr . SetAttribute ( a , start , end )
2019-05-22 20:35:00 -05:00
}
}
func makeAttributedString ( ) {
2019-05-22 21:11:43 -05:00
Data . attrstr = ui . NewAttributedString ( "" )
2019-05-22 20:35:00 -05:00
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 )
2019-05-22 21:11:43 -05:00
Data . attrstr . AppendUnattributed ( "\n" )
Data . attrstr . AppendUnattributed ( "\n" )
2019-05-22 20:35:00 -05:00
appendWithAttributes ( "This control panel requires:\n" )
2019-05-22 21:11:43 -05:00
Data . attrstr . AppendUnattributed ( "\n" )
2019-05-22 20:35:00 -05:00
appendWithAttributes ( "IPv6\n" )
appendWithAttributes ( "Your hostname in DNS\n" )
2019-05-22 21:11:43 -05:00
Data . attrstr . AppendUnattributed ( "\n\n\n\n\n" )
2019-05-22 20:35:00 -05:00
appendWithAttributes ( "<click or press any key>\n" , ui . TextSize ( 10 ) )
}
func ( ah areaHandler ) Draw ( a * ui . Area , p * ui . AreaDrawParams ) {
tl := ui . DrawNewTextLayout ( & ui . DrawTextLayoutParams {
2019-05-22 21:11:43 -05:00
String : Data . attrstr ,
DefaultFont : Data . fontButton . Font ( ) ,
2019-05-22 20:35:00 -05:00
Width : p . AreaWidth ,
Align : ui . DrawTextAlign ( 1 ) ,
} )
p . Context . Text ( tl , 0 , 0 )
defer tl . Free ( )
}
func ( ah areaHandler ) MouseEvent ( a * ui . Area , me * ui . AreaMouseEvent ) {
2019-05-23 15:44:53 -05:00
if ( Data . Debug ) {
2019-05-24 03:51:37 -05:00
log . Println ( "GOT MouseEvent()" )
2019-05-23 15:44:53 -05:00
spew . Dump ( me )
}
2019-05-22 20:35:00 -05:00
if ( me . Down == 1 ) {
log . Println ( "GOT MOUSE DOWN" )
}
if ( me . Up == 1 ) {
log . Println ( "GOT MOUSE UP" )
log . Println ( "GOT MOUSE UP" )
log . Println ( "GOT MOUSE UP" )
2019-05-26 00:07:37 -05:00
mouseClick ( myAH . button )
2019-05-22 20:35:00 -05:00
}
}
func ( ah areaHandler ) MouseCrossed ( a * ui . Area , left bool ) {
log . Println ( "GOT MouseCrossed()" )
}
func ( ah areaHandler ) DragBroken ( a * ui . Area ) {
log . Println ( "GOT DragBroken()" )
}
func ( ah areaHandler ) KeyEvent ( a * ui . Area , ke * ui . AreaKeyEvent ) ( handled bool ) {
log . Println ( "GOT KeyEvent()" )
if ( ke . Key == 10 ) {
log . Println ( "GOT ENTER" )
log . Println ( "GOT ENTER" )
log . Println ( "GOT ENTER" )
}
if ( ke . Key == 32 ) {
log . Println ( "GOT ENTER" )
log . Println ( "GOT ENTER" )
log . Println ( "GOT ENTER" )
}
spew . Dump ( ke )
// splashWin.Destroy()
// ui.Quit()
return false
}