Here is how I’m creating the SWindow
RowWindow = SNew(SWindow)
.AutoCenter(EAutoCenter::None)
.Title(FText::FromString(TEXT("Add New Lines")))
.IsInitiallyMaximized(false)
.ScreenPosition(FVector2D(100, 100))
.CreateTitleBar(true)
.SizingRule(ESizingRule::Autosized)
.SupportsMaximize(false)
.SupportsMinimize(true)
.HasCloseButton(true)
.Style(&WindowStyle)
[
BuildEditableBox()
];
Then, called in BuildEditableBox(), I’m building the rows that populate the SWindow:
I am using “ManualWidth” to try and have the columns be wide enough for the content inside the rows. They seem to autosize based on the column name, not the content in rows below..
SAssignNew(LamsAddedRowsWidget, SListView<TSharedPtr<FLAMSWidgetRowData>>)
.ItemHeight(20)
.ScrollBarStyle(&ScrollStyle)
.ListViewStyle(&TableViewStyle)
.ListItemsSource(&DisplayArray)
.SelectionMode(ESelectionMode::Multi)
.OnGenerateRow_Raw(this, &SLAMSDataEntryWidget::MakeRowDataListViewWidget)
.OnSelectionChanged_Raw(this, &SLAMSDataEntryWidget::EntrySelectionChanged)
.OnKeyDownHandler_Raw(this, &SLAMSDataEntryWidget::OnKeyDown)
.HeaderRow(
SNew(SHeaderRow)
.Style(&HeaderStyle)
+ SHeaderRow::Column("Select").DefaultLabel(NSLOCTEXT("LAMSData", "SelectColumn", "Select")) .ManualWidth(AdjustedSize.X * 0.03)
+ SHeaderRow::Column("Section").DefaultLabel(NSLOCTEXT("LAMSData", "SectionColumn", "Section")) .ManualWidth(AdjustedSize.X * 0.1)
+ SHeaderRow::Column("SubSection").DefaultLabel(NSLOCTEXT("LAMSData", "SubSectionColumn", "SubSection")) .ManualWidth(AdjustedSize.X * 0.12)
+ SHeaderRow::Column("SubSectionType").DefaultLabel(NSLOCTEXT("LAMSData", "SubSectionTypeColumn", "SubSectionType")) .ManualWidth(AdjustedSize.X * 0.05)
+ SHeaderRow::Column("PrecedingLine").DefaultLabel(NSLOCTEXT("LAMSData", "PrecedingLineColumn", "Preceding Line")) .ManualWidth(AdjustedSize.X * 0.15)
+ SHeaderRow::Column("Character").DefaultLabel(NSLOCTEXT("LAMSData", "CharacterColumn", "Character")) .ManualWidth(AdjustedSize.X * 0.08)
+ SHeaderRow::Column("LineType").DefaultLabel(NSLOCTEXT("LAMSData", "LineTypeColumn", "Line Type")) .ManualWidth(AdjustedSize.X * 0.05)
+ SHeaderRow::Column("UniqueName").DefaultLabel(NSLOCTEXT("LAMSData", "UniqueNameColumn", "Unique Name")) .ManualWidth(AdjustedSize.X * 0.20)
+ SHeaderRow::Column("Direction").DefaultLabel(NSLOCTEXT("LAMSData", "DirectionColumn", "Direction")) .ManualWidth(AdjustedSize.X * 0.08)
+ SHeaderRow::Column("Location").DefaultLabel(NSLOCTEXT("LAMSData", "LocationColumn", "Location")) .ManualWidth(AdjustedSize.X * 0.08)
+ SHeaderRow::Column("Text").DefaultLabel(NSLOCTEXT("LAMSData", "TextColumn", "Text")) .ManualWidth(AdjustedSize.X * 0.25)
+ SHeaderRow::Column("Remove").DefaultLabel(NSLOCTEXT("LAMSData", "RemoveColumn", "Remove")) .ManualWidth(AdjustedSize.X * 0.035))
Here is how I am calculating the “AdjustedSize” member:
float DPI_Scale = -1;
FVector2D viewportSize(0, 0);
if (GEditor && MainPluginTab)
{
FIntPoint SizeXY;
FViewport* Viewport = GEditor->GetActiveViewport();
SizeXY = Viewport ? Viewport->GetSizeXY() : FIntPoint(2000,1000);
viewportSize = FVector2D(SizeXY.X, SizeXY.Y);
int32 X = FGenericPlatformMath::FloorToInt((float)SizeXY.X);
int32 Y = FGenericPlatformMath::FloorToInt((float)SizeXY.Y);
DPI_Scale = GetDefault<UUserInterfaceSettings>(UUserInterfaceSettings::StaticClass())->GetDPIScaleBasedOnSize(FIntPoint(X, Y));
}
AdjustedSize = DPI_Scale == -1 ? FVector2D(2000, 1000) : (1 / DPI_Scale) * viewportSize;