Browse Source

scenecomposer : small refactor in shortcut management

Dokthar 9 years ago
parent
commit
dcb5fd0f25

+ 2 - 2
jme3-scenecomposer/src/com/jme3/gde/scenecomposer/tools/shortcuts/MoveShortcut.java

@@ -76,8 +76,8 @@ public class MoveShortcut extends ShortcutTool {
     @Override
     public void keyPressed(KeyInputEvent kie) {
         if (kie.isPressed()) {
-            Lookup.getDefault().lookup(ShortcutManager.class).activateShortcut(kie);
-
+            Lookup.getDefault().lookup(ShortcutManager.class).setActiveShortcut(this);
+            
             boolean axisChanged = ShortcutManager.isAxisKey(kie);
             if (axisChanged) {
                 currentAxis = ShortcutManager.getAxisKey(kie);

+ 4 - 4
jme3-scenecomposer/src/com/jme3/gde/scenecomposer/tools/shortcuts/RotateShortcut.java

@@ -77,7 +77,7 @@ public class RotateShortcut extends ShortcutTool {
     @Override
     public void keyPressed(KeyInputEvent kie) {
         if (kie.isPressed()) {
-            Lookup.getDefault().lookup(ShortcutManager.class).activateShortcut(kie);
+            Lookup.getDefault().lookup(ShortcutManager.class).setActiveShortcut(this);
 
             boolean axisChanged = ShortcutManager.isAxisKey(kie);
             if (axisChanged) {
@@ -99,7 +99,7 @@ public class RotateShortcut extends ShortcutTool {
                 spatial.setLocalRotation(startRotation.clone());
             } else if (axisChanged || numberChanged) {
                 //update transformation
-       /*         float number = ShortcutManager.getNumberKey(numberBuilder);
+                /*         float number = ShortcutManager.getNumberKey(numberBuilder);
                  Vector3f translation = currentAxis.mult(number);
                  finalPosition = startPosition.add(translation);
                  spatial.setLocalTranslation(finalPosition);
@@ -145,8 +145,8 @@ public class RotateShortcut extends ShortcutTool {
         }
 
         if (pickManager.updatePick(camera, screenCoord)) {
-            
-            Quaternion rotation = startRotation.mult(pickManager.getRotation(startWorldRotate.inverse()));           
+
+            Quaternion rotation = startRotation.mult(pickManager.getRotation(startWorldRotate.inverse()));
             toolController.getSelectedSpatial().setLocalRotation(rotation);
             finalRotation = rotation;
             updateToolsTransformation();

+ 1 - 1
jme3-scenecomposer/src/com/jme3/gde/scenecomposer/tools/shortcuts/ScaleShortcut.java

@@ -75,7 +75,7 @@ public class ScaleShortcut extends ShortcutTool {
     @Override
     public void keyPressed(KeyInputEvent kie) {
         if (kie.isPressed()) {
-            Lookup.getDefault().lookup(ShortcutManager.class).activateShortcut(kie);
+            Lookup.getDefault().lookup(ShortcutManager.class).setActiveShortcut(this);
 
             boolean axisChanged = ShortcutManager.isAxisKey(kie);
             if (axisChanged) {

+ 6 - 0
jme3-scenecomposer/src/com/jme3/gde/scenecomposer/tools/shortcuts/ShortcutManager.java

@@ -140,6 +140,12 @@ public class ShortcutManager {
         }
         return newShortcut != null;
     }
+    
+    public void setActiveShortcut(ShortcutTool newShortcut) {
+        if (newShortcut != null && newShortcut != currentShortcut) {
+            currentShortcut = newShortcut;
+        }
+    }
 
     /**
      * This should be called to trigger the currentShortcut.keyPressed() method.