diff --git a/rtengine/dynamicprofile.cc b/rtengine/dynamicprofile.cc index 1b1cd4833..3ae009537 100644 --- a/rtengine/dynamicprofile.cc +++ b/rtengine/dynamicprofile.cc @@ -178,9 +178,7 @@ bool DynamicProfileRules::loadRules() const Glib::ustring fileName = Glib::build_filename (Options::rtdir, "dynamicprofile.cfg"); try { - if (Glib::file_test(fileName, Glib::FILE_TEST_EXISTS)) { - kf.load_from_file (fileName); - } else { + if (!(Glib::file_test(fileName, Glib::FILE_TEST_EXISTS) && kf.load_from_file (fileName))) { return false; } } catch (Glib::Error &e) { diff --git a/rtgui/batchqueuebuttonset.cc b/rtgui/batchqueuebuttonset.cc index f68a7b4e7..1f4de2286 100644 --- a/rtgui/batchqueuebuttonset.cc +++ b/rtgui/batchqueuebuttonset.cc @@ -25,9 +25,9 @@ bool BatchQueueButtonSet::iconsLoaded = false; -std::shared_ptr BatchQueueButtonSet::cancelIcon = std::shared_ptr(nullptr); -std::shared_ptr BatchQueueButtonSet::headIcon = std::shared_ptr(nullptr); -std::shared_ptr BatchQueueButtonSet::tailIcon = std::shared_ptr(nullptr); +std::shared_ptr BatchQueueButtonSet::cancelIcon; +std::shared_ptr BatchQueueButtonSet::headIcon; +std::shared_ptr BatchQueueButtonSet::tailIcon; Glib::ustring BatchQueueButtonSet::moveHeadToolTip; Glib::ustring BatchQueueButtonSet::moveEndToolTip; diff --git a/rtgui/batchqueuepanel.cc b/rtgui/batchqueuepanel.cc index f44c54cd0..1de5613c5 100644 --- a/rtgui/batchqueuepanel.cc +++ b/rtgui/batchqueuepanel.cc @@ -228,13 +228,13 @@ void BatchQueuePanel::updateTab (int qsize, int forceOrientation) } } else { if (!qsize ) { - grid->attach_next_to(*Gtk::manage (new RTImage ("gears")), Gtk::POS_RIGHT, 1, 1); + grid->attach_next_to(*Gtk::manage (new RTImage ("gears", Gtk::ICON_SIZE_LARGE_TOOLBAR)), Gtk::POS_RIGHT, 1, 1); grid->attach_next_to(*Gtk::manage (new Gtk::Label (M("MAIN_FRAME_QUEUE") )), Gtk::POS_RIGHT, 1, 1); } else if (qStartStop->get_active()) { - grid->attach_next_to(*Gtk::manage (new RTImage ("gears-play")), Gtk::POS_RIGHT, 1, 1); + grid->attach_next_to(*Gtk::manage (new RTImage ("gears-play", Gtk::ICON_SIZE_LARGE_TOOLBAR)), Gtk::POS_RIGHT, 1, 1); grid->attach_next_to(*Gtk::manage (new Gtk::Label (M("MAIN_FRAME_QUEUE") + " [" + Glib::ustring::format( qsize ) + "]" )), Gtk::POS_RIGHT, 1, 1); } else { - grid->attach_next_to(*Gtk::manage (new RTImage ("gears-pause")), Gtk::POS_RIGHT, 1, 1); + grid->attach_next_to(*Gtk::manage (new RTImage ("gears-pause", Gtk::ICON_SIZE_LARGE_TOOLBAR)), Gtk::POS_RIGHT, 1, 1); grid->attach_next_to(*Gtk::manage (new Gtk::Label (M("MAIN_FRAME_QUEUE") + " [" + Glib::ustring::format( qsize ) + "]" )), Gtk::POS_RIGHT, 1, 1); } diff --git a/rtgui/cursormanager.cc b/rtgui/cursormanager.cc index 12eb0fa37..4cecc6756 100644 --- a/rtgui/cursormanager.cc +++ b/rtgui/cursormanager.cc @@ -43,12 +43,10 @@ void CursorManager::init (Glib::RefPtr mainWindow) // - By default, cursor hotspot is located at middle of surface. // Use (offX, offY) between -1 and 0.99 to move cursor hotspot auto cursor_surf = RTSurface(name, Gtk::ICON_SIZE_MENU); - double offXb = std::min(std::max(-1., offX), 0.99); // offX should belong to (-1; 0.99) - double offYb = std::min(std::max(-1., offY), 0.99); // offY should belong to (-1; 0.99) auto cursor = Gdk::Cursor::create(this->display, cursor_surf.get(), - cursor_surf.getWidth() / 2 * (1. + offXb), - cursor_surf.getHeight() / 2 * (1. + offYb)); + std::min(std::max(cursor_surf.getWidth() / 2 * (1. + offX), 0.), static_cast(cursor_surf.getWidth())), + std::min(std::max(cursor_surf.getHeight() / 2 * (1. + offY), 0.), static_cast(cursor_surf.getHeight()))); if (!cursor) { cursor = Gdk::Cursor::create(this->display, fb_cursor); @@ -58,7 +56,7 @@ void CursorManager::init (Glib::RefPtr mainWindow) }; cAdd = createCursor("crosshair-hicontrast", Gdk::PLUS); - cAddPicker = createCursor("color-picker-add-hicontrast", Gdk::PLUS, -0.333, 0.75); + cAddPicker = createCursor("color-picker-add-hicontrast", Gdk::PLUS, -0.666, 0.75); cCropDraw = createCursor("crop-point-hicontrast", Gdk::DIAMOND_CROSS); cCrosshair = createCursor("crosshair-hicontrast", Gdk::CROSSHAIR); cEmpty = createCursor("empty", Gdk::BLANK_CURSOR); @@ -74,7 +72,7 @@ void CursorManager::init (Glib::RefPtr mainWindow) cMoveXY = createCursor("node-move-xy-hicontrast", Gdk::FLEUR); cMoveY = createCursor("node-move-y-hicontrast", Gdk::SB_V_DOUBLE_ARROW); cRotate = createCursor("rotate-aroundnode-hicontrast", Gdk::EXCHANGE); - cWB = createCursor("color-picker-hicontrast", Gdk::TARGET, -0.333, 0.75); + cWB = createCursor("color-picker-hicontrast", Gdk::TARGET, -0.666, 0.75); cWait = createCursor("gears", Gdk::CLOCK); window = mainWindow; diff --git a/rtgui/filterpanel.h b/rtgui/filterpanel.h index 4c4a8b0da..32592bbd0 100644 --- a/rtgui/filterpanel.h +++ b/rtgui/filterpanel.h @@ -63,7 +63,7 @@ protected: ExifFilterSettings curefs; FilterPanelListener* listener; - std::shared_ptr ornamentSurface; + std::unique_ptr ornamentSurface; public: FilterPanel (); diff --git a/rtgui/lensprofile.cc b/rtgui/lensprofile.cc index c0d2a8fa2..d4640a71b 100644 --- a/rtgui/lensprofile.cc +++ b/rtgui/lensprofile.cc @@ -64,7 +64,7 @@ LensProfilePanel::LensProfilePanel() : lensfunCameras(Gtk::manage((new MyComboBox()))), lensfunLensesLbl(Gtk::manage((new Gtk::Label(M("EXIFFILTER_LENS"))))), lensfunLenses(Gtk::manage((new MyComboBox()))), - warning(Gtk::manage(new RTImage("warning"))), + warning(Gtk::manage(new RTImage("warning", Gtk::ICON_SIZE_LARGE_TOOLBAR))), ckbUseDist(Gtk::manage((new Gtk::CheckButton(M("TP_LENSPROFILE_USE_GEOMETRIC"))))), ckbUseVign(Gtk::manage((new Gtk::CheckButton(M("TP_LENSPROFILE_USE_VIGNETTING"))))), ckbUseCA(Gtk::manage((new Gtk::CheckButton(M("TP_LENSPROFILE_USE_CA"))))) diff --git a/rtgui/rtimage.cc b/rtgui/rtimage.cc index 9bd942c47..bcfa9ad55 100644 --- a/rtgui/rtimage.cc +++ b/rtgui/rtimage.cc @@ -82,20 +82,7 @@ RTImage::RTImage (const Glib::RefPtr& gIcon, const Gtk::IconSiz void RTImage::set_from_icon_name(const Glib::ustring& iconName) { - this->icon_name = iconName; - - // Set surface from icon cache - surface = RTImageCache::getCachedSurface(this->icon_name, this->size); - - // Add it to the RTImage if surface exists - if (surface) { - set(surface->get()); - } - - // Unset Gio::Icon if firstly exists - if (this->g_icon) { - g_icon = Glib::RefPtr(); - } + set_from_icon_name(iconName, this->size); } void RTImage::set_from_icon_name(const Glib::ustring& iconName, const Gtk::IconSize iconSize) @@ -119,17 +106,7 @@ void RTImage::set_from_icon_name(const Glib::ustring& iconName, const Gtk::IconS void RTImage::set_from_gicon(const Glib::RefPtr& gIcon) { - this->g_icon = gIcon; - - // Set image from Gio::Icon - set(this->g_icon, this->size); - - // Unset surface if previously chosen - this->icon_name = ""; - - if (surface) { - surface = std::shared_ptr(); - } + set_from_gicon(gIcon, this->size); } void RTImage::set_from_gicon(const Glib::RefPtr& gIcon, const Gtk::IconSize iconSize) diff --git a/rtgui/rtscalable.cc b/rtgui/rtscalable.cc index 5e61e8655..58b67ed52 100644 --- a/rtgui/rtscalable.cc +++ b/rtgui/rtscalable.cc @@ -32,7 +32,7 @@ extern Glib::ustring argv0; double RTScalable::dpi = 96.; int RTScalable::scale = 1; -void RTScalable::updateDPInScale(const Gtk::Window* window, double &newDPI, int &newScale) +void RTScalable::getDPInScale(const Gtk::Window* window, double &newDPI, int &newScale) { if (window) { const auto screen = window->get_screen(); @@ -169,6 +169,7 @@ Cairo::RefPtr RTScalable::loadSurfaceFromSVG(const Glib::us if (error) { std::cerr << "Failed to load SVG file \"" << fname << "\": " << std::endl << Glib::ustring(error->message) << std::endl; + free(error); return surf; } @@ -215,6 +216,7 @@ Cairo::RefPtr RTScalable::loadSurfaceFromSVG(const Glib::us if (!success && error) { std::cerr << "Failed to load SVG file \"" << fname << "\": " << std::endl << Glib::ustring(error->message) << std::endl; + free(error); return surf; } @@ -234,12 +236,12 @@ Cairo::RefPtr RTScalable::loadSurfaceFromSVG(const Glib::us void RTScalable::init(const Gtk::Window* window) { // Retrieve DPI and Scale paremeters from OS - updateDPInScale(window, dpi, scale); + getDPInScale(window, dpi, scale); } void RTScalable::setDPInScale (const Gtk::Window* window) { - updateDPInScale(window, dpi, scale); + getDPInScale(window, dpi, scale); } void RTScalable::setDPInScale (const double newDPI, const int newScale) diff --git a/rtgui/rtscalable.h b/rtgui/rtscalable.h index 6913515aa..80312adef 100644 --- a/rtgui/rtscalable.h +++ b/rtgui/rtscalable.h @@ -54,7 +54,7 @@ class RTScalable private: static double dpi; static int scale; - static void updateDPInScale(const Gtk::Window* window, double &newDPI, int &newScale); + static void getDPInScale(const Gtk::Window* window, double &newDPI, int &newScale); protected: static Cairo::RefPtr loadSurfaceFromIcon(const Glib::ustring &icon_name, const Gtk::IconSize iconSize = Gtk::ICON_SIZE_SMALL_TOOLBAR); diff --git a/rtgui/rtsurface.cc b/rtgui/rtsurface.cc index d26f2cb02..a4015494a 100644 --- a/rtgui/rtsurface.cc +++ b/rtgui/rtsurface.cc @@ -32,7 +32,7 @@ RTSurface::RTSurface() : scaleBack = RTScalable::getScale(); // Initialize other private parameters - type = RTSurface::InvalidType; + type = RTSurfaceType::InvalidType; name = ""; icon_size = Gtk::ICON_SIZE_INVALID; } @@ -45,7 +45,7 @@ RTSurface::RTSurface(const Glib::ustring &icon_name, const Gtk::IconSize iconSiz if (surface) { // Save private parameters - type = RTSurface::IconType; + type = RTSurfaceType::IconType; name = icon_name; icon_size = iconSize; } @@ -67,7 +67,7 @@ RTSurface::RTSurface(const Glib::ustring &fname) : if (surface) { // Save private parameter - type = RTSurface::PNGType; + type = RTSurfaceType::PNGType; name = fname; } } @@ -79,7 +79,7 @@ RTSurface::RTSurface(const Glib::ustring &fname) : if (surface) { // Save private parameter - type = RTSurface::SVGType; + type = RTSurfaceType::SVGType; name = fname; } } @@ -92,7 +92,7 @@ int RTSurface::getWidth() if (hasSurface()) { switch (type) { - case RTSurface::IconType: + case RTSurfaceType::IconType: // Get width from Gtk::IconSize if (!Gtk::IconSize::lookup(icon_size, w, h)) { // Size in invalid w = h = -1; // Invalid case @@ -100,15 +100,15 @@ int RTSurface::getWidth() return w; - case RTSurface::PNGType: + case RTSurfaceType::PNGType: // Directly return surface width return surface->get_width(); - case RTSurface::SVGType: + case RTSurfaceType::SVGType: // Returned size shall consider the scaling return (surface->get_width() / RTScalable::getScale()); - case RTSurface::InvalidType: + case RTSurfaceType::InvalidType: default: // Invalid case return -1; @@ -125,7 +125,7 @@ int RTSurface::getHeight() if (hasSurface()) { switch (type) { - case RTSurface::IconType: + case RTSurfaceType::IconType: // Get width from Gtk::IconSize if (!Gtk::IconSize::lookup(icon_size, w, h)) { // Size in invalid w = h = -1; // Invalid case @@ -133,15 +133,15 @@ int RTSurface::getHeight() return h; - case RTSurface::PNGType: + case RTSurfaceType::PNGType: // Directly return surface width return surface->get_height(); - case RTSurface::SVGType: + case RTSurfaceType::SVGType: // Returned size shall consider the scaling return (surface->get_height() / RTScalable::getScale()); - case RTSurface::InvalidType: + case RTSurfaceType::InvalidType: default: // Invalid case return -1; @@ -175,13 +175,13 @@ void RTSurface::updateSurface() { // Update surface based on the scale switch (type) { - case RTSurface::IconType : + case RTSurfaceType::IconType : surface = RTScalable::loadSurfaceFromIcon(name, icon_size); break; - case RTSurface::PNGType : + case RTSurfaceType::PNGType : surface = RTScalable::loadSurfaceFromPNG(name); break; - case RTSurface::SVGType : + case RTSurfaceType::SVGType : surface = RTScalable::loadSurfaceFromSVG(name); break; default : diff --git a/rtgui/rtsurface.h b/rtgui/rtsurface.h index 629a07a83..515b079c7 100644 --- a/rtgui/rtsurface.h +++ b/rtgui/rtsurface.h @@ -27,11 +27,11 @@ class RTSurface final : public RTScalable { public: - enum RTSurfaceType { - InvalidType = 1, - IconType = 2, - PNGType = 3, - SVGType = 4 + enum class RTSurfaceType { + InvalidType, + IconType, + PNGType, + SVGType }; private: