Code refactoring
[sixth-3d.git] / src / main / java / eu / svjatoslav / sixth / e3d / gui / humaninput / KeyboardInputHandler.java
diff --git a/src/main/java/eu/svjatoslav/sixth/e3d/gui/humaninput/KeyboardInputHandler.java b/src/main/java/eu/svjatoslav/sixth/e3d/gui/humaninput/KeyboardInputHandler.java
new file mode 100644 (file)
index 0000000..3f26cdf
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Sixth 3D engine. Author: Svjatoslav Agejenko. 
+ * This project is released under Creative Commons Zero (CC0) license.
+ */
+package eu.svjatoslav.sixth.e3d.gui.humaninput;
+
+import eu.svjatoslav.sixth.e3d.gui.ViewPanel;
+
+import java.awt.event.KeyEvent;
+
+/**
+ * This is the process:
+ *
+ * 1. Component receives focus, perhaps because user clicked on it with the mouse.
+ * 2. Now component will receive user key press and release events from the keyboard.
+ * 3. Component loses focus. Perhaps user chose another component to interact with.
+ */
+public interface KeyboardInputHandler {
+
+    /**
+     * @return <code>true</code> if view needs to be re-rendered.
+     */
+    boolean focusLost(ViewPanel viewPanel);
+
+    /**
+     * @return <code>true</code> if view needs to be re-rendered.
+     */
+    boolean focusReceived(ViewPanel viewPanel);
+
+    /**
+     * @return <code>true</code> if view needs to be re-rendered.
+     */
+    boolean keyPressed(KeyEvent event, ViewPanel viewPanel);
+
+    /**
+     * @return <code>true</code> if view needs to be re-rendered.
+     */
+    boolean keyReleased(KeyEvent event, ViewPanel viewPanel);
+
+}