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
8namespace Chesto {
9
11{
12public:
20 NetImageElement(const char *url, std::function<Texture *(void)> getImageFallback = NULL, bool immediateLoad = true);
22
24 void fetch();
25
26 // TODO: introduce a boolean to control auto-loading described below
28 bool process(InputEvents* event) override;
29
31 void render(Element* parent) override;
32 bool loaded = false;
33 bool updateSizeAfterLoad = false;
34
35private:
36 void imgDownloadComplete(DownloadOperation *download);
37
38 DownloadOperation *imgDownload = nullptr;
39 Texture *imgFallback = nullptr;
40 bool downloadStarted = false;
41};
42
43} // namespace Chesto
Element * parent
the parent element (reference only, not owned)
Definition: Element.hpp:116
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 render(Element *parent) override
Render the image.
bool process(InputEvents *event) override
Checks if we're onscreen and start download if needed.
void fetch()
Start downloading the image (called in the constructor unless immediateLoad is false)