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

@@ -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;
}
}