コード例 #1
0
ファイル: testlib.go プロジェクト: leonardyp/mandala
// eventLoopFunc is listening for events originating from the
// framwork.
func (t *TestSuite) eventLoopFunc(renderLoopControl *renderLoopControl) loop.LoopFunc {
	return func(loop loop.Loop) error {

		for {
			select {

			case c := <-t.resetActionMove:
				t.testActionMove = make(chan mandala.ActionMoveEvent, c)
				t.moving = true
				t.resetActionMove <- 0

			// Receive events from the framework.
			case untypedEvent := <-mandala.Events():

				switch event := untypedEvent.(type) {

				case mandala.CreateEvent:
					t.creationSequence = append(t.creationSequence, "onCreate")

				case mandala.StartEvent:
					t.creationSequence = append(t.creationSequence, "onStart")

				case mandala.NativeWindowCreatedEvent:
					renderLoopControl.window <- event.Window

					// Finger down/up on the screen.
				case mandala.ActionUpDownEvent:
					if !t.moving {
						t.testActionUpDown <- event
					}

					// Finger is moving on the screen.
				case mandala.ActionMoveEvent:
					if t.moving {
						t.testActionMove <- event
					}

				case mandala.NativeWindowDestroyedEvent:
					mandala.Debugf("Window destroyed")

				case mandala.DestroyEvent:
					// return nil

				case mandala.NativeWindowRedrawNeededEvent:
					mandala.Debugf("Redraw needed")

				case mandala.PauseEvent:

				case mandala.ResumeEvent:
					t.creationSequence = append(t.creationSequence, "onResume")

				}
			}
		}
	}
}
コード例 #2
0
ファイル: game.go プロジェクト: TimothyKlim/mandala-examples
// eventLoopFunc listen to events originating from the
// framework.
func eventLoopFunc(renderLoopControl *renderLoopControl) loop.LoopFunc {
	return func(loop loop.Loop) error {

		for {
			select {

			case untypedEvent := <-mandala.Events():
				switch event := untypedEvent.(type) {

				// Receive a native window
				// from the framework and send
				// it to the render loop in
				// order to begin the
				// rendering process.
				case mandala.NativeWindowCreatedEvent:
					renderLoopControl.window <- event.Window

				// Finger down/up on the screen.
				case mandala.ActionUpDownEvent:
					if event.Down {
						renderLoopControl.tapEvent <- [2]float32{event.X, event.Y}
					}

					// Finger is moving on the screen.
				case mandala.ActionMoveEvent:
					mandala.Logf("Finger is moving at coord %f %f", event.X, event.Y)

				case mandala.DestroyEvent:
					mandala.Logf("Quitting from application now...\n")
					return nil

				case mandala.NativeWindowRedrawNeededEvent:

				case mandala.PauseEvent:
					mandala.Logf("Application was paused. Stopping rendering ticker.")
					renderLoopControl.pause <- event

				case mandala.ResumeEvent:
					mandala.Logf("Application was resumed. Reactivating rendering ticker.")
					renderLoopControl.resume <- true

				}
			}
		}
	}
}
コード例 #3
0
ファイル: testlib.go プロジェクト: remogatto/gltext
// eventLoopFunc is listening for events originating from the
// framwork.
func (t *TestSuite) eventLoopFunc(renderLoopControl *renderLoopControl) loop.LoopFunc {
	return func(loop loop.Loop) error {

		for {
			select {

			// Receive events from the framework.
			case untypedEvent := <-mandala.Events():

				switch event := untypedEvent.(type) {

				case mandala.CreateEvent:

				case mandala.StartEvent:

				case mandala.NativeWindowCreatedEvent:
					renderLoopControl.window <- event.Window

				case mandala.ActionUpDownEvent:

				case mandala.ActionMoveEvent:

				case mandala.NativeWindowDestroyedEvent:

				case mandala.DestroyEvent:

				case mandala.NativeWindowRedrawNeededEvent:

				case mandala.PauseEvent:

				case mandala.ResumeEvent:

				}
			}
		}
	}
}
コード例 #4
0
ファイル: game.go プロジェクト: remogatto/mandala-examples
// eventLoopFunc listen to events originating from the
// framework.
func eventLoopFunc(renderLoopControl *renderLoopControl) loop.LoopFunc {
	return func(loop loop.Loop) error {

		for {
			select {

			// Receive an EGL state from the
			// framework and notify the render
			// loop about that.
			// case eglState := <-mandala.Init:
			// 	mandala.Logf("EGL surface initialized W:%d H:%d", eglState.SurfaceWidth, eglState.SurfaceHeight)
			// 	renderLoopControl.eglState <- eglState

			// Receive events from the framework.
			//
			// When the application starts the
			// typical events chain is:
			//
			// * onCreate
			// * onResume
			// * onInputQueueCreated
			// * onNativeWindowCreated
			// * onNativeWindowResized
			// * onWindowFocusChanged
			// * onNativeRedrawNeeded
			//
			// Pausing (i.e. clicking on the back
			// button) the application produces
			// following events chain:
			//
			// * onPause
			// * onWindowDestroy
			// * onWindowFocusChanged
			// * onInputQueueDestroy
			// * onDestroy

			case untypedEvent := <-mandala.Events():
				switch event := untypedEvent.(type) {

				// Receive a native window
				// from the framework and send
				// it to the render loop in
				// order to begin the
				// rendering process.
				case mandala.NativeWindowCreatedEvent:
					renderLoopControl.window <- event.Window

				// Finger down/up on the screen.
				case mandala.ActionUpDownEvent:
					if event.Down {
						mandala.Logf("Finger is DOWN at %f %f", event.X, event.Y)
					} else {
						mandala.Logf("Finger is now UP")
					}

					// Finger is moving on the screen.
				case mandala.ActionMoveEvent:
					mandala.Logf("Finger is moving at coord %f %f", event.X, event.Y)

				case mandala.DestroyEvent:
					mandala.Logf("Stop rendering...\n")
					mandala.Logf("Quitting from application...\n")
					return nil

				case mandala.NativeWindowRedrawNeededEvent:

				case mandala.PauseEvent:
					mandala.Logf("Application was paused. Stopping rendering ticker.")
					renderLoopControl.pause <- true

				case mandala.ResumeEvent:
					mandala.Logf("Application was resumed. Reactivating rendering ticker.")
					renderLoopControl.resume <- true

				}
			}
		}
	}
}