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

@ -148,7 +148,7 @@ void BatchQueueEntry::removeButtonSet ()
buttonSet = nullptr;
}
std::vector<Glib::RefPtr<Gdk::Pixbuf> > BatchQueueEntry::getIconsOnImageArea ()
std::vector<Glib::RefPtr<Gdk::Pixbuf>> BatchQueueEntry::getIconsOnImageArea ()
{
std::vector<Glib::RefPtr<Gdk::Pixbuf> > ret;
@ -160,7 +160,7 @@ std::vector<Glib::RefPtr<Gdk::Pixbuf> > 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);

View File

@ -68,9 +68,9 @@ public:
void removeButtonSet ();
std::vector<Glib::RefPtr<Gdk::Pixbuf> > getIconsOnImageArea () override;
void getIconSize (int& w, int& h) override;
Glib::ustring getToolTip (int x, int y) override;
std::vector<Glib::RefPtr<Gdk::Pixbuf>> 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;

View File

@ -119,39 +119,37 @@ void FileBrowserEntry::calcThumbnailSize ()
}
}
std::vector<Glib::RefPtr<Gdk::Pixbuf> > FileBrowserEntry::getIconsOnImageArea ()
std::vector<Glib::RefPtr<Gdk::Pixbuf>> FileBrowserEntry::getIconsOnImageArea ()
{
std::vector<Glib::RefPtr<Gdk::Pixbuf> > ret;
if (!thumbnail) {
return ret;
return {};
}
std::vector<Glib::RefPtr<Gdk::Pixbuf>> 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<Glib::RefPtr<Gdk::Pixbuf> > FileBrowserEntry::getSpecificityIconsOnImageArea ()
std::vector<Glib::RefPtr<Gdk::Pixbuf>> FileBrowserEntry::getSpecificityIconsOnImageArea ()
{
std::vector<Glib::RefPtr<Gdk::Pixbuf> > ret;
if (!thumbnail) {
return ret;
return {};
}
std::vector<Glib::RefPtr<Gdk::Pixbuf>> ret;
if (thumbnail->isHDR() && 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 ();
@ -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) {

View File

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

View File

@ -37,9 +37,6 @@
#include "batchqueue.h"
#include "placesbrowser.h"
#define BENCHMARK
#include "../rtengine/StopWatch.h"
using namespace std;
#define CHECKTIME 2000
@ -568,7 +565,7 @@ void FileCatalog::closeDir ()
std::vector<Glib::ustring> FileCatalog::getFileList()
{
BENCHFUN
std::vector<Glib::ustring> names;
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)
{
BENCHFUN
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) {
return;
@ -1681,7 +1678,7 @@ void FileCatalog::filterChanged ()
void FileCatalog::reparseDirectory ()
{
BENCHFUN
if (selectedDirectory.empty()) {
return;
}

View File

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

View File

@ -197,8 +197,7 @@ void RTImage::updateImages()
Glib::RefPtr<Gdk::Pixbuf> RTImage::createPixbufFromFile (const Glib::ustring& 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 pixbuf;
return Gdk::Pixbuf::create(imgSurf, 0, 0, imgSurf->get_width(), imgSurf->get_height());
}
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()),
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<Pango::Context> 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<Pango::Layout> fn = w->create_pango_layout(shortname);
Glib::RefPtr<Pango::Layout> 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<Glib::RefPtr<Gdk::Pixbuf> > ThumbBrowserEntryBase::getIconsOnImageArea()
std::vector<Glib::RefPtr<Gdk::Pixbuf>> ThumbBrowserEntryBase::getIconsOnImageArea()
{
return std::vector<Glib::RefPtr<Gdk::Pixbuf> >();
}
@ -710,12 +706,6 @@ std::vector<Glib::RefPtr<Gdk::Pixbuf> > ThumbBrowserEntryBase::getSpecificityIco
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)
{
@ -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;
}
}

View File

@ -16,8 +16,7 @@
* You should have received a copy of the GNU General Public License
* along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _THUMBNAILBROWSERENTRYBASE_
#define _THUMBNAILBROWSERENTRYBASE_
#pragma once
#include <atomic>
@ -82,8 +81,8 @@ protected:
Glib::RefPtr<BackBuffer> backBuffer;
bool bbSelected, bbFramed;
guint8* bbPreview;
std::vector<Glib::RefPtr<Gdk::Pixbuf> > bbIcons;
std::vector<Glib::RefPtr<Gdk::Pixbuf> > bbSpecificityIcons;
std::vector<Glib::RefPtr<Gdk::Pixbuf>> bbIcons;
std::vector<Glib::RefPtr<Gdk::Pixbuf>> bbSpecificityIcons;
CursorShape cursor_type;
void drawFrame (Cairo::RefPtr<Cairo::Context> 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<Cairo::Context> cc);
void updateBackBuffer ();
void resize (int h);
virtual void draw (Cairo::RefPtr<Cairo::Context> 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<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> > getSpecificityIconsOnImageArea ();
virtual void getIconSize (int& w, int& h);
virtual std::vector<Glib::RefPtr<Gdk::Pixbuf>> getIconsOnImageArea ();
virtual std::vector<Glib::RefPtr<Gdk::Pixbuf>> 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