Files
abaddon/components/lazyimage.hpp
2021-01-17 22:50:55 -05:00

20 lines
496 B
C++

#pragma once
#include <gtkmm.h>
// 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 SetURL(const std::string &url);
private:
bool OnDraw(const Cairo::RefPtr<Cairo::Context> &context);
bool m_needs_request = true;
std::string m_url;
int m_width;
int m_height;
};