#pragma once

#include "application/state.h"
#include "core/corefactory.h"
#include "core/music.h"
#include "core/functional.h"

class BPMCalculator;
class Group;

namespace kku { class Editor; }

class EditorState : public GUIState
{
public:

    struct Callbacks
    {
        kku::lambda onLeaveEditorState;
    };

    explicit EditorState(const std::shared_ptr<kku::CoreFactory>& core_factory, std::unique_ptr<kku::Editor>&& editor, Callbacks&& callbacks);
    virtual ~EditorState() override;
    virtual void input(const kku::SystemEvent& event) override;
    virtual void update(const kku::microsec& dt) override;
    virtual void display() const override;

    virtual void enter() override;
    virtual void leave() override;

private:
    const Callbacks _callbacks;
    const std::shared_ptr<kku::CoreFactory> _core_factory;
    std::shared_ptr<kku::Music> _music;
    
    std::shared_ptr<BPMCalculator> _bpm_calculator;
    std::shared_ptr<Group> _group;

    std::unique_ptr<kku::Editor> _editor;
};

