#ifndef UI_H
#define UI_H

namespace Menus {
    /**
     * UI class
     * @brief Provides a user-friendly abstraction layer above the graphics
     * namespace, allowing the programmer to add labels, buttons and other 
     * UI elements to the 'canvas', without worrying about positioning or 
     * input management.
     * @see Graphics::UI
     */
    class UI {
    public:
        /**
         * @brief Creates a new UI object ready to be used
         */
        UI();
        
        /**
         * @brief Destructor
         */
        ~UI();
        
        /**
         * @brief Should be called before a new Menu is loaded, to reset state
         * such as the cursor position.
         */
        void reset();
        
        /**
         * @brief Should be called every frame, prepares the 'canvas' for a new
         * set of 'draw' calls.
         */
        void clear();
        
        /**
         * @brief Draws a 'title' style label to the screen, essentially the
         * same as drawLabel.
         * @param text The text of the title, must be <= 8 characters
         * @see drawLabel
         */
        void drawTitle(const char * text);
        
        /**
         * @brief Draws a label to the canvas and advance the 'canvas pointer'.
         * @param text The text of the label, must be <= 8 characters
         */
        void drawLabel(const char * text);
        
        /**
         * @brief 
         * @param text The text of the flashing label, must be <= 8 characters
         * @see drawLabel
         */
        void drawFlashingLabel(const char * text);
        
        /**
         * @brief
         * @param text The text of the button, must be <= 8 characters
         * @returns true if the button is pressed this frame, else false.
         */
        bool drawAndCheckButton(const char * text);
        
        /**
         * @brief Draws the big inverted 'TETRIS' logo and advances the canvas
         * pointer.
         */
        void drawLogo();
    
        /**
         * @brief Called to move the 'cursor' (highlighted button) down to
         * the next one vertically beneath.
         */
        void selectNextButton();
        
        /**
         * @brief Called to move the 'cursor' (highlighted button) up to
         * the next one vertically above.
         */
        void selectPreviousButton();
        
        /**
         * @brief "Presses" the current button, so it's draw function
         * will return true.
         */
        void pressButton();
        
        /**
         * @brief Simply adds vertical whitespace to the canvas.
         */
        void newLine();
    
    private:
        static const int PADDING_X = 3;
        static const int PADDING_Y = 4;
        static const int LINE_PADDING = 3;
        int next_y_pos;
        int nextY();
        int button_currently_selected;
        int button_currently_drawing;
        bool button_pressed_frame;
        int frame;
    };
};
#endif