Update example apps and documentation

master
Noah Petherbridge 2021-06-03 12:27:48 -07:00
parent b7190fe958
commit ff76b831ad
19 changed files with 74 additions and 28 deletions

View File

@ -27,6 +27,9 @@ requests are accepted on GitHub.
# Example
See the [eg/](https://git.kirsle.net/go/ui/src/branch/master/eg) directory
in this git repository for several example programs and screenshots.
```go
package main

View File

@ -1,10 +1,16 @@
# Examples for go/ui
* [Hello, World!](hello-world/): a basic UI demo.
* [Frame Place()](frame-place/): demonstrates using the Place() layout management
option for Frame widgets.]
Here are some example programs using go/ui, each accompanied by a
screenshot and description:
* [Hello, World!](hello-world/): a basic UI demo with a Label and a
Button.
* [Frame Place()](frame-place/): demonstrates using the Place() layout
management option for Frame widgets.
* [Window Manager](windows/): demonstrates the Window widget and window
management features of the Supervisor.
* [Tooltip](tooltip/): demonstrates the Tooltip widget on a variety of buttons
scattered around the window.
* [Menus](menus/): demonstrates various Menu Buttons and a Menu Bar.
* [Themes](themes/): a UI demo that shows off the Default, Flat, and Dark UI
themes as part of experimental theming support.

View File

@ -134,8 +134,9 @@ func CreateButtons(window *ui.MainWindow, parent *ui.Frame) {
}))
// When clicked, change the window title to ID this button.
button.Handle(ui.Click, func(ed ui.EventData) {
button.Handle(ui.Click, func(ed ui.EventData) error {
window.SetTitle(parent.Name + ": " + setting.Label)
return nil
})
parent.Place(button, setting.Place)

11
eg/hello-world/README.md Normal file
View File

@ -0,0 +1,11 @@
# Hello World
![Screenshot](screenshot.png)
A simple Hello World featuring a Label and a Button. The button logs
to the console window when clicked.
## Running It
From your terminal, just type `go run main.go` from this
example's directory.

View File

@ -44,8 +44,9 @@ func main() {
Padding: 4,
},
}))
button.Handle(ui.Click, func(ed ui.EventData) {
button.Handle(ui.Click, func(ed ui.EventData) error {
fmt.Println("I've been clicked!")
return nil
})
mw.Pack(button, ui.Pack{
Side: ui.N,

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

View File

@ -1,7 +0,0 @@
package layout
import "fmt"
func main() {
fmt.Println("Hello world")
}

View File

@ -1,12 +0,0 @@
package main
import (
"fmt"
"git.kirsle.net/go/ui/eg/layout"
)
func main() {
fmt.Println("Hello world")
layout.main()
}

View File

@ -1,5 +1,7 @@
# Menu Example
![Screenshot](screenshot.png)
This example shows off the Menu, MenuButton, and MenuBar widgets.
* MenuButton is your basic button that pops up a Menu when clicked.

BIN
eg/menus/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

13
eg/themes/README.md Normal file
View File

@ -0,0 +1,13 @@
# Themes Example
![Screenshot](screenshot.png)
This demo shows off experimental UI theme support.
The main menu bar lets you open a Window with widgets all using a
selected theme.
## Running It
From your terminal, just type `go run main.go` or `make run` from this
example's directory.

BIN
eg/themes/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

10
eg/tooltip/README.md Normal file
View File

@ -0,0 +1,10 @@
# Tooltips Demo
![Screenshot](screenshot.png)
A screen full of buttons having different Tooltip properties.
## Running It
From your terminal, just type `go run main.go` from this
example's directory.

View File

@ -132,8 +132,9 @@ func CreateButtons(window *ui.MainWindow, parent *ui.Frame) {
}))
// When clicked, change the window title to ID this button.
button.Handle(ui.Click, func(ed ui.EventData) {
button.Handle(ui.Click, func(ed ui.EventData) error {
window.SetTitle(parent.Name + ": " + setting.Label)
return nil
})
// Tooltip for it.

BIN
eg/tooltip/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

11
eg/windows/README.md Normal file
View File

@ -0,0 +1,11 @@
# Windows Demo
![Screenshot](screenshot.png)
This demo lets you open a bunch of Window widgets that can be moved
around, overlapped, and closed.
## Running It
From your terminal, just type `go run main.go` from this
example's directory.

BIN
eg/windows/screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

6
go.mod
View File

@ -2,8 +2,8 @@ module git.kirsle.net/go/ui
go 1.13
replace git.kirsle.net/go/render => /home/kirsle/go/src/git.kirsle.net/go/render
require (
git.kirsle.net/go/render v0.0.0-20200102014411-4d008b5c468d
git.kirsle.net/go/render v0.0.0-20210104010442-b4a1979a8ba1
github.com/veandco/go-sdl2 v0.4.7 // indirect
golang.org/x/image v0.0.0-20210504121937-7319ad40d33e // indirect
)

6
go.sum
View File

@ -3,6 +3,8 @@ cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMT
cloud.google.com/go v0.37.4/go.mod h1:NHPJ89PdicEuT9hdPXMROBD91xc5uRDxsMtSB16k7hw=
git.kirsle.net/go/render v0.0.0-20200102014411-4d008b5c468d h1:vErak6oVRT2dosyQzcwkjXyWQ2NRIVL8q9R8NOUTtsg=
git.kirsle.net/go/render v0.0.0-20200102014411-4d008b5c468d/go.mod h1:ywZtC+zE2SpeObfkw0OvG01pWHQadsVQ4WDKOYzaejc=
git.kirsle.net/go/render v0.0.0-20210104010442-b4a1979a8ba1 h1:wGQLjBnWvqx7rU43yFG8ow4rnYqUMUwqorEkxdPaJ6Q=
git.kirsle.net/go/render v0.0.0-20210104010442-b4a1979a8ba1/go.mod h1:ss7pvZbGWrMaDuZwyUTjV9+T0AJwAkxZZHwMFsvHrkk=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/Shopify/sarama v1.19.0/go.mod h1:FVkBWblsNy7DGZRfXLU0O9RCGt5g3g3yEuWXgklEdEo=
github.com/Shopify/toxiproxy v2.1.4+incompatible/go.mod h1:OXgGpZ6Cli1/URJOF1DMxUHB2q5Ap20/P/eIdh4G0pI=
@ -95,6 +97,8 @@ github.com/tomnomnom/xtermcolor v0.0.0-20160428124646-b78803f00a7e/go.mod h1:fSI
github.com/urfave/negroni v1.0.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4=
github.com/veandco/go-sdl2 v0.4.1 h1:HmSBvVmKWI8LAOeCfTTM8R33rMyPcs6U3o8n325c9Qg=
github.com/veandco/go-sdl2 v0.4.1/go.mod h1:FB+kTpX9YTE+urhYiClnRzpOXbiWgaU3+5F2AB78DPg=
github.com/veandco/go-sdl2 v0.4.7 h1:VfpCM+LfEGDbHdByglCo2bcBsevjFvzl8W0f6VLNitg=
github.com/veandco/go-sdl2 v0.4.7/go.mod h1:OROqMhHD43nT4/i9crJukyVecjPNYYuCofep6SNiAjY=
go.opencensus.io v0.20.1/go.mod h1:6WKK9ahsWS3RSO+PY9ZHZUfv2irvY6gN279GOPZjmmk=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
@ -105,6 +109,8 @@ golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL
golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs=
golang.org/x/image v0.0.0-20200119044424-58c23975cae1 h1:5h3ngYt7+vXCDZCup/HkCQgW5XwmSvR/nA2JmJ0RErg=
golang.org/x/image v0.0.0-20200119044424-58c23975cae1/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/image v0.0.0-20210504121937-7319ad40d33e h1:PzJMNfFQx+QO9hrC1GwZ4BoPGeNGhfeQEgcQFArEjPk=
golang.org/x/image v0.0.0-20210504121937-7319ad40d33e/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0=
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=