| 570 | } |
| 571 | |
| 572 | void FileDialog::m_select(const std::filesystem::path& path, bool isCtrlDown) |
| 573 | { |
| 574 | bool multiselect = isCtrlDown && m_isMultiselect; |
| 575 | |
| 576 | if (!multiselect) { |
| 577 | m_selections.clear(); |
| 578 | m_selections.push_back(path); |
| 579 | } else { |
| 580 | auto it = std::find(m_selections.begin(), m_selections.end(), path); |
| 581 | if (it != m_selections.end()) |
| 582 | m_selections.erase(it); |
| 583 | else |
| 584 | m_selections.push_back(path); |
| 585 | } |
| 586 | |
| 587 | if (m_selections.size() == 1) { |
| 588 | auto filename = m_selections[0].filename().u8string(); |
| 589 | if (filename.size() == 0) |
| 590 | filename = m_selections[0].u8string(); // drive |
| 591 | |
| 592 | std::memcpy(m_inputTextbox, filename.c_str(), filename.size()); |
| 593 | m_inputTextbox[filename.size()] = 0; |
| 594 | } |
| 595 | else { |
| 596 | std::string textboxVal = ""; |
| 597 | for (const auto& sel : m_selections) { |
| 598 | std::string filename = sel.filename().string(); |
| 599 | if (filename.size() == 0) |
| 600 | filename = sel.string(); |
| 601 | |
| 602 | textboxVal += "\"" + filename + "\", "; |
| 603 | } |
| 604 | std::memcpy(m_inputTextbox, textboxVal.substr(0, textboxVal.size() - 2).c_str(), textboxVal.size() - 2); |
| 605 | m_inputTextbox[textboxVal.size() - 2] = 0; |
| 606 | } |
| 607 | } |
| 608 | |
| 609 | bool FileDialog::m_finalize(const std::u8string& filename) |
| 610 | { |