#include "PS_Editor_MainWidget.h"
#include "Components/TextBlock.h"
#include "Components/VerticalBox.h"
#include "Components/VerticalBoxSlot.h"
#include "Components/Border.h"
#include "Widgets/SBoxPanel.h"
#include "Widgets/Text/STextBlock.h"
#include "Widgets/Layout/SBorder.h"
#include "Widgets/SOverlay.h"

TSharedRef<SWidget> UPS_Editor_MainWidget::RebuildWidget()
{
	// Build the widget tree using Slate (C++ driven UMG)
	return SNew(SOverlay)
		// Top bar
		+ SOverlay::Slot()
		.HAlign(HAlign_Left)
		.VAlign(VAlign_Top)
		.Padding(16.0f)
		[
			SNew(SBorder)
			.BorderBackgroundColor(FLinearColor(0.05f, 0.05f, 0.05f, 0.85f))
			.Padding(FMargin(12.0f, 8.0f))
			[
				SNew(SHorizontalBox)
				+ SHorizontalBox::Slot()
				.AutoWidth()
				.VAlign(VAlign_Center)
				[
					SNew(STextBlock)
					.Text(FText::FromString(TEXT("PS Editor")))
					.ColorAndOpacity(FLinearColor(0.2f, 0.7f, 1.0f, 1.0f))
					.Font(FCoreStyle::GetDefaultFontStyle("Bold", 14))
				]
				+ SHorizontalBox::Slot()
				.AutoWidth()
				.VAlign(VAlign_Center)
				.Padding(12.0f, 0.0f, 0.0f, 0.0f)
				[
					SNew(STextBlock)
					.Text(FText::FromString(TEXT("Edit Mode")))
					.ColorAndOpacity(FLinearColor(0.7f, 0.7f, 0.7f, 1.0f))
					.Font(FCoreStyle::GetDefaultFontStyle("Regular", 11))
				]
			]
		]
		// Bottom help bar
		+ SOverlay::Slot()
		.HAlign(HAlign_Center)
		.VAlign(VAlign_Bottom)
		.Padding(16.0f)
		[
			SNew(SBorder)
			.BorderBackgroundColor(FLinearColor(0.05f, 0.05f, 0.05f, 0.75f))
			.Padding(FMargin(16.0f, 6.0f))
			[
				SNew(STextBlock)
				.Text(FText::FromString(TEXT("LMB: Pan | RMB: Fly (ZQSD) | Alt+LMB / MMB: Orbit | E/A: Up/Down | Scroll: Zoom")))
				.ColorAndOpacity(FLinearColor(0.6f, 0.6f, 0.6f, 1.0f))
				.Font(FCoreStyle::GetDefaultFontStyle("Regular", 10))
			]
		];
}

void UPS_Editor_MainWidget::NativeConstruct()
{
	Super::NativeConstruct();
}
