Skip to content

File evabInputSelectorPx.h

File List > src > evabInputSelectorPx.h

Go to the documentation of this file

#pragma once

#include <evabElementBase.h>

namespace evab
{

    template <class TAlbum>
    class InputSelectorPx : public ElementBase
    {
    public:
        InputSelectorPx(int aValue = 0)
        {
            mValue = constrain(aValue, 0, TAlbum::Count - 1);
        }

        void Select(int aValue)
        {
            aValue = constrain(aValue, 0, TAlbum::Count - 1);
            if (mValue == aValue)
                return;
            mValue = aValue;
            redraw();
        }

        signed char Selected() const
        {
            return mValue;
        }

        void Increment(signed char aSteps)
        {
            Select(mValue + aSteps);
        }

        unsigned char Count() const
        {
            return TAlbum::Count;
        }

    protected:
        void drawer(Screen *aScreen, Coor aPos, Coor aSize, unsigned char aIsFocused) override
        {
            aScreen->Clear(aPos, aSize, aIsFocused);
            aScreen->Picto(aPos, TAlbum::GetTile(mValue), aIsFocused);
        }

    private:
        signed char mValue; 
    };

}