func main() { desktop.Main(func(display driver.Display) { gopher := loadImage("samples/gopher.png") img0 := vu.NewImage(vu.UniformImageLayout{}, gopher) img0.SetSelectable(true) img1 := vu.NewImage(vu.FillImageLayout{}, gopher) img1.SetSelectable(true) img2 := vu.NewImage(vu.UniformFillImageLayout{}, gopher) img2.SetSelectable(true) view := vu.NewView( vu.NewFrame(vu.VerticalLayout{Spacing: 10}, img0, img1, img2, ), ) window, _ := display.NewWindow(driver.MainWindowConfig( driver.DefaultWindowTitle(), view.PreferredSize(geom.Size{-1, -1}), )) for { var event interface{} select { case event = <-window.Events(): case event = <-view.Events(): } if view.Process(window, event) != nil { break } } }) }
func main() { desktop.Main(func(display driver.Display) { f0 := text.BasicFont() defer f0.Close() f1 := text.TTF(clearSans, text.FaceData{Size: 12}) defer f1.Close() f2 := text.TTF(clearSansBoldItalic, text.FaceData{Size: 12}) defer f2.Close() monaco, _ := display.NewFont("Monaco") f3 := monaco.Face(text.FaceData{}) defer f3.Close() t1 := vu.NewText("Hello World!\nHow are you doing?", f0, nil) t1.SetWrappable(true) t1.SetSelectable(true) t2 := vu.NewText("How are you doing?", f1, text.Left) t2.SetWrappable(true) t2.SetSelectable(true) t3 := vu.NewText("How are you doing?", f3, text.Center) t3.SetWrappable(true) t3.SetSelectable(true) t3.SetForeground(image.NewUniform(color.RGBA{255, 0, 0, 255})) t3.SetBackground(image.NewUniform(color.RGBA{255, 255, 0, 255})) t4 := vu.NewText("How are you doing?", f1, text.Right) t4.SetWrappable(true) t4.SetSelectable(true) t4.SetDirection(text.RightToLeft) t5 := vu.NewText("How are you doing?", f1, text.Justify) t5.SetWrappable(true) t5.SetSelectable(true) t6 := vu.NewText("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890", f2, nil) t6.SetWrappable(true) t6.SetSelectable(true) t6.SetSelection(text.Range{10, 10}) view := vu.NewView( vu.NewMarginBox(geom.MakeMargin(10), vu.NewFrame(nil, t1, t2, t3, t4, t5, t6), ), ) window, _ := display.NewWindow(driver.MainWindowConfig( driver.DefaultWindowTitle(), view.PreferredSize(geom.Size{-1, -1}), )) for { var event interface{} select { case event = <-window.Events(): case event = <-view.Events(): } if view.Process(window, event) != nil { break } } }) }