100 lines
2.3 KiB
C++
100 lines
2.3 KiB
C++
// Fill out your copyright notice in the Description page of Project Settings.
|
|
|
|
|
|
#include "SMixerEffectItem.h"
|
|
|
|
#include "MultiBoxBuilder.h"
|
|
#include "SButton.h"
|
|
#include "SlateApplication.h"
|
|
#include "SlateOptMacros.h"
|
|
#include "PluginHost/PluginHost.h"
|
|
#include "Singleton/PluginHostList.h"
|
|
#include "Widgets/SBoxPanel.h"
|
|
#include "UI/Widget/WindowManager.h"
|
|
#include "UI/Widget/ChannelInterface/SPluginHostChannelInterface.h"
|
|
|
|
BEGIN_SLATE_FUNCTION_BUILD_OPTIMIZATION
|
|
|
|
#define LOCTEXT_NAMESPACE "SMixer"
|
|
|
|
void SMixerEffectItem::Construct(const FArguments& InArgs, FPluginHost* InPluginHost)
|
|
{
|
|
PluginHost = InPluginHost;
|
|
|
|
ChildSlot
|
|
[
|
|
SNew(SHorizontalBox)
|
|
+SHorizontalBox::Slot()
|
|
.FillWidth(1.f)
|
|
[
|
|
SNew(SButton)
|
|
.Text(FText::FromString(PluginHost->Name))
|
|
.OnClicked(this, &SMixerEffectItem::OnButtonClicked)
|
|
]
|
|
+SHorizontalBox::Slot()
|
|
.AutoWidth()
|
|
[
|
|
SAssignNew(MenuAnchor, SMenuAnchor)
|
|
.OnGetMenuContent(this, &SMixerEffectItem::CreateChannelInterfaceMenu)
|
|
[
|
|
SNew(SButton)
|
|
.Text(FText::FromString("X"))
|
|
.OnClicked(this, &SMixerEffectItem::OnChannelInterfaceClicked)
|
|
]
|
|
]
|
|
];
|
|
}
|
|
|
|
FReply SMixerEffectItem::OnMouseButtonUp(const FGeometry& MyGeometry, const FPointerEvent& MouseEvent)
|
|
{
|
|
if (MouseEvent.GetEffectingButton() == EKeys::RightMouseButton)
|
|
{
|
|
ShowMenu();
|
|
}
|
|
return FReply::Handled();
|
|
}
|
|
|
|
FReply SMixerEffectItem::OnButtonClicked()
|
|
{
|
|
FWindowManager::Get().TogglePluginEditor(PluginHost);
|
|
return FReply::Handled();
|
|
}
|
|
|
|
FReply SMixerEffectItem::OnChannelInterfaceClicked()
|
|
{
|
|
MenuAnchor->SetIsOpen(true);
|
|
return FReply::Handled();
|
|
}
|
|
|
|
TSharedRef<SWidget> SMixerEffectItem::CreateChannelInterfaceMenu()
|
|
{
|
|
return SNew(SPluginHostChannelInterface, PluginHost);
|
|
}
|
|
|
|
void SMixerEffectItem::ShowMenu()
|
|
{
|
|
FMenuBuilder MenuBuilder(true, nullptr);
|
|
// Delete effect
|
|
MenuBuilder.AddMenuEntry(
|
|
LOCTEXT("DeleteEffect", "删除效果器"),
|
|
LOCTEXT("DeleteEffectTooltip", "从混音轨道中删除该效果。"),
|
|
FSlateIcon(),
|
|
FUIAction(
|
|
FExecuteAction::CreateLambda([this]()
|
|
{
|
|
FPluginHostList::Get().RemovePluginHost(PluginHost);
|
|
})
|
|
)
|
|
);
|
|
FSlateApplication::Get().PushMenu(
|
|
AsShared(),
|
|
FWidgetPath(),
|
|
MenuBuilder.MakeWidget(),
|
|
FSlateApplication::Get().GetCursorPos(),
|
|
FPopupTransitionEffect(FPopupTransitionEffect::ContextMenu)
|
|
);
|
|
}
|
|
|
|
END_SLATE_FUNCTION_BUILD_OPTIMIZATION
|
|
#undef LOCTEXT_NAMESPACE
|