Example #1
0
func (m *Module) Display(display Display, sz size.Event, glctx gl.Context, images *glutil.Images) {
	im := images.NewImage(sz.WidthPx, sz.HeightPx)

	switch {
	case m.err != nil:
		// There was an error of some kind. We should display the error indication until the error
		// is removed from the module by a timeout.
		m.renderInformation(im.RGBA, sz.Size(), errorBackground, "T_T", "T_T")
	case !display.Loaded:
		// We haven't loaded any predictions yet. Dislay the loading screen.
		loadingStr := "Loading" + strings.Repeat(".", int(time.Now().Unix()%4))
		m.renderInformation(im.RGBA, sz.Size(), loadingBackground, loadingStr, "Loading...")
	case !display.NextOK:
		// We don't have a prediction for the next train. This is probably because there are no
		// trains coming for a while (ex., after nightly shutdown).
		m.renderInformation(im.RGBA, sz.Size(), loadingBackground, "No trains :(", "No trains :(")
	default:
		// If everything else is ok, then we have at least 1 prediction. Display it.
		m.render(im.RGBA, display, sz.Size())
	}

	if display.TransitRouteName != "" {
		m.renderTransitRouteName(im.RGBA, sz.Size(), display.TransitRouteName)
	}

	im.Upload()
	im.Draw(
		sz,
		geom.Point{},
		geom.Point{X: sz.WidthPt},
		geom.Point{Y: sz.HeightPt},
		sz.Bounds())
	im.Release()
}