diff --git a/rtgui/batchqueuebuttonset.cc b/rtgui/batchqueuebuttonset.cc index f5be480e8..b42d3c773 100644 --- a/rtgui/batchqueuebuttonset.cc +++ b/rtgui/batchqueuebuttonset.cc @@ -27,6 +27,10 @@ Cairo::RefPtr BatchQueueButtonSet::cancelIcon; Cairo::RefPtr BatchQueueButtonSet::headIcon; Cairo::RefPtr BatchQueueButtonSet::tailIcon; +Glib::ustring BatchQueueButtonSet::moveHeadToolTip; +Glib::ustring BatchQueueButtonSet::moveEndToolTip; +Glib::ustring BatchQueueButtonSet::cancelJobToolTip; + BatchQueueButtonSet::BatchQueueButtonSet (BatchQueueEntry* myEntry) { @@ -34,10 +38,13 @@ BatchQueueButtonSet::BatchQueueButtonSet (BatchQueueEntry* myEntry) cancelIcon = Cairo::RefPtr(new RTSurface("cancel-small.png")); headIcon = Cairo::RefPtr(new RTSurface("goto-start-small.png")); tailIcon = Cairo::RefPtr(new RTSurface("goto-end-small.png")); + moveHeadToolTip = M("FILEBROWSER_POPUPMOVEHEAD"); + moveEndToolTip = M("FILEBROWSER_POPUPMOVEEND"); + cancelJobToolTip = M("FILEBROWSER_POPUPCANCELJOB"); iconsLoaded = true; } - add (new LWButton (headIcon, 8, myEntry, LWButton::Left, LWButton::Center, M("FILEBROWSER_POPUPMOVEHEAD"))); - add (new LWButton (tailIcon, 9, myEntry, LWButton::Left, LWButton::Center, M("FILEBROWSER_POPUPMOVEEND"))); - add (new LWButton (cancelIcon, 10, myEntry, LWButton::Right, LWButton::Center, M("FILEBROWSER_POPUPCANCELJOB"))); + add(new LWButton(headIcon, 8, myEntry, LWButton::Left, LWButton::Center, &moveHeadToolTip)); + add(new LWButton(tailIcon, 9, myEntry, LWButton::Left, LWButton::Center, &moveEndToolTip)); + add(new LWButton(cancelIcon, 10, myEntry, LWButton::Right, LWButton::Center, &cancelJobToolTip)); } diff --git a/rtgui/batchqueuebuttonset.h b/rtgui/batchqueuebuttonset.h index 66dab91a1..e97819719 100644 --- a/rtgui/batchqueuebuttonset.h +++ b/rtgui/batchqueuebuttonset.h @@ -34,6 +34,10 @@ public: static Cairo::RefPtr headIcon; static Cairo::RefPtr tailIcon; + static Glib::ustring moveHeadToolTip; + static Glib::ustring moveEndToolTip; + static Glib::ustring cancelJobToolTip; + explicit BatchQueueButtonSet (BatchQueueEntry* myEntry); }; diff --git a/rtgui/batchqueueentry.cc b/rtgui/batchqueueentry.cc index d52fe4305..a5dfb6dde 100644 --- a/rtgui/batchqueueentry.cc +++ b/rtgui/batchqueueentry.cc @@ -148,7 +148,7 @@ void BatchQueueEntry::removeButtonSet () buttonSet = nullptr; } -std::vector > BatchQueueEntry::getIconsOnImageArea () +std::vector> BatchQueueEntry::getIconsOnImageArea () { std::vector > ret; @@ -160,7 +160,7 @@ std::vector > BatchQueueEntry::getIconsOnImageArea () return ret; } -void BatchQueueEntry::getIconSize (int& w, int& h) +void BatchQueueEntry::getIconSize (int& w, int& h) const { w = savedAsIcon->get_width (); @@ -168,7 +168,7 @@ void BatchQueueEntry::getIconSize (int& w, int& h) } -Glib::ustring BatchQueueEntry::getToolTip (int x, int y) +Glib::ustring BatchQueueEntry::getToolTip (int x, int y) const { // get the parent class' tooltip first Glib::ustring tooltip = ThumbBrowserEntryBase::getToolTip(x, y); diff --git a/rtgui/batchqueueentry.h b/rtgui/batchqueueentry.h index f3e8c1336..d13dfe827 100644 --- a/rtgui/batchqueueentry.h +++ b/rtgui/batchqueueentry.h @@ -68,9 +68,9 @@ public: void removeButtonSet (); - std::vector > getIconsOnImageArea () override; - void getIconSize (int& w, int& h) override; - Glib::ustring getToolTip (int x, int y) override; + std::vector> getIconsOnImageArea () override; + void getIconSize (int& w, int& h) const override; + Glib::ustring getToolTip (int x, int y) const override; // bqentryupdatelistener interface void updateImage (guint8* img, int w, int h, int origw, int origh, guint8* newOPreview) override; diff --git a/rtgui/cropwindow.cc b/rtgui/cropwindow.cc index 4b2c1a6cc..b29aa5eeb 100644 --- a/rtgui/cropwindow.cc +++ b/rtgui/cropwindow.cc @@ -38,6 +38,13 @@ using namespace rtengine; +bool CropWindow::initialized = false; + +Glib::ustring CropWindow::zoomOuttt; +Glib::ustring CropWindow::zoomIntt; +Glib::ustring CropWindow::zoom100tt; +Glib::ustring CropWindow::closett; + CropWindow::CropWindow (ImageArea* parent, bool isLowUpdatePriority_, bool isDetailWindow) : ObjectMOBuffer(parent), state(SNormal), press_x(0), press_y(0), action_x(0), action_y(0), pickedObject(-1), pickModifierKey(0), rot_deg(0), onResizeArea(false), deleted(false), fitZoomEnabled(true), fitZoom(false), cursor_type(CSArrow), /*isLowUpdatePriority(isLowUpdatePriority_),*/ hoveredPicker(nullptr), cropLabel(Glib::ustring("100%")), @@ -61,11 +68,18 @@ CropWindow::CropWindow (ImageArea* parent, bool isLowUpdatePriority_, bool isDet titleHeight = ih; - bZoomOut = new LWButton (Cairo::RefPtr(new RTSurface("magnifier-minus-small.png")), 0, nullptr, LWButton::Left, LWButton::Center, "Zoom Out"); - bZoomIn = new LWButton (Cairo::RefPtr(new RTSurface("magnifier-plus-small.png")), 1, nullptr, LWButton::Left, LWButton::Center, "Zoom In"); - bZoom100 = new LWButton (Cairo::RefPtr(new RTSurface("magnifier-1to1-small.png")), 2, nullptr, LWButton::Left, LWButton::Center, "Zoom 100/%"); - //bZoomFit = new LWButton (Cairo::RefPtr(new RTSurface("magnifier-fit.png")), 3, NULL, LWButton::Left, LWButton::Center, "Zoom Fit"); - bClose = new LWButton (Cairo::RefPtr(new RTSurface("cancel-small.png")), 4, nullptr, LWButton::Right, LWButton::Center, "Close"); + if (!initialized) { + zoomOuttt = "Zoom Out"; + zoomIntt = "Zoom In"; + zoom100tt = "Zoom 100/%"; + closett = "Close"; + initialized = true; + } + bZoomOut = new LWButton(Cairo::RefPtr(new RTSurface("magnifier-minus-small.png")), 0, nullptr, LWButton::Left, LWButton::Center, &zoomOuttt); + bZoomIn = new LWButton(Cairo::RefPtr(new RTSurface("magnifier-plus-small.png")), 1, nullptr, LWButton::Left, LWButton::Center, &zoomIntt); + bZoom100 = new LWButton(Cairo::RefPtr(new RTSurface("magnifier-1to1-small.png")), 2, nullptr, LWButton::Left, LWButton::Center, &zoom100tt); + //bZoomFit = new LWButton (Cairo::RefPtr(new RTSurface("magnifier-fit.png")), 3, NULL, LWButton::Left, LWButton::Center, "Zoom Fit"); + bClose = new LWButton(Cairo::RefPtr(new RTSurface("cancel-small.png")), 4, nullptr, LWButton::Right, LWButton::Center, &closett); buttonSet.add (bZoomOut); buttonSet.add (bZoomIn); diff --git a/rtgui/cropwindow.h b/rtgui/cropwindow.h index 287cbf1ef..6e2097d3b 100644 --- a/rtgui/cropwindow.h +++ b/rtgui/cropwindow.h @@ -47,6 +47,12 @@ public: class ImageArea; class CropWindow : public LWButtonListener, public CropDisplayHandler, public EditCoordSystem, public ObjectMOBuffer { + static bool initialized; + + static Glib::ustring zoomOuttt; + static Glib::ustring zoomIntt; + static Glib::ustring zoom100tt; + static Glib::ustring closett; // state management ImgEditState state; // current state of user (see enum State) diff --git a/rtgui/filebrowser.cc b/rtgui/filebrowser.cc index a270e5af8..cc215e70a 100644 --- a/rtgui/filebrowser.cc +++ b/rtgui/filebrowser.cc @@ -592,15 +592,16 @@ void FileBrowser::addEntry_ (FileBrowserEntry* entry) { entry->selected = false; entry->drawable = false; - entry->framed = editedFiles.find (entry->filename) != editedFiles.end(); + entry->framed = editedFiles.find(entry->filename) != editedFiles.end(); // add button set to the thumbbrowserentry - entry->addButtonSet (new FileThumbnailButtonSet (entry)); - entry->getThumbButtonSet()->setRank (entry->thumbnail->getRank()); - entry->getThumbButtonSet()->setColorLabel (entry->thumbnail->getColorLabel()); - entry->getThumbButtonSet()->setInTrash (entry->thumbnail->getStage()); - entry->getThumbButtonSet()->setButtonListener (this); - entry->resize (getThumbnailHeight()); + entry->addButtonSet(new FileThumbnailButtonSet(entry)); + entry->getThumbButtonSet()->setRank(entry->thumbnail->getRank()); + entry->getThumbButtonSet()->setColorLabel(entry->thumbnail->getColorLabel()); + entry->getThumbButtonSet()->setInTrash(entry->thumbnail->getStage()); + entry->getThumbButtonSet()->setButtonListener(this); + entry->resize(getThumbnailHeight()); + entry->filtered = !checkFilter(entry); // find place in abc order { @@ -619,9 +620,9 @@ void FileBrowser::addEntry_ (FileBrowserEntry* entry) entry ); - initEntry (entry); + initEntry(entry); } - redraw (); + redraw(false); } FileBrowserEntry* FileBrowser::delEntry (const Glib::ustring& fname) diff --git a/rtgui/filebrowserentry.cc b/rtgui/filebrowserentry.cc index 0fa5694de..4b1764824 100644 --- a/rtgui/filebrowserentry.cc +++ b/rtgui/filebrowserentry.cc @@ -119,39 +119,37 @@ void FileBrowserEntry::calcThumbnailSize () } } -std::vector > FileBrowserEntry::getIconsOnImageArea () +std::vector> FileBrowserEntry::getIconsOnImageArea () { - - std::vector > ret; - if (!thumbnail) { - return ret; + return {}; } + std::vector> ret; + if (thumbnail->hasProcParams() && editedIcon) { - ret.push_back (editedIcon); + ret.push_back(editedIcon); } if (thumbnail->isRecentlySaved() && recentlySavedIcon) { - ret.push_back (recentlySavedIcon); + ret.push_back(recentlySavedIcon); } if (thumbnail->isEnqueued () && enqueuedIcon) { - ret.push_back (enqueuedIcon); + ret.push_back(enqueuedIcon); } return ret; } -std::vector > FileBrowserEntry::getSpecificityIconsOnImageArea () +std::vector> FileBrowserEntry::getSpecificityIconsOnImageArea () { - - std::vector > ret; - if (!thumbnail) { - return ret; + return {}; } + std::vector> ret; + if (thumbnail->isHDR() && hdr) { ret.push_back (hdr); } @@ -188,7 +186,7 @@ void FileBrowserEntry::customBackBufferUpdate (Cairo::RefPtr c) } } -void FileBrowserEntry::getIconSize (int& w, int& h) +void FileBrowserEntry::getIconSize (int& w, int& h) const { w = editedIcon->get_width (); @@ -286,34 +284,29 @@ void FileBrowserEntry::_updateImage(rtengine::IImage8* img, double s, const rten bool FileBrowserEntry::motionNotify (int x, int y) { - bool b = ThumbBrowserEntryBase::motionNotify (x, y); + const bool b = ThumbBrowserEntryBase::motionNotify(x, y); - int ix = x - startx - ofsX; - int iy = y - starty - ofsY; + const int ix = x - startx - ofsX; + const int iy = y - starty - ofsY; Inspector* inspector = parent->getInspector(); if (inspector && inspector->isActive() && !parent->isInTabMode()) { - rtengine::Coord2D coord(-1., -1.); - getPosInImgSpace(x, y, coord); + const rtengine::Coord2D coord(getPosInImgSpace(x, y)); if (coord.x != -1.) { if (!wasInside) { inspector->switchImage(filename); + wasInside = true; } - - wasInside = true; inspector->mouseMove(coord, 0); } else { - if (wasInside) { - wasInside = false; - rtengine::Coord2D coord(-1, -1); - } + wasInside = false; } } - if (inside (x, y)) { - updateCursor (ix, iy); + if (inside(x, y)) { + updateCursor(ix, iy); } if (state == SRotateSelecting) { diff --git a/rtgui/filebrowserentry.h b/rtgui/filebrowserentry.h index 3a3d32977..5122de55f 100644 --- a/rtgui/filebrowserentry.h +++ b/rtgui/filebrowserentry.h @@ -93,9 +93,9 @@ public: void refreshQuickThumbnailImage () override; void calcThumbnailSize () override; - std::vector > getIconsOnImageArea () override; - std::vector > getSpecificityIconsOnImageArea () override; - void getIconSize (int& w, int& h) override; + std::vector> getIconsOnImageArea () override; + std::vector> getSpecificityIconsOnImageArea () override; + void getIconSize (int& w, int& h) const override; // thumbnaillistener interface void procParamsChanged (Thumbnail* thm, int whoChangedIt) override; diff --git a/rtgui/filecatalog.cc b/rtgui/filecatalog.cc index fcccaac3a..dbe540cb4 100644 --- a/rtgui/filecatalog.cc +++ b/rtgui/filecatalog.cc @@ -563,44 +563,49 @@ void FileCatalog::closeDir () redrawAll (); } -std::vector FileCatalog::getFileList () +std::vector FileCatalog::getFileList() { + std::vector names; - std::set extensions; - for (const auto& parsedExt : options.parsedExtensions) { - extensions.emplace (parsedExt.lowercase ()); - } + const std::set& extensions = options.parsedExtensionsSet; try { - auto dir = Gio::File::create_for_path (selectedDirectory); + const auto dir = Gio::File::create_for_path(selectedDirectory); - auto enumerator = dir->enumerate_children ("standard::name"); + auto enumerator = dir->enumerate_children("standard::name,standard::type,standard::is-hidden"); while (true) { try { - auto file = enumerator->next_file (); + const auto file = enumerator->next_file(); if (!file) { break; } - const Glib::ustring fname = file->get_name (); - - auto lastdot = fname.find_last_of ('.'); - if (lastdot >= fname.length () - 1) { + if (file->get_file_type() == Gio::FILE_TYPE_DIRECTORY) { continue; } - const auto fext = fname.substr (lastdot + 1).lowercase (); - if (extensions.count (fext) == 0) { + if (!options.fbShowHidden && file->is_hidden()) { continue; } - names.emplace_back (Glib::build_filename (selectedDirectory, fname)); + const Glib::ustring fname = file->get_name(); + const auto lastdot = fname.find_last_of('.'); + + if (lastdot >= fname.length() - 1) { + continue; + } + + if (extensions.find(fname.substr(lastdot + 1).lowercase()) == extensions.end()) { + continue; + } + + names.push_back(Glib::build_filename(selectedDirectory, fname)); } catch (Glib::Exception& exception) { if (options.rtSettings.verbose) { - std::cerr << exception.what () << std::endl; + std::cerr << exception.what() << std::endl; } } } @@ -620,13 +625,13 @@ void FileCatalog::dirSelected (const Glib::ustring& dirname, const Glib::ustring { try { - Glib::RefPtr dir = Gio::File::create_for_path (dirname); + const Glib::RefPtr dir = Gio::File::create_for_path(dirname); if (!dir) { return; } - closeDir (); + closeDir(); previewsToLoad = 0; previewsLoaded = 0; @@ -636,16 +641,14 @@ void FileCatalog::dirSelected (const Glib::ustring& dirname, const Glib::ustring } selectedDirectory = dir->get_parse_name(); - //printf("FileCatalog::dirSelected selectedDirectory = %s\n",selectedDirectory.c_str()); - BrowsePath->set_text (selectedDirectory); - buttonBrowsePath->set_image (*iRefreshWhite); - fileNameList = getFileList (); + + BrowsePath->set_text(selectedDirectory); + buttonBrowsePath->set_image(*iRefreshWhite); + fileNameList = getFileList(); for (unsigned int i = 0; i < fileNameList.size(); i++) { - Glib::RefPtr f = Gio::File::create_for_path(fileNameList[i]); - - if (f->get_parse_name() != openfile) { // if we opened a file at the beginning don't add it again - checkAndAddFile (f); + if (openfile.empty() || fileNameList[i] != openfile) { // if we opened a file at the beginning don't add it again + addFile(fileNameList[i]); } } @@ -696,34 +699,33 @@ void FileCatalog::_refreshProgressBar () // In tab mode, no progress bar at all // Also mention that this progress bar only measures the FIRST pass (quick thumbnails) // The second, usually longer pass is done multithreaded down in the single entries and is NOT measured by this - if (!inTabMode) { + if (!inTabMode && (!previewsToLoad || std::floor(100.f * previewsLoaded / previewsToLoad) != std::floor(100.f * (previewsLoaded - 1) / previewsToLoad))) { GThreadLock lock; // All GUI access from idle_add callbacks or separate thread HAVE to be protected - Gtk::Notebook *nb = (Gtk::Notebook *)(filepanel->get_parent()); - Gtk::Grid* grid = Gtk::manage (new Gtk::Grid ()); + Gtk::Grid* grid = Gtk::manage(new Gtk::Grid()); Gtk::Label *label = nullptr; - if (!previewsToLoad ) { - grid->attach_next_to(*Gtk::manage (new RTImage ("folder-closed.png")), options.mainNBVertical ? Gtk::POS_TOP : Gtk::POS_RIGHT, 1, 1); + if (!previewsToLoad) { + grid->attach_next_to(*Gtk::manage(new RTImage("folder-closed.png")), options.mainNBVertical ? Gtk::POS_TOP : Gtk::POS_RIGHT, 1, 1); int filteredCount = min(fileBrowser->getNumFiltered(), previewsLoaded); - label = Gtk::manage (new Gtk::Label (M("MAIN_FRAME_FILEBROWSER") + - (filteredCount != previewsLoaded ? " [" + Glib::ustring::format(filteredCount) + "/" : " (") - + Glib::ustring::format(previewsLoaded) + - (filteredCount != previewsLoaded ? "]" : ")"))); + label = Gtk::manage(new Gtk::Label(M("MAIN_FRAME_FILEBROWSER") + + (filteredCount != previewsLoaded ? " [" + Glib::ustring::format(filteredCount) + "/" : " (") + + Glib::ustring::format(previewsLoaded) + + (filteredCount != previewsLoaded ? "]" : ")"))); } else { - grid->attach_next_to(*Gtk::manage (new RTImage ("magnifier.png")), options.mainNBVertical ? Gtk::POS_TOP : Gtk::POS_RIGHT, 1, 1); - label = Gtk::manage (new Gtk::Label (M("MAIN_FRAME_FILEBROWSER") + " [" + Glib::ustring::format(std::fixed, std::setprecision(0), std::setw(3), (double)previewsLoaded / previewsToLoad * 100 ) + "%]" )); + grid->attach_next_to(*Gtk::manage(new RTImage("magnifier.png")), options.mainNBVertical ? Gtk::POS_TOP : Gtk::POS_RIGHT, 1, 1); + label = Gtk::manage(new Gtk::Label(M("MAIN_FRAME_FILEBROWSER") + " [" + Glib::ustring::format(std::fixed, std::setprecision(0), std::setw(3), (double)previewsLoaded / previewsToLoad * 100 ) + "%]" )); filepanel->loadingThumbs("", (double)previewsLoaded / previewsToLoad); } - if( options.mainNBVertical ) { + if (options.mainNBVertical) { label->set_angle(90); } grid->attach_next_to(*label, options.mainNBVertical ? Gtk::POS_TOP : Gtk::POS_RIGHT, 1, 1); - grid->set_tooltip_markup (M("MAIN_FRAME_FILEBROWSER_TOOLTIP")); - grid->show_all (); + grid->set_tooltip_markup(M("MAIN_FRAME_FILEBROWSER_TOOLTIP")); + grid->show_all(); if (nb) { nb->set_tab_label(*filepanel, *grid); @@ -1005,12 +1007,16 @@ void FileCatalog::copyMoveRequested(const std::vector& tbe, b Gtk::FileChooserDialog fc (getToplevelWindow (this), fc_title, Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER ); fc.add_button( M("GENERAL_CANCEL"), Gtk::RESPONSE_CANCEL); fc.add_button( M("GENERAL_OK"), Gtk::RESPONSE_OK); - // open dialog at the 1-st file's path - fc.set_filename(tbe[0]->filename); + if (!options.lastCopyMovePath.empty() && Glib::file_test(options.lastCopyMovePath, Glib::FILE_TEST_IS_DIR)) { + fc.set_current_folder(options.lastCopyMovePath); + } else { + // open dialog at the 1-st file's path + fc.set_current_folder(Glib::path_get_dirname(tbe[0]->filename)); + } //!!! TODO prevent dialog closing on "enter" key press if( fc.run() == Gtk::RESPONSE_OK ) { - Glib::ustring dest_Dir = fc.get_current_folder(); + options.lastCopyMovePath = fc.get_current_folder(); // iterate through selected files for (unsigned int i = 0; i < tbe.size(); i++) { @@ -1027,10 +1033,10 @@ void FileCatalog::copyMoveRequested(const std::vector& tbe, b Glib::ustring fname_Ext = getExtension(fname); // construct destination File Paths - Glib::ustring dest_fPath = Glib::build_filename (dest_Dir, fname); + Glib::ustring dest_fPath = Glib::build_filename (options.lastCopyMovePath, fname); Glib::ustring dest_fPath_param = dest_fPath + paramFileExtension; - if (moveRequested && (src_Dir == dest_Dir)) { + if (moveRequested && (src_Dir == options.lastCopyMovePath)) { continue; } @@ -1085,7 +1091,7 @@ void FileCatalog::copyMoveRequested(const std::vector& tbe, b // adjust destination fname to avoid conflicts (append "_", preserve extension) Glib::ustring dest_fname = Glib::ustring::compose("%1%2%3%4%5", fname_noExt, "_", i_copyindex, ".", fname_Ext); // re-construct destination File Paths - dest_fPath = Glib::build_filename (dest_Dir, dest_fname); + dest_fPath = Glib::build_filename (options.lastCopyMovePath, dest_fname); dest_fPath_param = dest_fPath + paramFileExtension; i_copyindex++; } @@ -1677,49 +1683,46 @@ void FileCatalog::reparseDirectory () return; } - if (!Glib::file_test (selectedDirectory, Glib::FILE_TEST_IS_DIR)) { - closeDir (); + if (!Glib::file_test(selectedDirectory, Glib::FILE_TEST_IS_DIR)) { + closeDir(); return; } - std::vector nfileNameList = getFileList (); - // check if a thumbnailed file has been deleted - const std::vector& t = fileBrowser->getEntries (); + const std::vector& t = fileBrowser->getEntries(); std::vector fileNamesToDel; - for (size_t i = 0; i < t.size(); i++) - if (!Glib::file_test (t[i]->filename, Glib::FILE_TEST_EXISTS)) { - fileNamesToDel.push_back (t[i]->filename); + for (const auto& entry : t) { + if (!Glib::file_test(entry->filename, Glib::FILE_TEST_EXISTS)) { + fileNamesToDel.push_back(entry->filename); } - - for (size_t i = 0; i < fileNamesToDel.size(); i++) { - delete fileBrowser->delEntry (fileNamesToDel[i]); - cacheMgr->deleteEntry (fileNamesToDel[i]); - previewsLoaded--; } - if (!fileNamesToDel.empty ()) { + for (const auto& toDelete : fileNamesToDel) { + delete fileBrowser->delEntry(toDelete); + cacheMgr->deleteEntry(toDelete); + --previewsLoaded; + } + + if (!fileNamesToDel.empty()) { _refreshProgressBar(); } // check if a new file has been added - for (size_t i = 0; i < nfileNameList.size(); i++) { - bool found = false; + // build a set of collate-keys for faster search + std::set oldNames; + for (const auto& oldName : fileNameList) { + oldNames.insert(oldName.collate_key()); + } - for (size_t j = 0; j < fileNameList.size(); j++) - if (nfileNameList[i] == fileNameList[j]) { - found = true; - break; - } - - if (!found) { - checkAndAddFile (Gio::File::create_for_parse_name (nfileNameList[i])); - _refreshProgressBar (); + fileNameList = getFileList(); + for (const auto& newName : fileNameList) { + if (oldNames.find(newName.collate_key()) == oldNames.end()) { + addFile(newName); + _refreshProgressBar(); } } - fileNameList = nfileNameList; } void FileCatalog::on_dir_changed (const Glib::RefPtr& file, const Glib::RefPtr& other_file, Gio::FileMonitorEvent event_type, bool internal) @@ -1736,85 +1739,55 @@ void FileCatalog::on_dir_changed (const Glib::RefPtr& file, const Gli } } -void FileCatalog::checkAndAddFile (Glib::RefPtr file) +void FileCatalog::addFile (const Glib::ustring& fName) { - - if (!file) { - return; - } - - try { - - const auto info = file->query_info("standard::*"); - - if (!info || info->get_file_type() == Gio::FILE_TYPE_DIRECTORY) { - return; - } - - if (!options.fbShowHidden && info->is_hidden()) { - return; - } - - Glib::ustring ext; - - const auto lastdot = info->get_name().find_last_of('.'); - - if (lastdot != Glib::ustring::npos) { - ext = info->get_name().substr(lastdot + 1); - } - - if (!options.is_extention_enabled(ext)) { - return; - } - - previewLoader->add(selectedDirectoryId, file->get_parse_name(), this); + if (!fName.empty()) { + previewLoader->add(selectedDirectoryId, fName, this); previewsToLoad++; - - } catch(Gio::Error&) {} + } } void FileCatalog::addAndOpenFile (const Glib::ustring& fname) { - auto file = Gio::File::create_for_path (fname); + auto file = Gio::File::create_for_path(fname); if (!file ) { return; } - if (!file->query_exists ()) { + if (!file->query_exists()) { return; } try { - auto info = file->query_info (); + const auto info = file->query_info(); if (!info) { return; } - Glib::ustring ext; - - auto lastdot = info->get_name().find_last_of ('.'); + const auto lastdot = info->get_name().find_last_of('.'); if (lastdot != Glib::ustring::npos) { - ext = info->get_name ().substr (lastdot + 1); - } - - if (!options.is_extention_enabled(ext)) { + if (!options.is_extention_enabled(info->get_name().substr(lastdot + 1))) { + return; + } + } else { return; } + // if supported, load thumbnail first - const auto tmb = cacheMgr->getEntry (file->get_parse_name ()); + const auto tmb = cacheMgr->getEntry(file->get_parse_name()); if (!tmb) { return; } - FileBrowserEntry* entry = new FileBrowserEntry (tmb, file->get_parse_name ()); - previewReady (selectedDirectoryId, entry); + FileBrowserEntry* entry = new FileBrowserEntry(tmb, file->get_parse_name()); + previewReady(selectedDirectoryId, entry); // open the file - tmb->increaseRef (); + tmb->increaseRef(); idle_register.add( [this, tmb]() -> bool { @@ -1829,27 +1802,30 @@ void FileCatalog::addAndOpenFile (const Glib::ustring& fname) void FileCatalog::emptyTrash () { - const std::vector t = fileBrowser->getEntries (); + const auto& t = fileBrowser->getEntries(); std::vector toDel; - for (size_t i = 0; i < t.size(); i++) - if ((static_cast(t[i]))->thumbnail->getStage() == 1) { - toDel.push_back (static_cast(t[i])); + for (const auto entry : t) { + if ((static_cast(entry))->thumbnail->getStage() == 1) { + toDel.push_back(static_cast(entry)); } - - deleteRequested (toDel, false, false); - trashChanged(); + } + if (toDel.size() > 0) { + deleteRequested(toDel, false, false); + trashChanged(); + } } bool FileCatalog::trashIsEmpty () { - const std::vector t = fileBrowser->getEntries (); - for (size_t i = 0; i < t.size(); i++) - if ((static_cast(t[i]))->thumbnail->getStage() == 1) { + const auto& t = fileBrowser->getEntries(); + + for (const auto entry : t) { + if ((static_cast(entry))->thumbnail->getStage() == 1) { return false; } - + } return true; } diff --git a/rtgui/filecatalog.h b/rtgui/filecatalog.h index 4c0d13e51..2f3054bcf 100644 --- a/rtgui/filecatalog.h +++ b/rtgui/filecatalog.h @@ -141,7 +141,7 @@ private: IdleRegister idle_register; void addAndOpenFile (const Glib::ustring& fname); - void checkAndAddFile (Glib::RefPtr info); + void addFile (const Glib::ustring& fName); std::vector getFileList (); BrowserFilter getFilter (); void trashChanged (); diff --git a/rtgui/filethumbnailbuttonset.cc b/rtgui/filethumbnailbuttonset.cc index 455ed8555..4c7d8743d 100644 --- a/rtgui/filethumbnailbuttonset.cc +++ b/rtgui/filethumbnailbuttonset.cc @@ -29,12 +29,14 @@ Cairo::RefPtr FileThumbnailButtonSet::unRankIcon; Cairo::RefPtr FileThumbnailButtonSet::trashIcon; Cairo::RefPtr FileThumbnailButtonSet::unTrashIcon; Cairo::RefPtr FileThumbnailButtonSet::processIcon; -Cairo::RefPtr FileThumbnailButtonSet::colorLabelIcon_0; -Cairo::RefPtr FileThumbnailButtonSet::colorLabelIcon_1; -Cairo::RefPtr FileThumbnailButtonSet::colorLabelIcon_2; -Cairo::RefPtr FileThumbnailButtonSet::colorLabelIcon_3; -Cairo::RefPtr FileThumbnailButtonSet::colorLabelIcon_4; -Cairo::RefPtr FileThumbnailButtonSet::colorLabelIcon_5; +std::array, 6> FileThumbnailButtonSet::colorLabelIcon; + +Glib::ustring FileThumbnailButtonSet::processToolTip; +Glib::ustring FileThumbnailButtonSet::unrankToolTip; +Glib::ustring FileThumbnailButtonSet::trashToolTip; +Glib::ustring FileThumbnailButtonSet::untrashToolTip; +Glib::ustring FileThumbnailButtonSet::colorLabelToolTip; +std::array FileThumbnailButtonSet::rankToolTip; FileThumbnailButtonSet::FileThumbnailButtonSet (FileBrowserEntry* myEntry) { @@ -46,73 +48,57 @@ FileThumbnailButtonSet::FileThumbnailButtonSet (FileBrowserEntry* myEntry) trashIcon = Cairo::RefPtr(new RTSurface("trash-small.png")); unTrashIcon = Cairo::RefPtr(new RTSurface("trash-remove-small.png")); processIcon = Cairo::RefPtr(new RTSurface("gears-small.png")); + colorLabelIcon[0] = Cairo::RefPtr(new RTSurface("circle-empty-gray-small.png")); + colorLabelIcon[1] = Cairo::RefPtr(new RTSurface("circle-red-small.png")); + colorLabelIcon[2] = Cairo::RefPtr(new RTSurface("circle-yellow-small.png")); + colorLabelIcon[3] = Cairo::RefPtr(new RTSurface("circle-green-small.png")); + colorLabelIcon[4] = Cairo::RefPtr(new RTSurface("circle-blue-small.png")); + colorLabelIcon[5] = Cairo::RefPtr(new RTSurface("circle-purple-small.png")); + + processToolTip = M("FILEBROWSER_POPUPPROCESS"); + unrankToolTip = M("FILEBROWSER_UNRANK_TOOLTIP"); + trashToolTip = M("FILEBROWSER_POPUPTRASH"); + untrashToolTip = M("FILEBROWSER_POPUPUNTRASH"); + colorLabelToolTip = M("FILEBROWSER_COLORLABEL_TOOLTIP"); + rankToolTip[0] = M("FILEBROWSER_RANK1_TOOLTIP"); + rankToolTip[1] = M("FILEBROWSER_RANK2_TOOLTIP"); + rankToolTip[2] = M("FILEBROWSER_RANK3_TOOLTIP"); + rankToolTip[3] = M("FILEBROWSER_RANK4_TOOLTIP"); + rankToolTip[4] = M("FILEBROWSER_RANK5_TOOLTIP"); - colorLabelIcon_0 = Cairo::RefPtr(new RTSurface("circle-empty-gray-small.png")); - colorLabelIcon_1 = Cairo::RefPtr(new RTSurface("circle-red-small.png")); - colorLabelIcon_2 = Cairo::RefPtr(new RTSurface("circle-yellow-small.png")); - colorLabelIcon_3 = Cairo::RefPtr(new RTSurface("circle-green-small.png")); - colorLabelIcon_4 = Cairo::RefPtr(new RTSurface("circle-blue-small.png")); - colorLabelIcon_5 = Cairo::RefPtr(new RTSurface("circle-purple-small.png"));; iconsLoaded = true; } - add (new LWButton (processIcon, 6, myEntry, LWButton::Left, LWButton::Center, M("FILEBROWSER_POPUPPROCESS"))); - add (new LWButton (unRankIcon, 0, myEntry, LWButton::Left, LWButton::Center, M("FILEBROWSER_UNRANK_TOOLTIP"))); + add(new LWButton(processIcon, 6, myEntry, LWButton::Left, LWButton::Center, &processToolTip)); + add(new LWButton(unRankIcon, 0, myEntry, LWButton::Left, LWButton::Center, &unrankToolTip)); for (int i = 0; i < 5; i++) { - add (new LWButton (rankIcon, i + 1, myEntry, LWButton::Left)); + add(new LWButton(rankIcon, i + 1, myEntry, LWButton::Left, LWButton::Center, &rankToolTip[i])); } - add (new LWButton (trashIcon, 7, myEntry, LWButton::Right, LWButton::Center, M("FILEBROWSER_POPUPTRASH"))); - - add (new LWButton (colorLabelIcon_0, 8, myEntry, LWButton::Right, LWButton::Center, M("FILEBROWSER_COLORLABEL_TOOLTIP"))); - - buttons[2]->setToolTip (M("FILEBROWSER_RANK1_TOOLTIP")); - buttons[3]->setToolTip (M("FILEBROWSER_RANK2_TOOLTIP")); - buttons[4]->setToolTip (M("FILEBROWSER_RANK3_TOOLTIP")); - buttons[5]->setToolTip (M("FILEBROWSER_RANK4_TOOLTIP")); - buttons[6]->setToolTip (M("FILEBROWSER_RANK5_TOOLTIP")); + add(new LWButton(trashIcon, 7, myEntry, LWButton::Right, LWButton::Center, &trashToolTip)); + add(new LWButton(colorLabelIcon[0], 8, myEntry, LWButton::Right, LWButton::Center, &colorLabelToolTip)); } void FileThumbnailButtonSet::setRank (int stars) { for (int i = 1; i <= 5; i++) { - buttons[i + 1]->setIcon (i <= stars ? rankIcon : gRankIcon); + buttons[i + 1]->setIcon(i <= stars ? rankIcon : gRankIcon); } } void FileThumbnailButtonSet::setColorLabel (int colorLabel) { - if (colorLabel == 0) { - buttons[8]->setIcon (colorLabelIcon_0); //transparent label - } - - if (colorLabel == 1) { - buttons[8]->setIcon (colorLabelIcon_1); - } - - if (colorLabel == 2) { - buttons[8]->setIcon (colorLabelIcon_2); - } - - if (colorLabel == 3) { - buttons[8]->setIcon (colorLabelIcon_3); - } - - if (colorLabel == 4) { - buttons[8]->setIcon (colorLabelIcon_4); - } - - if (colorLabel == 5) { - buttons[8]->setIcon (colorLabelIcon_5); + if (colorLabel >= 0 && colorLabel <= 5) { + buttons[8]->setIcon(colorLabelIcon[colorLabel]); } } void FileThumbnailButtonSet::setInTrash (bool inTrash) { - buttons[7]->setIcon (inTrash ? unTrashIcon : trashIcon); - buttons[7]->setToolTip (inTrash ? M("FILEBROWSER_POPUPUNTRASH") : M("FILEBROWSER_POPUPTRASH")); + buttons[7]->setIcon(inTrash ? unTrashIcon : trashIcon); + buttons[7]->setToolTip(inTrash ? &untrashToolTip : &trashToolTip); } diff --git a/rtgui/filethumbnailbuttonset.h b/rtgui/filethumbnailbuttonset.h index 57811addd..13265b8c0 100644 --- a/rtgui/filethumbnailbuttonset.h +++ b/rtgui/filethumbnailbuttonset.h @@ -19,6 +19,8 @@ #ifndef _FILETHUMBNAILBUTTONSET_ #define _FILETHUMBNAILBUTTONSET_ +#include + #include "lwbuttonset.h" #include #include "filebrowserentry.h" @@ -38,12 +40,14 @@ public: static Cairo::RefPtr unTrashIcon; static Cairo::RefPtr processIcon; - static Cairo::RefPtr colorLabelIcon_0; - static Cairo::RefPtr colorLabelIcon_1; - static Cairo::RefPtr colorLabelIcon_2; - static Cairo::RefPtr colorLabelIcon_3; - static Cairo::RefPtr colorLabelIcon_4; - static Cairo::RefPtr colorLabelIcon_5; + static std::array, 6> colorLabelIcon; + + static Glib::ustring processToolTip; + static Glib::ustring unrankToolTip; + static Glib::ustring trashToolTip; + static Glib::ustring untrashToolTip; + static Glib::ustring colorLabelToolTip; + static std::array rankToolTip; explicit FileThumbnailButtonSet (FileBrowserEntry* myEntry); void setRank (int stars); diff --git a/rtgui/inspector.h b/rtgui/inspector.h index d5ed327b8..86ad9114e 100644 --- a/rtgui/inspector.h +++ b/rtgui/inspector.h @@ -87,7 +87,7 @@ public: /** @brief Get the on/off state */ - bool isActive() + bool isActive() const { return active; }; diff --git a/rtgui/lwbutton.cc b/rtgui/lwbutton.cc index 48843a02e..02041ea0c 100644 --- a/rtgui/lwbutton.cc +++ b/rtgui/lwbutton.cc @@ -19,7 +19,7 @@ #include "lwbutton.h" #include "guiutils.h" -LWButton::LWButton (Cairo::RefPtr i, int aCode, void* aData, Alignment ha, Alignment va, Glib::ustring tooltip) +LWButton::LWButton (Cairo::RefPtr i, int aCode, void* aData, Alignment ha, Alignment va, Glib::ustring* tooltip) : xpos(0), ypos(0), halign(ha), valign(va), icon(i), bgr(0.0), bgg(0.0), bgb(0.0), fgr(0.0), fgg(0.0), fgb(0.0), state(Normal), listener(nullptr), actionCode(aCode), actionData(aData), toolTip(tooltip) { @@ -31,7 +31,7 @@ LWButton::LWButton (Cairo::RefPtr i, int aCode, void* aData, Alignmen } } -void LWButton::getSize (int& minw, int& minh) +void LWButton::getSize (int& minw, int& minh) const { minw = w; @@ -45,7 +45,7 @@ void LWButton::setPosition (int x, int y) ypos = y; } -void LWButton::getPosition (int& x, int& y) +void LWButton::getPosition (int& x, int& y) const { x = xpos; @@ -65,7 +65,7 @@ void LWButton::setIcon (Cairo::RefPtr i) } } -Cairo::RefPtr LWButton::getIcon () +Cairo::RefPtr LWButton::getIcon () const { return icon; @@ -82,7 +82,7 @@ void LWButton::setColors (const Gdk::RGBA& bg, const Gdk::RGBA& fg) fgb = fg.get_blue (); } -bool LWButton::inside (int x, int y) +bool LWButton::inside (int x, int y) const { return x > xpos && x < xpos + w && y > ypos && y < ypos + h; @@ -210,24 +210,27 @@ void LWButton::redraw (Cairo::RefPtr context) } } -void LWButton::getAlignment (Alignment& ha, Alignment& va) +void LWButton::getAlignment (Alignment& ha, Alignment& va) const { ha = halign; va = valign; } -Glib::ustring LWButton::getToolTip (int x, int y) +Glib::ustring LWButton::getToolTip (int x, int y) const { - - if (inside (x, y)) { - return toolTip; - } else { - return ""; - } + if (inside(x, y)) { + if (toolTip) { + return *toolTip; + } else { + return ""; + } + } else { + return ""; + } } -void LWButton::setToolTip (const Glib::ustring& tooltip) +void LWButton::setToolTip (Glib::ustring* tooltip) { toolTip = tooltip; diff --git a/rtgui/lwbutton.h b/rtgui/lwbutton.h index 4ab34f265..aec875d55 100644 --- a/rtgui/lwbutton.h +++ b/rtgui/lwbutton.h @@ -49,26 +49,26 @@ private: LWButtonListener* listener; int actionCode; void* actionData; - Glib::ustring toolTip; + Glib::ustring* toolTip; public: - LWButton (Cairo::RefPtr i, int aCode, void* aData, Alignment ha = Left, Alignment va = Center, Glib::ustring tooltip = ""); + LWButton (Cairo::RefPtr i, int aCode, void* aData, Alignment ha = Left, Alignment va = Center, Glib::ustring* tooltip = nullptr); - void getSize (int& minw, int& minh); - void getAlignment (Alignment& ha, Alignment& va); + void getSize (int& minw, int& minh) const; + void getAlignment (Alignment& ha, Alignment& va) const; void setPosition (int x, int y); - void getPosition (int& x, int& y); - bool inside (int x, int y); + void getPosition (int& x, int& y) const; + bool inside (int x, int y) const; void setIcon (Cairo::RefPtr i); - Cairo::RefPtr getIcon (); + Cairo::RefPtr getIcon () const; void setColors (const Gdk::RGBA& bg, const Gdk::RGBA& fg); - void setToolTip (const Glib::ustring& tooltip); + void setToolTip (Glib::ustring* tooltip); bool motionNotify (int x, int y); bool pressNotify (int x, int y); bool releaseNotify (int x, int y); - Glib::ustring getToolTip (int x, int y); + Glib::ustring getToolTip (int x, int y) const; void setButtonListener (LWButtonListener* bl) { diff --git a/rtgui/lwbuttonset.cc b/rtgui/lwbuttonset.cc index 6265c1039..99d3dce7c 100644 --- a/rtgui/lwbuttonset.cc +++ b/rtgui/lwbuttonset.cc @@ -18,7 +18,7 @@ */ #include "lwbuttonset.h" -LWButtonSet::LWButtonSet () : aw(0), ah(0), ax(0), ay(0) +LWButtonSet::LWButtonSet () : aw(0), ah(0), ax(-1), ay(-1) { } @@ -42,20 +42,21 @@ void LWButtonSet::getMinimalDimensions (int& w, int& h) w = 0; h = 0; - for (size_t i = 0; i < buttons.size(); i++) { + for (const auto entry : buttons) { int bw, bh; - buttons[i]->getSize (bw, bh); + entry->getSize(bw, bh); w += bw; - - if (bh > h) { - h = bh; - } + h = std::max(bh, h); } } void LWButtonSet::arrangeButtons (int x, int y, int w, int h) { + if (x == ax && y == ay && w == aw && (h == -1 || h == ah )) { + return; + } + int mw, mh; getMinimalDimensions (mw, mh); diff --git a/rtgui/options.cc b/rtgui/options.cc index 2437f5313..640aa0243 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -369,6 +369,7 @@ void Options::setDefaults() multiUser = true; profilePath = "profiles"; loadSaveProfilePath = ""; // will be corrected in load as otherwise construction fails + lastCopyMovePath = ""; version = "0.0.0.0"; // temporary value; will be correctly set in RTWindow::on_realize thumbSize = 160; thumbSizeTab = 160; @@ -412,6 +413,7 @@ void Options::setDefaults() favorites.clear(); parseExtensionsEnabled.clear(); parsedExtensions.clear(); + parsedExtensionsSet.clear(); renameUseTemplates = false; renameTemplates.clear(); thumbnailZoomRatios.clear(); @@ -648,10 +650,12 @@ Options* Options::copyFrom(Options* other) void Options::filterOutParsedExtensions() { parsedExtensions.clear(); + parsedExtensionsSet.clear(); for (unsigned int i = 0; i < parseExtensions.size(); i++) if (parseExtensionsEnabled[i]) { parsedExtensions.push_back(parseExtensions[i].lowercase()); + parsedExtensionsSet.emplace(parseExtensions[i].lowercase()); } } @@ -1836,6 +1840,7 @@ void Options::readFromFile(Glib::ustring fname) safeDirGet(keyFile, "Dialogs", "LastProfilingReferenceDir", lastProfilingReferenceDir); safeDirGet(keyFile, "Dialogs", "LastLensProfileDir", lastLensProfileDir); safeDirGet(keyFile, "Dialogs", "LastICCProfCreatorDir", lastICCProfCreatorDir); + safeDirGet(keyFile, "Dialogs", "LastCopyMovePath", lastCopyMovePath); if (keyFile.has_key("Dialogs", "GimpPluginShowInfoDialog")) { gimpPluginShowInfoDialog = keyFile.get_boolean("Dialogs", "GimpPluginShowInfoDialog"); @@ -2229,6 +2234,7 @@ void Options::saveToFile(Glib::ustring fname) keyFile.set_string("Dialogs", "LastProfilingReferenceDir", lastProfilingReferenceDir); keyFile.set_string("Dialogs", "LastLensProfileDir", lastLensProfileDir); keyFile.set_string("Dialogs", "LastICCProfCreatorDir", lastICCProfCreatorDir); + keyFile.set_string("Dialogs", "LastCopyMovePath", lastCopyMovePath); keyFile.set_boolean("Dialogs", "GimpPluginShowInfoDialog", gimpPluginShowInfoDialog); keyFile.set_string("Lensfun", "DBDirectory", rtSettings.lensfunDbDirectory); @@ -2464,36 +2470,17 @@ bool Options::is_parse_extention(Glib::ustring fname) /* * return true if fname ends with one of the retained image file extensions */ -bool Options::has_retained_extention(Glib::ustring fname) +bool Options::has_retained_extention(const Glib::ustring& fname) { - - Glib::ustring ext = getExtension(fname).lowercase(); - - if (!ext.empty()) { - // there is an extension to the filename - - // look out if it has one of the retained extensions - for (unsigned int i = 0; i < parsedExtensions.size(); i++) { - if (ext == parsedExtensions[i]) { - return true; - } - } - } - - return false; + return parsedExtensionsSet.find(getExtension(fname).lowercase()) != parsedExtensionsSet.end(); } /* * return true if ext is an enabled extension */ -bool Options::is_extention_enabled(Glib::ustring ext) +bool Options::is_extention_enabled(const Glib::ustring& ext) { - for (int j = 0; j < (int)parseExtensions.size(); j++) - if (parseExtensions[j].casefold() == ext.casefold()) { - return j >= (int)parseExtensionsEnabled.size() || parseExtensionsEnabled[j]; - } - - return false; + return parsedExtensionsSet.find(ext.lowercase()) != parsedExtensionsSet.end(); } Glib::ustring Options::getUserProfilePath() diff --git a/rtgui/options.h b/rtgui/options.h index 304a1e220..d1d14a11f 100644 --- a/rtgui/options.h +++ b/rtgui/options.h @@ -19,6 +19,7 @@ #ifndef _OPTIONS_ #define _OPTIONS_ +#include #include #include "../rtengine/rtengine.h" #include @@ -174,6 +175,7 @@ public: Glib::ustring startupPath; Glib::ustring profilePath; // can be an absolute or relative path; depending on this value, bundled profiles may not be found bool useBundledProfiles; // only used if multiUser == true + Glib::ustring lastCopyMovePath; Glib::ustring loadSaveProfilePath; Glib::ustring lastSaveAsPath; int saveAsDialogWidth; @@ -259,6 +261,7 @@ public: std::vector parseExtensions; // List containing all extensions type std::vector parseExtensionsEnabled; // List of bool to retain extension or not std::vector parsedExtensions; // List containing all retained extensions (lowercase) + std::set parsedExtensionsSet; // Set containing all retained extensions (lowercase) std::vector tpOpen; bool autoSaveTpOpen; //std::vector crvOpen; @@ -422,8 +425,8 @@ public: Glib::ustring getGlobalProfilePath(); Glib::ustring findProfilePath (Glib::ustring &profName); bool is_parse_extention (Glib::ustring fname); - bool has_retained_extention (Glib::ustring fname); - bool is_extention_enabled (Glib::ustring ext); + bool has_retained_extention (const Glib::ustring& fname); + bool is_extention_enabled (const Glib::ustring& ext); bool is_defProfRawMissing(); bool is_bundledDefProfRawMissing(); bool is_defProfImgMissing(); diff --git a/rtgui/rtimage.cc b/rtgui/rtimage.cc index 6a289ead6..cd687f252 100644 --- a/rtgui/rtimage.cc +++ b/rtgui/rtimage.cc @@ -197,8 +197,7 @@ void RTImage::updateImages() Glib::RefPtr RTImage::createPixbufFromFile (const Glib::ustring& fileName) { Cairo::RefPtr imgSurf = createImgSurfFromFile(fileName); - Glib::RefPtr pixbuf = Gdk::Pixbuf::create(imgSurf, 0, 0, imgSurf->get_width(), imgSurf->get_height()); - return pixbuf; + return Gdk::Pixbuf::create(imgSurf, 0, 0, imgSurf->get_width(), imgSurf->get_height()); } Cairo::RefPtr RTImage::createImgSurfFromFile (const Glib::ustring& fileName) diff --git a/rtgui/thumbbrowserbase.cc b/rtgui/thumbbrowserbase.cc index 334f00e51..1ae0cdf98 100644 --- a/rtgui/thumbbrowserbase.cc +++ b/rtgui/thumbbrowserbase.cc @@ -563,7 +563,7 @@ void ThumbBrowserBase::configScrollBars () } } -void ThumbBrowserBase::arrangeFiles() +void ThumbBrowserBase::arrangeFiles(bool checkfilter) { MYREADERLOCK(l, entryRW); @@ -572,17 +572,17 @@ void ThumbBrowserBase::arrangeFiles() //GThreadLock lock; int rowHeight = 0; - - for (unsigned int i = 0; i < fd.size(); i++) { - // apply filter - fd[i]->filtered = !checkFilter (fd[i]); + for (const auto entry : fd) { + if (checkfilter) { + // apply filter + entry->filtered = !checkFilter(entry); + } // compute size of the items - if (!fd[i]->filtered && fd[i]->getMinimalHeight() > rowHeight) { - rowHeight = fd[i]->getMinimalHeight (); + if (!entry->filtered) { + rowHeight = std::max(entry->getMinimalHeight(), rowHeight); } } - if (arrangement == TB_Horizontal) { numOfCols = 1; @@ -667,9 +667,9 @@ void ThumbBrowserBase::arrangeFiles() } if (ct < fd.size()) { - fd[ct]->setPosition(currx, curry, colWidths[i % numOfCols], rowHeight); + fd[ct]->setPosition(currx, curry, colWidths[i], rowHeight); fd[ct]->drawable = true; - currx += colWidths[i % numOfCols]; + currx += colWidths[i]; } } @@ -970,12 +970,12 @@ bool ThumbBrowserBase::Internal::on_scroll_event (GdkEventScroll* event) } -void ThumbBrowserBase::redraw () +void ThumbBrowserBase::redraw (bool checkfilter) { GThreadLock lock; - arrangeFiles (); - queue_draw (); + arrangeFiles(checkfilter); + queue_draw(); } void ThumbBrowserBase::zoomChanged (bool zoomIn) diff --git a/rtgui/thumbbrowserbase.h b/rtgui/thumbbrowserbase.h index dcda30f92..ae561db43 100644 --- a/rtgui/thumbbrowserbase.h +++ b/rtgui/thumbbrowserbase.h @@ -179,7 +179,7 @@ protected: std::set editedFiles; - void arrangeFiles (); + void arrangeFiles (bool checkfilter = true); void zoomChanged (bool zoomIn); public: @@ -201,7 +201,7 @@ public: return fd; } void on_style_updated () override; - void redraw (); // arrange files and draw area + void redraw (bool checkfilter = true); // arrange files and draw area void refreshThumbImages (); // refresh thumbnail sizes, re-generate thumbnail images, arrange and draw void refreshQuickThumbImages (); // refresh thumbnail sizes, re-generate thumbnail images, arrange and draw void refreshEditedState (const std::set& efiles); diff --git a/rtgui/thumbbrowserentrybase.cc b/rtgui/thumbbrowserentrybase.cc index ed34c65c7..2960ccf70 100644 --- a/rtgui/thumbbrowserentrybase.cc +++ b/rtgui/thumbbrowserentrybase.cc @@ -157,9 +157,6 @@ ThumbBrowserEntryBase::ThumbBrowserEntryBase (const Glib::ustring& fname) : collate_name(getPaddedName(dispname).casefold_collate_key()), thumbnail(nullptr), filename(fname), - shortname(dispname), - exifline(""), - datetimeline(""), selected(false), drawable(false), filtered(false), @@ -439,7 +436,6 @@ void ThumbBrowserEntryBase::getTextSizes (int& infow, int& infoh) Gtk::Widget* w = parent->getDrawingArea (); // calculate dimensions of the text based fields - dispname = shortname; Glib::RefPtr context = w->get_pango_context () ; context->set_font_description (w->get_style_context()->get_font()); @@ -449,7 +445,7 @@ void ThumbBrowserEntryBase::getTextSizes (int& infow, int& infoh) Pango::FontDescription fontd = context->get_font_description (); fontd.set_weight (Pango::WEIGHT_BOLD); context->set_font_description (fontd); - Glib::RefPtr fn = w->create_pango_layout(shortname); + Glib::RefPtr fn = w->create_pango_layout(dispname); fn->get_pixel_size (fnlabw, fnlabh); // calculate cummulated height of all info fields @@ -672,16 +668,15 @@ void ThumbBrowserEntryBase::setOffset (int x, int y) } } -bool ThumbBrowserEntryBase::inside (int x, int y) +bool ThumbBrowserEntryBase::inside (int x, int y) const { return x > ofsX + startx && x < ofsX + startx + exp_width && y > ofsY + starty && y < ofsY + starty + exp_height; } -void ThumbBrowserEntryBase::getPosInImgSpace (int x, int y, rtengine::Coord2D &coord) +rtengine::Coord2D ThumbBrowserEntryBase::getPosInImgSpace (int x, int y) const { - - coord.x = coord.y = -1.; + rtengine::Coord2D coord(-1., -1.); if (preview) { x -= ofsX + startx; @@ -692,15 +687,16 @@ void ThumbBrowserEntryBase::getPosInImgSpace (int x, int y, rtengine::Coord2D &c coord.y = double(y - prey) / double(preh); } } + return coord; } -bool ThumbBrowserEntryBase::insideWindow (int x, int y, int w, int h) +bool ThumbBrowserEntryBase::insideWindow (int x, int y, int w, int h) const { return !(ofsX + startx > x + w || ofsX + startx + exp_width < x || ofsY + starty > y + h || ofsY + starty + exp_height < y); } -std::vector > ThumbBrowserEntryBase::getIconsOnImageArea() +std::vector> ThumbBrowserEntryBase::getIconsOnImageArea() { return std::vector >(); } @@ -710,12 +706,6 @@ std::vector > ThumbBrowserEntryBase::getSpecificityIco return std::vector >(); } -void ThumbBrowserEntryBase::getIconSize(int& w, int& h) -{ - w = 0; - h = 0; -} - bool ThumbBrowserEntryBase::motionNotify (int x, int y) { @@ -734,12 +724,12 @@ bool ThumbBrowserEntryBase::releaseNotify (int button, int type, int bstate, int return buttonSet ? buttonSet->releaseNotify (x, y) : false; } -Glib::ustring ThumbBrowserEntryBase::getToolTip (int x, int y) +Glib::ustring ThumbBrowserEntryBase::getToolTip (int x, int y) const { - Glib::ustring tooltip = ""; + Glib::ustring tooltip; if (buttonSet) { - tooltip = buttonSet->getToolTip (x, y); + tooltip = buttonSet->getToolTip(x, y); } // Always show the filename in the tooltip since the filename in the thumbnail could be truncated. @@ -748,11 +738,11 @@ Glib::ustring ThumbBrowserEntryBase::getToolTip (int x, int y) tooltip = dispname; if (withFilename < WFNAME_FULL) { - if (options.fbShowDateTime && datetimeline != "") { + if (options.fbShowDateTime && !datetimeline.empty()) { tooltip += Glib::ustring("\n") + datetimeline; } - if (options.fbShowBasicExif && exifline != "") { + if (options.fbShowBasicExif && !exifline.empty()) { tooltip += Glib::ustring("\n") + exifline; } } diff --git a/rtgui/thumbbrowserentrybase.h b/rtgui/thumbbrowserentrybase.h index 8237b7c6b..12e64c60d 100644 --- a/rtgui/thumbbrowserentrybase.h +++ b/rtgui/thumbbrowserentrybase.h @@ -16,8 +16,7 @@ * You should have received a copy of the GNU General Public License * along with RawTherapee. If not, see . */ -#ifndef _THUMBNAILBROWSERENTRYBASE_ -#define _THUMBNAILBROWSERENTRYBASE_ +#pragma once #include @@ -82,8 +81,8 @@ protected: Glib::RefPtr backBuffer; bool bbSelected, bbFramed; guint8* bbPreview; - std::vector > bbIcons; - std::vector > bbSpecificityIcons; + std::vector> bbIcons; + std::vector> bbSpecificityIcons; CursorShape cursor_type; void drawFrame (Cairo::RefPtr cr, const Gdk::RGBA& bg, const Gdk::RGBA& fg); @@ -101,7 +100,6 @@ public: // thumbnail preview properties: Glib::ustring filename; - Glib::ustring shortname; Glib::ustring exifline; Glib::ustring datetimeline; @@ -117,61 +115,61 @@ public: bool updatepriority; eWithFilename withFilename; - explicit ThumbBrowserEntryBase (const Glib::ustring& fname); - virtual ~ThumbBrowserEntryBase (); + explicit ThumbBrowserEntryBase (const Glib::ustring& fname); + virtual ~ThumbBrowserEntryBase (); void setParent (ThumbBrowserBase* l) { parent = l; } - void updateBackBuffer (); - void resize (int h); - virtual void draw (Cairo::RefPtr cc); + void updateBackBuffer (); + void resize (int h); + virtual void draw (Cairo::RefPtr cc); - void addButtonSet (LWButtonSet* bs); - int getMinimalHeight () + void addButtonSet (LWButtonSet* bs); + int getMinimalHeight () const { return height; } - int getMinimalWidth () + int getMinimalWidth () const { return width; } - int getEffectiveWidth () const + int getEffectiveWidth () const { return exp_width; } - int getEffectiveHeight () const + int getEffectiveHeight () const { return exp_height; } - int getPreviewHeight () const + int getPreviewHeight () const { return preh; } - int getStartX () const + int getStartX () const { return startx; } - int getStartY () const + int getStartY () const { return starty; } - int getX () const + int getX () const { return ofsX + startx; } - int getY () const + int getY () const { return ofsY + starty; } - bool inside (int x, int y); - void getPosInImgSpace (int x, int y, rtengine::Coord2D &coord); - bool insideWindow (int x, int y, int w, int h); - void setPosition (int x, int y, int w, int h); + bool inside (int x, int y) const; + rtengine::Coord2D getPosInImgSpace (int x, int y) const; + bool insideWindow (int x, int y, int w, int h) const; + void setPosition (int x, int y, int w, int h); void setOffset (int x, int y); bool operator <(const ThumbBrowserEntryBase& other) const @@ -179,33 +177,29 @@ public: return collate_name < other.collate_name; } - ThumbBrowserEntryBase* getOriginal () const; - void setOriginal (ThumbBrowserEntryBase* original); - - virtual void refreshThumbnailImage () {} + virtual void refreshThumbnailImage () = 0; virtual void refreshQuickThumbnailImage () {} - virtual void calcThumbnailSize () {} + virtual void calcThumbnailSize () = 0; virtual void drawProgressBar (Glib::RefPtr win, const Gdk::RGBA& foregr, const Gdk::RGBA& backgr, int x, int w, int y, int h) {} - virtual std::vector > getIconsOnImageArea (); - virtual std::vector > getSpecificityIconsOnImageArea (); - virtual void getIconSize (int& w, int& h); + virtual std::vector> getIconsOnImageArea (); + virtual std::vector> getSpecificityIconsOnImageArea (); + virtual void getIconSize (int& w, int& h) const = 0; + + virtual bool motionNotify (int x, int y); + virtual bool pressNotify (int button, int type, int bstate, int x, int y); + virtual bool releaseNotify (int button, int type, int bstate, int x, int y); + virtual Glib::ustring getToolTip (int x, int y) const; + + inline ThumbBrowserEntryBase* getOriginal() const + { + return original; + } + + inline void setOriginal(ThumbBrowserEntryBase* original) + { + this->original = original; + } - virtual bool motionNotify (int x, int y); - virtual bool pressNotify (int button, int type, int bstate, int x, int y); - virtual bool releaseNotify (int button, int type, int bstate, int x, int y); - virtual Glib::ustring getToolTip (int x, int y); }; - -inline ThumbBrowserEntryBase* ThumbBrowserEntryBase::getOriginal() const -{ - return original; -} - -inline void ThumbBrowserEntryBase::setOriginal(ThumbBrowserEntryBase* original) -{ - this->original = original; -} - -#endif