Example #1
0
func main() {
	window := ui.NewWindow("", "Text Example", 2650, 25, 1637, 580)
	table := layout.NewTable(window)
	table.SetCellMargin(ui.Margin{3, 3, 10, 3})
	table.SetRowHeight(0, 40)
	table.SetRowHeight(1, 400)
	table.SetRowHeight(2, 40)
	table.SetRowHeight(3, 80)

	addText := func(a text.Alignment, atxt string, c color.Color, col, row, w, h int) {
		table.SetColWidth(col, 400)
		txt := text.New(table, "", atxt)
		txt.Background = color.Gray10
		txt.Foreground = color.White
		txt.Alignment = text.CENTER
		table.AddMultiCell(txt, col, row-1, w, h)

		txt = text.New(table, "", TEXT)
		txt.Alignment = a
		txt.Foreground = c
		table.AddMultiCell(txt, col, row, w, h)

	}

	addText(text.LEFT, "Left", color.Gray13, 0, 1, 1, 1)
	addText(text.JUSTIFY, "Justify", color.Purple2, 1, 1, 1, 1)
	addText(text.CENTER, "Center", color.Green2, 2, 1, 1, 1)
	addText(text.RIGHT, "Right", color.Blue4, 3, 1, 1, 1)
	addText(text.NOWRAP, "No Wrapping", color.Red2, 0, 3, 4, 1)

	window.SetChild(table)
	end := window.Start()
	<-end
}
Example #2
0
func main() {
	window := ui.NewWindow("", "Vizstra Kitchen Sink", 1570, 60, 450, 450)

	fill := layout.NewFill(window)
	fill.SetMargin(ui.Margin{3, 3, 3, 3})
	table := layout.NewTable(fill)
	fill.SetChild(table)

	table.SetDefaultCellDimensions(50, 50)
	table.SetCellMargin(ui.Margin{2, 2, 2, 2})

	b1 := button.NewImageButton(table, "none", "Click Here!")
	b1.HoverBackground = color.RGBA(10, 10, 10, 50)
	b1.SetImagePath("src/github.com/vizstra/ui/res/img/b.png")
	b1.SetHoverImagePath("src/github.com/vizstra/ui/res/img/a.png")
	table.AddMultiCell(b1, 0, 0, 2, 1)

	b2 := button.NewImageButton(table, "none", "Click Here!")
	b2.HoverBackground = color.RGBA(10, 10, 10, 50)
	b2.SetImagePath("src/github.com/vizstra/ui/res/img/candy-apple-icon.png")
	table.AddMultiCell(b2, 2, 0, 2, 1)

	b := button.NewButton(table, "none", "Normal Button")
	table.AddMultiCell(b, 4, 0, 3, 1)

	text := text.New(table, "", "This is a test")
	table.AddMultiCell(text, 4, 1, 4, 7)

	table2 := layout.NewTable(table)
	bg := color.Orange1
	table2.Background = &bg
	table2.SetDefaultCellDimensions(30, 30)
	table.AddMultiCell(table2, 0, 1, 0, 0)

	activity := button.NewActivityBar(table, "", 100.0, []float64{})
	go func() {
		for {
			activity.Data = append(activity.Data, rand.Float64()*100)
			time.Sleep(1000 * time.Millisecond)
		}
	}()

	activity.Foreground = color.Purple2
	table.AddMultiCell(activity, 0, 5, 4, 1)

	pb := button.NewProgressBar(table2, "", 100)
	pb.HoverBackground = color.RGBA(10, 10, 10, 50)
	pb.Value = 70
	table2.AddMultiCell(pb, 0, 1, 4, 1)

	table.AddMultiCell(BuildChart(table), 0, 3, 4, 2)
	window.SetChild(fill)
	end := window.Start()
	<-end
}