Browse Source

Working on W/E/R shortcuts for gizmo modes, improved mode graphics, editor skin updates

Josh Engebretson 10 years ago
parent
commit
60fab537d8

BIN
Resources/EditorData/AtomicEditor/editor/skin/3d_rotate.png


BIN
Resources/EditorData/AtomicEditor/editor/skin/3d_scale.png


BIN
Resources/EditorData/AtomicEditor/editor/skin/3d_translate.png


BIN
Resources/EditorData/AtomicEditor/editor/skin/play.png


+ 3 - 3
Resources/EditorData/AtomicEditor/editor/skin/skin.tb.txt

@@ -147,11 +147,11 @@ elements
 		background-color #23241f
 		background-color #23241f
 
 
 	3DScaleBitmap
 	3DScaleBitmap
-		bitmap 3d_scale.png		
+		bitmap 3d_scale.png
 	3DTranslateBitmap
 	3DTranslateBitmap
-		bitmap 3d_translate.png		
+		bitmap 3d_translate.png
 	3DRotateBitmap
 	3DRotateBitmap
-		bitmap 3d_rotate.png		
+		bitmap 3d_rotate.png
 
 
 	DarkGrayText
 	DarkGrayText
 		text-color #aaaaaa
 		text-color #aaaaaa

+ 8 - 5
Resources/EditorData/AtomicEditor/editor/ui/maintoolbar.tb.txt

@@ -1,18 +1,21 @@
 definitions
 definitions
 	menubutton		
 	menubutton		
 		lp: height: 28, width: 28
 		lp: height: 28, width: 28
-		skin TBButton.flat
-TBLayout: distribution: gravity
+		skin TBButton.uniformflat
+TBLayout: distribution: gravity, spacing: 4
 	TBButton 
 	TBButton 
 		@include definitions>menubutton
 		@include definitions>menubutton
 		TBSkinImage: skin: PlayButton
 		TBSkinImage: skin: PlayButton
 		id maintoolbar_play
 		id maintoolbar_play
-	TBButton: skin: TBButton.flat
+	TBButton: toggle-mode: 1
+		@include definitions>menubutton
 		TBSkinImage: skin: 3DTranslateBitmap
 		TBSkinImage: skin: 3DTranslateBitmap
 		id 3d_translate
 		id 3d_translate
-	TBButton: skin: TBButton.flat
+	TBButton: toggle-mode: 1
+		@include definitions>menubutton
 		TBSkinImage: skin: 3DRotateBitmap
 		TBSkinImage: skin: 3DRotateBitmap
 		id 3d_rotate
 		id 3d_rotate
-	TBButton: skin: TBButton.flat
+	TBButton: toggle-mode: 1
+		@include definitions>menubutton
 		TBSkinImage: skin: 3DScaleBitmap
 		TBSkinImage: skin: 3DScaleBitmap
 		id 3d_scale
 		id 3d_scale

+ 16 - 0
Resources/EditorData/AtomicEditor/resources/default_skin/skin.tb.txt

@@ -53,6 +53,22 @@ elements
 		bitmap button_flat_pressed.png
 		bitmap button_flat_pressed.png
 		cut 8
 		cut 8
 
 
+	TBButton.uniformflat
+		text-color #fefefe
+		padding 4 4
+		children
+			element TBButton.uniformflat.hovered
+				state hovered
+			element TBButton.uniformflat.pressed
+				state pressed
+	TBButton.uniformflat.hovered
+		bitmap button_flat_outline.png
+		cut 15
+		expand 6
+	TBButton.uniformflat.pressed
+		bitmap button_flat_pressed.png
+		cut 8		
+
 	TBButton.link
 	TBButton.link
 		text-color #73FDFF
 		text-color #73FDFF
 		padding 6 8
 		padding 6 8

+ 30 - 0
Script/AtomicEditor/ui/MainToolbar.ts

