#include "TopBar.h"

#include "Color.h"
#include "Theme.h"

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

TopBar::TopBar()
{
    setBackgroundColor(Theme::getBackgroundPrimary());

    auto fileButton = Button::Create();
    fileButton->setLabel("File");
    fileButton->setBackgroundColor(Theme::getBackgroundPrimary());
    fileButton->setMargin(2);
    fileButton->setMaxWidth(60);

    auto onClick = [this](Widget* self){
                if(this)
                {
                    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>();
}
