Update README

menus
Noah 2020-03-09 17:32:28 -07:00
parent fb9127f0d5
commit 911585ea4d
2 changed files with 20 additions and 7 deletions

View File

@ -77,9 +77,11 @@ func main() {
Side: ui.N, Side: ui.N,
}) })
// Add the button to the MainWindow's Supervisor so it can be // Add a mouse-over tooltip to the button.
// clicked on and interacted with. ui.NewTooltip(button, ui.Tooltip{
mw.Add(button) Text: "You know you want to click this button",
Edge: ui.Right,
})
mw.MainLoop() mw.MainLoop()
} }
@ -133,6 +135,7 @@ most complex.
state of the checkbox. state of the checkbox.
* [x] **Window**: a Frame with a title bar Frame on top. * [x] **Window**: a Frame with a title bar Frame on top.
* Note: Window is not yet draggable or closeable. * Note: Window is not yet draggable or closeable.
* [x] **Tooltip**: a mouse hover label attached to a widget.
**Work in progress widgets:** **Work in progress widgets:**

View File

@ -4,9 +4,14 @@ import (
"fmt" "fmt"
"git.kirsle.net/go/render" "git.kirsle.net/go/render"
"git.kirsle.net/go/render/sdl"
"git.kirsle.net/go/ui" "git.kirsle.net/go/ui"
) )
func init() {
sdl.DefaultFontFilename = "../DejaVuSans.ttf"
}
func main() { func main() {
mw, err := ui.NewMainWindow("Hello World") mw, err := ui.NewMainWindow("Hello World")
if err != nil { if err != nil {
@ -19,10 +24,9 @@ func main() {
label := ui.NewLabel(ui.Label{ label := ui.NewLabel(ui.Label{
Text: "Hello, world!", Text: "Hello, world!",
Font: render.Text{ Font: render.Text{
FontFilename: "../DejaVuSans.ttf", Size: 32,
Size: 32, Color: render.SkyBlue,
Color: render.SkyBlue, Shadow: render.SkyBlue.Darken(40),
Shadow: render.SkyBlue.Darken(40),
}, },
}) })
mw.Pack(label, ui.Pack{ mw.Pack(label, ui.Pack{
@ -47,5 +51,11 @@ func main() {
Side: ui.N, 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() mw.MainLoop()
} }