#ifndef SNAPFILE_H #define SNAPFILE_H // Description /* SnapFile is a library based on SDL and SDL_gfx built to manage an index. Author : Jovian Hersmeule Last modification : 14 May 2017 > Why is it relevant to use index ? Index are commonly used to list files inside a folder. Using index is relevant because it doesn't rely on a specific exploitation system. Indeed, listing files in a folder recquires specific libraries which are different between Windows and Linux. > What can perform SnapFile ? SnapFile has many functions do update and read your index. Thanks to SDL, SnapFile can create windows in order to interact easily with a user, in order to type a file name or to choose a file from the index. */ // Basic includes #include #include #include // Graphic includes #include #include // Graphic config struct SF_Graphic { unsigned int h; unsigned int w; Uint32 color_line; // GFX : RGBA Uint32 color_back; // SDL : ARGB Uint32 color_select; // GFX : RGBA std::string name; }; // Standard graphic config #define SF_STDGRPH {300, 400, 0xffff00ff, 0xff000000, 0xffffffff, "SnapFile"} // Add files listed in the index given void SF_makeList( const std::string & indexName, std::vector & dirList ); // Keep files with desired extension, and remove them if wanted void SF_filter( std::vector & dirList, std::string ext, bool autoRemove = false ); // Create a window and return file chosen void SF_choose( const std::string & indexName, std::string & fileChosen, SDL_Surface* tgt = nullptr, const SF_Graphic cfg = SF_STDGRPH ); // Create a window to write a name void SF_keyName( std::string & fileName, SDL_Surface* tgt = nullptr, const SF_Graphic cfg = SF_STDGRPH ); // Create a window to add a file, modify arg "fileName" void SF_addAskedFile( const std::string & indexName, std::string & fileName, SDL_Surface* tgt = nullptr, const SF_Graphic cfg = SF_STDGRPH ); // Add a file in a index, with occurence check void SF_addFile( const std::string & indexName, const std::string & fileName ); // Create a window if needed, return true if creation bool SF_fixWindow( SDL_Surface* & tgt, const SF_Graphic cfg = SF_STDGRPH ); // Add shape and esthetic void SF_enhanceWindow( SDL_Surface* screen, const SF_Graphic & cfg ); #endif