//////////////////////////////////////////////////////////////////////////////
// This file is part of the Journey MMORPG client                           //
// Copyright © 2015-2016 Daniel Allendorf                                   //
//                                                                          //
// This program is free software: you can redistribute it and/or modify     //
// it under the terms of the GNU Affero General Public License as           //
// published by the Free Software Foundation, either version 3 of the       //
// License, or (at your option) any later version.                          //
//                                                                          //
// This program is distributed in the hope that it will be useful,          //
// but WITHOUT ANY WARRANTY; without even the implied warranty of           //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
// GNU Affero General Public License for more details.                      //
//                                                                          //
// You should have received a copy of the GNU Affero General Public License //
// along with this program.  If not, see <http://www.gnu.org/licenses/>.    //
//////////////////////////////////////////////////////////////////////////////
#pragma once
#include "../Cursor.h"

#include "../../Template/Rectangle.h"

#include <cstdint>
#include <functional>

namespace jrc
{
    // Base class for different button types.
    class Button
    {
    public:
        enum State
        {
            NORMAL,
            DISABLED,
            MOUSEOVER,
            PRESSED,
            IDENTITY,
            NUM_STATES
        };

        virtual ~Button() {}

        virtual void draw(Point<int16_t> parentpos) const = 0;
        virtual Rectangle<int16_t> bounds(Point<int16_t> parentpos) const = 0;

        int16_t width() const
        {
            return bounds({}).width();
        }

        int16_t height() const
        {
            return bounds({}).height();
        }

        void set_position(Point<int16_t> position);
        void set_state(State state);
        void set_active(bool active);

        bool is_active() const;
        State get_state() const;

    protected:
        State state;
        Point<int16_t> position;
        bool active;
    };
}
