Tabs are Windows
Tabs don't exist. The are simply windows within a window. There are *lots* of problems with trying to treat everything that way. Luckily, we don't have to care. All the problems with handling that concept can be pushed to the toolkits/ therefore, this primitive code can be kept as clean as possible Makefile and git cleanups Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
166614d89d
commit
80d0f34bc0
74
Makefile
74
Makefile
|
@ -1,12 +1,9 @@
|
||||||
.PHONY: README.md log examples
|
all:
|
||||||
|
|
||||||
all: README.md
|
|
||||||
# reset
|
|
||||||
@echo
|
@echo
|
||||||
@echo "make examples # will run all the Example demos and commands"
|
@echo This is the core gui package 'go.wit.com/gui/gui'
|
||||||
@echo "make update # full git update of all the dependencies"
|
|
||||||
@echo
|
@echo
|
||||||
@echo This Requires working IPv6
|
@echo It creates a binary tree of widgets
|
||||||
|
@echo The widgets are things like Windows, Buttons, Labels, etc
|
||||||
@echo
|
@echo
|
||||||
ifeq ($(GO111MODULE),)
|
ifeq ($(GO111MODULE),)
|
||||||
@echo
|
@echo
|
||||||
|
@ -19,49 +16,21 @@ ifeq ($(GO111MODULE),)
|
||||||
@echo
|
@echo
|
||||||
@echo export GO111MODULE=off
|
@echo export GO111MODULE=off
|
||||||
@echo
|
@echo
|
||||||
sleep 3
|
|
||||||
endif
|
endif
|
||||||
ifeq (,$(wildcard go.mod))
|
|
||||||
go mod init gui
|
|
||||||
go mod tidy
|
|
||||||
endif
|
|
||||||
make clean
|
|
||||||
make plugins
|
|
||||||
make examples-buttons
|
|
||||||
|
|
||||||
build-dep:
|
redomod:
|
||||||
apt install -f libgtk-3-dev
|
rm -f go.*
|
||||||
|
go mod init
|
||||||
|
go mod tidy
|
||||||
|
|
||||||
# should update every go dependancy (?)
|
# should update every go dependancy (?)
|
||||||
update:
|
update:
|
||||||
git pull
|
git pull
|
||||||
go get -v -t -u ./...
|
go get -v -t -u ./...
|
||||||
|
|
||||||
examples: \
|
|
||||||
all \
|
|
||||||
examples-helloworld \
|
|
||||||
examples-buttons \
|
|
||||||
examples-console-ui-helloworld
|
|
||||||
|
|
||||||
# this is the most basic one. This syntax should always work
|
|
||||||
examples-helloworld:
|
|
||||||
make -C examples/helloworld
|
|
||||||
|
|
||||||
examples-buttons:
|
|
||||||
make -C examples/buttons
|
|
||||||
|
|
||||||
examples-console-ui-helloworld:
|
|
||||||
make -C examples/console-ui-helloworld
|
|
||||||
|
|
||||||
git.wit.org:
|
|
||||||
git push witgui master
|
|
||||||
git push witgui devel
|
|
||||||
git push witgui jcarr
|
|
||||||
git push witgui --tags
|
|
||||||
|
|
||||||
# sync repo to the github backup
|
# sync repo to the github backup
|
||||||
# git remote add github git@github.com:wit-go/gui.git
|
# git remote add github git@github.com:wit-go/gui.git
|
||||||
github: git.wit.org
|
github:
|
||||||
git push origin master
|
git push origin master
|
||||||
git push origin devel
|
git push origin devel
|
||||||
git push origin --tags
|
git push origin --tags
|
||||||
|
@ -69,35 +38,12 @@ github: git.wit.org
|
||||||
git push github devel
|
git push github devel
|
||||||
git push github --tags
|
git push github --tags
|
||||||
@echo
|
@echo
|
||||||
|
@echo check https://git.wit.org/gui/gui
|
||||||
@echo check https://github.com/wit-go/gui
|
@echo check https://github.com/wit-go/gui
|
||||||
@echo
|
@echo
|
||||||
|
|
||||||
doc:
|
doc:
|
||||||
godoc -v
|
godoc -v
|
||||||
|
|
||||||
goget:
|
|
||||||
go get -v -t -u
|
|
||||||
make -C toolkit/gocui goget
|
|
||||||
make -C toolkit/andlabs goget
|
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f toolkit/*.so
|
|
||||||
|
|
||||||
plugins: plugins-gocui plugins-andlabs
|
|
||||||
|
|
||||||
plugins-gocui:
|
|
||||||
go build -C toolkit/gocui -v -buildmode=plugin -o ../gocui.so
|
|
||||||
go build -C toolkit/nocui -v -buildmode=plugin -o ../nocui.so
|
|
||||||
|
|
||||||
plugins-andlabs:
|
|
||||||
go build -C toolkit/andlabs -v -buildmode=plugin -o ../andlabs.so
|
|
||||||
|
|
||||||
objdump:
|
|
||||||
objdump -t toolkit/andlabs.so |less
|
|
||||||
|
|
||||||
log:
|
|
||||||
reset
|
|
||||||
tail -f /tmp/witgui.* /tmp/guilogfile
|
|
||||||
|
|
||||||
submit-to-docs:
|
submit-to-docs:
|
||||||
GOPROXY=https://proxy.golang.org GO111MODULE=on go get go.wit.com/gui@v1.0.0
|
GOPROXY=https://proxy.golang.org GO111MODULE=on go get go.wit.com/gui@v1.0.0
|
||||||
|
|
14
doc.go
14
doc.go
|
@ -41,20 +41,16 @@ Hello World Example
|
||||||
|
|
||||||
// go will sit here until the window exits
|
// go will sit here until the window exits
|
||||||
func main() {
|
func main() {
|
||||||
myGui = gui.New()
|
myGui = gui.New().Default()
|
||||||
|
|
||||||
|
helloworld()
|
||||||
}
|
}
|
||||||
|
|
||||||
// This initializes the first window and 2 tabs
|
// This initializes the first window, a group and a button
|
||||||
func helloworld() {
|
func helloworld() {
|
||||||
window := myGui.NewWindow("hello world")
|
window := myGui.NewWindow("hello world")
|
||||||
addTab(window, "A Simple Tab Demo")
|
|
||||||
addTab(window, "A Second Tab")
|
|
||||||
}
|
|
||||||
|
|
||||||
func addTab(w *gui.Node, title string) {
|
group := window.NewGroup("foo bar")
|
||||||
tab := w.NewTab(title)
|
|
||||||
|
|
||||||
group := tab.NewGroup("foo bar")
|
|
||||||
group.NewButton("hello", func() {
|
group.NewButton("hello", func() {
|
||||||
log.Println("world")
|
log.Println("world")
|
||||||
})
|
})
|
||||||
|
|
|
@ -29,9 +29,6 @@ type guiConfig struct {
|
||||||
// This is the master node. The Binary Tree starts here
|
// This is the master node. The Binary Tree starts here
|
||||||
rootNode *Node
|
rootNode *Node
|
||||||
|
|
||||||
// if the user prefers new windows or 'windows within windows' tabs
|
|
||||||
makeTabs bool
|
|
||||||
|
|
||||||
// A node off of rootNode for passing debugging flags
|
// A node off of rootNode for passing debugging flags
|
||||||
flag *Node
|
flag *Node
|
||||||
|
|
||||||
|
|
42
tab.go
42
tab.go
|
@ -1,42 +0,0 @@
|
||||||
package gui
|
|
||||||
|
|
||||||
import (
|
|
||||||
"go.wit.com/log"
|
|
||||||
|
|
||||||
"go.wit.com/gui/toolkits"
|
|
||||||
)
|
|
||||||
|
|
||||||
// This function should make a new node with the parent and
|
|
||||||
// the 'tab' as a child
|
|
||||||
|
|
||||||
func (n *Node) NewTab(text string) *Node {
|
|
||||||
// check to make sure n is actually a window
|
|
||||||
|
|
||||||
if (n.WidgetType != toolkit.Window) {
|
|
||||||
// figure out what the actual window is
|
|
||||||
log.Warn("NewTab() is being requested on something that isn't a Window. node =", n)
|
|
||||||
if (n.parent == nil) {
|
|
||||||
// TODO: find a window. any window. never give up. never die.
|
|
||||||
log.Warn("NewTab() TODO: make a window here", n)
|
|
||||||
panic("NewTab did not get passed a window")
|
|
||||||
}
|
|
||||||
log.Warn("NewTab() parent =", n.parent)
|
|
||||||
if (n.parent.WidgetType == toolkit.Root) {
|
|
||||||
// also broken
|
|
||||||
log.Warn("NewTab() TODO: make or find a window here", n)
|
|
||||||
panic("NewTab() did not get passed a window")
|
|
||||||
}
|
|
||||||
// go up the binary tree until we find a window widget to add a tab too
|
|
||||||
return n.parent.NewTab(text)
|
|
||||||
}
|
|
||||||
newNode := n.newNode(text, toolkit.Tab)
|
|
||||||
|
|
||||||
a := newAction(newNode, toolkit.Add)
|
|
||||||
sendAction(a)
|
|
||||||
|
|
||||||
// by default, create a box inside the tab
|
|
||||||
// TODO: allow this to be configurable
|
|
||||||
newBox := newNode.NewBox(text + " box", true)
|
|
||||||
|
|
||||||
return newBox
|
|
||||||
}
|
|
Loading…
Reference in New Issue