Created
September 23, 2021 21:44
-
-
Save mikeseese/f58609a3365893ae6031c3086c7f325d to your computer and use it in GitHub Desktop.
UE5 Zenmode Toggle Shortcut - (un)docks blueprint editor panels quickly
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 70de13383528ba05238cf0471275b507358107bf Mon Sep 17 00:00:00 2001 | |
From: Mike Seese <seesemichaelj@gmail.com> | |
Date: Thu, 23 Sep 2021 14:41:44 -0700 | |
Subject: [PATCH] add toggle zen mode shortcut | |
--- | |
.../Editor/Kismet/Private/BlueprintEditor.cpp | 11 +++++++++++ | |
.../Kismet/Private/BlueprintEditorCommands.cpp | 3 +++ | |
.../Kismet/Private/BlueprintEditorCommands.h | 3 +++ | |
.../Editor/Kismet/Public/BlueprintEditor.h | 3 +++ | |
.../Framework/Docking/SDockingTabStack.cpp | 18 ++++++++++++++++++ | |
.../Framework/Docking/SDockingTabStack.h | 3 +++ | |
.../Private/Framework/Docking/TabManager.cpp | 9 +++++++++ | |
.../Public/Framework/Docking/TabManager.h | 3 +++ | |
8 files changed, 53 insertions(+) | |
diff --git a/Engine/Source/Editor/Kismet/Private/BlueprintEditor.cpp b/Engine/Source/Editor/Kismet/Private/BlueprintEditor.cpp | |
index a42704ef9aad0..7e617d5a6d4ff 100644 | |
--- a/Engine/Source/Editor/Kismet/Private/BlueprintEditor.cpp | |
+++ b/Engine/Source/Editor/Kismet/Private/BlueprintEditor.cpp | |
@@ -2843,6 +2843,10 @@ void FBlueprintEditor::CreateDefaultCommands() | |
FCanExecuteAction(), | |
FIsActionChecked::CreateLambda([]()->bool{ return GetDefault<UBlueprintEditorSettings>()->bShowActionMenuItemSignatures; })); | |
+ ToolkitCommands->MapAction(FBlueprintEditorCommands::Get().ToggleZenMode, | |
+ FExecuteAction::CreateSP(this, &FBlueprintEditor::ToggleZenMode), | |
+ FCanExecuteAction()); | |
+ | |
for (int32 QuickJumpIndex = 0; QuickJumpIndex < FGraphEditorCommands::Get().QuickJumpCommands.Num(); ++QuickJumpIndex) | |
{ | |
ToolkitCommands->MapAction( | |
@@ -2923,6 +2927,13 @@ void FBlueprintEditor::OnDumpCachedIndexDataForBlueprint() | |
} | |
} | |
+void FBlueprintEditor::ToggleZenMode() | |
+{ | |
+ TabManager->ToggleSidebar(FBlueprintEditorTabs::DetailsID); | |
+ TabManager->ToggleSidebar(FBlueprintEditorTabs::MyBlueprintID); | |
+ TabManager->ToggleSidebar(FBlueprintEditorTabs::ConstructionScriptEditorID); | |
+} | |
+ | |
void FBlueprintEditor::FindInBlueprint_Clicked() | |
{ | |
SummonSearchUI(true); | |
diff --git a/Engine/Source/Editor/Kismet/Private/BlueprintEditorCommands.cpp b/Engine/Source/Editor/Kismet/Private/BlueprintEditorCommands.cpp | |
index 42fecc4fc45d4..fd25c4380df71 100644 | |
--- a/Engine/Source/Editor/Kismet/Private/BlueprintEditorCommands.cpp | |
+++ b/Engine/Source/Editor/Kismet/Private/BlueprintEditorCommands.cpp | |
@@ -73,6 +73,9 @@ void FBlueprintEditorCommands::RegisterCommands() | |
UI_COMMAND(GenerateSearchIndex, "Generate Search Index", "Generate the search index for this blueprint.", EUserInterfaceActionType::Button, FInputChord()); | |
UI_COMMAND(DumpCachedIndexData, "Dump Cached Index Data", "Dump the cached index data for this blueprint.", EUserInterfaceActionType::Button, FInputChord()); | |
UI_COMMAND(ShowActionMenuItemSignatures, "Show Action Menu Item Signatures", "If enabled, tooltips on action menu items will show the associated action's signature id (can be used to setup custom favorites menus).", EUserInterfaceActionType::ToggleButton, FInputChord()); | |
+ | |
+ // Custom commands | |
+ UI_COMMAND(ToggleZenMode, "Toggle Zen Mode", "Toggle docking Details, My Blueprint, and Components panels.", EUserInterfaceActionType::Button, FInputChord()); | |
// SCC commands | |
UI_COMMAND( BeginBlueprintMerge, "Merge", "Shows the Blueprint merge panel and toolbar, allowing the user to resolve conflicted blueprints", EUserInterfaceActionType::Button, FInputChord() ); | |
diff --git a/Engine/Source/Editor/Kismet/Private/BlueprintEditorCommands.h b/Engine/Source/Editor/Kismet/Private/BlueprintEditorCommands.h | |
index 799b22fe3451a..2914673805c07 100644 | |
--- a/Engine/Source/Editor/Kismet/Private/BlueprintEditorCommands.h | |
+++ b/Engine/Source/Editor/Kismet/Private/BlueprintEditorCommands.h | |
@@ -75,6 +75,9 @@ class FBlueprintEditorCommands : public TCommands<FBlueprintEditorCommands> | |
TSharedPtr< FUICommandInfo > DumpCachedIndexData; | |
TSharedPtr< FUICommandInfo > ShowActionMenuItemSignatures; | |
+ // Custom commands | |
+ TSharedPtr< FUICommandInfo > ToggleZenMode; | |
+ | |
// SSC commands | |
TSharedPtr< FUICommandInfo > BeginBlueprintMerge; | |
diff --git a/Engine/Source/Editor/Kismet/Public/BlueprintEditor.h b/Engine/Source/Editor/Kismet/Public/BlueprintEditor.h | |
index 0c0a3a5e995c0..f5342f788c50c 100644 | |
--- a/Engine/Source/Editor/Kismet/Public/BlueprintEditor.h | |
+++ b/Engine/Source/Editor/Kismet/Public/BlueprintEditor.h | |
@@ -596,6 +596,9 @@ class KISMET_API FBlueprintEditor : public IBlueprintEditor, public FGCObject, p | |
/** Dumps the currently-cached index data for the blueprint to a file for debugging */ | |
void OnDumpCachedIndexDataForBlueprint(); | |
+ /** Toggle zen mode for blueprints */ | |
+ void ToggleZenMode(); | |
+ | |
/** | |
* Check to see if we can customize the SCS editor for the passed-in scene component | |
* @param InComponentToCustomize The component to check to see if a customization exists | |
diff --git a/Engine/Source/Runtime/Slate/Private/Framework/Docking/SDockingTabStack.cpp b/Engine/Source/Runtime/Slate/Private/Framework/Docking/SDockingTabStack.cpp | |
index fde92dfa537bb..172fb64de1534 100644 | |
--- a/Engine/Source/Runtime/Slate/Private/Framework/Docking/SDockingTabStack.cpp | |
+++ b/Engine/Source/Runtime/Slate/Private/Framework/Docking/SDockingTabStack.cpp | |
@@ -958,6 +958,24 @@ void SDockingTabStack::MoveForegroundTabToSidebar() | |
} | |
} | |
+void SDockingTabStack::ToggleTabSidebar(TSharedRef<SDockTab> Tab) | |
+{ | |
+ const int32 OpenedTabIndex = Tabs.IndexOfByPredicate(FTabMatcher(Tab->GetLayoutIdentifier(), ETabState::OpenedTab)); | |
+ if(OpenedTabIndex != INDEX_NONE) | |
+ { | |
+ MoveTabToSidebar(Tab); | |
+ return; | |
+ } | |
+ | |
+ const int32 SidebarTabIndex = Tabs.IndexOfByPredicate(FTabMatcher(Tab->GetLayoutIdentifier(), ETabState::SidebarTab)); | |
+ if (SidebarTabIndex != INDEX_NONE) | |
+ { | |
+ RestoreTabFromSidebar(Tab); | |
+ Tab->RequestCloseTab(); | |
+ return; | |
+ } | |
+} | |
+ | |
void SDockingTabStack::MoveTabToSidebar(TSharedRef<SDockTab> Tab) | |
{ | |
const int32 TabIndex = Tabs.IndexOfByPredicate(FTabMatcher(Tab->GetLayoutIdentifier(), ETabState::OpenedTab)); | |
diff --git a/Engine/Source/Runtime/Slate/Private/Framework/Docking/SDockingTabStack.h b/Engine/Source/Runtime/Slate/Private/Framework/Docking/SDockingTabStack.h | |
index ab7a52fcb2a8c..6a650b281663c 100644 | |
--- a/Engine/Source/Runtime/Slate/Private/Framework/Docking/SDockingTabStack.h | |
+++ b/Engine/Source/Runtime/Slate/Private/Framework/Docking/SDockingTabStack.h | |
@@ -83,6 +83,9 @@ class SLATE_API SDockingTabStack : public SDockingNode | |
/** @return true if the specified tab can be moved to a sidebar */ | |
bool CanMoveTabToSideBar(TSharedRef<SDockTab> Tab) const; | |
+ /** Toggles a specific tab from this stack to/from a sidebar */ | |
+ void ToggleTabSidebar(TSharedRef<SDockTab> Tab); | |
+ | |
/** Moves a specific tab from this stack into a sidebar */ | |
void MoveTabToSidebar(TSharedRef<SDockTab> Tab); | |
diff --git a/Engine/Source/Runtime/Slate/Private/Framework/Docking/TabManager.cpp b/Engine/Source/Runtime/Slate/Private/Framework/Docking/TabManager.cpp | |
index 3f7942e668ded..62ba64b3bbc6f 100644 | |
--- a/Engine/Source/Runtime/Slate/Private/Framework/Docking/TabManager.cpp | |
+++ b/Engine/Source/Runtime/Slate/Private/Framework/Docking/TabManager.cpp | |
@@ -2336,6 +2336,15 @@ void FTabManager::GetRecordableStats( int32& OutTabCount, TArray<TSharedPtr<SWin | |
} | |
} | |
+void FTabManager::ToggleSidebar(const FTabId & TabId) | |
+{ | |
+ TSharedPtr<SDockTab> Tab = FindExistingLiveTab(TabId); | |
+ if (Tab.IsValid() && !Tab->GetTabLabel().EqualTo(FText::GetEmpty())) | |
+ { | |
+ Tab->GetParentDockTabStack()->ToggleTabSidebar(Tab.ToSharedRef()); | |
+ } | |
+} | |
+ | |
const TSharedRef<FGlobalTabmanager>& FGlobalTabmanager::Get() | |
{ | |
static const TSharedRef<FGlobalTabmanager> Instance = FGlobalTabmanager::New(); | |
diff --git a/Engine/Source/Runtime/Slate/Public/Framework/Docking/TabManager.h b/Engine/Source/Runtime/Slate/Public/Framework/Docking/TabManager.h | |
index f56ad1884f30b..a308ccd1da754 100644 | |
--- a/Engine/Source/Runtime/Slate/Public/Framework/Docking/TabManager.h | |
+++ b/Engine/Source/Runtime/Slate/Public/Framework/Docking/TabManager.h | |
@@ -1080,6 +1080,9 @@ class SLATE_API FTabManager : public TSharedFromThis<FTabManager> | |
/** Tabs which have been temporarily put in the a sidebar */ | |
TArray<TWeakPtr<SDockTab>> TemporarilySidebaredTabs; | |
+ | |
+ public: | |
+ void ToggleSidebar(const FTabId & TabId); | |
}; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment