Files
UnrealEngineUWP/Engine/Source/Editor/Layers/Private/SLayersViewRow.cpp
Steve Robb 0756ef15b9 Delegate comparisons deprecated, lots of other associated code deprecated, and lots of warning fixups:
* Multicast delegate Add* calls now return FDelegateHandles, and Remove* calls are now all deprecated, except for a new Remove function which takes a FDelegateHandle.
* New FConsoleManager::RegisterConsoleVariableSink_Handle and UnregisterConsoleVariableSink_Handle functions which work in terms of FConsoleVariableSinkHandle.
* Timer calls which don't take FTimerHandles are deprecated.
* FTicker::AddTicker now returns an FDelegateHandle and is removed by an overloaded Remove function.
* DEFINE_ONLINE_DELEGATE* macros now define _Handle variants of the Add/Remove functions which return/take handles.
* Various other handle-based registration changes.
* Some unity build fixes.
* Some simplification of delegate code.
* Fixes for lots of existing code to use handle-based registration and unregistration.

#codereview robert.manuszewski

[CL 2400883 by Steve Robb in Main branch]
2015-01-08 09:29:27 -05:00

191 lines
5.3 KiB
C++

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#include "LayersPrivatePCH.h"
#include "SLayersViewRow.h"
#include "SInlineEditableTextBlock.h"
#define LOCTEXT_NAMESPACE "LayersView"
void SLayersViewRow::Construct(const FArguments& InArgs, TSharedRef< FLayerViewModel > InViewModel, TSharedRef< STableViewBase > InOwnerTableView)
{
ViewModel = InViewModel;
HighlightText = InArgs._HighlightText;
SMultiColumnTableRow< TSharedPtr< FLayerViewModel > >::Construct(FSuperRowType::FArguments(), InOwnerTableView);
}
SLayersViewRow::~SLayersViewRow()
{
ViewModel->OnRenamedRequest().Remove(EnterEditingModeDelegateHandle);
}
TSharedRef< SWidget > SLayersViewRow::GenerateWidgetForColumn(const FName& ColumnID)
{
TSharedPtr< SWidget > TableRowContent;
if (ColumnID == LayersView::ColumnID_LayerLabel)
{
TableRowContent =
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.AutoWidth()
.Padding(0.0f, 1.0f, 3.0f, 1.0f)
[
SNew(SImage)
.Image(FEditorStyle::GetBrush(TEXT("Layer.Icon16x")))
.ColorAndOpacity(FSlateColor::UseForeground())
]
+ SHorizontalBox::Slot()
.FillWidth(1.0f)
[
SAssignNew(InlineTextBlock, SInlineEditableTextBlock)
.Font(FEditorStyle::GetFontStyle("LayersView.LayerNameFont"))
.Text(ViewModel.Get(), &FLayerViewModel::GetNameAsText)
.ColorAndOpacity(this, &SLayersViewRow::GetColorAndOpacity)
.HighlightText(HighlightText)
.ToolTipText(LOCTEXT("DoubleClickToolTip", "Double Click to Select All Actors"))
.OnVerifyTextChanged(this, &SLayersViewRow::OnRenameLayerTextChanged)
.OnTextCommitted(this, &SLayersViewRow::OnRenameLayerTextCommitted)
.IsSelected(this, &SLayersViewRow::IsSelectedExclusively)
]
;
EnterEditingModeDelegateHandle = ViewModel->OnRenamedRequest().AddSP(InlineTextBlock.Get(), &SInlineEditableTextBlock::EnterEditingMode);
}
else if (ColumnID == LayersView::ColumnID_Visibility)
{
TableRowContent =
SAssignNew(VisibilityButton, SButton)
.ContentPadding(0)
.ButtonStyle(FEditorStyle::Get(), "NoBorder")
.OnClicked(this, &SLayersViewRow::OnToggleVisibility)
.ToolTipText(LOCTEXT("VisibilityButtonToolTip", "Toggle Layer Visibility"))
.HAlign(HAlign_Center)
.VAlign(VAlign_Center)
.Content()
[
SNew(SImage)
.Image(this, &SLayersViewRow::GetVisibilityBrushForLayer)
]
;
}
else
{
checkf(false, TEXT("Unknown ColumnID provided to SLayersView"));
}
return TableRowContent.ToSharedRef();
}
void SLayersViewRow::OnRenameLayerTextCommitted(const FText& InText, ETextCommit::Type eInCommitType)
{
if (!InText.IsEmpty())
{
ViewModel->RenameTo(*InText.ToString());
}
}
bool SLayersViewRow::OnRenameLayerTextChanged(const FText& NewText, FText& OutErrorMessage)
{
FString OutMessage;
if (!ViewModel->CanRenameTo(*NewText.ToString(), OutMessage))
{
OutErrorMessage = FText::FromString(OutMessage);
return false;
}
return true;
}
void SLayersViewRow::OnDragLeave(const FDragDropEvent& DragDropEvent)
{
TSharedPtr< FActorDragDropGraphEdOp > DragActorOp = DragDropEvent.GetOperationAs< FActorDragDropGraphEdOp >();
if (DragActorOp.IsValid())
{
DragActorOp->ResetToDefaultToolTip();
}
}
FReply SLayersViewRow::OnDragOver(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent)
{
TSharedPtr< FActorDragDropGraphEdOp > DragActorOp = DragDropEvent.GetOperationAs< FActorDragDropGraphEdOp >();
if (!DragActorOp.IsValid())
{
return FReply::Unhandled();
}
bool bCanAssign = false;
FText Message;
if (DragActorOp->Actors.Num() > 1)
{
bCanAssign = ViewModel->CanAssignActors(DragActorOp->Actors, OUT Message);
}
else
{
bCanAssign = ViewModel->CanAssignActor(DragActorOp->Actors[0], OUT Message);
}
if (bCanAssign)
{
DragActorOp->SetToolTip(FActorDragDropGraphEdOp::ToolTip_CompatibleGeneric, Message);
}
else
{
DragActorOp->SetToolTip(FActorDragDropGraphEdOp::ToolTip_IncompatibleGeneric, Message);
}
return FReply::Handled();
}
FReply SLayersViewRow::OnDrop(const FGeometry& MyGeometry, const FDragDropEvent& DragDropEvent)
{
TSharedPtr< FActorDragDropGraphEdOp > DragActorOp = DragDropEvent.GetOperationAs< FActorDragDropGraphEdOp >();
if (!DragActorOp.IsValid())
{
return FReply::Unhandled();
}
ViewModel->AddActors(DragActorOp->Actors);
return FReply::Handled();
}
FSlateColor SLayersViewRow::GetColorAndOpacity() const
{
if (!FSlateApplication::Get().IsDragDropping())
{
return FSlateColor::UseForeground();
}
bool bCanAcceptDrop = false;
TSharedPtr<FDragDropOperation> DragDropOp = FSlateApplication::Get().GetDragDroppingContent();
if (DragDropOp.IsValid() && DragDropOp->IsOfType<FActorDragDropGraphEdOp>())
{
TSharedPtr<FActorDragDropGraphEdOp> DragDropActorOp = StaticCastSharedPtr<FActorDragDropGraphEdOp>(DragDropOp);
FText Message;
bCanAcceptDrop = ViewModel->CanAssignActors(DragDropActorOp->Actors, OUT Message);
}
return (bCanAcceptDrop) ? FSlateColor::UseForeground() : FLinearColor(0.30f, 0.30f, 0.30f);
}
const FSlateBrush* SLayersViewRow::GetVisibilityBrushForLayer() const
{
if (ViewModel->IsVisible())
{
return IsHovered() ? FEditorStyle::GetBrush("Level.VisibleHighlightIcon16x") :
FEditorStyle::GetBrush("Level.VisibleIcon16x");
}
else
{
return IsHovered() ? FEditorStyle::GetBrush("Level.NotVisibleHighlightIcon16x") :
FEditorStyle::GetBrush("Level.NotVisibleIcon16x");
}
}
#undef LOCTEXT_NAMESPACE