#ifndef DATA_OUTPUT_TABLE_HPP_
#define DATA_OUTPUT_TABLE_HPP_

#include <functional>
#include <optional>

#include <Widget/Layout/CompoundWidget/CompoundWidget.hpp>
#include <Widget/Layout/Column/Column.hpp>
#include <Widget/Layout/Center/Center.hpp>
#include <Widget/Label/Label.hpp>
#include <Widget/Layout/Column/HorizontalSeparator/HorizontalSeparator.hpp>
#include <Widget/Panel/Panel.hpp>
#include <Widget/Layout/CompoundWidget/DataChannelPicker/DataChannelPicker.hpp>
#include <Widget/Layout/ScrollPanel/ScrollPanel.hpp>
#include <Widget/Layout/Margin/Margin.hpp>

/**
 * @brief The data output table widget.
 */
class DataOutputTable : public CompoundWidget
{
private:
    static constexpr int naturalHeight = 120;

public:
    /**
     * @brief An entry in the table.
     */
    class Entry : public CompoundWidget
    {
    public:
        Entry(
            Widget *label,
            std::optional<DataLink::Channel> &selection,
            std::function<void()> onUpdated
        );
    };

    template<typename... TChildren>
    DataOutputTable(TChildren... children) :
        CompoundWidget(
            new Column(
                new Center(new Label("Data wire to")),
                new Center(new Label("activate when...")),
                new HorizontalSeparator(),

                Layout::WithProportion<1>(),
                new ScrollPanel(
                    naturalHeight,
                    new Column(children...)
                )
            )
        )
    {}
};

#endif