SnapFile.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #ifndef SNAPFILE_H
  2. #define SNAPFILE_H
  3. // Description
  4. /*
  5. SnapFile is a library based on SDL and SDL_gfx built to manage an index.
  6. Author : Jovian Hersmeule
  7. Last modification : 14 May 2017
  8. > Why is it relevant to use index ?
  9. Index are commonly used to list files inside a folder. Using index is
  10. relevant because it doesn't rely on a specific exploitation system.
  11. Indeed, listing files in a folder recquires specific libraries which
  12. are different between Windows and Linux.
  13. > What can perform SnapFile ?
  14. SnapFile has many functions do update and read your index. Thanks to SDL, SnapFile
  15. can create windows in order to interact easily with a user, in order to type a file
  16. name or to choose a file from the index.
  17. */
  18. // Basic includes
  19. #include <iostream>
  20. #include <vector>
  21. #include <fstream>
  22. // Graphic includes
  23. #include <SDL/SDL.h>
  24. #include <SDL/SDL_gfxPrimitives.h>
  25. // Graphic config
  26. struct SF_Graphic
  27. {
  28. unsigned int h;
  29. unsigned int w;
  30. Uint32 color_line; // GFX : RGBA
  31. Uint32 color_back; // SDL : ARGB
  32. Uint32 color_select; // GFX : RGBA
  33. std::string name;
  34. };
  35. // Standard graphic config
  36. #define SF_STDGRPH {300, 400, 0xffff00ff, 0xff000000, 0xffffffff, "SnapFile"}
  37. // Add files listed in the index given
  38. void SF_makeList( const std::string & indexName, std::vector<std::string> & dirList );
  39. // Keep files with desired extension, and remove them if wanted
  40. void SF_filter( std::vector<std::string> & dirList, std::string ext, bool autoRemove = false );
  41. // Use a window and return file chosen
  42. void SF_choose( const std::string & indexName, std::string & fileChosen, SDL_Surface* tgt = nullptr, const SF_Graphic cfg = SF_STDGRPH );
  43. // Use a window to write a name
  44. void SF_keyName( std::string & fileName, SDL_Surface* tgt = nullptr, const SF_Graphic cfg = SF_STDGRPH );
  45. // Use a window to add a file, modify arg "fileName"
  46. void SF_addAskedFile( const std::string & indexName, std::string & fileName, SDL_Surface* tgt = nullptr, const SF_Graphic cfg = SF_STDGRPH );
  47. // Add a file in a index, with occurence check
  48. void SF_addFile( const std::string & indexName, const std::string & fileName );
  49. // Create a window if needed, return true if creation
  50. bool SF_fixWindow( SDL_Surface* & tgt, const SF_Graphic cfg = SF_STDGRPH );
  51. // Add shape and esthetic
  52. void SF_enhanceWindow( SDL_Surface* screen, const SF_Graphic & cfg );
  53. #endif