diff options
Diffstat (limited to 'area.go')
| -rw-r--r-- | area.go | 58 |
1 files changed, 16 insertions, 42 deletions
@@ -7,28 +7,14 @@ import _ "github.com/andlabs/ui/winmanifest" import "github.com/davecgh/go-spew/spew" -func makeGenericArea(gb *GuiBox, newText *ui.AttributedString, custom func(*GuiButton)) { - // make this button just to get the default font (but don't display the button) - // There should be another way to do this (?) - var newB *GuiButton - newB = CreateFontButton(gb, "AREA") - newB.Box = gb - newB.Custom = custom - - gw := gb.Window - // initialize the GuiArea{} - gw.Area = new(GuiArea) - gw.Area.Button = newB - gw.Area.Box = gb - gw.Area.UiAttrstr = newText - gw.Area.UiArea = ui.NewArea(gw.Area) - - if (Config.Debug) { - spew.Dump(gw.Area.UiArea) - log.Println("DEBUGGING", Config.Debug) - } else { - log.Println("NOT DEBUGGING AREA mhAH.Button =", gw.Area.Button) - } +// make this button just to get the default font (but don't display the button) +// There should be another way to do this (?) +func (n *Node) makeGenericArea(newText *ui.AttributedString, custom func(*Node)) { + newNode := n.CreateFontButton("AREA") + newNode.custom = custom + area := new(GuiArea) + newNode.uiArea = ui.NewArea(area) + newNode.uiAttrstr = newText } func AreaAppendText(newText *ui.AttributedString, what string, attrs ...ui.Attribute) { @@ -52,7 +38,7 @@ func appendWithAttributes(newText *ui.AttributedString, what string, attrs ...ui func (ah GuiArea) Draw(a *ui.Area, p *ui.AreaDrawParams) { tl := ui.DrawNewTextLayout(&ui.DrawTextLayoutParams{ String: ah.UiAttrstr, - DefaultFont: ah.Button.FB.Font(), + DefaultFont: ah.N.uiFontButton.Font(), Width: p.AreaWidth, Align: ui.DrawTextAlign(1), }) @@ -61,6 +47,7 @@ func (ah GuiArea) Draw(a *ui.Area, p *ui.AreaDrawParams) { } func (ah GuiArea) MouseEvent(a *ui.Area, me *ui.AreaMouseEvent) { + /* if (Config.Debug) { log.Println("GOT MouseEvent() ah.Button =", ah.Button) spew.Dump(me) @@ -80,6 +67,7 @@ func (ah GuiArea) MouseEvent(a *ui.Area, me *ui.AreaMouseEvent) { Data.MouseClick(ah.Button) } } + */ } func (ah GuiArea) MouseCrossed(a *ui.Area, left bool) { @@ -107,28 +95,14 @@ func (ah GuiArea) KeyEvent(a *ui.Area, ke *ui.AreaKeyEvent) (handled bool) { return false } -func ShowTextBox(gw *GuiWindow, newText *ui.AttributedString, custom func(*GuiButton), name string) *GuiBox { +func (n *Node) ShowTextBox(newText *ui.AttributedString, custom func(*Node), name string) { log.Println("ShowTextBox() START") - if (gw == nil) { - log.Println("ShowTextBox() ERROR gw = nil") - return nil - } - log.Println("ShowTextBox() START gw =", gw) - - var newbox *GuiBox - newbox = new(GuiBox) - newbox.Window = gw - newbox.Name = name - hbox := ui.NewVerticalBox() - newbox.UiBox = hbox // TODO: allow padded & axis here - hbox.SetPadded(true) - - add(gw.BoxMap["MAINBOX"], newbox) + n.uiBox.SetPadded(true) - makeGenericArea(newbox, newText, custom) - newbox.UiBox.Append(newbox.Window.Area.UiArea, true) + // add(gw.BoxMap["MAINBOX"], newbox) - return newbox + n.makeGenericArea(newText, custom) + n.uiBox.Append(n.area.UiArea, true) } |
