summaryrefslogtreecommitdiff
path: root/README.md
blob: 7d09bd46d32bfd84223c0dfcd26cbc4aa700261d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# gui

Package gui implements a abstraction layer for Go visual elements.

## Hello World Example

```go
// This creates a simple hello world window
package main

import 	(
	"log"
	"go.wit.com/gui"
)

var myGui *gui.Node // This is your gui object

func main() {
	myGui = gui.New().Default()

    helloworld()

    // go will sit here until the window exits
    // intermittently, it will show toolkit statistics
    gui.Watchdog()
}

// This initializes the first window and 2 tabs
func helloworld() {
	window := myGui.NewWindow()

	group := window.NewGroup("a group of widgets")
	group.NewButton("hello", func() {
		log.Println("world")
	})
}
```

## Build

This will build the simple hello world example above.

```go
go install go.wit.com/apps/helloworld@latest
```

A more extensive list of applications can be found on [go.wit.com](https://go.wit.com).

### Build Toolkit Plugins

This is an example of how to build the console based
toolkit plugin built against the gocui package.

```go
GO111MODULE=off go get go.wit.com/toolkits/gocui
cd ~/go/src/go.wit.com/toolkits/gocui
go build -v -buildmode=plugin -o ~/go/lib/toolkits/gocui.so
```

## Toolkits

The toolkits are compiled as plugins and communicate only over a channel
to your application. This way, the toolkits are isolated and you don't
have to care about what the user uses to display things when you write
your application. Also, that allows the control panels to run in both
a traditional GUI like GTK or in the console like ncurses.

There are two working toolkits. One is written to the andlabs package
which provides a native linux, macos and windows. The second one is
terminal window based using gocui. (There is a 3rd one using STDIN/STDOUT
as a template to create new toolkit plugins.) Also, GO doesn't support
plugins on Windows so the native Windows GUI awaits someone to fix that.

* andlabs - [github](https://github.com/andlabs/ui)
* gocui - [github](https://github.com/awesome-gocui/gocui)

The next step is to allow this to work against go-gtk and go-qt.

Others potential plugins: Fyne, WASM, native macos & windows, android and
hopefully also things like libSDL, faiface/pixel, slint

## General Thoughts

A primary design purpose for this toolkit is to be able to develop a
modern set of control panels for linux. Specifically a DNS and IPv6
control panel. Since the toolkit interface plugins are cross platform,
these control panels should be able to run on the Macos and Windows also.

Definitions:

```go
* Toolkit: the underlying GUI library (MacOS gui, Windows gui, gtk, qt, etc)
* Node: A binary tree of all the underlying widgets
```

Principles:

```go
* Make code using this package simple to use
* Hide complexity internally here
* Isolate the GUI toolkit
* Widget names should try to match [Wikipedia Graphical widget]
* When in doubt, search upward in the binary tree
* It's ok to guess. Try to do something sensible.
```

## Bugs

"The author's idea of friendly may differ to that of many other people."

-- quote from the minimalistic window manager 'evilwm'

## References

Useful links and other
external things which might be useful

* [A History of the GUI](https://arstechnica.com/features/2005/05/gui/)
* [Wikipedia Graphical widget](https://en.wikipedia.org/wiki/Graphical_widget)
* [Federated git pull](https://github.com/forgefed/forgefed)
* [GO Style Guide](https://google.github.io/styleguide/go/index)