From a51a54bc5979a2491f152abc47ad54e6b63f27c8 Mon Sep 17 00:00:00 2001 From: Dylam De La Torre Date: Tue, 23 Nov 2021 05:21:56 +0100 Subject: Restructure source and resource files (#46) importantly, res is now res/res and css is now res/css --- src/components/lazyimage.hpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/components/lazyimage.hpp (limited to 'src/components/lazyimage.hpp') diff --git a/src/components/lazyimage.hpp b/src/components/lazyimage.hpp new file mode 100644 index 0000000..fae69df --- /dev/null +++ b/src/components/lazyimage.hpp @@ -0,0 +1,21 @@ +#pragma once +#include + +// loads an image only when the widget is drawn for the first time +class LazyImage : public Gtk::Image { +public: + LazyImage(int w, int h, bool use_placeholder = true); + LazyImage(const std::string &url, int w, int h, bool use_placeholder = true); + + void SetAnimated(bool is_animated); + void SetURL(const std::string &url); + +private: + bool OnDraw(const Cairo::RefPtr &context); + + bool m_animated = false; + bool m_needs_request = true; + std::string m_url; + int m_width; + int m_height; +}; -- cgit v1.2.3