diff --git a/area.go b/area.go index 7e93a77..ccc7877 100644 --- a/area.go +++ b/area.go @@ -25,16 +25,16 @@ func makeSplashArea(wm *GuiWindow, ah *GuiArea) { // There should be another way to do this (?) newB := CreateFontButton(wm, "AREA") - // ah.Attrstr = makeAttributedString() - ah.Area = ui.NewArea(ah) - newB.A = ah.Area + // ah.UiAttrstr = makeAttributedString() + ah.UiArea = ui.NewArea(ah) + newB.A = ah.UiArea newB.WM = wm - // Data.AllButtons[1].A = ah.Area + // Data.AllButtons[1].A = ah.UiArea // ah.Button = &Data.AllButtons[1] ah.Button = newB if (Data.Debug) { - spew.Dump(ah.Area) + spew.Dump(ah.UiArea) log.Println("DEBUGGING", Data.Debug) } else { log.Println("NOT DEBUGGING AREA mhAH.Button =", ah.Button) @@ -61,7 +61,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.Attrstr, + String: ah.UiAttrstr, DefaultFont: ah.Button.FB.Font(), Width: p.AreaWidth, Align: ui.DrawTextAlign(1), diff --git a/splash.go b/splash.go index 07ae6da..da2f8f4 100644 --- a/splash.go +++ b/splash.go @@ -25,10 +25,10 @@ func ShowSplashBox(wm *GuiWindow, newText *ui.AttributedString) *ui.Box { // initialize the GuiArea{} wm.AH = new(GuiArea) wm.AH.WM = wm - wm.AH.Attrstr = newText + wm.AH.UiAttrstr = newText makeSplashArea(wm, wm.AH) - newbox.Append(wm.AH.Area, true) + newbox.Append(wm.AH.UiArea, true) if runtime.GOOS == "linux" { newbox.Append(ui.NewLabel("OS: Linux"), false) diff --git a/structs.go b/structs.go index 0476f6c..b857b1d 100644 --- a/structs.go +++ b/structs.go @@ -16,9 +16,7 @@ import pb "git.wit.com/wit/witProtobuf" var Data GuiData type GuiData struct { - State string - // Width int - // Height int + State string // used like a state machine // a fallback default function to handle mouse events // if nothing else is defined to handle them @@ -56,11 +54,28 @@ type GuiData struct { EntryPass *ui.Entry } -type TableColumnData struct { - Index int - CellType string - Heading string - Color string +// Note: every mouse click is handled +// as a 'Button' regardless of where +// the user clicks it. You could probably +// call this 'GuiMouseClick' +type GuiButton struct { + // andlabs/ui stuff + B *ui.Button + FB *ui.FontButton + A *ui.Area + W *ui.Window + T *ui.Tab + + AH *GuiArea + + // git.wit.com/wit/gui stuff + WM *GuiWindow + Account *pb.Account + VM *pb.Event_VM + Action string // what type of button + + // a callback function for the main application + custom func (*GuiButton) } type GuiEntry struct { @@ -82,9 +97,9 @@ type GuiEntry struct { } type GuiBox struct { + W *GuiWindow EntryMap map[string][]*GuiEntry - AH *GuiArea - + A *GuiArea } type GuiWindow struct { @@ -99,47 +114,95 @@ type GuiWindow struct { Action string } +// +// AREA STRUCTURES START +// AREA STRUCTURES START +// AREA STRUCTURES START +// +type GuiArea struct{ + WM *GuiWindow + Button *GuiButton + + UiAttrstr *ui.AttributedString + UiArea *ui.Area +} + type FontString struct { S string Size int F font.Face W font.Weight } - -type GuiButton struct { - // andlabs/ui stuff - B *ui.Button - FB *ui.FontButton - A *ui.Area - W *ui.Window - T *ui.Tab - - AH *GuiArea - - // git.wit.com/wit/gui stuff - WM *GuiWindow - Account *pb.Account - VM *pb.Event_VM - Action string // what type of button - - // a callback function for the main application - custom func (*GuiButton) -} - - -// AREA STRUCTURES START -type GuiArea struct{ - Button *GuiButton - Attrstr *ui.AttributedString - Area *ui.Area - WM *GuiWindow -} +// // AREA STRUCTURES END +// AREA STRUCTURES END +// AREA STRUCTURES END +// // // TABLE DATA STRUCTURES START +// TABLE DATA STRUCTURES START +// TABLE DATA STRUCTURES START // +// +// This is the structure that andlabs/ui uses to pass information +// to the GUI. This is the "authoritative" data. +// +type TableData struct { + RowCount int // This is the number of 'rows' which really means data elements not what the human sees + RowWidth int // This is how wide each row is + Rows []RowData // This is all the table data by row + generatedColumnTypes []ui.TableValue // generate this dynamically + + Cells [20]CellData + Human [20]HumanMap + + Account *pb.Account // what account this table is for + + lastRow int + lastColumn int + parentTab *ui.Tab +} + +// +// This maps the andlabs/ui & libui components into a "human" +// readable cell reference list. The reason is that there +// are potentially 3 values for each cell. The Text, the Color +// and an image. These are not always needed so the number +// of fields varies between 1 and 3. Internally, the toolkit +// GUI abstraction needs to list all of them, but it's then +// hard to figure out which column goes with the columns that +// you see when you visually are looking at it like a spreadsheet +// +// This makes a map so that we can say "give me the value at +// row 4 and column 2" and find the fields that are needed +// +// TODO: re-add images and the progress bar (works in andlabs/ui) +// +type HumanCellData struct { + Name string // what kind of row is this? + Text string + TextID int + Color color.RGBA + ColorID int + VM *pb.Event_VM + Button *GuiButton +} + +type HumanMap struct { + Name string // what kind of row is this? + TextID int + ColorID int +} + +type TableColumnData struct { + Index int + CellType string + Heading string + Color string +} + type CellData struct { Index int HumanID int @@ -161,57 +224,6 @@ type RowData struct { VM *pb.Event_VM } -// -// This maps the andlabs/ui & libui components into a "human" -// readable cell reference list. The reason is that there -// are potentially 3 values for each cell. The Text, the Color -// and an image. These are not always needed so the number -// of fields varies between 1 and 3. Internally, the toolkit -// GUI abstraction needs to list all of them, but it's then -// hard to figure out which column goes with the columns that -// you see when you visually are looking at it like a spreadsheet -// -// This makes a map so that we can say "give me the value at -// row 4 and column 2" and find the fields that are needed -// -// TODO: add back image support and the progress bar -// -type HumanCellData struct { - Name string // what kind of row is this? - Text string - TextID int - Color color.RGBA - ColorID int - VM *pb.Event_VM - Button *GuiButton -} - -type HumanMap struct { - Name string // what kind of row is this? - TextID int - ColorID int -} - -// -// This is the structure that andlabs/ui uses to pass information -// to the GUI. This is the "authoritative" data. -// -type TableData struct { - RowCount int // This is the number of 'rows' which really means data elements not what the human sees - RowWidth int // This is how wide each row is - Rows []RowData // This is all the table data by row - generatedColumnTypes []ui.TableValue // generate this dynamically - - Cells [20]CellData - Human [20]HumanMap - - Account *pb.Account // what account this table is for - - lastRow int - lastColumn int - parentTab *ui.Tab -} - // // TABLE DATA STRUCTURES END //