Esempio n. 1
0
func NewStatusBar(p *Widget) *StatusBar {
	sb := new(StatusBar)
	sb.view = NewView(p, "Status Bar")
	sb.view.AutoWidth = false
	sb.view.AutoHeight = false
	sb.view.SetWidth(101)
	sb.view.SetHeight(8)

	sb.icons = fonts.NewFontFromFile("/home/kernelcode/icon_font.fnt")
	sb.tiny = fonts.NewFontFromFile("/home/kernelcode/tiny_font.fnt")

	sb.State = STATE_NONE
	sb.Repeat, sb.Shuffle = false, false
	sb.TrackNum, sb.Tracks = 0, 0

	sb.stateLabel = NewLabel(sb.view.Widget, sb.icons)
	sb.stateLabel.SetPos(image.Point{2, 0})
	sb.repeatLabel = NewLabel(sb.view.Widget, sb.icons)
	sb.repeatLabel.SetPos(image.Point{10, 0})
	sb.shuffleLabel = NewLabel(sb.view.Widget, sb.icons)
	sb.shuffleLabel.SetPos(image.Point{19, 0})
	sb.tracksLabel = NewLabel(sb.view.Widget, sb.tiny)
	sb.tracksLabel.AutoWidth = false
	sb.tracksLabel.SetWidth(70)
	width := sb.view.Bounds().Dx()
	sb.tracksLabel.SetPos(image.Point{width - 70, 0})
	sb.tracksLabel.HAlign = Right

	sb.view.AddChild(sb.stateLabel)
	sb.view.AddChild(sb.repeatLabel)
	sb.view.AddChild(sb.shuffleLabel)
	sb.view.AddChild(sb.tracksLabel)
	//sb.view.Damage(sb.Bounds())
	return sb
}
Esempio n. 2
0
func TestList(t *testing.T) {
	screen := s4548.NewS4548(s4548.GetS4548EnvPath())
	font := fonts.NewFontFromFile("/home/kernelcode/tiny_font.fnt")
	iconFont := fonts.NewFontFromFile("/home/kernelcode/icon_font.fnt")
	fmt.Println("Font Loaded")

	list := NewList(nil, font, iconFont)
	list.Title = "A test list:"
	list.SetWidth(101)
	list.SetHeight(40)
	fmt.Println("Set size:", list.Bounds())
	list.AutoHeight = false
	list.Selected = 0

	list.AddItem("Zero", 0, nil, nil)
	/*
	   list.AddItem("One")
	   list.AddItem("Two")
	   list.AddItem("Three")
	   list.AddItem("Four")
	   list.AddItem("Five")
	   list.AddItem("Six")
	*/
	time.Sleep(500 * time.Millisecond)

	for j := 0; j < 5; j++ {
		for i := 0; i < 1; i++ {
			time.Sleep(500 * time.Millisecond)
			list.Selected = i
			list.Draw(screen)
			screen.Scanout()

		}
	}

}
Esempio n. 3
0
func TestView(t *testing.T) {
	screen := s4548.NewS4548(s4548.GetS4548EnvPath())
	font := fonts.NewFontFromFile("/home/kernelcode/tiny_font.fnt")
	fmt.Println("Font Loaded")

	r := rand.New(rand.NewSource(99))

	view := NewView(nil, "Test View")
	view.SetWidth(101)
	view.SetHeight(40)

	lbl1 := NewLabel(nil, font)
	lbl1.AutoWidth = false
	lbl1.AutoHeight = true
	lbl1.SetWidth(101)
	lbl1.SetHeight(40)
	lbl1.VAlign = Middle
	lbl1.HAlign = Centre
	lbl1.Text = "This is a big long label test which should be scrolling with any luck"
	lbl1.Scroll = true

	view.AddChild(lbl1)

	bar := NewProgressBar(nil)
	bar.SetWidth(101)
	bar.SetHeight(8)
	bar.SetPos(image.Point{0, 32})
	bar.Progress = 33

	view.AddChild(bar)

	for i := 0; i < 20; i++ {
		time.Sleep(500 * time.Millisecond)
		bar.Progress = r.Intn(101)
		view.Draw(screen)
		screen.Scanout()
	}
}
Esempio n. 4
0
func TestVertical(t *testing.T) {
	//screen := s4548.NewS4548("/dev/s4548-0")
	screen := s4548.NewS4548(s4548.GetS4548EnvPath())
	font := fonts.NewFontFromFile("/home/kernelcode/tiny_font.fnt")
	fmt.Println("Font Loaded")

	multiLine := NewLabel(nil, font)
	multiLine.AutoWidth = false
	multiLine.AutoHeight = false
	multiLine.Wrap = true
	multiLine.Scroll = false
	multiLine.SetWidth(101)
	multiLine.SetHeight(40)
	multiLine.SetPos(image.Point{0, 0})
	multiLine.VAlign = Middle
	multiLine.HAlign = Centre
	multiLine.Text = "Once upon a time in a galaxy far away... STAR WARS The evil galactic empire have taken over hundreds of systems"

	multiLine.Update()
	multiLine.Draw(screen)
	screen.Scanout()

	time.Sleep(5000 * time.Millisecond)

	multiLine.Scroll = true
	multiLine.Active = true
	for i := 0; i < 20; i++ {
		multiLine.Update()
		multiLine.Draw(screen)
		screen.Scanout()

		time.Sleep(300 * time.Millisecond)
	}

	screen.Close()

	time.Sleep(5000 * time.Millisecond)
}
Esempio n. 5
0
func TestHorizontal(t *testing.T) {
	//screen := s4548.NewS4548("/dev/s4548-0")
	screen := s4548.NewS4548(s4548.GetS4548EnvPath())
	font := fonts.NewFontFromFile("/home/kernelcode/tiny_font.fnt")
	fmt.Println("Font Loaded")

	longLine := NewLabel(nil, font)
	longLine.AutoWidth = false
	longLine.AutoHeight = true
	longLine.Wrap = false
	longLine.Scroll = false
	longLine.SetWidth(80)
	longLine.SetPos(image.Point{10, 8})
	longLine.VAlign = Middle
	longLine.HAlign = Centre
	longLine.Text = "Lazee ft. Neverstore - Hold On (Matrix & Futurebound Remix)"

	longLine.Update()
	longLine.Draw(screen)
	screen.Scanout()

	time.Sleep(1000 * time.Millisecond)

	longLine.Scroll = true
	longLine.Active = true
	for i := 0; i < 50; i++ {
		longLine.Update()
		longLine.Draw(screen)
		screen.Scanout()

		time.Sleep(200 * time.Millisecond)
	}
	screen.Close()

	time.Sleep(1000 * time.Millisecond)
}
Esempio n. 6
0
func TestAlign(t *testing.T) {
	//screen := s4548.NewS4548("/dev/s4548-0")
	screen := s4548.NewS4548(s4548.GetS4548EnvPath())
	font := fonts.NewFontFromFile("/home/kernelcode/tiny_font.fnt")
	fmt.Println("Font Loaded")

	short := NewLabel(nil, font)
	short.AutoWidth = false
	short.AutoHeight = false
	short.SetWidth(101)
	short.SetHeight(40)
	short.VAlign = Middle
	short.HAlign = Centre
	short.Text = "Short"
	short.Background = color.Black
	short.Foreground = color.White

	for i := 0; i < 3; i++ {
		switch i {
		case 0:
			short.VAlign = Top
		case 1:
			short.VAlign = Middle
		case 2:
			short.VAlign = Bottom
		}
		for j := 0; j < 3; j++ {
			switch j {
			case 0:
				short.HAlign = Left
			case 1:
				short.HAlign = Centre
			case 2:
				short.HAlign = Right
			}
			time.Sleep(500 * time.Millisecond)

			short.Update()
			short.Draw(screen)
			screen.Scanout()
		}
	}

	screen.Close()
	time.Sleep(1000 * time.Millisecond)

	/*
	   for {v
	       l.Update()
	       l.Draw(screen)

	       l.Text = "Today I learned that writing word wrapping for the second time was still around 100,000,000 times harder than I was expecting"
	       l.Widget.AutoWidth = true
	       //l.SetWidth(101)
	       l.SetPos(image.Point{0,0})
	       l.Update()
	       l.Draw(screen)

	       screen.Scanout()
	       time.Sleep(300 * time.Millisecond)
	   }
	*/
}