filecatalog/filebrowser: further optimizations

This commit is contained in:
Ingo Weyrich 2019-07-19 23:45:02 +02:00
parent 0840b3ee00
commit d9c93e77ae
9 changed files with 89 additions and 116 deletions

View File

@ -160,7 +160,7 @@ std::vector<Glib::RefPtr<Gdk::Pixbuf> > BatchQueueEntry::getIconsOnImageArea ()
return ret; return ret;
} }
void BatchQueueEntry::getIconSize (int& w, int& h) void BatchQueueEntry::getIconSize (int& w, int& h) const
{ {
w = savedAsIcon->get_width (); 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 // get the parent class' tooltip first
Glib::ustring tooltip = ThumbBrowserEntryBase::getToolTip(x, y); Glib::ustring tooltip = ThumbBrowserEntryBase::getToolTip(x, y);

View File

@ -69,8 +69,8 @@ public:
void removeButtonSet (); void removeButtonSet ();
std::vector<Glib::RefPtr<Gdk::Pixbuf>> getIconsOnImageArea () override; std::vector<Glib::RefPtr<Gdk::Pixbuf>> getIconsOnImageArea () override;
void getIconSize (int& w, int& h) override; void getIconSize (int& w, int& h) const override;
Glib::ustring getToolTip (int x, int y) override; Glib::ustring getToolTip (int x, int y) const override;
// bqentryupdatelistener interface // bqentryupdatelistener interface
void updateImage (guint8* img, int w, int h, int origw, int origh, guint8* newOPreview) override; void updateImage (guint8* img, int w, int h, int origw, int origh, guint8* newOPreview) override;

View File

@ -121,13 +121,12 @@ void FileBrowserEntry::calcThumbnailSize ()
std::vector<Glib::RefPtr<Gdk::Pixbuf>> FileBrowserEntry::getIconsOnImageArea () std::vector<Glib::RefPtr<Gdk::Pixbuf>> FileBrowserEntry::getIconsOnImageArea ()
{ {
if (!thumbnail) {
return {};
}
std::vector<Glib::RefPtr<Gdk::Pixbuf>> ret; std::vector<Glib::RefPtr<Gdk::Pixbuf>> ret;
if (!thumbnail) {
return ret;
}
if (thumbnail->hasProcParams() && editedIcon) { if (thumbnail->hasProcParams() && editedIcon) {
ret.push_back(editedIcon); ret.push_back(editedIcon);
} }
@ -145,13 +144,12 @@ std::vector<Glib::RefPtr<Gdk::Pixbuf> > FileBrowserEntry::getIconsOnImageArea ()
std::vector<Glib::RefPtr<Gdk::Pixbuf>> FileBrowserEntry::getSpecificityIconsOnImageArea () std::vector<Glib::RefPtr<Gdk::Pixbuf>> FileBrowserEntry::getSpecificityIconsOnImageArea ()
{ {
if (!thumbnail) {
return {};
}
std::vector<Glib::RefPtr<Gdk::Pixbuf>> ret; std::vector<Glib::RefPtr<Gdk::Pixbuf>> ret;
if (!thumbnail) {
return ret;
}
if (thumbnail->isHDR() && hdr) { if (thumbnail->isHDR() && hdr) {
ret.push_back (hdr); ret.push_back (hdr);
} }
@ -188,7 +186,7 @@ void FileBrowserEntry::customBackBufferUpdate (Cairo::RefPtr<Cairo::Context> c)
} }
} }
void FileBrowserEntry::getIconSize (int& w, int& h) void FileBrowserEntry::getIconSize (int& w, int& h) const
{ {
w = editedIcon->get_width (); w = editedIcon->get_width ();
@ -286,29 +284,24 @@ void FileBrowserEntry::_updateImage(rtengine::IImage8* img, double s, const rten
bool FileBrowserEntry::motionNotify (int x, int y) 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; const int ix = x - startx - ofsX;
int iy = y - starty - ofsY; const int iy = y - starty - ofsY;
Inspector* inspector = parent->getInspector(); Inspector* inspector = parent->getInspector();
if (inspector && inspector->isActive() && !parent->isInTabMode()) { if (inspector && inspector->isActive() && !parent->isInTabMode()) {
rtengine::Coord2D coord(-1., -1.); const rtengine::Coord2D coord(getPosInImgSpace(x, y));
getPosInImgSpace(x, y, coord);
if (coord.x != -1.) { if (coord.x != -1.) {
if (!wasInside) { if (!wasInside) {
inspector->switchImage(filename); inspector->switchImage(filename);
}
wasInside = true; wasInside = true;
}
inspector->mouseMove(coord, 0); inspector->mouseMove(coord, 0);
} else { } else {
if (wasInside) {
wasInside = false; wasInside = false;
rtengine::Coord2D coord(-1, -1);
}
} }
} }

View File

@ -95,7 +95,7 @@ public:
std::vector<Glib::RefPtr<Gdk::Pixbuf>> getIconsOnImageArea () override; std::vector<Glib::RefPtr<Gdk::Pixbuf>> getIconsOnImageArea () override;
std::vector<Glib::RefPtr<Gdk::Pixbuf>> getSpecificityIconsOnImageArea () override; std::vector<Glib::RefPtr<Gdk::Pixbuf>> getSpecificityIconsOnImageArea () override;
void getIconSize (int& w, int& h) override; void getIconSize (int& w, int& h) const override;
// thumbnaillistener interface // thumbnaillistener interface
void procParamsChanged (Thumbnail* thm, int whoChangedIt) override; void procParamsChanged (Thumbnail* thm, int whoChangedIt) override;

View File

@ -37,9 +37,6 @@
#include "batchqueue.h" #include "batchqueue.h"
#include "placesbrowser.h" #include "placesbrowser.h"
#define BENCHMARK
#include "../rtengine/StopWatch.h"
using namespace std; using namespace std;
#define CHECKTIME 2000 #define CHECKTIME 2000
@ -568,7 +565,7 @@ void FileCatalog::closeDir ()
std::vector<Glib::ustring> FileCatalog::getFileList() std::vector<Glib::ustring> FileCatalog::getFileList()
{ {
BENCHFUN
std::vector<Glib::ustring> names; std::vector<Glib::ustring> names;
const std::set<std::string>& extensions = options.parsedExtensionsSet; const std::set<std::string>& extensions = options.parsedExtensionsSet;
@ -626,9 +623,9 @@ std::vector<Glib::ustring> FileCatalog::getFileList()
void FileCatalog::dirSelected (const Glib::ustring& dirname, const Glib::ustring& openfile) void FileCatalog::dirSelected (const Glib::ustring& dirname, const Glib::ustring& openfile)
{ {
BENCHFUN
try { try {
Glib::RefPtr<Gio::File> dir = Gio::File::create_for_path (dirname); const Glib::RefPtr<Gio::File> dir = Gio::File::create_for_path(dirname);
if (!dir) { if (!dir) {
return; return;
@ -1681,7 +1678,7 @@ void FileCatalog::filterChanged ()
void FileCatalog::reparseDirectory () void FileCatalog::reparseDirectory ()
{ {
BENCHFUN
if (selectedDirectory.empty()) { if (selectedDirectory.empty()) {
return; return;
} }

View File

@ -87,7 +87,7 @@ public:
/** @brief Get the on/off state /** @brief Get the on/off state
*/ */
bool isActive() bool isActive() const
{ {
return active; return active;
}; };

View File

@ -197,8 +197,7 @@ void RTImage::updateImages()
Glib::RefPtr<Gdk::Pixbuf> RTImage::createPixbufFromFile (const Glib::ustring& fileName) Glib::RefPtr<Gdk::Pixbuf> RTImage::createPixbufFromFile (const Glib::ustring& fileName)
{ {
Cairo::RefPtr<Cairo::ImageSurface> imgSurf = createImgSurfFromFile(fileName); Cairo::RefPtr<Cairo::ImageSurface> imgSurf = createImgSurfFromFile(fileName);
Glib::RefPtr<Gdk::Pixbuf> pixbuf = Gdk::Pixbuf::create(imgSurf, 0, 0, imgSurf->get_width(), imgSurf->get_height()); return Gdk::Pixbuf::create(imgSurf, 0, 0, imgSurf->get_width(), imgSurf->get_height());
return pixbuf;
} }
Cairo::RefPtr<Cairo::ImageSurface> RTImage::createImgSurfFromFile (const Glib::ustring& fileName) Cairo::RefPtr<Cairo::ImageSurface> RTImage::createImgSurfFromFile (const Glib::ustring& fileName)

View File

@ -157,9 +157,6 @@ ThumbBrowserEntryBase::ThumbBrowserEntryBase (const Glib::ustring& fname) :
collate_name(getPaddedName(dispname).casefold_collate_key()), collate_name(getPaddedName(dispname).casefold_collate_key()),
thumbnail(nullptr), thumbnail(nullptr),
filename(fname), filename(fname),
shortname(dispname),
exifline(""),
datetimeline(""),
selected(false), selected(false),
drawable(false), drawable(false),
filtered(false), filtered(false),
@ -439,7 +436,6 @@ void ThumbBrowserEntryBase::getTextSizes (int& infow, int& infoh)
Gtk::Widget* w = parent->getDrawingArea (); Gtk::Widget* w = parent->getDrawingArea ();
// calculate dimensions of the text based fields // calculate dimensions of the text based fields
dispname = shortname;
Glib::RefPtr<Pango::Context> context = w->get_pango_context () ; Glib::RefPtr<Pango::Context> context = w->get_pango_context () ;
context->set_font_description (w->get_style_context()->get_font()); 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 (); Pango::FontDescription fontd = context->get_font_description ();
fontd.set_weight (Pango::WEIGHT_BOLD); fontd.set_weight (Pango::WEIGHT_BOLD);
context->set_font_description (fontd); context->set_font_description (fontd);
Glib::RefPtr<Pango::Layout> fn = w->create_pango_layout(shortname); Glib::RefPtr<Pango::Layout> fn = w->create_pango_layout(dispname);
fn->get_pixel_size (fnlabw, fnlabh); fn->get_pixel_size (fnlabw, fnlabh);
// calculate cummulated height of all info fields // 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; 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
{ {
rtengine::Coord2D coord(-1., -1.);
coord.x = coord.y = -1.;
if (preview) { if (preview) {
x -= ofsX + startx; x -= ofsX + startx;
@ -692,9 +687,10 @@ void ThumbBrowserEntryBase::getPosInImgSpace (int x, int y, rtengine::Coord2D &c
coord.y = double(y - prey) / double(preh); 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); return !(ofsX + startx > x + w || ofsX + startx + exp_width < x || ofsY + starty > y + h || ofsY + starty + exp_height < y);
@ -710,12 +706,6 @@ std::vector<Glib::RefPtr<Gdk::Pixbuf> > ThumbBrowserEntryBase::getSpecificityIco
return std::vector<Glib::RefPtr<Gdk::Pixbuf> >(); return std::vector<Glib::RefPtr<Gdk::Pixbuf> >();
} }
void ThumbBrowserEntryBase::getIconSize(int& w, int& h)
{
w = 0;
h = 0;
}
bool ThumbBrowserEntryBase::motionNotify (int x, int y) bool ThumbBrowserEntryBase::motionNotify (int x, int y)
{ {
@ -734,9 +724,9 @@ bool ThumbBrowserEntryBase::releaseNotify (int button, int type, int bstate, int
return buttonSet ? buttonSet->releaseNotify (x, y) : false; 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) { if (buttonSet) {
tooltip = buttonSet->getToolTip(x, y); tooltip = buttonSet->getToolTip(x, y);
@ -748,11 +738,11 @@ Glib::ustring ThumbBrowserEntryBase::getToolTip (int x, int y)
tooltip = dispname; tooltip = dispname;
if (withFilename < WFNAME_FULL) { if (withFilename < WFNAME_FULL) {
if (options.fbShowDateTime && datetimeline != "") { if (options.fbShowDateTime && !datetimeline.empty()) {
tooltip += Glib::ustring("\n") + datetimeline; tooltip += Glib::ustring("\n") + datetimeline;
} }
if (options.fbShowBasicExif && exifline != "") { if (options.fbShowBasicExif && !exifline.empty()) {
tooltip += Glib::ustring("\n") + exifline; tooltip += Glib::ustring("\n") + exifline;
} }
} }

View File

@ -16,8 +16,7 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>. * along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
*/ */
#ifndef _THUMBNAILBROWSERENTRYBASE_ #pragma once
#define _THUMBNAILBROWSERENTRYBASE_
#include <atomic> #include <atomic>
@ -101,7 +100,6 @@ public:
// thumbnail preview properties: // thumbnail preview properties:
Glib::ustring filename; Glib::ustring filename;
Glib::ustring shortname;
Glib::ustring exifline; Glib::ustring exifline;
Glib::ustring datetimeline; Glib::ustring datetimeline;
@ -130,11 +128,11 @@ public:
virtual void draw (Cairo::RefPtr<Cairo::Context> cc); virtual void draw (Cairo::RefPtr<Cairo::Context> cc);
void addButtonSet (LWButtonSet* bs); void addButtonSet (LWButtonSet* bs);
int getMinimalHeight () int getMinimalHeight () const
{ {
return height; return height;
} }
int getMinimalWidth () int getMinimalWidth () const
{ {
return width; return width;
} }
@ -168,9 +166,9 @@ public:
return ofsY + starty; return ofsY + starty;
} }
bool inside (int x, int y); bool inside (int x, int y) const;
void getPosInImgSpace (int x, int y, rtengine::Coord2D &coord); rtengine::Coord2D getPosInImgSpace (int x, int y) const;
bool insideWindow (int x, int y, int w, int h); bool insideWindow (int x, int y, int w, int h) const;
void setPosition (int x, int y, int w, int h); void setPosition (int x, int y, int w, int h);
void setOffset (int x, int y); void setOffset (int x, int y);
@ -179,33 +177,29 @@ public:
return collate_name < other.collate_name; return collate_name < other.collate_name;
} }
ThumbBrowserEntryBase* getOriginal () const; virtual void refreshThumbnailImage () = 0;
void setOriginal (ThumbBrowserEntryBase* original);
virtual void refreshThumbnailImage () {}
virtual void refreshQuickThumbnailImage () {} virtual void refreshQuickThumbnailImage () {}
virtual void calcThumbnailSize () {} virtual void calcThumbnailSize () = 0;
virtual void drawProgressBar (Glib::RefPtr<Gdk::Window> win, const Gdk::RGBA& foregr, const Gdk::RGBA& backgr, int x, int w, int y, int h) {} virtual void drawProgressBar (Glib::RefPtr<Gdk::Window> win, const Gdk::RGBA& foregr, const Gdk::RGBA& backgr, int x, int w, int y, int h) {}
virtual std::vector<Glib::RefPtr<Gdk::Pixbuf>> getIconsOnImageArea (); virtual std::vector<Glib::RefPtr<Gdk::Pixbuf>> getIconsOnImageArea ();
virtual std::vector<Glib::RefPtr<Gdk::Pixbuf>> getSpecificityIconsOnImageArea (); virtual std::vector<Glib::RefPtr<Gdk::Pixbuf>> getSpecificityIconsOnImageArea ();
virtual void getIconSize (int& w, int& h); virtual void getIconSize (int& w, int& h) const = 0;
virtual bool motionNotify (int x, int y); virtual bool motionNotify (int x, int y);
virtual bool pressNotify (int button, int type, int bstate, 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 bool releaseNotify (int button, int type, int bstate, int x, int y);
virtual Glib::ustring getToolTip (int x, int y); virtual Glib::ustring getToolTip (int x, int y) const;
};
inline ThumbBrowserEntryBase* ThumbBrowserEntryBase::getOriginal() const inline ThumbBrowserEntryBase* getOriginal() const
{ {
return original; return original;
} }
inline void ThumbBrowserEntryBase::setOriginal(ThumbBrowserEntryBase* original) inline void setOriginal(ThumbBrowserEntryBase* original)
{ {
this->original = original; this->original = original;
} }
#endif };