Beispiel #1
0
func TestStatusBar(t *testing.T) {
	fmt.Println(s4548.GetS4548EnvPath())
	screen := s4548.NewS4548(s4548.GetS4548EnvPath())

	statusbar := NewStatusBar(nil)
	state := false
	statusbar.Tracks = 1000
	r := rand.New(rand.NewSource(99))

	for i := 0; i < 10; i++ {
		time.Sleep(1000 * time.Millisecond)
		if state {
			statusbar.State = STATE_PAUSED
		} else {
			statusbar.State = STATE_PLAYING
		}
		state = !state
		statusbar.Repeat = !statusbar.Repeat
		statusbar.Shuffle = !statusbar.Shuffle

		statusbar.TrackNum = r.Intn(1000)

		statusbar.Draw(screen)
		screen.Scanout()
	}
}
Beispiel #2
0
func TestHorz(t *testing.T) {
	screen := s4548.NewS4548(s4548.GetS4548EnvPath())

	bar := NewProgressBar(nil)
	bar.SetWidth(101)
	bar.SetHeight(7)
	bar.SetPos(image.Point{0, 10})

	for i := 0; i <= 110; i++ {
		bar.Progress = i
		//bar.MakeGraphics()
		bar.Draw(screen)
		screen.Scanout()
		time.Sleep(100 * time.Millisecond)
	}

	bar.Direction = Vertical
	bar.SetWidth(30)
	bar.SetHeight(40)
	bar.SetPos(image.Point{10, 0})
	for i := 0; i <= 110; i++ {
		bar.Progress = i
		//bar.MakeGraphics()
		bar.Draw(screen)
		screen.Scanout()
		time.Sleep(100 * time.Millisecond)
	}

	screen.Close()
	time.Sleep(1000 * time.Millisecond)
}
Beispiel #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()
	}
}
Beispiel #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)
}
Beispiel #5
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()

		}
	}

}
Beispiel #6
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)
}
Beispiel #7
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)
	   }
	*/
}