2019-05-24 13:32:47 -05:00
|
|
|
package gui
|
|
|
|
|
|
|
|
import "image/color"
|
2019-05-29 17:46:21 -05:00
|
|
|
import "golang.org/x/image/font"
|
2019-05-24 13:32:47 -05:00
|
|
|
|
|
|
|
import "github.com/andlabs/ui"
|
|
|
|
import _ "github.com/andlabs/ui/winmanifest"
|
|
|
|
|
|
|
|
import pb "git.wit.com/wit/witProtobuf"
|
|
|
|
|
|
|
|
//
|
|
|
|
// All GUI Data Structures and functions that are external
|
|
|
|
// If you need cross platform support, these might only
|
|
|
|
// be the safe way to interact with the GUI
|
|
|
|
//
|
2019-05-30 00:24:41 -05:00
|
|
|
var Data GuiData
|
2019-05-24 13:32:47 -05:00
|
|
|
|
2019-05-30 00:24:41 -05:00
|
|
|
type GuiData struct {
|
2019-05-24 13:32:47 -05:00
|
|
|
State string
|
2019-05-30 02:51:59 -05:00
|
|
|
// Width int
|
|
|
|
// Height int
|
2019-05-24 13:32:47 -05:00
|
|
|
|
|
|
|
// a fallback default function to handle mouse events
|
|
|
|
// if nothing else is defined to handle them
|
2019-05-30 10:55:54 -05:00
|
|
|
MouseClick func(*GuiButton)
|
2019-05-24 13:32:47 -05:00
|
|
|
|
2019-05-27 18:27:43 -05:00
|
|
|
// account entry textboxes
|
|
|
|
Config *pb.Config
|
|
|
|
|
|
|
|
// general information on the App
|
2019-05-24 13:32:47 -05:00
|
|
|
Version string
|
|
|
|
GitCommit string
|
|
|
|
GoVersion string
|
|
|
|
Buildtime string
|
|
|
|
HomeDir string
|
|
|
|
Debug bool
|
|
|
|
DebugTable bool
|
|
|
|
|
|
|
|
// official hostname and IPv6 address for this box
|
|
|
|
Hostname string
|
|
|
|
IPv6 string
|
|
|
|
|
|
|
|
// A map of all buttons everywhere on all
|
|
|
|
// windows, all tabs, across all goroutines
|
|
|
|
// This is "GLOBAL"
|
2019-05-30 10:55:54 -05:00
|
|
|
AllButtons []GuiButton
|
2019-05-30 11:19:49 -05:00
|
|
|
ButtonMap map[*GuiButton][]func (*GuiButton)
|
2019-05-24 13:32:47 -05:00
|
|
|
|
2019-05-27 18:27:43 -05:00
|
|
|
// A map of all the entry boxes
|
2019-05-30 10:52:28 -05:00
|
|
|
AllEntries []*GuiEntry
|
2019-05-27 18:27:43 -05:00
|
|
|
|
2019-05-30 10:52:28 -05:00
|
|
|
Windows []*GuiWindow
|
2019-05-29 14:21:10 -05:00
|
|
|
|
2019-05-27 12:55:10 -05:00
|
|
|
EntryNick *ui.Entry
|
|
|
|
EntryUser *ui.Entry
|
|
|
|
EntryPass *ui.Entry
|
2019-05-24 13:32:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
type TableColumnData struct {
|
|
|
|
Index int
|
|
|
|
CellType string
|
|
|
|
Heading string
|
|
|
|
Color string
|
|
|
|
}
|
|
|
|
|
2019-05-30 10:52:28 -05:00
|
|
|
type GuiEntry struct {
|
2019-05-27 18:27:43 -05:00
|
|
|
E *ui.Entry
|
|
|
|
Edit bool
|
2019-05-27 19:23:19 -05:00
|
|
|
Last string // the last value
|
|
|
|
Normalize func (string) string // function to 'normalize' the data
|
2019-05-27 18:27:43 -05:00
|
|
|
|
|
|
|
Account *pb.Account
|
|
|
|
VM *pb.Event_VM
|
|
|
|
|
2019-05-30 10:55:54 -05:00
|
|
|
B *GuiButton
|
2019-05-27 18:27:43 -05:00
|
|
|
FB *ui.FontButton
|
|
|
|
A *ui.Area
|
|
|
|
W *ui.Window
|
|
|
|
T *ui.Tab
|
|
|
|
|
|
|
|
Action string // what type of button
|
|
|
|
}
|
|
|
|
|
2019-05-30 11:19:49 -05:00
|
|
|
type GuiBox struct {
|
|
|
|
EntryMap map[string][]*GuiEntry
|
|
|
|
AH *GuiArea
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2019-05-30 10:52:28 -05:00
|
|
|
type GuiWindow struct {
|
2019-05-29 13:48:32 -05:00
|
|
|
W *ui.Window
|
|
|
|
T *ui.Tab
|
2019-05-29 15:11:08 -05:00
|
|
|
Box1 *ui.Box
|
|
|
|
Box2 *ui.Box
|
2019-05-29 13:48:32 -05:00
|
|
|
|
2019-05-29 21:57:15 -05:00
|
|
|
C *pb.Config
|
|
|
|
|
2019-05-30 11:19:49 -05:00
|
|
|
AH *GuiArea
|
2019-05-29 21:57:15 -05:00
|
|
|
Action string
|
2019-05-29 17:46:21 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
type FontString struct {
|
|
|
|
S string
|
|
|
|
Size int
|
|
|
|
F font.Face
|
|
|
|
W font.Weight
|
2019-05-29 13:48:32 -05:00
|
|
|
}
|
|
|
|
|
2019-05-30 10:55:54 -05:00
|
|
|
type GuiButton struct {
|
2019-05-29 21:57:15 -05:00
|
|
|
// andlabs/ui stuff
|
2019-05-24 13:32:47 -05:00
|
|
|
B *ui.Button
|
|
|
|
FB *ui.FontButton
|
2019-05-26 00:07:37 -05:00
|
|
|
A *ui.Area
|
2019-05-26 17:03:20 -05:00
|
|
|
W *ui.Window
|
2019-05-26 19:28:34 -05:00
|
|
|
T *ui.Tab
|
2019-05-26 17:03:20 -05:00
|
|
|
|
2019-05-30 11:19:49 -05:00
|
|
|
AH *GuiArea
|
2019-05-29 21:57:15 -05:00
|
|
|
|
|
|
|
// git.wit.com/wit/gui stuff
|
2019-05-30 10:52:28 -05:00
|
|
|
WM *GuiWindow
|
2019-05-25 04:50:43 -05:00
|
|
|
Account *pb.Account
|
2019-05-24 22:54:09 -05:00
|
|
|
VM *pb.Event_VM
|
2019-05-24 21:45:03 -05:00
|
|
|
Action string // what type of button
|
2019-05-24 21:29:08 -05:00
|
|
|
|
2019-05-29 21:57:15 -05:00
|
|
|
// a callback function for the main application
|
2019-05-30 10:55:54 -05:00
|
|
|
custom func (*GuiButton)
|
2019-05-24 13:32:47 -05:00
|
|
|
}
|
|
|
|
|
2019-05-26 00:07:37 -05:00
|
|
|
|
|
|
|
// AREA STRUCTURES START
|
2019-05-30 11:19:49 -05:00
|
|
|
type GuiArea struct{
|
2019-05-30 10:55:54 -05:00
|
|
|
Button *GuiButton
|
2019-05-29 09:24:40 -05:00
|
|
|
Attrstr *ui.AttributedString
|
|
|
|
Area *ui.Area
|
2019-05-30 10:52:28 -05:00
|
|
|
WM *GuiWindow
|
2019-05-26 00:07:37 -05:00
|
|
|
}
|
|
|
|
// AREA STRUCTURES END
|
|
|
|
|
2019-05-24 13:32:47 -05:00
|
|
|
//
|
|
|
|
// TABLE DATA STRUCTURES START
|
|
|
|
//
|
|
|
|
|
|
|
|
type CellData struct {
|
|
|
|
Index int
|
|
|
|
HumanID int
|
|
|
|
Name string // what type of cell is this?
|
|
|
|
}
|
|
|
|
|
|
|
|
// hmm. will this stand the test of time?
|
|
|
|
type RowData struct {
|
|
|
|
Name string // what kind of row is this?
|
|
|
|
Status string // status of the row?
|
|
|
|
/*
|
2019-05-24 21:45:03 -05:00
|
|
|
// TODO: These may or may not be implementable
|
2019-05-24 13:32:47 -05:00
|
|
|
click func() // what function to call if the user clicks on it
|
|
|
|
doubleclick func() // what function to call if the user double clicks on it
|
|
|
|
*/
|
|
|
|
HumanData [20]HumanCellData
|
|
|
|
|
|
|
|
// The VM from the protobuf
|
2019-05-24 22:54:09 -05:00
|
|
|
VM *pb.Event_VM
|
2019-05-24 13:32:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// 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
|
2019-05-26 16:47:30 -05:00
|
|
|
VM *pb.Event_VM
|
2019-05-30 10:55:54 -05:00
|
|
|
Button *GuiButton
|
2019-05-24 13:32:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
|
2019-05-25 04:50:43 -05:00
|
|
|
Account *pb.Account // what account this table is for
|
2019-05-24 22:54:09 -05:00
|
|
|
|
2019-05-24 13:32:47 -05:00
|
|
|
lastRow int
|
|
|
|
lastColumn int
|
2019-05-24 14:51:04 -05:00
|
|
|
parentTab *ui.Tab
|
2019-05-24 13:32:47 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// TABLE DATA STRUCTURES END
|
|
|
|
//
|