summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-02-23 18:55:55 -0600
committerJeff Carr <[email protected]>2025-02-23 18:55:55 -0600
commit2d83d9ca7912ac6b8a3b01ef15aff5fc8dc4812f (patch)
tree0f236ca2b8b33f9cc6314f53001a0f442c5299a1
parent2856d88b1254f51770f94d903396ca45f5389e41 (diff)
switch to GenericWindow
-rw-r--r--doGui.go2
-rw-r--r--windowGeneric.go87
-rw-r--r--windowHowto.go12
3 files changed, 58 insertions, 43 deletions
diff --git a/doGui.go b/doGui.go
index 203b555..1a4d043 100644
--- a/doGui.go
+++ b/doGui.go
@@ -98,7 +98,7 @@ func drawWindow(win *gadgets.BasicWindow) {
// me.autoWorkingPwd = gadgets.NewOneLiner(grid, "working directory (pwd)")
me.goSrcPwd = gadgets.NewOneLiner(grid, "repo src home")
grid.NewLabel("")
- var howtoWin *genericWindow
+ var howtoWin *GenericWindow
me.demoB = grid.NewButton("Howto", func() {
if howtoWin != nil {
howtoWin.Toggle()
diff --git a/windowGeneric.go b/windowGeneric.go
index 7daae01..a487574 100644
--- a/windowGeneric.go
+++ b/windowGeneric.go
@@ -3,6 +3,9 @@
package main
+// This model works for 99.9% of all windows
+// This is the Default Standard Window Model
+
import (
"go.wit.com/lib/gadgets"
"go.wit.com/log"
@@ -10,82 +13,94 @@ import (
"go.wit.com/gui"
)
-type genericWindow struct {
- win *gadgets.BasicWindow // the window widget itself
- box *gui.Node // the top box of the repolist window
- group *gui.Node // the default group
+type GenericWindow struct {
+ Win *gadgets.BasicWindow // the window widget itself
+ Shelf *gui.Node // the overall box: the shelf
+ Stack *gui.Node // the first box is a stack
+ Top *gui.Node // the first item in the stack is always a shelf like box
+ Group *gui.Node // the first item top box is always a group
+ Middle *gui.Node // the middle box (shelf style)
+ Bottom *gui.Node // the bottom box (stack style)
}
-func (r *genericWindow) Hidden() bool {
- if r == nil {
+func (gw *GenericWindow) Hidden() bool {
+ if gw == nil {
return true
}
- if r.win == nil {
+ if gw.Win == nil {
return true
}
- return r.win.Hidden()
+ return gw.Win.Hidden()
}
-func (r *genericWindow) Toggle() {
- if r.Hidden() {
- r.Show()
+func (gw *GenericWindow) Toggle() {
+ if gw.Hidden() {
+ gw.Show()
} else {
- r.Hide()
+ gw.Hide()
}
}
-func (r *genericWindow) Show() {
- if r == nil {
+func (gw *GenericWindow) Show() {
+ if gw == nil {
return
}
- if r.win == nil {
+ if gw.Win == nil {
return
}
- r.win.Show()
+ gw.Win.Show()
}
-func (r *genericWindow) Hide() {
- if r == nil {
+func (gw *GenericWindow) Hide() {
+ if gw == nil {
return
}
- if r.win == nil {
+ if gw.Win == nil {
return
}
- r.win.Hide()
+ gw.Win.Hide()
}
-func (r *genericWindow) Disable() {
- if r == nil {
+func (gw *GenericWindow) Disable() {
+ if gw == nil {
return
}
- if r.box == nil {
+ if gw.Shelf == nil {
return
}
- r.box.Disable()
+ gw.Shelf.Disable()
}
-func (r *genericWindow) Enable() {
- if r == nil {
+func (gw *GenericWindow) Enable() {
+ if gw == nil {
return
}
- if r.box == nil {
+ if gw.Shelf == nil {
return
}
- r.box.Enable()
+ gw.Shelf.Enable()
}
-func initGenericWindow(title string, grouptxt string) *genericWindow {
- gw := new(genericWindow)
- gw.win = gadgets.RawBasicWindow(title)
- gw.win.Make()
+func NewGenericWindow(title string, grouptxt string) *GenericWindow {
+ gw := new(GenericWindow)
+ gw.Win = gadgets.RawBasicWindow(title)
+ gw.Win.Make()
- gw.box = gw.win.Box().Vertical() // a vertical box (like a stack of books)
- gw.win.Custom = func() {
+ gw.Win.Custom = func() {
log.Warn("Found Window close. setting hidden=true")
// sets the hidden flag to false so Toggle() works
- gw.win.Hide()
+ gw.Win.Hide()
}
- gw.group = gw.box.NewGroup(grouptxt)
+ gw.Shelf = gw.Win.Box()
+ // gw.Shelf.Vertical().SetProgName("ShelfBox")
+ gw.Stack = gw.Shelf.NewVerticalBox("Stackbox")
+
+ gw.Top = gw.Stack.NewVerticalBox("Stackbox")
+ gw.Middle = gw.Stack.Box()
+ gw.Bottom = gw.Stack.Box()
+
+ gw.Group = gw.Top.NewGroup(grouptxt)
+
gw.Show()
return gw
diff --git a/windowHowto.go b/windowHowto.go
index bc27078..4d61f93 100644
--- a/windowHowto.go
+++ b/windowHowto.go
@@ -13,14 +13,14 @@ import (
"go.wit.com/log"
)
-func makeHowtoWin() *genericWindow {
- howtoWin := initGenericWindow("Howto", "forge -- a GUI tool for git repostories")
+func makeHowtoWin() *GenericWindow {
+ howtoWin := NewGenericWindow("Howto", "forge -- a GUI tool for git repostories")
tmp := `A good way to see how forge works is to download forge
This will 'git clone' a few things (~50 repos):
`
- howtoWin.group.NewLabel(tmp)
- grid := howtoWin.group.RawGrid()
+ howtoWin.Group.NewLabel(tmp)
+ grid := howtoWin.Group.RawGrid()
grid.NewLabel("forge")
grid.NewLabel("the sources for forge")
grid.NextRow()
@@ -40,8 +40,8 @@ func makeHowtoWin() *genericWindow {
grid.NewLabel("") // a stupid way to add padding
grid.NextRow()
- howtoWin.group.NewLabel("Working dir: " + me.forge.GetGoSrc())
- grid = howtoWin.group.RawGrid()
+ howtoWin.Group.NewLabel("Working dir: " + me.forge.GetGoSrc())
+ grid = howtoWin.Group.RawGrid()
grid.NewButton("Download", func() {
howtoWin.Disable()
defer howtoWin.Enable()