summaryrefslogtreecommitdiff
path: root/components/cellrendererpixbufanimation.hpp
diff options
context:
space:
mode:
authorouwou <26526779+ouwou@users.noreply.github.com>2021-03-17 23:55:41 -0400
committerouwou <26526779+ouwou@users.noreply.github.com>2021-03-17 23:55:41 -0400
commit60404783bd4ce9be26233fe66fc3a74475d9eaa3 (patch)
tree7fd851858e9bdf25ad36c0e1542f5b28fb1c1e64 /components/cellrendererpixbufanimation.hpp
parent65943b4bd74ae52e6f6ffbff0e9ba619053172d6 (diff)
downloadabaddon-portaudio-60404783bd4ce9be26233fe66fc3a74475d9eaa3.tar.gz
abaddon-portaudio-60404783bd4ce9be26233fe66fc3a74475d9eaa3.zip
manage emojis
Diffstat (limited to 'components/cellrendererpixbufanimation.hpp')
-rw-r--r--components/cellrendererpixbufanimation.hpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/components/cellrendererpixbufanimation.hpp b/components/cellrendererpixbufanimation.hpp
new file mode 100644
index 0000000..f47e928
--- /dev/null
+++ b/components/cellrendererpixbufanimation.hpp
@@ -0,0 +1,41 @@
+#pragma once
+#include <gtkmm.h>
+#include <unordered_map>
+
+// handles both static and animated
+class CellRendererPixbufAnimation : public Gtk::CellRenderer {
+public:
+ CellRendererPixbufAnimation();
+ virtual ~CellRendererPixbufAnimation();
+
+ Glib::PropertyProxy<Glib::RefPtr<Gdk::Pixbuf>> property_pixbuf();
+ Glib::PropertyProxy<Glib::RefPtr<Gdk::PixbufAnimation>> property_pixbuf_animation();
+
+protected:
+ void get_preferred_width_vfunc(Gtk::Widget &widget, int &minimum_width, int &natural_width) const override;
+
+ void get_preferred_width_for_height_vfunc(Gtk::Widget &widget, int height, int &minimum_width, int &natural_width) const override;
+
+ void get_preferred_height_vfunc(Gtk::Widget &widget, int &minimum_height, int &natural_height) const override;
+
+ void get_preferred_height_for_width_vfunc(Gtk::Widget &widget, int width, int &minimum_height, int &natural_height) const override;
+
+ void render_vfunc(const Cairo::RefPtr<Cairo::Context> &cr,
+ Gtk::Widget &widget,
+ const Gdk::Rectangle &background_area,
+ const Gdk::Rectangle &cell_area,
+ Gtk::CellRendererState flag) override;
+
+private:
+ Glib::Property<Glib::RefPtr<Gdk::Pixbuf>> m_property_pixbuf;
+ Glib::Property<Glib::RefPtr<Gdk::PixbufAnimation>> m_property_pixbuf_animation;
+ /* one cellrenderer is used for every animation and i dont know how to
+ store data per-pixbuf (in this case the iter) so this little map thing will have to do
+ i would try set_data on the pixbuf but i dont know if that will cause memory leaks
+ this would mean if a row's pixbuf animation is changed more than once then it wont be released immediately
+ but thats not a problem for me in this case
+
+ unordered_map doesnt compile cuz theres no hash overload, i guess
+ */
+ std::map<Glib::RefPtr<Gdk::PixbufAnimation>, Glib::RefPtr<Gdk::PixbufAnimationIter>> m_pixbuf_animation_iters;
+};