Allow editor modes to override if they allow the viewport to use a drag tool or not

[CL 2287161 by Matt Kuhlenschmidt in Main branch]
This commit is contained in:
Matt Kuhlenschmidt
2014-09-05 20:14:52 -04:00
committed by UnrealBot
parent 4f9ee1e529
commit 4055550174
5 changed files with 24 additions and 1 deletions

View File

@@ -1567,6 +1567,16 @@ bool FEditorModeTools::EndTracking(FEditorViewportClient* InViewportClient, FVie
return bTransactionHandled;
}
bool FEditorModeTools::AllowsViewportDragTool() const
{
bool bCanUseDragTool = false;
for (const TSharedPtr<FEdMode>& Mode : Modes)
{
bCanUseDragTool |= Mode->AllowsViewportDragTool();
}
return bCanUseDragTool;
}
/** Notifies all active modes that a map change has occured */
void FEditorModeTools::MapChangeNotify()
{

View File

@@ -3101,6 +3101,11 @@ TSharedPtr<FDragTool> FEditorViewportClient::MakeDragTool(EDragTool::Type)
return MakeShareable( new FDragTool );
}
bool FEditorViewportClient::CanUseDragTool() const
{
return !ShouldOrbitCamera() && GetCurrentWidgetAxis() == EAxisList::None && (!ModeTools || ModeTools->AllowsViewportDragTool());
}
bool FEditorViewportClient::ShouldOrbitCamera() const
{
if( bCameraLock )

View File

@@ -316,7 +316,7 @@ void FMouseDeltaTracker::ConditionalBeginUsingDragTool( FEditorViewportClient* I
if( bEnoughMouseMovement )
{
const bool bCanDrag = !InViewportClient->ShouldOrbitCamera() && InViewportClient->GetCurrentWidgetAxis() == EAxisList::None && !DragTool.IsValid() && !RightMouseButtonDown;
const bool bCanDrag = !DragTool.IsValid() && !RightMouseButtonDown && InViewportClient->CanUseDragTool();
if (bCanDrag && !bHasAttemptedDragTool)
{

View File

@@ -249,6 +249,9 @@ public:
/** Check to see if an actor can be selected in this mode - no side effects */
virtual bool IsSelectionAllowed( AActor* InActor, bool bInSelection ) const { return true; }
/** @return True if this mode allows the viewport to use a drag tool */
virtual bool AllowsViewportDragTool() const { return true; }
/** Returns the editor mode identifier. */
FEditorModeID GetID() const { return Info.ID; }
@@ -547,6 +550,8 @@ public:
bool EndTracking(FEditorViewportClient* InViewportClient, FViewport* InViewport);
bool IsTracking() const { return bIsTracking; }
bool AllowsViewportDragTool() const;
/** Notifies all active modes that a map change has occured */
void MapChangeNotify();

View File

@@ -611,6 +611,9 @@ public:
*/
virtual TSharedPtr<class FDragTool> MakeDragTool( EDragTool::Type DragToolType );
/** @return true if a drag tool can be used */
bool CanUseDragTool() const;
/** @return Whether or not to orbit the camera */
virtual bool ShouldOrbitCamera() const ;