parent
6112b54b1e
commit
7107b534bc
51
area.go
51
area.go
|
@ -1,32 +1,51 @@
|
||||||
package gui
|
package gui
|
||||||
|
|
||||||
import "log"
|
import "log"
|
||||||
|
import "time"
|
||||||
|
|
||||||
import "github.com/andlabs/ui"
|
import "github.com/andlabs/ui"
|
||||||
import _ "github.com/andlabs/ui/winmanifest"
|
import _ "github.com/andlabs/ui/winmanifest"
|
||||||
|
|
||||||
import "github.com/davecgh/go-spew/spew"
|
import "github.com/davecgh/go-spew/spew"
|
||||||
|
|
||||||
|
func findFB(button *ButtonMap) *ButtonMap {
|
||||||
|
var a *ButtonMap
|
||||||
|
for key, foo := range Data.AllButtons {
|
||||||
|
log.Println("defaultButtonClick() Data.AllButtons =", key, foo)
|
||||||
|
// if Data.AllButtons[key] == *button {
|
||||||
|
if &foo == button {
|
||||||
|
a = &foo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return a
|
||||||
|
}
|
||||||
|
|
||||||
func makeSplashArea() *AreaHandler {
|
func makeSplashArea() *AreaHandler {
|
||||||
// make this button just to get the default font (but don't display the button)
|
// make this button just to get the default font (but don't display the button)
|
||||||
// There should be another way to do this (?)
|
// There should be another way to do this (?)
|
||||||
Data.fontButton = CreateFontButton("SplashFont", "DONE")
|
newB := CreateFontButton("AREA")
|
||||||
|
|
||||||
|
time.Sleep(200 * time.Millisecond)
|
||||||
|
tmp := findFB(newB)
|
||||||
|
log.Println("makeSplashArea() newB =", newB)
|
||||||
|
log.Println("makeSplashArea() newB.AH =", newB.AH)
|
||||||
|
log.Println("makeSplashArea() newB =", newB)
|
||||||
|
newB.AH = &myAH
|
||||||
|
// log.Println("makeSplashArea() newB.AH =", newB.AH)
|
||||||
|
log.Println("makeSplashArea() newB =", newB)
|
||||||
|
|
||||||
|
time.Sleep(200 * time.Millisecond)
|
||||||
|
tmp = findFB(newB)
|
||||||
|
log.Println("makeSplashArea() tmp =", tmp, "newB", newB)
|
||||||
|
|
||||||
myAH.Attrstr = makeAttributedString()
|
myAH.Attrstr = makeAttributedString()
|
||||||
Data.splashArea = ui.NewArea(myAH)
|
myAH.Area = ui.NewArea(myAH)
|
||||||
Data.MyArea = Data.splashArea
|
newB.A = myAH.Area
|
||||||
myAH.Area = Data.splashArea
|
myAH.FontButton = newB.FB
|
||||||
|
myAH.Button = newB
|
||||||
// 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
|
|
||||||
Data.AllButtons = append(Data.AllButtons, newmap)
|
|
||||||
|
|
||||||
if (Data.Debug) {
|
if (Data.Debug) {
|
||||||
spew.Dump(Data.splashArea)
|
spew.Dump(myAH.Area)
|
||||||
log.Println("DEBUGGING", Data.Debug)
|
log.Println("DEBUGGING", Data.Debug)
|
||||||
} else {
|
} else {
|
||||||
log.Println("NOT DEBUGGING AREA mhAH.Button =", myAH.Button)
|
log.Println("NOT DEBUGGING AREA mhAH.Button =", myAH.Button)
|
||||||
|
@ -45,8 +64,8 @@ func appendWithAttributes(newText *ui.AttributedString, what string, attrs ...ui
|
||||||
|
|
||||||
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{
|
tl := ui.DrawNewTextLayout(&ui.DrawTextLayoutParams{
|
||||||
String: myAH.Attrstr,
|
String: ah.Attrstr,
|
||||||
DefaultFont: Data.fontButton.Font(),
|
DefaultFont: ah.FontButton.Font(),
|
||||||
Width: p.AreaWidth,
|
Width: p.AreaWidth,
|
||||||
Align: ui.DrawTextAlign(1),
|
Align: ui.DrawTextAlign(1),
|
||||||
})
|
})
|
||||||
|
@ -66,7 +85,7 @@ 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")
|
log.Println("GOT MOUSE UP")
|
||||||
log.Println("GOT MOUSE UP")
|
log.Println("GOT MOUSE UP")
|
||||||
mouseClick(myAH.Button)
|
mouseClick(ah.Button)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
14
gui.go
14
gui.go
|
@ -225,17 +225,17 @@ func CreateButton(a *pb.Account, vm *pb.Event_VM,
|
||||||
return newB
|
return newB
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateFontButton(action string, note string) *ui.FontButton {
|
func CreateFontButton(action string) *ButtonMap {
|
||||||
newB := ui.NewFontButton()
|
newB := ui.NewFontButton()
|
||||||
|
|
||||||
// create a 'fake' button entry for the mouse clicks
|
// create a 'fake' button entry for the mouse clicks
|
||||||
var newButtonMap ButtonMap
|
var newBM ButtonMap
|
||||||
newButtonMap.Action = action
|
newBM.Action = action
|
||||||
newButtonMap.FB = newB
|
newBM.FB = newB
|
||||||
Data.AllButtons = append(Data.AllButtons, newButtonMap)
|
Data.AllButtons = append(Data.AllButtons, newBM)
|
||||||
|
|
||||||
newB.OnChanged(func (*ui.FontButton) {
|
newB.OnChanged(func (*ui.FontButton) {
|
||||||
mouseClick(&newButtonMap)
|
mouseClick(&newBM)
|
||||||
})
|
})
|
||||||
return newB
|
return &newBM
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,15 +63,10 @@ type GuiDataStructure struct {
|
||||||
cloudBox *ui.Box
|
cloudBox *ui.Box
|
||||||
smallBox *ui.Box
|
smallBox *ui.Box
|
||||||
|
|
||||||
// mainwin *ui.Window
|
|
||||||
// maintab *ui.Tab
|
|
||||||
tabcount int
|
tabcount int
|
||||||
|
|
||||||
// stuff for the 'area'
|
// stuff for the 'area'
|
||||||
MyArea *ui.Area
|
// fontButton *ui.FontButton
|
||||||
fontButton *ui.FontButton
|
|
||||||
attrstr *ui.AttributedString
|
|
||||||
splashArea *ui.Area
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type TableColumnData struct {
|
type TableColumnData struct {
|
||||||
|
@ -123,6 +118,8 @@ type AreaHandler struct{
|
||||||
Button *ButtonMap
|
Button *ButtonMap
|
||||||
Attrstr *ui.AttributedString
|
Attrstr *ui.AttributedString
|
||||||
Area *ui.Area
|
Area *ui.Area
|
||||||
|
FontButton *ui.FontButton
|
||||||
|
FB func () *ButtonMap
|
||||||
}
|
}
|
||||||
// AREA STRUCTURES END
|
// AREA STRUCTURES END
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue