#pragma once

#include "widget.h"
#include "menudrop.h"
#include "button.h"

class MenuBar : public Widget
{
public:
    explicit MenuBar(const std::shared_ptr<kku::CoreFactory>& factory);

    virtual void input(const kku::SystemEvent& event) override;
    virtual void update(const kku::microsec& dt) override;
    virtual void display() const override;
    virtual void move(const kku::Vector2<float>& delta) override;
    virtual bool isUnderMouse(const kku::Point& position) const override;
    virtual void setVisibility(bool is_visible = true) override;

    virtual void setRect(const kku::Area<float>& rect) override;
    virtual kku::Area<float> getRect() const override;

    virtual void setPosition(const kku::Point& position) override;
    virtual kku::Point getPosition() const override;

    void addRootSubMenu(std::string name, const std::shared_ptr<MenuDrop>& submenu);
    void addDependentSubmenu(const std::shared_ptr<MenuDrop>& submenu);

private:
    const std::shared_ptr<kku::CoreFactory> _core_factory;
    const std::shared_ptr<kku::Rectangle> _bar_rect;
    std::size_t _amount_buttons;
    std::size_t _button_width;

    std::vector<std::shared_ptr<MenuDrop>> _submenus;
};
