mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
Multiple file selection for OSX
and finetuning creation UI for MultiFile source
This commit is contained in:
@@ -301,9 +301,27 @@ std::list<std::string> DialogToolkit::selectImagesFileDialog(const std::string &
|
|||||||
char const * open_file_names;
|
char const * open_file_names;
|
||||||
open_file_names = tinyfd_openFileDialog( "Select images", startpath.c_str(), 3, open_pattern, "Images", 1);
|
open_file_names = tinyfd_openFileDialog( "Select images", startpath.c_str(), 3, open_pattern, "Images", 1);
|
||||||
|
|
||||||
if (open_file_names)
|
if (open_file_names) {
|
||||||
// filename = std::string(open_file_name);
|
|
||||||
// TODO
|
const std::string& str (open_file_names);
|
||||||
|
const std::string& delimiters = "|";
|
||||||
|
// Skip delimiters at beginning.
|
||||||
|
std::string::size_type lastPos = str.find_first_not_of(delimiters, 0);
|
||||||
|
|
||||||
|
// Find first non-delimiter.
|
||||||
|
std::string::size_type pos = str.find_first_of(delimiters, lastPos);
|
||||||
|
|
||||||
|
while (std::string::npos != pos || std::string::npos != lastPos) {
|
||||||
|
// Found a token, add it to the vector.
|
||||||
|
files.push_back(str.substr(lastPos, pos - lastPos));
|
||||||
|
|
||||||
|
// Skip delimiters.
|
||||||
|
lastPos = str.find_first_not_of(delimiters, pos);
|
||||||
|
|
||||||
|
// Find next non-delimiter.
|
||||||
|
pos = str.find_first_of(delimiters, lastPos);
|
||||||
|
}
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
if (!gtk_init()) {
|
if (!gtk_init()) {
|
||||||
|
|||||||
@@ -269,6 +269,9 @@ Source * Mixer::createSourceMultifile(const std::list<std::string> &list_files,
|
|||||||
// propose a new name
|
// propose a new name
|
||||||
s->setName( SystemToolkit::base_filename( BaseToolkit::common_prefix(list_files) ) );
|
s->setName( SystemToolkit::base_filename( BaseToolkit::common_prefix(list_files) ) );
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
Log::Notify("Could not find a sequence of consecutively numbered files.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
|||||||
@@ -2676,7 +2676,7 @@ void Navigator::RenderNewPannel()
|
|||||||
if (Settings::application.source.new_type == 0) {
|
if (Settings::application.source.new_type == 0) {
|
||||||
|
|
||||||
// clic button to load file
|
// clic button to load file
|
||||||
if ( ImGui::Button( ICON_FA_FILE_EXPORT " Open file", ImVec2(ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN, 0)) ) {
|
if ( ImGui::Button( ICON_FA_FILE_EXPORT " Open media", ImVec2(ImGui::GetContentRegionAvail().x IMGUI_RIGHT_ALIGN, 0)) ) {
|
||||||
// launch async call to file dialog and get its future.
|
// launch async call to file dialog and get its future.
|
||||||
if (fileImportFileDialogs.empty()) {
|
if (fileImportFileDialogs.empty()) {
|
||||||
fileImportFileDialogs.emplace_back( std::async(std::launch::async, DialogToolkit::openMediaFileDialog, Settings::application.recentImport.path) );
|
fileImportFileDialogs.emplace_back( std::async(std::launch::async, DialogToolkit::openMediaFileDialog, Settings::application.recentImport.path) );
|
||||||
@@ -2752,6 +2752,9 @@ void Navigator::RenderNewPannel()
|
|||||||
if (_selectedImagesFileDialogs.back().wait_for(timeout) == std::future_status::ready ) {
|
if (_selectedImagesFileDialogs.back().wait_for(timeout) == std::future_status::ready ) {
|
||||||
// get the filenames from this file dialog
|
// get the filenames from this file dialog
|
||||||
_selectedFiles = _selectedImagesFileDialogs.back().get();
|
_selectedFiles = _selectedImagesFileDialogs.back().get();
|
||||||
|
if (_selectedFiles.empty()) {
|
||||||
|
Log::Notify("No file selected.");
|
||||||
|
}
|
||||||
// done with this file dialog
|
// done with this file dialog
|
||||||
_selectedImagesFileDialogs.pop_back();
|
_selectedImagesFileDialogs.pop_back();
|
||||||
fileDialogPending_ = false;
|
fileDialogPending_ = false;
|
||||||
@@ -2760,8 +2763,8 @@ void Navigator::RenderNewPannel()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// a selection was made
|
// multiple files selected
|
||||||
if (!_selectedFiles.empty()) {
|
if (_selectedFiles.size() > 1) {
|
||||||
|
|
||||||
// set framerate
|
// set framerate
|
||||||
static int _fps = 30;
|
static int _fps = 30;
|
||||||
@@ -2777,20 +2780,23 @@ void Navigator::RenderNewPannel()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (update_new_source) {
|
if (update_new_source) {
|
||||||
// multiple files selected
|
std::string label = BaseToolkit::transliterate( BaseToolkit::common_pattern(_selectedFiles) );
|
||||||
if (_selectedFiles.size() > 1) {
|
label = BaseToolkit::trunc_string(label, 35);
|
||||||
std::string label = BaseToolkit::transliterate( _selectedFiles.front() );
|
new_source_preview_.setSource( Mixer::manager().createSourceMultifile(_selectedFiles, _fps), label);
|
||||||
label = BaseToolkit::trunc_string(label, 35);
|
|
||||||
new_source_preview_.setSource( Mixer::manager().createSourceMultifile(_selectedFiles, _fps), label);
|
|
||||||
}
|
|
||||||
// single file selected
|
|
||||||
else {
|
|
||||||
std::string label = BaseToolkit::transliterate( _selectedFiles.front() );
|
|
||||||
label = BaseToolkit::trunc_string(label, 35);
|
|
||||||
new_source_preview_.setSource( Mixer::manager().createSourceFile(_selectedFiles.front()), label);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// single file selected
|
||||||
|
else if (_selectedFiles.size() > 0) {
|
||||||
|
|
||||||
|
ImGui::Text("Single file selected");
|
||||||
|
|
||||||
|
if (update_new_source) {
|
||||||
|
std::string label = BaseToolkit::transliterate( _selectedFiles.front() );
|
||||||
|
label = BaseToolkit::trunc_string(label, 35);
|
||||||
|
new_source_preview_.setSource( Mixer::manager().createSourceFile(_selectedFiles.front()), label);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
// Internal Source creator
|
// Internal Source creator
|
||||||
|
|||||||
Reference in New Issue
Block a user