summaryrefslogtreecommitdiff
path: root/structs.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2022-10-08 23:22:47 -0500
committerJeff Carr <[email protected]>2022-10-08 23:22:47 -0500
commit086986b6b8f55d15d18595bcbf3f76c023365b61 (patch)
tree9f1dc4da5b2d125f7a017418d4d9912e16b71039 /structs.go
parentf92a50e2e665a18e2201f1d6714025dcc39301cc (diff)
parent45644ef9bc333f5def62d1c7f474dc96274e63fa (diff)
Merge branch 'master' into jcarr
Diffstat (limited to 'structs.go')
-rw-r--r--structs.go230
1 files changed, 81 insertions, 149 deletions
diff --git a/structs.go b/structs.go
index aae0b7f..79b3fbf 100644
--- a/structs.go
+++ b/structs.go
@@ -1,153 +1,85 @@
package gui
-import "image/color"
-import "golang.org/x/image/font"
+import (
+ "image/color"
+// "log"
-import "github.com/andlabs/ui"
-import _ "github.com/andlabs/ui/winmanifest"
+ "github.com/andlabs/ui"
+ "golang.org/x/image/font"
+
+ _ "github.com/andlabs/ui/winmanifest"
+)
//
// 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
//
-var Data GuiData
-var Config GuiConfig
+var Data GuiData
+var Config GuiConfig
type GuiConfig struct {
- Width int
- Height int
- Debug bool
- DebugTable bool
+ Title string
+ Width int
+ Height int
+ Stretchy bool
+ Menu bool
+ Exit func(*Node)
+
+ Debug bool
+ DebugNode bool
+ DebugTabs bool
+ DebugTable bool
+ DebugWindow bool
+
+ depth int
+ counter int // used to make unique ID's
+ prefix string
}
type GuiData struct {
- // a fallback default function to handle mouse events
+ // a fallback default function to handle mouse events
// if nothing else is defined to handle them
- MouseClick func(*GuiButton)
+ MouseClick func(*Node)
// A map of all the entry boxes
- AllEntries []*GuiEntry
- Windows []*GuiWindow
- WindowMap map[string]*GuiWindow
-
- // A map of all buttons everywhere on all
- // windows, all tabs, across all goroutines
- // This is "GLOBAL"
- //
- // This has to work this way because of how
- // andlabs/ui & andlabs/libui work
- AllButtons []*GuiButton
- buttonMap map[*ui.Button]*GuiButton
-}
-
-//
-// stores information on the 'window'
-//
-// This merges the concept of andlabs/ui *Window and *Tab
-//
-// More than one Window is not supported in a cross platform
-// sense & may never be. On Windows and MacOS, you have to have
-// 'tabs'. Even under Linux, more than one Window is currently
-// unstable
-//
-// This code will make a 'GuiWindow' regardless of if it is
-// a stand alone window (which is more or less working on Linux)
-// or a 'tab' inside a window (which is all that works on MacOS
-// and MSWindows.
-//
-// This struct keeps track of what is in the window so you
-// can destroy and replace it with something else
-//
-type GuiWindow struct {
- Name string // field for human readable name
- Width int
- Height int
-
- // the callback function to make the window contents
- MakeWindow func(*GuiWindow) *GuiBox
-
- // the components of the window
- BoxMap map[string]*GuiBox
- EntryMap map[string]*GuiEntry
- Area *GuiArea
-
- // andlabs/ui abstraction mapping
- UiWindow *ui.Window
- UiTab *ui.Tab // if this != nil, the window is 'tabbed'
-}
+ AllEntries []*GuiEntry
-// GuiBox is any type of ui.Hbox or ui.Vbox
-// There can be lots of these for each GuiWindow
-type GuiBox struct {
- Name string // field for human readable name
- Axis int // does it add items to the X or Y axis
- Window *GuiWindow // the parent Window
-
- // andlabs/ui abstraction mapping
- UiBox *ui.Box
-}
-
-// 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 {
- Name string // field for human readable name
- Box *GuiBox // what box the button click was in
-
- // a callback function for the main application
- Custom func (*GuiButton)
- Values interface {}
-
- // andlabs/ui abstraction mapping
- B *ui.Button
- FB *ui.FontButton
+ // Store access to everything via binary tree's
+ NodeMap map[string]*Node
+ NodeArray []*Node
+ NodeSlice []*Node
}
// text entry fields
type GuiEntry struct {
- Name string // field for human readable name
- Edit bool
- Last string // the last value
- Normalize func (string) string // function to 'normalize' the data
+ Name string // field for human readable name
+ Edit bool
+ Last string // the last value
+ Normalize func(string) string // function to 'normalize' the data
- B *GuiButton
- Box *GuiBox
+ N *Node
// andlabs/ui abstraction mapping
- UiEntry *ui.Entry
+ UiEntry *ui.Entry
}
-//
-// AREA STRUCTURES START
-// AREA STRUCTURES START
-// AREA STRUCTURES START
-//
-type GuiArea struct{
- Button *GuiButton // what button handles mouse events
- Box *GuiBox
+type GuiArea struct {
+ N *Node // what node to pass mouse events
- UiAttrstr *ui.AttributedString
- UiArea *ui.Area
+ UiAttrstr *ui.AttributedString
+ UiArea *ui.Area
}
type FontString struct {
- S string
- Size int
- F font.Face
- W font.Weight
+ S string
+ Size int
+ F font.Face
+ W font.Weight
}
-//
-// AREA STRUCTURES END
-// AREA STRUCTURES END
-// AREA STRUCTURES END
-//
//
// TABLE DATA STRUCTURES START
-// TABLE DATA STRUCTURES START
-// TABLE DATA STRUCTURES START
//
//
@@ -155,18 +87,18 @@ type FontString struct {
// 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
+ 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
+ Cells [20]CellData
+ Human [20]HumanMap
- Box *GuiBox
+ n *Node
- lastRow int
- lastColumn int
+ lastRow int
+ lastColumn int
}
//
@@ -185,44 +117,44 @@ type TableData struct {
// 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
- Button *GuiButton
+ Name string // what kind of row is this?
+ Text string
+ TextID int
+ Color color.RGBA
+ ColorID int
+ N *Node
}
type HumanMap struct {
- Name string // what kind of row is this?
- TextID int
- ColorID int
+ Name string // what kind of row is this?
+ TextID int
+ ColorID int
}
type TableColumnData struct {
- Index int
- CellType string
- Heading string
- Color string
+ Index int
+ CellType string
+ Heading string
+ Color string
}
type CellData struct {
- Index int
- HumanID int
- Name string // what type of cell is this?
+ 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?
-/*
- // TODO: These may or may not be implementable
- // depending on if it's possible to detect the bgcolor or what row is selected
- 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
+ Name string // what kind of row is this?
+ Status string // status of the row?
+ /*
+ // TODO: These may or may not be implementable
+ // depending on if it's possible to detect the bgcolor or what row is selected
+ 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
}
//