From 911585ea4d21a6d0f621bae59fbaf88d3e10d4ce Mon Sep 17 00:00:00 2001 From: Noah Petherbridge Date: Mon, 9 Mar 2020 17:32:28 -0700 Subject: [PATCH] Update README --- README.md | 9 ++++++--- eg/hello-world/main.go | 18 ++++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index fb87bb5..06b544b 100644 --- a/README.md +++ b/README.md @@ -77,9 +77,11 @@ func main() { Side: ui.N, }) - // Add the button to the MainWindow's Supervisor so it can be - // clicked on and interacted with. - mw.Add(button) + // Add a mouse-over tooltip to the button. + ui.NewTooltip(button, ui.Tooltip{ + Text: "You know you want to click this button", + Edge: ui.Right, + }) mw.MainLoop() } @@ -133,6 +135,7 @@ most complex. state of the checkbox. * [x] **Window**: a Frame with a title bar Frame on top. * Note: Window is not yet draggable or closeable. +* [x] **Tooltip**: a mouse hover label attached to a widget. **Work in progress widgets:** diff --git a/eg/hello-world/main.go b/eg/hello-world/main.go index 32b5641..c6ae838 100644 --- a/eg/hello-world/main.go +++ b/eg/hello-world/main.go @@ -4,9 +4,14 @@ import ( "fmt" "git.kirsle.net/go/render" + "git.kirsle.net/go/render/sdl" "git.kirsle.net/go/ui" ) +func init() { + sdl.DefaultFontFilename = "../DejaVuSans.ttf" +} + func main() { mw, err := ui.NewMainWindow("Hello World") if err != nil { @@ -19,10 +24,9 @@ func main() { label := ui.NewLabel(ui.Label{ Text: "Hello, world!", Font: render.Text{ - FontFilename: "../DejaVuSans.ttf", - Size: 32, - Color: render.SkyBlue, - Shadow: render.SkyBlue.Darken(40), + Size: 32, + Color: render.SkyBlue, + Shadow: render.SkyBlue.Darken(40), }, }) mw.Pack(label, ui.Pack{ @@ -47,5 +51,11 @@ func main() { Side: ui.N, }) + // Add a mouse-over tooltip to the button. + ui.NewTooltip(button, ui.Tooltip{ + Text: "You know you want to click this button", + Edge: ui.Right, + }) + mw.MainLoop() }