Skip to content

File evabBoxy.h

File List > src > evabBoxy.h

Go to the documentation of this file

#pragma once

#include <evaHandler.h>
#include <evaDelayTimer.h>

#include <evabElementBase.h>
#include <evabScreen.h>
#include <evabKeys.h>

namespace evab
{
    class Boxy : public eva::IHandler
    {
    public:
        template <class TScreen, class TFont, typename... Args>
        static void Begin(ElementBase *aGround, Args &&...args)
        {
            static TFont font;
            static TScreen screen(&font, args...);
            auto instance = Instance();
            instance->mScreen = &screen;
            instance->mGround = aGround;
            if (instance->mGround)
                instance->mGround->Draw(instance->mScreen, {0, 0}, instance->mScreen->Size(), 1);
        }

        static void Key(Keys aKey);

        static Screen *GetScreen();

        static Boxy *Instance();

        static void Message(const __FlashStringHelper *, const char *aText);

    private:
        void invoke(void *, eva::CallbackInfo) override;

    private:
        Screen *mScreen;                        
        ElementBase *mGround;                   
        eva::DelayTimer mMessageTimer = {this}; 
    };
}