Files
UnrealEngineUWP/Engine/Source/Editor/LevelEditor/Private/LevelViewportLayoutOnePane.cpp

74 lines
2.0 KiB
C++
Raw Normal View History

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#ttp 323891 - EDITOR: Viewport Layouts: Please add a 1x1 viewport preset layout option #branch UE4 #proj Editor.LevelEditor #summary Added 1x1 viewport layout and tidied the margins in the layout menu #add Added FLevelViewportLayout::bIsMaximizeSupported and public getter IsMaximizeSupported(). This is set on the new one-pane layout to block the maximize command/button. #add LevelViewportConfigurationNames::OnePane - new named layout config. #add FLevelViewportCommands::ViewportConfig_OnePane - new layout command. #change FLevelViewportLayout::InitCommonLayoutFromString() - will never start a layout maximised if bIsMaximizeSupported is false. #change FLevelViewportLayout::SaveCommonLayoutString() - will never save a layout maximised if bIsMaximizeSupported is false. #change FLevelViewportLayout::MaximizeViewport() - checks that bIsMaximizeSupported is true as it should never be called on a layout that doesn't support it. #add SlateEditorStyle - added brushes for one pane option in the viewport layout menu. #add SLevelViewportToolBar::GenerateViewportConfigsMenu() - new section for one pane layouts with the one pane button in it. #change SLevelViewportToolBar::GenerateViewportConfigsMenu() - fixed the layout margins by setting the label visibility to collapsed instead of passing an empty string as the label. #add Binding new ViewportConfig_OnePane command SLevelViewport::BindViewCommands to OnSetViewportConfiguration(). #change SLevelViewport::GetMaximizeToggleVisibility() & OnToggleMaximize - check IsMaximizeSupported() on the parent layout and always collapses the maximize button when it isn't supported. #add FLevelViewportTabContent::ConstructViewportLayoutByTypeName() - added LevelViewportConfigurationNames::OnePane. #add New icon image for one pane button in the menu - ViewportLayout_OnePane.png #add New layout class FLevelViewportLayoutOnePane - based on other layouts but simpler because it only contains one pane and therefore no splitters. reviewedby Thomas.Sarkanen, Max.Preussner [CL 2048729 by Chris Wood in Main branch]
2014-04-23 19:20:45 -04:00
#include "LevelEditor.h"
#include "LevelViewportLayoutOnePane.h"
#include "SLevelViewport.h"
// FLevelViewportLayoutOnePane /////////////////////////////
void FLevelViewportLayoutOnePane::SaveLayoutString(const FString& LayoutString) const
{
if (!bIsTransitioning)
{
FString SpecificLayoutString = GetTypeSpecificLayoutString(LayoutString);
SaveCommonLayoutString(SpecificLayoutString);
}
}
TSharedRef<SWidget> FLevelViewportLayoutOnePane::MakeViewportLayout(const FString& LayoutString)
{
// single viewport layout blocks maximize feature as it doesn't make sense
bIsMaximizeSupported = false;
FString SpecificLayoutString = GetTypeSpecificLayoutString(LayoutString);
FEngineShowFlags OrthoShowFlags(ESFIM_Editor);
ApplyViewMode(VMI_BrushWireframe, false, OrthoShowFlags);
FEngineShowFlags PerspectiveShowFlags(ESFIM_Editor);
ApplyViewMode(VMI_Lit, true, PerspectiveShowFlags);
FString ViewportKey;
if (!SpecificLayoutString.IsEmpty())
{
ViewportKey = SpecificLayoutString + TEXT(".Viewport0");
}
TSharedPtr<SLevelViewport> ViewportWidget;
ViewportBox =
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
[
SAssignNew(ViewportWidget, SLevelViewport)
.ViewportType(LVT_Perspective)
.Realtime(true)
.ParentLayout(AsShared())
.ParentLevelEditor(ParentLevelEditor)
.ConfigKey(ViewportKey)
];
Viewports.Add(ViewportWidget);
// Make newly-created perspective viewports active by default
GCurrentLevelEditingViewportClient = &ViewportWidget->GetLevelViewportClient();
InitCommonLayoutFromString(SpecificLayoutString);
return StaticCastSharedRef<SWidget>(ViewportBox.ToSharedRef());
}
void FLevelViewportLayoutOnePane::ReplaceWidget(TSharedRef<SWidget> Source, TSharedRef<SWidget> Replacement)
{
check(ViewportBox->GetChildren()->Num() == 1)
TSharedRef<SWidget> ViewportWidget = ViewportBox->GetChildren()->GetChildAt(0);
check(ViewportWidget == Source);
ViewportBox->RemoveSlot(Source);
ViewportBox->AddSlot()
[
Replacement
];
}