diff --git a/rtgui/batchqueueentry.cc b/rtgui/batchqueueentry.cc index a04ede5b8..334dc529f 100644 --- a/rtgui/batchqueueentry.cc +++ b/rtgui/batchqueueentry.cc @@ -26,12 +26,13 @@ #include "multilangmgr.h" #include "thumbbrowserbase.h" #include "thumbnail.h" +#include "rtsurface.h" #include "../rtengine/procparams.h" #include "../rtengine/rtengine.h" bool BatchQueueEntry::iconsLoaded(false); -std::shared_ptr BatchQueueEntry::savedAsIcon; +std::shared_ptr BatchQueueEntry::savedAsIcon(std::shared_ptr(nullptr)); BatchQueueEntry::BatchQueueEntry (rtengine::ProcessingJob* pjob, const rtengine::procparams::ProcParams& pparams, Glib::ustring fname, int prevw, int prevh, Thumbnail* thm, bool overwrite) : ThumbBrowserEntryBase(fname), @@ -59,7 +60,7 @@ BatchQueueEntry::BatchQueueEntry (rtengine::ProcessingJob* pjob, const rtengine: #endif if (!iconsLoaded) { - savedAsIcon = std::shared_ptr(new RTPixbuf("save-small", Gtk::ICON_SIZE_BUTTON)); + savedAsIcon = std::shared_ptr(new RTSurface("save-small", Gtk::ICON_SIZE_SMALL_TOOLBAR)); iconsLoaded = true; } @@ -153,13 +154,13 @@ void BatchQueueEntry::removeButtonSet () buttonSet = nullptr; } -std::vector> BatchQueueEntry::getIconsOnImageArea () +std::vector> BatchQueueEntry::getIconsOnImageArea () { - std::vector > ret; + std::vector> ret; if (!outFileName.empty()) { - ret.push_back (savedAsIcon->get()); + ret.push_back (savedAsIcon); } return ret; diff --git a/rtgui/batchqueueentry.h b/rtgui/batchqueueentry.h index 6b57614e8..5d17939fb 100644 --- a/rtgui/batchqueueentry.h +++ b/rtgui/batchqueueentry.h @@ -29,7 +29,7 @@ #include "../rtengine/noncopyable.h" class Thumbnail; -class RTPixbuf; +class RTSurface; namespace rtengine { @@ -62,7 +62,7 @@ class BatchQueueEntry final : public ThumbBrowserEntryBase, public BQEntryUpdate public: - static std::shared_ptr savedAsIcon; + static std::shared_ptr savedAsIcon; rtengine::ProcessingJob* job; const std::unique_ptr params; @@ -85,7 +85,7 @@ public: void removeButtonSet (); - std::vector> getIconsOnImageArea () override; + std::vector> getIconsOnImageArea () override; void getIconSize (int& w, int& h) const override; std::tuple getToolTip (int x, int y) const override; diff --git a/rtgui/dirbrowser.cc b/rtgui/dirbrowser.cc index 369b69233..6a1168fa4 100644 --- a/rtgui/dirbrowser.cc +++ b/rtgui/dirbrowser.cc @@ -86,6 +86,15 @@ std::vector listSubDirs (const Glib::RefPtr& dir, bool DirBrowser::DirBrowser () : dirTreeModel(), dtColumns(), tvc(M("DIRBROWSER_FOLDERS")), + + openfolder("folder-open-small"), + closedfolder("folder-closed-small"), + icdrom("device-optical"), + ifloppy("device-floppy"), + ihdd("device-hdd"), + inetwork("device-network"), + iremovable("device-usb"), + expandSuccess(false) #ifdef WIN32 , volumes(0) @@ -120,15 +129,6 @@ DirBrowser::~DirBrowser() void DirBrowser::fillDirTree () { - - openfolder = std::shared_ptr(new RTPixbuf("folder-open-small", Gtk::ICON_SIZE_SMALL_TOOLBAR)); - closedfolder = std::shared_ptr(new RTPixbuf("folder-closed-small", Gtk::ICON_SIZE_SMALL_TOOLBAR)); - icdrom = std::shared_ptr(new RTPixbuf("device-optical", Gtk::ICON_SIZE_SMALL_TOOLBAR)); - ifloppy = std::shared_ptr(new RTPixbuf("device-floppy", Gtk::ICON_SIZE_SMALL_TOOLBAR)); - ihdd = std::shared_ptr(new RTPixbuf("device-hdd", Gtk::ICON_SIZE_SMALL_TOOLBAR)); - iremovable = std::shared_ptr(new RTPixbuf("device-usb", Gtk::ICON_SIZE_SMALL_TOOLBAR)); - inetwork = std::shared_ptr(new RTPixbuf("device-network", Gtk::ICON_SIZE_SMALL_TOOLBAR)); - //Create the Tree model: dirTreeModel = Gtk::TreeStore::create(dtColumns); dirtree->set_model (dirTreeModel); @@ -136,10 +136,9 @@ void DirBrowser::fillDirTree () fillRoot (); Gtk::CellRendererPixbuf* render_pb = Gtk::manage ( new Gtk::CellRendererPixbuf () ); + render_pb->property_stock_size() = Gtk::ICON_SIZE_SMALL_TOOLBAR; tvc.pack_start (*render_pb, false); - tvc.add_attribute(*render_pb, "pixbuf-expander-closed", dtColumns.icon2); - tvc.add_attribute(*render_pb, "pixbuf", dtColumns.icon2); - tvc.add_attribute(*render_pb, "pixbuf-expander-open", dtColumns.icon1); + tvc.add_attribute(*render_pb, "icon-name", dtColumns.icon_name); tvc.pack_start (crt); tvc.add_attribute(crt, "text", dtColumns.filename); @@ -156,6 +155,7 @@ void DirBrowser::fillDirTree () render_pb->property_ypad() = 0; dirtree->signal_row_expanded().connect(sigc::mem_fun(*this, &DirBrowser::row_expanded)); + dirtree->signal_row_collapsed().connect(sigc::mem_fun(*this, &DirBrowser::row_collapsed)); dirtree->signal_row_activated().connect(sigc::mem_fun(*this, &DirBrowser::row_activated)); dirTreeModel->signal_sort_column_changed().connect(sigc::mem_fun(*this, &DirBrowser::on_sort_column_changed)); } @@ -175,22 +175,17 @@ void DirBrowser::addRoot (char letter) int type = GetDriveType (volume); if (type == DRIVE_CDROM) { - root->set_value (0, icdrom->get()); - root->set_value (1, icdrom->get()); + root->set_value (dtColumns.icon_name, icdrom); } else if (type == DRIVE_REMOVABLE) { if (letter - 'A' < 2) { - root->set_value (0, ifloppy->get()); - root->set_value (1, ifloppy->get()); + root->set_value (dtColumns.icon_name, ifloppy); } else { - root->set_value (0, iremovable->get()); - root->set_value (1, iremovable->get()); + root->set_value (dtColumns.icon_name, iremovable); } } else if (type == DRIVE_REMOTE) { - root->set_value (0, inetwork->get()); - root->set_value (1, inetwork->get()); + root->set_value (dtColumns.icon_name, inetwork); } else if (type == DRIVE_FIXED) { - root->set_value (0, ihdd->get()); - root->set_value (1, ihdd->get()); + root->set_value (dtColumns.icon_name, ihdd); } Gtk::TreeModel::iterator child = dirTreeModel->append (root->children()); @@ -319,11 +314,20 @@ void DirBrowser::row_expanded (const Gtk::TreeModel::iterator& iter, const Gtk:: expandSuccess = true; + // Update row icon + iter->set_value(dtColumns.icon_name, openfolder); + Glib::RefPtr monitor = dir->monitor_directory (); iter->set_value (dtColumns.monitor, monitor); monitor->signal_changed().connect (sigc::bind(sigc::mem_fun(*this, &DirBrowser::file_changed), iter, dir->get_parse_name())); } +void DirBrowser::row_collapsed (const Gtk::TreeModel::iterator& iter, const Gtk::TreeModel::Path& path) +{ + // Update row icon + iter->set_value(dtColumns.icon_name, closedfolder); +} + void DirBrowser::updateDir (const Gtk::TreeModel::iterator& iter) { @@ -366,8 +370,7 @@ void DirBrowser::addDir (const Gtk::TreeModel::iterator& iter, const Glib::ustri Gtk::TreeModel::iterator child = dirTreeModel->append(iter->children()); child->set_value (dtColumns.filename, dirname); - child->set_value (dtColumns.icon1, openfolder->get()); - child->set_value (dtColumns.icon2, closedfolder->get()); + child->set_value (dtColumns.icon_name, closedfolder); Glib::ustring fullname = Glib::build_filename (iter->get_value (dtColumns.dirname), dirname); child->set_value (dtColumns.dirname, fullname); Gtk::TreeModel::iterator fooRow = dirTreeModel->append(child->children()); diff --git a/rtgui/dirbrowser.h b/rtgui/dirbrowser.h index 599f9fa16..706efb8bb 100644 --- a/rtgui/dirbrowser.h +++ b/rtgui/dirbrowser.h @@ -23,8 +23,6 @@ #include "guiutils.h" -class RTPixbuf; - class DirBrowser : public Gtk::Box { public: @@ -37,15 +35,13 @@ private: struct DirTreeColumns : public Gtk::TreeModelColumnRecord { public: Gtk::TreeModelColumn filename; - Gtk::TreeModelColumn > icon1; - Gtk::TreeModelColumn > icon2; + Gtk::TreeModelColumn icon_name; Gtk::TreeModelColumn dirname; Gtk::TreeModelColumn > monitor; DirTreeColumns() { - add(icon1); - add(icon2); + add(icon_name); add(filename); add(dirname); add(monitor); @@ -55,7 +51,6 @@ private: DirTreeColumns dtColumns; Gtk::TreeViewColumn tvc; Gtk::CellRendererText crt; - Gtk::CellRendererPixbuf crb; Gtk::TreeView *dirtree; @@ -64,13 +59,13 @@ private: void fillRoot (); - std::shared_ptr openfolder; - std::shared_ptr closedfolder; - std::shared_ptr icdrom; - std::shared_ptr ifloppy; - std::shared_ptr ihdd; - std::shared_ptr inetwork; - std::shared_ptr iremovable; + Glib::ustring openfolder; + Glib::ustring closedfolder; + Glib::ustring icdrom; + Glib::ustring ifloppy; + Glib::ustring ihdd; + Glib::ustring inetwork; + Glib::ustring iremovable; bool expandSuccess; @@ -96,6 +91,7 @@ public: void fillDirTree (); void on_sort_column_changed() const; void row_expanded (const Gtk::TreeModel::iterator& iter, const Gtk::TreeModel::Path& path); + void row_collapsed (const Gtk::TreeModel::iterator& iter, const Gtk::TreeModel::Path& path); void row_activated (const Gtk::TreeModel::Path& path, Gtk::TreeViewColumn* column); void file_changed (const Glib::RefPtr& file, const Glib::RefPtr& other_file, Gio::FileMonitorEvent event_type, const Gtk::TreeModel::iterator& iter, const Glib::ustring& dirName); void open (const Glib::ustring& dirName, const Glib::ustring& fileName = ""); // goes to dir "dirName" and selects file "fileName" diff --git a/rtgui/filebrowserentry.cc b/rtgui/filebrowserentry.cc index f922e2084..60691d8b6 100644 --- a/rtgui/filebrowserentry.cc +++ b/rtgui/filebrowserentry.cc @@ -38,11 +38,11 @@ //extern Glib::Threads::Thread* mainThread; bool FileBrowserEntry::iconsLoaded(false); -std::shared_ptr FileBrowserEntry::editedIcon(std::shared_ptr(nullptr)); -std::shared_ptr FileBrowserEntry::recentlySavedIcon(std::shared_ptr(nullptr)); -std::shared_ptr FileBrowserEntry::enqueuedIcon(std::shared_ptr(nullptr)); -std::shared_ptr FileBrowserEntry::hdr(std::shared_ptr(nullptr)); -std::shared_ptr FileBrowserEntry::ps(std::shared_ptr(nullptr)); +std::shared_ptr FileBrowserEntry::editedIcon(std::shared_ptr(nullptr)); +std::shared_ptr FileBrowserEntry::recentlySavedIcon(std::shared_ptr(nullptr)); +std::shared_ptr FileBrowserEntry::enqueuedIcon(std::shared_ptr(nullptr)); +std::shared_ptr FileBrowserEntry::hdr(std::shared_ptr(nullptr)); +std::shared_ptr FileBrowserEntry::ps(std::shared_ptr(nullptr)); FileBrowserEntry::FileBrowserEntry (Thumbnail* thm, const Glib::ustring& fname) : ThumbBrowserEntryBase (fname), wasInside(false), iatlistener(nullptr), press_x(0), press_y(0), action_x(0), action_y(0), rot_deg(0.0), landscape(true), cropParams(new rtengine::procparams::CropParams), cropgl(nullptr), state(SNormal), crop_custom_ratio(0.f) @@ -61,11 +61,11 @@ FileBrowserEntry::FileBrowserEntry (Thumbnail* thm, const Glib::ustring& fname) scale = 1; if (!iconsLoaded) { - editedIcon = std::shared_ptr(new RTPixbuf("tick-small", Gtk::ICON_SIZE_SMALL_TOOLBAR)); - recentlySavedIcon = std::shared_ptr(new RTPixbuf("save-small", Gtk::ICON_SIZE_SMALL_TOOLBAR)); - enqueuedIcon = std::shared_ptr(new RTPixbuf("gears-small", Gtk::ICON_SIZE_SMALL_TOOLBAR)); - hdr = std::shared_ptr(new RTPixbuf("filetype-hdr", Gtk::ICON_SIZE_SMALL_TOOLBAR)); - ps = std::shared_ptr(new RTPixbuf("filetype-ps", Gtk::ICON_SIZE_SMALL_TOOLBAR)); + editedIcon = std::shared_ptr(new RTSurface("tick-small", Gtk::ICON_SIZE_SMALL_TOOLBAR)); + recentlySavedIcon = std::shared_ptr(new RTSurface("save-small", Gtk::ICON_SIZE_SMALL_TOOLBAR)); + enqueuedIcon = std::shared_ptr(new RTSurface("gears-small", Gtk::ICON_SIZE_SMALL_TOOLBAR)); + hdr = std::shared_ptr(new RTSurface("filetype-hdr", Gtk::ICON_SIZE_SMALL_TOOLBAR)); + ps = std::shared_ptr(new RTSurface("filetype-ps", Gtk::ICON_SIZE_SMALL_TOOLBAR)); iconsLoaded = true; } @@ -125,43 +125,43 @@ void FileBrowserEntry::calcThumbnailSize () } } -std::vector> FileBrowserEntry::getIconsOnImageArea () +std::vector> FileBrowserEntry::getIconsOnImageArea () { if (!thumbnail) { return {}; } - std::vector> ret; + std::vector> ret; if (thumbnail->hasProcParams() && editedIcon) { - ret.push_back(editedIcon->get()); + ret.push_back(editedIcon); } if (thumbnail->isRecentlySaved() && recentlySavedIcon) { - ret.push_back(recentlySavedIcon->get()); + ret.push_back(recentlySavedIcon); } if (thumbnail->isEnqueued () && enqueuedIcon) { - ret.push_back(enqueuedIcon->get()); + ret.push_back(enqueuedIcon); } return ret; } -std::vector> FileBrowserEntry::getSpecificityIconsOnImageArea () +std::vector> FileBrowserEntry::getSpecificityIconsOnImageArea () { if (!thumbnail) { return {}; } - std::vector> ret; + std::vector> ret; if (thumbnail->isHDR() && hdr) { - ret.push_back (hdr->get()); + ret.push_back (hdr); } if (thumbnail->isPixelShift() && ps) { - ret.push_back (ps->get()); + ret.push_back (ps); } return ret; diff --git a/rtgui/filebrowserentry.h b/rtgui/filebrowserentry.h index fcf916f00..0b0b07b7c 100644 --- a/rtgui/filebrowserentry.h +++ b/rtgui/filebrowserentry.h @@ -35,7 +35,7 @@ class FileBrowserEntry; class Thumbnail; -class RTPixbuf; +class RTSurface; struct FileBrowserEntryIdleHelper { FileBrowserEntry* fbentry; @@ -73,11 +73,11 @@ class FileBrowserEntry final : public ThumbBrowserEntryBase, public: - static std::shared_ptr editedIcon; - static std::shared_ptr recentlySavedIcon; - static std::shared_ptr enqueuedIcon; - static std::shared_ptr hdr; - static std::shared_ptr ps; + static std::shared_ptr editedIcon; + static std::shared_ptr recentlySavedIcon; + static std::shared_ptr enqueuedIcon; + static std::shared_ptr hdr; + static std::shared_ptr ps; FileBrowserEntry (Thumbnail* thm, const Glib::ustring& fname); ~FileBrowserEntry () override; @@ -94,8 +94,8 @@ public: void refreshQuickThumbnailImage () override; void calcThumbnailSize () override; - std::vector> getIconsOnImageArea () override; - std::vector> getSpecificityIconsOnImageArea () override; + std::vector> getIconsOnImageArea () override; + std::vector> getSpecificityIconsOnImageArea () override; void getIconSize (int& w, int& h) const override; // thumbnaillistener interface diff --git a/rtgui/rtscalable.cc b/rtgui/rtscalable.cc index b161591cb..26ea0542e 100644 --- a/rtgui/rtscalable.cc +++ b/rtgui/rtscalable.cc @@ -138,7 +138,7 @@ Cairo::RefPtr RTScalable::loadSurfaceFromSVG(const Glib::us // Directly use fname as a path path = fname; } else { - // Look for PNG file in "images" folder + // Look for SVG file in "images" folder Glib::ustring imagesFolder = Glib::build_filename(DATA_SEARCH_PATH, "images"); path = Glib::build_filename(imagesFolder, fname); } diff --git a/rtgui/rtsurface.cc b/rtgui/rtsurface.cc index b72a87d0d..dccb3271c 100644 --- a/rtgui/rtsurface.cc +++ b/rtgui/rtsurface.cc @@ -88,18 +88,68 @@ RTSurface::RTSurface(const Glib::ustring &fname) : int RTSurface::getWidth() { - return - surface - ? (surface->get_width() / RTScalable::getScale()) - : -1; + int w, h; + + if (hasSurface()) { + switch (type) { + case RTSurface::IconType: + // Get width from Gtk::IconSize + if (!Gtk::IconSize::lookup(icon_size, w, h)) { // Size in invalid + w = h = -1; // Invalid case + } + + return w; + + case RTSurface::PNGType: + // Directly return surface width + return surface->get_width(); + + case RTSurface::SVGType: + // Returned size shall consider the scaling + return (surface->get_width() / RTScalable::getScale()); + + case RTSurface::InvalidType: + default: + // Invalid case + return -1; + } + } else { + // Invalid case + return -1; + } } int RTSurface::getHeight() { - return - surface - ? (surface->get_height() / RTScalable::getScale()) - : -1; + int w, h; + + if (hasSurface()) { + switch (type) { + case RTSurface::IconType: + // Get width from Gtk::IconSize + if (!Gtk::IconSize::lookup(icon_size, w, h)) { // Size in invalid + w = h = -1; // Invalid case + } + + return h; + + case RTSurface::PNGType: + // Directly return surface width + return surface->get_height(); + + case RTSurface::SVGType: + // Returned size shall consider the scaling + return (surface->get_height() / RTScalable::getScale()); + + case RTSurface::InvalidType: + default: + // Invalid case + return -1; + } + } else { + // Invalid case + return -1; + } } bool RTSurface::hasSurface() @@ -132,168 +182,3 @@ Cairo::RefPtr RTSurface::get() return surface; } - -RTPixbuf::RTPixbuf() -{ - // Initialize "back" parameters from RTScalable - dpiBack = RTPixbuf::getDPI(); - scaleBack = RTPixbuf::getScale(); - - // Initialize other private parameters - type = RTPixbuf::InvalidType; - name = ""; - icon_size = Gtk::ICON_SIZE_INVALID; -} - -RTPixbuf::RTPixbuf(const Glib::ustring &icon_name, const Gtk::IconSize iconSize) : - RTPixbuf() -{ - // Create surface - const Cairo::RefPtr surface = RTScalable::loadSurfaceFromIcon(icon_name, iconSize); - - if (surface) { - // Downscale surface before creating pixbuf - const Cairo::RefPtr _surface = Cairo::Surface::create(surface, - Cairo::CONTENT_COLOR_ALPHA, - surface->get_width() / RTScalable::getScale(), - surface->get_height() / RTScalable::getScale()); - const auto c = Cairo::Context::create(_surface); - c->scale(1. / static_cast(RTScalable::getScale()), 1. / static_cast(RTScalable::getScale())); - c->set_source(surface, 0., 0.); - c->paint(); - - // Create pixbuf from surface - pixbuf = Gdk::Pixbuf::create(_surface, - 0, - 0, - surface->get_width() / RTScalable::getScale(), - surface->get_height() / RTScalable::getScale()); - - // Save private parameters - type = RTPixbuf::IconType; - name = icon_name; - icon_size = iconSize; - } -} - -RTPixbuf::RTPixbuf(const Glib::ustring &fname) : - RTPixbuf() -{ - // Create surface based on file extension - const auto pos = fname.find_last_of('.'); - - if (pos >= 0 && pos < fname.length()) { - const auto fext = fname.substr(pos + 1, fname.length()).lowercase(); - - // Case where fname is a PNG file - if (fext == "png") { - // Create surface from PNG file - const Cairo::RefPtr surface = RTScalable::loadSurfaceFromPNG(fname); - - if (surface) { - // Downscale surface before creating pixbuf - const Cairo::RefPtr _surface = Cairo::Surface::create(surface, - Cairo::CONTENT_COLOR_ALPHA, - surface->get_width() / RTScalable::getScale(), - surface->get_height() / RTScalable::getScale()); - const auto c = Cairo::Context::create(_surface); - c->scale(1. / static_cast(RTScalable::getScale()), 1. / static_cast(RTScalable::getScale())); - c->set_source(surface, 0., 0.); - c->paint(); - - // Create pixbuf from surface - pixbuf = Gdk::Pixbuf::create(_surface, - 0, - 0, - surface->get_width() / RTScalable::getScale(), - surface->get_height() / RTScalable::getScale()); - - // Save private parameter - type = RTPixbuf::PNGType; - name = fname; - } - } - - // Case where fname is a SVG file - if (fext == "svg") { - // Create surface from SVG file - const Cairo::RefPtr surface = RTScalable::loadSurfaceFromSVG(fname); - - if (surface) { - // Downscale surface before creating pixbuf - const Cairo::RefPtr _surface = Cairo::Surface::create(surface, - Cairo::CONTENT_COLOR_ALPHA, - surface->get_width() / RTScalable::getScale(), - surface->get_height() / RTScalable::getScale()); - const auto c = Cairo::Context::create(_surface); - c->scale(1. / static_cast(RTScalable::getScale()), 1. / static_cast(RTScalable::getScale())); - c->set_source(surface, 0., 0.); - c->paint(); - - // Create pixbuf from surface - pixbuf = Gdk::Pixbuf::create(_surface, - 0, - 0, - surface->get_width() / RTScalable::getScale(), - surface->get_height() / RTScalable::getScale()); - - // Save private parameter - type = RTPixbuf::SVGType; - name = fname; - } - } - } -} - -int RTPixbuf::getWidth() -{ - return - pixbuf - ? pixbuf->get_width() - : -1; -} - -int RTPixbuf::getHeight() -{ - return - pixbuf - ? pixbuf->get_height() - : -1; -} - -bool RTPixbuf::hasPixbuf() -{ - return static_cast(pixbuf); -} - -Glib::RefPtr RTPixbuf::get() -{ - if (dpiBack != RTScalable::getDPI() || - scaleBack != RTScalable::getScale()) { - Cairo::RefPtr surface; - - // Surface needs to be regenerated - switch (type) { - case RTPixbuf::IconType : - surface = RTScalable::loadSurfaceFromIcon(name, icon_size); - pixbuf = Gdk::Pixbuf::create(surface, 0, 0, surface->get_width(), surface->get_height()); - break; - case RTPixbuf::PNGType : - surface = RTScalable::loadSurfaceFromPNG(name); - pixbuf = Gdk::Pixbuf::create(surface, 0, 0, surface->get_width(), surface->get_height()); - break; - case RTPixbuf::SVGType : - surface = RTScalable::loadSurfaceFromSVG(name); - pixbuf = Gdk::Pixbuf::create(surface, 0, 0, surface->get_width(), surface->get_height()); - break; - default : - break; - } - - // Save new DPI and scale - dpiBack = RTScalable::getDPI(); - scaleBack = RTScalable::getScale(); - } - - return pixbuf; -} diff --git a/rtgui/rtsurface.h b/rtgui/rtsurface.h index 46a8bcdb5..e58c1b206 100644 --- a/rtgui/rtsurface.h +++ b/rtgui/rtsurface.h @@ -53,36 +53,3 @@ public: Cairo::RefPtr get(); }; - -/** - * @brief A custom class in order to handle Hi-DPI pixbuf. - */ -class RTPixbuf final : public RTScalable -{ -public: - enum RTPixbufType { - InvalidType = 1, - IconType = 2, - PNGType = 3, - SVGType = 4 - }; - -private: - double dpiBack; // Used to identify dpi change - int scaleBack; // Used to identify scale change - RTPixbufType type; - Glib::ustring name; - Gtk::IconSize icon_size; - Glib::RefPtr pixbuf; - -public: - RTPixbuf(); - explicit RTPixbuf(const Glib::ustring &icon_name, const Gtk::IconSize iconSize); - explicit RTPixbuf(const Glib::ustring &fname); - - int getWidth(); - int getHeight(); - bool hasPixbuf(); - - Glib::RefPtr get(); -}; diff --git a/rtgui/thumbbrowserentrybase.cc b/rtgui/thumbbrowserentrybase.cc index 306b491be..2b5c102e3 100644 --- a/rtgui/thumbbrowserentrybase.cc +++ b/rtgui/thumbbrowserentrybase.cc @@ -21,6 +21,7 @@ #include "options.h" #include "thumbbrowserbase.h" #include "../rtengine/rt_math.h" +#include "rtsurface.h" namespace { @@ -284,10 +285,10 @@ void ThumbBrowserEntryBase::updateBackBuffer () int iheight = 0; for (size_t i = 0; i < bbIcons.size(); i++) { - iwidth += bbIcons[i]->get_width() + (i > 0 ? igap : 0); + iwidth += bbIcons[i]->getWidth() + (i > 0 ? igap : 0); - if (bbIcons[i]->get_height() > iheight) { - iheight = bbIcons[i]->get_height(); + if (bbIcons[i]->getHeight() > iheight) { + iheight = bbIcons[i]->getHeight(); } } @@ -310,10 +311,10 @@ void ThumbBrowserEntryBase::updateBackBuffer () for (size_t i = 0; i < bbIcons.size(); i++) { // Draw the image at 110, 90, except for the outermost 10 pixels. - Gdk::Cairo::set_source_pixbuf(cc, bbIcons[i], istartx, istarty); - cc->rectangle(istartx, istarty, bbIcons[i]->get_width(), bbIcons[i]->get_height()); + cc->set_source(bbIcons[i]->get(), istartx, istarty); + cc->rectangle(istartx, istarty, bbIcons[i]->getWidth(), bbIcons[i]->getHeight()); cc->fill(); - istartx += bbIcons[i]->get_width() + igap; + istartx += bbIcons[i]->getWidth() + igap; } } @@ -323,9 +324,9 @@ void ThumbBrowserEntryBase::updateBackBuffer () int istarty2 = prey + preh - igap - 1; for (size_t i = 0; i < bbSpecificityIcons.size(); ++i) { - istartx2 -= bbSpecificityIcons[i]->get_width() - igap; - Gdk::Cairo::set_source_pixbuf(cc, bbSpecificityIcons[i], istartx2, istarty2 - bbSpecificityIcons[i]->get_height()); - cc->rectangle(istartx2, istarty2 - bbSpecificityIcons[i]->get_height(), bbSpecificityIcons[i]->get_width(), bbSpecificityIcons[i]->get_height()); + istartx2 -= bbSpecificityIcons[i]->getWidth() - igap; + cc->set_source(bbSpecificityIcons[i]->get(), istartx2, istarty2 - bbSpecificityIcons[i]->getHeight()); + cc->rectangle(istartx2, istarty2 - bbSpecificityIcons[i]->getHeight(), bbSpecificityIcons[i]->getWidth(), bbSpecificityIcons[i]->getHeight()); cc->fill(); } } @@ -694,14 +695,14 @@ 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 >(); + return std::vector>(); } -std::vector > ThumbBrowserEntryBase::getSpecificityIconsOnImageArea() +std::vector> ThumbBrowserEntryBase::getSpecificityIconsOnImageArea() { - return std::vector >(); + return std::vector>(); } bool ThumbBrowserEntryBase::motionNotify (int x, int y) diff --git a/rtgui/thumbbrowserentrybase.h b/rtgui/thumbbrowserentrybase.h index 764f806fd..fa3e8f0f3 100644 --- a/rtgui/thumbbrowserentrybase.h +++ b/rtgui/thumbbrowserentrybase.h @@ -31,6 +31,7 @@ class Thumbnail; class ThumbBrowserBase; +class RTSurface; class ThumbBrowserEntryBase { @@ -83,8 +84,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); @@ -185,8 +186,8 @@ public: 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 std::vector> getIconsOnImageArea (); + virtual std::vector> getSpecificityIconsOnImageArea (); virtual void getIconSize (int& w, int& h) const = 0; virtual bool motionNotify (int x, int y);