diff --git a/DialogToolkit.cpp b/DialogToolkit.cpp index c7d2c12..4db508b 100644 --- a/DialogToolkit.cpp +++ b/DialogToolkit.cpp @@ -222,7 +222,7 @@ bool DialogToolkit::MultipleImagesDialog::closed() std::string saveSessionFileDialog(const std::string &label, const std::string &path) { std::string filename = ""; - char const * save_pattern[1] = { VIMIX_FILES_PATTERN }; + char const * save_pattern[1] = { VIMIX_FILE_PATTERN }; #if USE_TINYFILEDIALOG char const * save_file_name; @@ -273,9 +273,8 @@ std::string saveSessionFileDialog(const std::string &label, const std::string &p wait_for_event(); #endif - std::string extension = filename.substr(filename.find_last_of(".") + 1); - if (!filename.empty() && extension != "mix") - filename += ".mix"; + if (!filename.empty() && !SystemToolkit::has_extension(filename, VIMIX_FILE_EXT ) ) + filename += std::string(".") + VIMIX_FILE_EXT; return filename; } @@ -285,7 +284,7 @@ std::string openSessionFileDialog(const std::string &label, const std::string &p { std::string filename = ""; std::string startpath = SystemToolkit::file_exists(path) ? path : SystemToolkit::home_path(); - char const * open_pattern[1] = { VIMIX_FILES_PATTERN }; + char const * open_pattern[1] = { VIMIX_FILE_PATTERN }; #if USE_TINYFILEDIALOG char const * open_file_name; diff --git a/DialogToolkit.h b/DialogToolkit.h index 8b73054..659c1ba 100644 --- a/DialogToolkit.h +++ b/DialogToolkit.h @@ -6,13 +6,6 @@ #include #include -#define VIMIX_FILES_PATTERN "*.mix" -#define MEDIA_FILES_PATTERN "*.mix", "*.mp4", "*.mpg", "*.mpeg", "*.m2v", "*.m4v", "*.avi", "*.mov",\ - "*.mkv", "*.webm", "*.mod", "*.wmv", "*.mxf", "*.ogg",\ - "*.flv", "*.hevc", "*.asf", "*.jpg", "*.png", "*.gif",\ - "*.tif", "*.tiff", "*.webp", "*.bmp", "*.ppm", "*.svg," -#define IMAGES_FILES_PATTERN "*.jpg", "*.png", "*.bmp", "*.ppm", "*.gif" - namespace DialogToolkit { diff --git a/Mixer.cpp b/Mixer.cpp index 24c70a8..b1d360d 100644 --- a/Mixer.cpp +++ b/Mixer.cpp @@ -244,8 +244,7 @@ Source * Mixer::createSourceFile(const std::string &path) if ( SystemToolkit::file_exists( path ) ) { // test type of file by extension - std::string ext = SystemToolkit::extension_filename(path); - if ( ext == "mix" ) + if ( SystemToolkit::has_extension(path, VIMIX_FILE_EXT ) ) { // create a session source SessionFileSource *ss = new SessionFileSource; diff --git a/SystemToolkit.cpp b/SystemToolkit.cpp index 303704d..d80c67b 100644 --- a/SystemToolkit.cpp +++ b/SystemToolkit.cpp @@ -163,6 +163,14 @@ string SystemToolkit::extension_filename(const string& filename) return ext; } +bool SystemToolkit::has_extension(const std::string& filename, const std::string& extension) +{ + std::string ext = extension_filename(filename); + std::transform (ext.begin(), ext.end(), ext.begin(), ::tolower); + + return ext.compare(extension) == 0; +} + std::string SystemToolkit::home_path() { string homePath; diff --git a/SystemToolkit.h b/SystemToolkit.h index b7bb44b..b80acb8 100644 --- a/SystemToolkit.h +++ b/SystemToolkit.h @@ -44,6 +44,7 @@ namespace SystemToolkit // extract the extension of a filename std::string extension_filename(const std::string& filename); + bool has_extension(const std::string& filename, const std::string& extension); // tests if dir is a directory and return its path, empty string otherwise std::string path_directory(const std::string& path); diff --git a/UserInterfaceManager.cpp b/UserInterfaceManager.cpp index a6a328e..eabea6b 100644 --- a/UserInterfaceManager.cpp +++ b/UserInterfaceManager.cpp @@ -5166,6 +5166,9 @@ void Navigator::RenderMainPannelVimix() // fill the session list depending on the mode static std::list sessions_list; + static std::list::iterator _file_over = sessions_list.end(); + static std::list::iterator _displayed_over = sessions_list.end(); + // change session list if changed if (selection_session_mode_changed || Settings::application.recentSessions.changed || Settings::application.recentFolders.changed) { @@ -5179,15 +5182,15 @@ void Navigator::RenderMainPannelVimix() // selection MODE 1 : LIST FOLDER else if ( selection_session_mode == 1) { // show list of vimix files in folder - sessions_list = SystemToolkit::list_directory( Settings::application.recentFolders.path, { VIMIX_FILES_PATTERN }); + sessions_list = SystemToolkit::list_directory( Settings::application.recentFolders.path, { VIMIX_FILE_PATTERN }); } // indicate the list changed (do not change at every frame) selection_session_mode_changed = false; + _file_over = sessions_list.end(); + _displayed_over = sessions_list.end(); } { - static std::list::iterator _file_over = sessions_list.end(); - static std::list::iterator _displayed_over = sessions_list.end(); static bool _tooltip = 0; // display the sessions list and detect if one was selected (double clic) diff --git a/defines.h b/defines.h index 9f4ced4..fec88b4 100644 --- a/defines.h +++ b/defines.h @@ -9,6 +9,14 @@ #define MAX_RECENT_HISTORY 20 #define MAX_SESSION_LEVEL 3 +#define VIMIX_FILE_EXT "mix" +#define VIMIX_FILE_PATTERN "*.mix" +#define MEDIA_FILES_PATTERN "*.mix", "*.mp4", "*.mpg", "*.mpeg", "*.m2v", "*.m4v", "*.avi", "*.mov",\ + "*.mkv", "*.webm", "*.mod", "*.wmv", "*.mxf", "*.ogg",\ + "*.flv", "*.hevc", "*.asf", "*.jpg", "*.png", "*.gif",\ + "*.tif", "*.tiff", "*.webp", "*.bmp", "*.ppm", "*.svg," +#define IMAGES_FILES_PATTERN "*.jpg", "*.png", "*.bmp", "*.ppm", "*.gif" + #define MINI(a, b) (((a) < (b)) ? (a) : (b)) #define MAXI(a, b) (((a) > (b)) ? (a) : (b)) #define ABS(a) (((a) < 0) ? -(a) : (a))