/******************************************************************************
*	File		-	tile_set_view.h
*	Author		-	Joey Pollack
*	Date		-	2022/02/16 (y/m/d)
*	Mod Date	-	2022/02/16 (y/m/d)
*	Description	-	panel for viewing the current tile set
******************************************************************************/

#ifndef TILE_SET_VIEW_H_
#define TILE_SET_VIEW_H_

#include <gui/panel.h>
#include <core/types.h>
#include <utils/high_resolution_timer.h>
#include <map>

namespace lunarium { class Image; }

namespace lunarium { namespace editor
{
    class MapEditor;
    class TileSet;
    class TileSetView : public gui::Panel
    {
    public: 
        TileSetView(MapEditor* editor);

        void Update(float delta);
        bool DoFrame();

        void ClearTileSets();
        void AddTileSet(TileSet* set);
        TileSet* GetTileSet();

        Vec2i GetSelectedTile();

        void Invalidate(bool remake_frame_buffer = false);

    private:
        MapEditor* mpEditor;
        std::map<int, TileSet*> mTileSets;
        TileSet* mpSelectedTileSet;
        int mFrameBuffer;
        bool mInvalidate;
        Image* mpViewImage;
        Vec2i mViewOffset;
        float mViewZoom;
        Vec2i mSelectedTile;

        bool mMouseDown;
        Vec2f mWorkAreaPos;
        Vec2f mWorkAreaSize;
        Vec2f mScrollOffset;
    };
}}

#endif  // TILE_SET_VIEW_H_