orx icon indicating copy to clipboard operation
orx copied to clipboard

[orx-camera] In OrbitalControls, make userInteraction toggleable

Open hamoid opened this issue 4 years ago • 3 comments

provide enable / disable userInteraction

Currently userInteraction is set up inside OrbitalControls::setup() and it stays the same during its lifetime. It contains 6 calls to .listen():

            program.mouse.moved.listen { mouseMoved(it) }
            program.mouse.buttonDown.listen { mouseButtonDown(it) }
            program.mouse.buttonUp.listen { state = STATE.NONE }
            program.mouse.scrolled.listen { mouseScrolled(it) }
            program.keyboard.keyDown.listen { keyPressed(it) }
            program.keyboard.keyRepeat.listen { keyPressed(it) }

A method in this direction would be needed:

public fun setUserInteraction(enabled: Boolean) {
  // here we either .listen() or .cancel() the listening
}

This method would replace the .listen() calls inside setup(), but also can be called by the user to enable / disable interaction.

For that to be doable Event.kt needs a method for canceling listeners.

Discussion at https://openrndr.slack.com/archives/CEASC1PB7/p1584368959475400

hamoid avatar Mar 16 '20 14:03 hamoid

Another approach would be to check if userInteraction is true inside the keyboard and mouse listeners.

edwinRNDR avatar Mar 16 '20 20:03 edwinRNDR

What would be best if we wanted to control two or more viewports with the mouse? Say drag on one viewport to rotate, then on a second viewport.

hamoid avatar Mar 16 '20 21:03 hamoid

What would be best if we wanted to control two or more viewports with the mouse? Say drag on one viewport to rotate, then on a second viewport.

That's pretty tricky I think. On one hand you have input handling that is tied to where the viewport is placed on the screen, on the other hand you will likely use render targets to implement the rendering so you don't want to use view port offsets there.

I guess you could start by giving OrbitalControls an optional inputArea Rectangle. Then either an additional extension or your application directly takes care of positioning the rendering results and recalculating the inputAreas

edwinRNDR avatar Mar 16 '20 21:03 edwinRNDR