Program Listing for File ZagalaSpecFeatureDocumentView.h#

↰ Return to documentation for file (ZagalaSpecEditor/Public/Widgets/ZagalaSpecFeatureDocumentView.h)

// Copyright (c) 2026, Zagala Game Solutions. All rights reserved.

#pragma once

#include "CoreMinimal.h"
#include "Widgets/SCompoundWidget.h"
#include "Widgets/DeclarativeSyntaxSupport.h"
#include "Widgets/Views/SListView.h"
#include "Document/ZagalaSpecDocumentRow.h"

class FZagalaSpecDocumentRowRendererRegistry;

DECLARE_DELEGATE_OneParam(FZagalaSpecOnDocumentRowSelected, const FZagalaSpecDocumentRowPtr& /*Row*/);

class ZAGALASPECEDITOR_API SZagalaSpecFeatureDocumentView : public SCompoundWidget
{
public:
    static constexpr float IndentWidth = 16.f;

    SLATE_BEGIN_ARGS(SZagalaSpecFeatureDocumentView) {}
        SLATE_ARGUMENT(TSharedPtr<FZagalaSpecDocumentRowRendererRegistry>, RendererRegistry)
        SLATE_EVENT(FZagalaSpecOnDocumentRowSelected, OnRowSelected)
    SLATE_END_ARGS()


    void Construct(const FArguments& InArgs);

    void SetRows(const TArray<FZagalaSpecDocumentRowPtr>& InRows);

    const TArray<FZagalaSpecDocumentRowPtr>& GetRows() const;

    void SetSelectedRow(const FZagalaSpecDocumentRowPtr& Row);

    FZagalaSpecDocumentRowPtr GetSelectedRow() const;

private:
    TSharedRef<ITableRow> GenerateRow(FZagalaSpecDocumentRowPtr Row, const TSharedRef<STableViewBase>& OwnerTable);

    void HandleSelectionChanged(FZagalaSpecDocumentRowPtr Row, ESelectInfo::Type SelectInfo);

    bool IsRowSelectable(FZagalaSpecDocumentRowPtr Row) const;

    bool IsInSelectedSection(const FZagalaSpecDocumentRowPtr& Row) const;

    TArray<FZagalaSpecDocumentRowPtr> Rows;

    TSharedPtr<SListView<FZagalaSpecDocumentRowPtr>> ListView;

    TSharedPtr<FZagalaSpecDocumentRowRendererRegistry> RendererRegistry;

    FZagalaSpecOnDocumentRowSelected OnRowSelected;

    bool bSettingSelection = false;
};