@@ -9,6 +9,9 @@ import EditorUI = require("./EditorUI");
 
 
 class MainToolbar extends Atomic.UIWidget {
 class MainToolbar extends Atomic.UIWidget {
 
 
+    translateButton: Atomic.UIButton;
+    rotateButton: Atomic.UIButton;
+    scaleButton: Atomic.UIButton;
 
 
     constructor(parent: Atomic.UIWidget) {
     constructor(parent: Atomic.UIWidget) {
 
 
@@ -16,11 +19,38 @@ class MainToolbar extends Atomic.UIWidget {
 
 
         this.load("AtomicEditor/editor/ui/maintoolbar.tb.txt");
         this.load("AtomicEditor/editor/ui/maintoolbar.tb.txt");
 
 
+        this.translateButton = <Atomic.UIButton>this.getWidget("3d_translate");
+        this.rotateButton = <Atomic.UIButton>this.getWidget("3d_rotate");
+        this.scaleButton = <Atomic.UIButton>this.getWidget("3d_scale");
+
+        this.translateButton.value = 1;
+
         parent.addChild(this);
         parent.addChild(this);
 
 
+        this.subscribeToEvent("GizmoEditModeChanged", (ev) => this.handleGizmoEditModeChanged(ev));
         this.subscribeToEvent(this, "WidgetEvent", (data) => this.handleWidgetEvent(data));
         this.subscribeToEvent(this, "WidgetEvent", (data) => this.handleWidgetEvent(data));
     }
     }
 
 
+    handleGizmoEditModeChanged(ev) {
+
+        this.translateButton.value = 0;
+        this.rotateButton.value = 0;
+        this.scaleButton.value = 0;
+
+        switch (ev.mode) {
+            case 1:
+                this.translateButton.value = 1;
+                break;
+            case 2:
+                this.rotateButton.value = 1;
+                break;
+            case 3:
+                this.scaleButton.value = 1;
+                break;
+        }
+
+    }
+
     handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
     handleWidgetEvent(ev: Atomic.UIWidgetEvent) {
 
 
         if (ev.type == Atomic.UI_EVENT_TYPE_CLICK && ev.target) {
         if (ev.type == Atomic.UI_EVENT_TYPE_CLICK && ev.target) {

+ 44 - 4
Script/AtomicEditor/ui/Shortcuts.ts

@@ -16,6 +16,8 @@ class Shortcuts extends Atomic.ScriptObject {
 
 
         this.subscribeToEvent("UIShortcut", (ev: Atomic.UIShortcutEvent) => this.handleUIShortcut(ev));
         this.subscribeToEvent("UIShortcut", (ev: Atomic.UIShortcutEvent) => this.handleUIShortcut(ev));
 
 
+        this.subscribeToEvent("KeyDown", (ev: Atomic.KeyDownEvent) => this.handleKeyDown(ev));
+
 
 
     }
     }
 
 
@@ -83,18 +85,56 @@ class Shortcuts extends Atomic.ScriptObject {
         this.invokeResourceFrameShortcut("selectall");
         this.invokeResourceFrameShortcut("selectall");
     }
     }
 
 
-    invokeResourceFrameShortcut(shortcut:string) {
+    invokeGizmoMode3DTranslate() {
+
+        this.sendEvent("GizmoEditModeChanged", { mode: 1 });
+
+    }
+
+    invokeGizmoMode3DRotate() {
+
+        this.sendEvent("GizmoEditModeChanged", { mode: 2 });
+
+    }
+
+    invokeGizmoMode3DScale() {
+
+        this.sendEvent("GizmoEditModeChanged", { mode: 3 });
+
+    }
+
+    invokeResourceFrameShortcut(shortcut: string) {
         if (!ToolCore.toolSystem.project) return;
         if (!ToolCore.toolSystem.project) return;
         var resourceFrame = EditorUI.getMainFrame().resourceframe.currentResourceEditor;
         var resourceFrame = EditorUI.getMainFrame().resourceframe.currentResourceEditor;
-        if(resourceFrame) {
+        if (resourceFrame) {
             resourceFrame.invokeShortcut(shortcut);
             resourceFrame.invokeShortcut(shortcut);
         }
         }
     }
     }
 
 
+    handleKeyDown(ev: Atomic.KeyDownEvent) {
+
+        // if the right mouse buttons isn't down
+        if (!(ev.buttons & Atomic.MOUSEB_RIGHT)) {
+
+            // TODO: Make these customizable
+
+            if (ev.key == Atomic.KEY_W) {
+                this.invokeGizmoMode3DTranslate();
+            } else if (ev.key == Atomic.KEY_E) {
+                this.invokeGizmoMode3DRotate();
+            } else if (ev.key == Atomic.KEY_R) {
+                this.invokeGizmoMode3DScale();
+            }
+
+        }
+
+    }
+
     // global shortcut handler
     // global shortcut handler
     handleUIShortcut(ev: Atomic.UIShortcutEvent) {
     handleUIShortcut(ev: Atomic.UIShortcutEvent) {
+
         var cmdKey;
         var cmdKey;
-        if(Atomic.platform == "MacOSX") {
+        if (Atomic.platform == "MacOSX") {
             cmdKey = (Atomic.input.getKeyDown(Atomic.KEY_LGUI) || Atomic.input.getKeyDown(Atomic.KEY_RGUI));
             cmdKey = (Atomic.input.getKeyDown(Atomic.KEY_LGUI) || Atomic.input.getKeyDown(Atomic.KEY_RGUI));
         } else {
         } else {
             cmdKey = (Atomic.input.getKeyDown(Atomic.KEY_LCTRL) || Atomic.input.getKeyDown(Atomic.KEY_RCTRL));
             cmdKey = (Atomic.input.getKeyDown(Atomic.KEY_LCTRL) || Atomic.input.getKeyDown(Atomic.KEY_RCTRL));
@@ -113,7 +153,7 @@ class Shortcuts extends Atomic.ScriptObject {
             }
             }
             else if (ev.key == Atomic.KEY_P) {
             else if (ev.key == Atomic.KEY_P) {
                 this.invokePlay();
                 this.invokePlay();
-            //if shift is pressed
+                //if shift is pressed
             } else if (ev.qualifiers & Atomic.QUAL_SHIFT) {
             } else if (ev.qualifiers & Atomic.QUAL_SHIFT) {
                 if (ev.key == Atomic.KEY_B) {
                 if (ev.key == Atomic.KEY_B) {
                     EditorUI.getModelOps().showBuildSettings();
                     EditorUI.getModelOps().showBuildSettings();

+ 22 - 0
Script/TypeScript/AtomicWork.d.ts

@@ -44,6 +44,28 @@ declare module Atomic {
 
 
     }
     }
 
 
+    export interface KeyDownEvent {
+
+        // keycode
+        key: number;
+        //  Atomic.QUAL_SHIFT, Atomic.QUAL_CTRL, Atomic.QUAL_ALT, Atomic.QUAL_ANY
+        qualifiers: number;
+
+        // mouse buttons down
+        buttons:number;
+
+    }
+
+    export interface KeyUpEvent {
+
+        // keycode
+        key: number;
+        //  Atomic.QUAL_SHIFT, Atomic.QUAL_CTRL, Atomic.QUAL_ALT, Atomic.QUAL_ANY
+        qualifiers: number;
+        // mouse buttons down
+        buttons:number;
+              
+    }
 
 
     export interface UIShortcutEvent {
     export interface UIShortcutEvent {
 
 

+ 1 - 1
Source/AtomicEditor/Editors/SceneEditor3D/SceneView3D.cpp

@@ -187,7 +187,7 @@ void SceneView3D::MoveCamera(float timeStep)
     bool superdown = input->GetKeyDown(KEY_LGUI) || input->GetKeyDown(KEY_RGUI);
     bool superdown = input->GetKeyDown(KEY_LGUI) || input->GetKeyDown(KEY_RGUI);
 #endif
 #endif
 
 
-    if (!superdown) {
+    if (!superdown && input->GetMouseButtonDown(MOUSEB_RIGHT)) {
 
 
         // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
         // Read WASD keys and move the camera scene node to the corresponding direction if they are pressed
         // Use the Translate() function (default local space) to move relative to the node's orientation.
         // Use the Translate() function (default local space) to move relative to the node's orientation.