diff --git a/README.md b/README.md index c9354db..c5dc2dd 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/eg/README.md b/eg/README.md index 5ab58e6..c6887b5 100644 --- a/eg/README.md +++ b/eg/README.md @@ -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. diff --git a/eg/frame-place/main.go b/eg/frame-place/main.go index ad1419d..4886b7e 100644 --- a/eg/frame-place/main.go +++ b/eg/frame-place/main.go @@ -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) diff --git a/eg/hello-world/README.md b/eg/hello-world/README.md new file mode 100644 index 0000000..b01e639 --- /dev/null +++ b/eg/hello-world/README.md @@ -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. diff --git a/eg/hello-world/main.go b/eg/hello-world/main.go index c6ae838..a448163 100644 --- a/eg/hello-world/main.go +++ b/eg/hello-world/main.go @@ -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, diff --git a/eg/hello-world/screenshot.png b/eg/hello-world/screenshot.png new file mode 100644 index 0000000..eca253b Binary files /dev/null and b/eg/hello-world/screenshot.png differ diff --git a/eg/layout/layout.go b/eg/layout/layout.go deleted file mode 100644 index 511c885..0000000 --- a/eg/layout/layout.go +++ /dev/null @@ -1,7 +0,0 @@ -package layout - -import "fmt" - -func main() { - fmt.Println("Hello world") -} diff --git a/eg/layout/main.go b/eg/layout/main.go deleted file mode 100644 index 8f99a7c..0000000 --- a/eg/layout/main.go +++ /dev/null @@ -1,12 +0,0 @@ -package main - -import ( - "fmt" - - "git.kirsle.net/go/ui/eg/layout" -) - -func main() { - fmt.Println("Hello world") - layout.main() -} diff --git a/eg/menus/README.md b/eg/menus/README.md index d80001f..11822d6 100644 --- a/eg/menus/README.md +++ b/eg/menus/README.md @@ -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. diff --git a/eg/menus/screenshot.png b/eg/menus/screenshot.png new file mode 100644 index 0000000..3c055ac Binary files /dev/null and b/eg/menus/screenshot.png differ diff --git a/eg/themes/README.md b/eg/themes/README.md new file mode 100644 index 0000000..999fe4f --- /dev/null +++ b/eg/themes/README.md @@ -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. diff --git a/eg/themes/screenshot.png b/eg/themes/screenshot.png new file mode 100644 index 0000000..fa903db Binary files /dev/null and b/eg/themes/screenshot.png differ diff --git a/eg/tooltip/README.md b/eg/tooltip/README.md new file mode 100644 index 0000000..9081890 --- /dev/null +++ b/eg/tooltip/README.md @@ -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. diff --git a/eg/tooltip/main.go b/eg/tooltip/main.go index 005a209..5c8664d 100644 --- a/eg/tooltip/main.go +++ b/eg/tooltip/main.go @@ -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. diff --git a/eg/tooltip/screenshot.png b/eg/tooltip/screenshot.png new file mode 100644 index 0000000..4eda807 Binary files /dev/null and b/eg/tooltip/screenshot.png differ diff --git a/eg/windows/README.md b/eg/windows/README.md new file mode 100644 index 0000000..d8b75b6 --- /dev/null +++ b/eg/windows/README.md @@ -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. diff --git a/eg/windows/screenshot.png b/eg/windows/screenshot.png new file mode 100644 index 0000000..4b5dd74 Binary files /dev/null and b/eg/windows/screenshot.png differ diff --git a/go.mod b/go.mod index 0f7fa2d..6c9025f 100644 --- a/go.mod +++ b/go.mod @@ -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 ) diff --git a/go.sum b/go.sum index 6f64f01..277cb31 100644 --- a/go.sum +++ b/go.sum @@ -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=