Эх сурвалжийг харах

Improvements to drag and drop

Josh Engebretson 10 жил өмнө
parent
commit
699c14c931

+ 7 - 1
Script/AtomicEditor/ui/HierarchyFrame.ts

@@ -112,7 +112,13 @@ class HierarchyFrame extends Atomic.UIWidget {
 
 
         this.hierList.deleteItemByID(node.id.toString());
         this.hierList.deleteItemByID(node.id.toString());
 
 
-        this.sendEvent(EditorEvents.ActiveNodeChange, { node: ev.parent ? ev.parent : this.scene });
+        var selectedId = Number(this.hierList.rootList.selectedItemID);
+        var selectedNode = this.scene.getNode(selectedId);
+        if (selectedNode == node) {
+
+          this.sendEvent(EditorEvents.ActiveNodeChange, { node: ev.parent ? ev.parent : this.scene });
+
+        }
 
 
     }
     }
 
 

+ 4 - 1
Source/Atomic/UI/UIDragDrop.cpp

@@ -174,11 +174,14 @@ void UIDragDrop::HandleMouseMove(StringHash eventType, VariantMap& eventData)
         tbw = tbw->GetParent();
         tbw = tbw->GetParent();
     }
     }
 
 
-    if (!tbw)
+    if (!tbw || !tbw->GetParent())
         return;
         return;
 
 
     UIWidget* hoverWidget = (UIWidget*) tbw->GetDelegate();
     UIWidget* hoverWidget = (UIWidget*) tbw->GetDelegate();
 
 
