199 lines
5.2 KiB
C++
199 lines
5.2 KiB
C++
#include "MainWindow.h"
|
|
|
|
#include "IChildWindow.h"
|
|
#include "SBackgroundBlur.h"
|
|
#include "SChildWindow.h"
|
|
#include "SMainWindowHeader.h"
|
|
#include "SConstraintCanvas.h"
|
|
#include "SlateApplication.h"
|
|
#include "SMainWindow.h"
|
|
#include "SWindow.h"
|
|
#include "SWindowTitleBar.h"
|
|
#include "WaveformViewer.h"
|
|
#include "ChannelRack/ChannelRack.h"
|
|
#include "Thread/MainThreadEventList.h"
|
|
#include "Thread/ThreadMessage.h"
|
|
#include "Mixer/SMixer.h"
|
|
#include "PlayList/SPlayList.h"
|
|
|
|
#define LOCTEXT_NAMESPACE "Arona"
|
|
|
|
DECLARE_THREAD_MESSAGE(FMainThreadEventList, PostCreateChildWindow,
|
|
FMainWindow* Window;
|
|
TSharedPtr<SChildWindow> ChildWindow;
|
|
)
|
|
{
|
|
Args.Window->FrontChildWindow(Args.ChildWindow);
|
|
}
|
|
|
|
void FMainWindow::Init()
|
|
{
|
|
auto NewTab = SNew(SDockTab);
|
|
TabManager = FGlobalTabmanager::Get()->NewTabManager(NewTab);
|
|
TArray<FName> TabNames = {"Tab0", "Tab1", "Tab2"};
|
|
auto Layout = FTabManager::NewLayout(TEXT("TestLayout"))
|
|
->AddArea(
|
|
FTabManager::NewPrimaryArea()
|
|
->SetOrientation(Orient_Horizontal)
|
|
->Split(
|
|
FTabManager::NewStack()
|
|
->AddTab(TabNames[0], ETabState::Type::OpenedTab)
|
|
)
|
|
->Split(
|
|
FTabManager::NewStack()
|
|
->AddTab(TabNames[1], ETabState::Type::OpenedTab)
|
|
)
|
|
);
|
|
|
|
TabManager->RegisterTabSpawner(TabNames[0], FOnSpawnTab::CreateLambda([](const FSpawnTabArgs& Args) -> TSharedRef<SDockTab>
|
|
{
|
|
return SNew(SDockTab)
|
|
.TabRole(ETabRole::NomadTab)
|
|
[
|
|
SNew(SButton)
|
|
];
|
|
}));
|
|
|
|
TabManager->RegisterTabSpawner(TabNames[1], FOnSpawnTab::CreateRaw(this, &FMainWindow::CreatePlayListTab));
|
|
|
|
|
|
MainWindow = SNew(SMainWindow)
|
|
.CreateTitleBar(false)
|
|
.AutoCenter(EAutoCenter::PrimaryWorkArea)
|
|
.ClientSize(FVector2D(1270, 720));
|
|
|
|
const auto WindowTitleBar = SNew(SWindowTitleBar, MainWindow.ToSharedRef(), nullptr, EHorizontalAlignment::HAlign_Fill)
|
|
.ShowAppIcon(false);
|
|
|
|
MainWindow->SetTitleBar(WindowTitleBar);
|
|
MainWindow->SetContent(
|
|
SNew(SVerticalBox)
|
|
+SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
[
|
|
WindowTitleBar
|
|
]
|
|
+SVerticalBox::Slot()
|
|
.AutoHeight()
|
|
[
|
|
SNew(SMainWindowHeader)
|
|
.OnChannelRackClicked_Raw(this, &FMainWindow::ToggleChannelRack)
|
|
.OnMixerClicked_Raw(this, &FMainWindow::ToggleMixer)
|
|
]
|
|
+SVerticalBox::Slot()
|
|
[
|
|
SNew(SOverlay)
|
|
+SOverlay::Slot()
|
|
[
|
|
TabManager->RestoreFrom(Layout, MainWindow).ToSharedRef()
|
|
]
|
|
+SOverlay::Slot()
|
|
[
|
|
SAssignNew(MainWindowCanvas, SConstraintCanvas)
|
|
]
|
|
+SOverlay::Slot()
|
|
[
|
|
SNew(SHorizontalBox)
|
|
+SHorizontalBox::Slot()
|
|
[
|
|
SNew(SWaveformViewer)
|
|
.Visibility(EVisibility::SelfHitTestInvisible)
|
|
].FillWidth(1.f)
|
|
// +SHorizontalBox::Slot()
|
|
// [
|
|
// SNew(SWaveformViewer)
|
|
// .Visibility(EVisibility::SelfHitTestInvisible)
|
|
// ].FillWidth(1.f)
|
|
]
|
|
]
|
|
);
|
|
|
|
FSlateApplication::Get().AddWindow(MainWindow.ToSharedRef());
|
|
|
|
InitChildWindow();
|
|
}
|
|
|
|
TSharedPtr<SChildWindow> FMainWindow::CreateChildWindow(FVector2D Size, FString Title, TSharedPtr<IChildWindow> Content, bool IsSingletonWindow)
|
|
{
|
|
auto* PanelChildren = static_cast<TPanelChildren<SConstraintCanvas::FSlot>*>(MainWindowCanvas->GetChildren());
|
|
|
|
TSharedPtr<SChildWindow> Out;
|
|
auto Slot = MainWindowCanvas->AddSlot();
|
|
Slot.ZOrder(PanelChildren->Num() + 2);
|
|
Slot.AttachWidget(SAssignNew(Out, SChildWindow, Slot.GetSlot())
|
|
.IsSingletonWindow(IsSingletonWindow)
|
|
.Title(Title)
|
|
.ResizeHandleSize(FVector2D(16, 16))
|
|
.Content(Content)
|
|
);
|
|
|
|
Slot.Offset(FMargin(0, 0, Size.X, Size.Y));
|
|
|
|
PUSH_THREAD_EVENT(PostCreateChildWindow, this, Out);
|
|
return Out;
|
|
}
|
|
|
|
void FMainWindow::FrontChildWindow(TSharedPtr<SChildWindow> ChildWindow)
|
|
{
|
|
const auto& PanelChildren = MainWindowCanvas->GetPanelChildren();
|
|
const TArray<TUniquePtr<SConstraintCanvas::FSlot>>& Children = PanelChildren.GetAllChildren();
|
|
for (auto& Slot : Children)
|
|
{
|
|
Slot->SetZOrder(Slot->GetZOrder() - 1);
|
|
}
|
|
ChildWindow->GetSlot()->SetZOrder(PanelChildren.Num());
|
|
FWidgetPath WidgetPath;
|
|
|
|
const TSharedPtr<SWidget> FocusWidget = ChildWindow->Content->GetFocusWidget();
|
|
if (FocusWidget.IsValid())
|
|
{
|
|
FSlateApplication::Get().SetAllUserFocus(FocusWidget);
|
|
FSlateApplication::Get().SetKeyboardFocus(FocusWidget);
|
|
}
|
|
else
|
|
{
|
|
FSlateApplication::Get().SetAllUserFocus(ChildWindow->Content->GetWidget());
|
|
FSlateApplication::Get().SetKeyboardFocus(ChildWindow->Content->GetWidget());
|
|
}
|
|
}
|
|
|
|
TSharedPtr<SChannelRack> FMainWindow::GetChannelRack()
|
|
{
|
|
return ChannelRack;
|
|
}
|
|
|
|
TSharedRef<SDockTab> FMainWindow::CreatePlayListTab(const FSpawnTabArgs& Args)
|
|
{
|
|
return SNew(SDockTab)
|
|
.TabRole(ETabRole::NomadTab)
|
|
.Label(LOCTEXT("PlayListTabTitle", "PlayList"))
|
|
[
|
|
SNew(SPlayList)
|
|
];
|
|
}
|
|
|
|
void FMainWindow::InitChildWindow()
|
|
{
|
|
ChannelRackWindow = CreateChildWindow(FVector2D(300, 600), "ChannelRack", SAssignNew(ChannelRack, SChannelRack), true);
|
|
MixerWindow = CreateChildWindow(FVector2D(600, 400), "Mixer", SNew(SMixer), true);
|
|
}
|
|
|
|
void FMainWindow::ToggleChildWindow(TSharedPtr<SChildWindow> ChildWindow)
|
|
{
|
|
if (ChildWindow->GetVisibility() != EVisibility::Visible)
|
|
ChildWindow->SetVisibility(EVisibility::Visible);
|
|
else
|
|
ChildWindow->SetVisibility(EVisibility::Collapsed);
|
|
}
|
|
|
|
void FMainWindow::ToggleChannelRack()
|
|
{
|
|
ToggleChildWindow(ChannelRackWindow);
|
|
}
|
|
|
|
void FMainWindow::ToggleMixer()
|
|
{
|
|
ToggleChildWindow(MixerWindow);
|
|
}
|
|
#undef LOCTEXT_NAMESPACE
|