diff options
author | Dylam De La Torre <DyXel04@gmail.com> | 2021-11-23 05:21:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-23 04:21:56 +0000 |
commit | a51a54bc5979a2491f152abc47ad54e6b63f27c8 (patch) | |
tree | ce67092b2f6df366033a65a6111e4650866766b2 /src/components/cellrendererpixbufanimation.hpp | |
parent | d88079000a79e6bcbe51c5a2868d57b303b5fcb6 (diff) | |
download | abaddon-portaudio-a51a54bc5979a2491f152abc47ad54e6b63f27c8.tar.gz abaddon-portaudio-a51a54bc5979a2491f152abc47ad54e6b63f27c8.zip |
Restructure source and resource files (#46)
importantly, res is now res/res and css is now res/css
Diffstat (limited to 'src/components/cellrendererpixbufanimation.hpp')
-rw-r--r-- | src/components/cellrendererpixbufanimation.hpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/src/components/cellrendererpixbufanimation.hpp b/src/components/cellrendererpixbufanimation.hpp new file mode 100644 index 0000000..f47e928 --- /dev/null +++ b/src/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; +}; |