#pragma once

#include <FL/Fl_Image.H>
#include <FL/Fl_Window.H>

#include <mutex>
#include <string>
#include <queue>
#include <vector>

namespace fe {
  class Thumbnail {
    public:
      Thumbnail();
      ~Thumbnail();

      void init();
      static void loadImagesCb(void *v);

    private:
      std::vector<std::string> imgfiles;
      std::vector<Fl_Image *> thumbs;
      std::queue<std::string> pending;
      std::mutex mutex;
      int curX = 10;
      int curY = 10;
      Fl_Window *loadingDialog;

      void createLoadingDialog();
      std::vector<std::string> listImages(const std::string &directory);
      void loadNextImage();
  };
}
