Creates an RTImage cache

Fixes:
- Fixes GUI issue on Windows (GDI handles limit reached)
- Fixes an incorrect icon name in Perspective tool
- Adds robustness RTScalable::loadSurfaceFromIcon function
This commit is contained in:
Pandagrapher
2022-09-02 19:15:42 +02:00
parent 35ce0d1227
commit 1c85926200
6 changed files with 130 additions and 21 deletions

View File

@@ -20,7 +20,18 @@
*/
#pragma once
#include <gtkmm/image.h>
#include <gtkmm.h>
class RTSurface;
class RTImageCache final
{
private:
static std::map<std::pair<Glib::ustring, Gtk::IconSize>, std::shared_ptr<RTSurface>> cache;
public:
static std::shared_ptr<RTSurface> getCachedSurface(const Glib::ustring &icon_name, const Gtk::IconSize icon_size);
static void updateCache();
};
/**
* @brief A derived class of Gtk::Image in order to handle theme-related icon sets.
@@ -29,6 +40,8 @@ class RTImage final : public Gtk::Image
{
private:
Gtk::IconSize size;
Glib::ustring icon_name;
std::shared_ptr<RTSurface> surface;
public:
RTImage ();
@@ -36,4 +49,7 @@ public:
void set_from_icon_name(const Glib::ustring& iconName);
void set_from_icon_name(const Glib::ustring& iconName, const Gtk::IconSize iconSize);
int get_width();
int get_height();
};