Chesto 0.9
A declarative and element-based library for creating GUIs on homebrew'd consoles
NetImageElement.hpp
1#pragma once
2
3#include <string>
4#include <functional>
5#include "Texture.hpp"
6#include "DownloadQueue.hpp"
7
8class NetImageElement : public Texture
9{
10public:
18 NetImageElement(const char *url, std::function<Texture *(void)> getImageFallback = NULL, bool immediateLoad = true);
20
22 void fetch();
23
25 void render(Element* parent);
26 bool loaded = false;
27 bool updateSizeAfterLoad = false;
28
29private:
30 void imgDownloadComplete(DownloadOperation *download);
31
32 DownloadOperation *imgDownload = nullptr;
33 Texture *imgFallback = nullptr;
34 bool downloadStarted = false;
35};
Element * parent
the parent element (can sometimes be null if it isn't set)
Definition: Element.hpp:102
void render(Element *parent)
Render the image.
NetImageElement(const char *url, std::function< Texture *(void)> getImageFallback=NULL, bool immediateLoad=true)
Creates a new image element, downloading the image from url If the url is not cached,...
void fetch()
Start downloading the image (called in the constructor unless immediateLoad is false)