#include "TopBar.h"

#include "Color.h"
#include "ITheme.h"

#include "Button.h"
#include "TopBarMenu.h"

TopBar::TopBar()
{
    setBackground(Theme::Sys::Color::Secondary);

    auto fileButton = Button::Create();
    fileButton->setLabel("File");
    fileButton->setBackground(Theme::Sys::Color::Primary);
    fileButton->setMargin(2);
    fileButton->setMaxWidth(60);

    auto onClick = [this](Widget*){
                auto menu = std::make_unique<TopBarMenu>();
                auto window = getTopLevelWindow();
                window->addPopup(std::move(menu));
            };
    fileButton->setOnClickFunction(onClick);
    addWidget(std::move(fileButton));
}

TopBar::~TopBar()
{

}

std::unique_ptr<TopBar> TopBar::Create()
{
    return std::make_unique<TopBar>();
}
