/** Generate a widget for the specified column name */ TSharedRef<SWidget> FPListNodeDictionary::GenerateWidgetForColumn(const FName& ColumnName, int32 InDepth, ITableRow* RowPtr) { TableRow = RowPtr; check(TableRow); if(ColumnName == "PListKeyColumn") { return SNew(SBorder) .BorderImage_Static(&IPListNode::GetOverlayBrushDelegate, AsShared()) [ SNew(SOverlay) + SOverlay::Slot() [ SNew(SHorizontalBox) // Space item representing item expansion + SHorizontalBox::Slot() [ SNew(SSpacer) .Size(FVector2D(20 * InDepth, 0)) ] + SHorizontalBox::Slot() .FillWidth(1.0f) [ SAssignNew(KeyStringTextBox, SEditableTextBox) .Text(bArrayMember ? FText::FromString(FString::FromInt(ArrayIndex)) : FText::FromString(TEXT("dictionary"))) .IsReadOnly(true) ] // Spacer between type + SHorizontalBox::Slot() [ SNew(SSpacer) .Size(FVector2D(30, 0)) ] ] // Expander for innards + SOverlay::Slot() .HAlign(HAlign_Left) [ SNew(SHorizontalBox) + SHorizontalBox::Slot() [ // Space before expander SNew(SSpacer) .Size(FVector2D(20 * (InDepth - 1), 0)) ] + SHorizontalBox::Slot() [ SAssignNew(ExpanderArrow, SButton) .ButtonStyle( FEditorStyle::Get(), "NoBorder" ) .ClickMethod( EButtonClickMethod::MouseDown ) .Visibility( this, &FPListNodeDictionary::GetExpanderVisibility ) .OnClicked( this, &FPListNodeDictionary::OnArrowClicked ) .ContentPadding(2.1f) .ForegroundColor( FSlateColor::UseForeground() ) [ SNew(SImage) .Image( this, &FPListNodeDictionary::GetExpanderImage ) .ColorAndOpacity( FSlateColor::UseForeground() ) ] ] ] ]; } else if(ColumnName == "PListValueTypeColumn") { return SNew(SBorder) .BorderImage_Static(&IPListNode::GetOverlayBrushDelegate, AsShared()) [ SNew(STextBlock) .Text(NSLOCTEXT("PListEditor", "dictionaryValueTypeLabel", "dictionary")) ]; } else if(ColumnName == "PListValueColumn") { return SNew(SBorder) .BorderImage_Static(&IPListNode::GetOverlayBrushDelegate, AsShared()) [ SAssignNew(InfoTextWidget, STextBlock) .Text(FText::Format(NSLOCTEXT("PListEditor", "NumKeyValuePairsFmt", "[{0} key/value pairs]"), FText::AsNumber(GetNumPairs()))) ]; } // Invalid column name else { return SNew(STextBlock) .Text(NSLOCTEXT("PListEditor", "UnknownColumn", "Unknown Column")); } }
/** Refreshes anything necessary in the node, such as a text used in information displaying */ void FPListNodeFile::Refresh() { // Refresh internals for(int32 i = 0; i < Children.Num(); ++i) { Children[i]->Refresh(); } // Calculate how many contained key/value pairs exist if(TextWidget.IsValid()) { TextWidget->SetText(FText::Format(NSLOCTEXT("PListEditor", "FileAndNumKeyValuePairsFmt", "file [{0} key/value pairs]"), FText::AsNumber(GetNumPairs()))); } }
/** Refreshes anything necessary in the node, such as a text used in information displaying */ void FPListNodeDictionary::Refresh() { // Update the display of the number of key/value pairs if(InfoTextWidget.IsValid()) { InfoTextWidget->SetText(FText::Format(NSLOCTEXT("PListEditor", "NumKeyValuePairsFmt", "[{0} key/value pairs]"), FText::AsNumber(GetNumPairs()))); } // Refresh all children for(int32 i = 0; i < Children.Num(); ++i) { Children[i]->Refresh(); } // Refresh my own display of my index if(bArrayMember) { if(KeyStringTextBox.IsValid()) { KeyStringTextBox->SetText(FText::FromString(FString::FromInt(ArrayIndex))); } } }
/** Generates a widget for a TableView row */ TSharedRef<ITableRow> FPListNodeFile::GenerateWidget(const TSharedRef<STableViewBase>& OwnerTable) { return SNew(STableRow<TSharedPtr<ITableRow> >, OwnerTable) .Content() [ SNew(SHorizontalBox) +SHorizontalBox::Slot() .AutoWidth() .Padding(2, 1) [ SAssignNew(TextWidget, STextBlock) .Text(FText::Format(NSLOCTEXT("PListEditor", "FileAndNumKeyValuePairsFmt", "file [{0} key/value pairs]"), FText::AsNumber(GetNumPairs()))) ] ]; }