+    if (!hoverWidget->GetInternalWidget())
+        return;
+
     if (hoverWidget != currentTargetWidget_)
     if (hoverWidget != currentTargetWidget_)
     {
     {
         if (currentTargetWidget_)
         if (currentTargetWidget_)

+ 42 - 19
Source/AtomicEditorWork/Editors/SceneEditor3D/SceneView3D.cpp

@@ -153,6 +153,8 @@ void SceneView3D::MoveCamera(float timeStep)
     // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
     // Use this frame's mouse motion to adjust camera node yaw and pitch. Clamp the pitch between -90 and 90 degrees
     if (input->GetMouseButtonDown(MOUSEB_RIGHT))
     if (input->GetMouseButtonDown(MOUSEB_RIGHT))
     {
     {
+
+        SetFocus();
         IntVector2 mouseMove = input->GetMouseMove();
         IntVector2 mouseMove = input->GetMouseMove();
         yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
         yaw_ += MOUSE_SENSITIVITY * mouseMove.x_;
         pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
         pitch_ += MOUSE_SENSITIVITY * mouseMove.y_;
@@ -177,16 +179,37 @@ void SceneView3D::MoveCamera(float timeStep)
     //Quaternion q = cameraNode_->GetWorldRotation();
     //Quaternion q = cameraNode_->GetWorldRotation();
     //LOGINFOF("%f %f %f : %f %f %f %f", pos.x_, pos.y_, pos.z_, q.x_, q.y_, q.z_, q.w_ );
     //LOGINFOF("%f %f %f : %f %f %f %f", pos.x_, pos.y_, pos.z_, q.x_, q.y_, q.z_, q.w_ );
 
 
-    // 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.
-    if (input->GetKeyDown('W'))
-        cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
-    if (input->GetKeyDown('S'))
-        cameraNode_->Translate(Vector3::BACK * MOVE_SPEED * timeStep);
-    if (input->GetKeyDown('A'))
-        cameraNode_->Translate(Vector3::LEFT * MOVE_SPEED * timeStep);
-    if (input->GetKeyDown('D'))
-        cameraNode_->Translate(Vector3::RIGHT * MOVE_SPEED * timeStep);
+#ifdef ATOMIC_PLATFORM_WINDOWS
+    bool superdown = input->GetKeyDown(KEY_LCTRL) || input->GetKeyDown(KEY_RCTRL);
+#else
+    bool superdown = input->GetKeyDown(KEY_LGUI) || input->GetKeyDown(KEY_RGUI);
+#endif
+
+    if (!superdown) {
+
+        // 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.
+        if (input->GetKeyDown('W'))
+        {
+            SetFocus();
+            cameraNode_->Translate(Vector3::FORWARD * MOVE_SPEED * timeStep);
+        }
+        if (input->GetKeyDown('S'))
+        {
+            SetFocus();
+            cameraNode_->Translate(Vector3::BACK * MOVE_SPEED * timeStep);
+        }
+        if (input->GetKeyDown('A'))
+        {   SetFocus();
+            cameraNode_->Translate(Vector3::LEFT * MOVE_SPEED * timeStep);
+        }
+        if (input->GetKeyDown('D'))
+        {
+            SetFocus();
+            cameraNode_->Translate(Vector3::RIGHT * MOVE_SPEED * timeStep);
+        }
+
+    }
 }
 }
 
 
 Ray SceneView3D::GetCameraRay()
 Ray SceneView3D::GetCameraRay()
@@ -270,6 +293,8 @@ void SceneView3D::HandlePostRenderUpdate(StringHash eventType, VariantMap& event
 
 
     if (input->GetMouseButtonPress(MOUSEB_LEFT))
     if (input->GetMouseButtonPress(MOUSEB_LEFT))
     {
     {
+        SetFocus();
+
         if (!mouseMoved_ && !sceneEditor_->GetGizmo()->Selected())
         if (!mouseMoved_ && !sceneEditor_->GetGizmo()->Selected())
         {
         {
             Ray camRay  = GetCameraRay();
             Ray camRay  = GetCameraRay();
@@ -518,9 +543,6 @@ void SceneView3D::HandleDragExitWidget(StringHash eventType, VariantMap& eventDa
     if (dragNode_.NotNull())
     if (dragNode_.NotNull())
     {
     {
         scene_->RemoveChild(dragNode_);
         scene_->RemoveChild(dragNode_);
-        VariantMap neventData;
-        neventData[EditorActiveNodeChange::P_NODE] = (RefCounted*) 0;
-        SendEvent(E_EDITORACTIVENODECHANGE, neventData);
     }
     }
 
 
     dragAssetGUID_ = "";
     dragAssetGUID_ = "";
@@ -534,6 +556,13 @@ void SceneView3D::HandleDragEnded(StringHash eventType, VariantMap& eventData)
 
 
     UIDragObject* dragObject = static_cast<UIDragObject*>(eventData[P_DRAGOBJECT].GetPtr());
     UIDragObject* dragObject = static_cast<UIDragObject*>(eventData[P_DRAGOBJECT].GetPtr());
 
 
+    if (dragNode_.NotNull())
+    {
+        VariantMap neventData;
+        neventData[EditorActiveNodeChange::P_NODE] = dragNode_;
+        SendEvent(E_EDITORACTIVENODECHANGE, neventData);
+    }
+
     if (dragObject && dragObject->GetObject()->GetType() == ToolCore::Asset::GetTypeStatic())
     if (dragObject && dragObject->GetObject()->GetType() == ToolCore::Asset::GetTypeStatic())
     {
     {
         Asset* asset = (ToolCore::Asset*) dragObject->GetObject();
         Asset* asset = (ToolCore::Asset*) dragObject->GetObject();
@@ -570,12 +599,6 @@ void SceneView3D::HandleDragEnded(StringHash eventType, VariantMap& eventData)
 
 
     }
     }
 
 
-    if (dragNode_.NotNull())
-    {
-        VariantMap neventData;
-        neventData[EditorActiveNodeChange::P_NODE] = dragNode_;
-        SendEvent(E_EDITORACTIVENODECHANGE, neventData);
-    }
     dragAssetGUID_ = "";
     dragAssetGUID_ = "";
     dragNode_ = 0;
     dragNode_ = 0;
 }
 }

+ 2 - 0
Source/ThirdParty/TurboBadger/tb_widgets.cpp

@@ -95,6 +95,8 @@ TBWidget::~TBWidget()
     if (m_delegate)
     if (m_delegate)
         m_delegate->OnDelete();
         m_delegate->OnDelete();
 
 
+    m_delegate = NULL;
+
 	TBWidgetListener::InvokeWidgetDelete(this);
 	TBWidgetListener::InvokeWidgetDelete(this);
 	DeleteAllChildren();
 	DeleteAllChildren();