gigawidgets 0.3.55
A wxWidgets-style UI library for the Arduino Giga Display Shield.
 
Loading...
Searching...
No Matches
image.hpp
Go to the documentation of this file.
1
2#pragma once
3
4#include "core/renderable.hpp"
5#include "core/widget.hpp"
6
7namespace ui {
8
12class Image : public Widget {
13 Renderable const *renderable;
14 shader_t shader;
16 bool renderEveryFrame;
17
18public:
25 Image(const Renderable &renderable, const Position &pos = {0, 0}, const Alignment &align = {ALIGN_LEFT, ALIGN_TOP});
26
27 void draw() const override;
28 Size size() const override;
29 void update(time_t time_ms) override;
30
35 void setShader(const shader_animated_t &shader);
36
41 void setShader(const shader_oneframe_t &shader);
42
47
52 void setRender(const Renderable &renderable);
53
54 DERIVE_EVENT_HANDLERS(Image)
55};
56
57} // namespace ui
Display an arbitrary (non-animated) renderable to the screen with an optional shader.
Definition image.hpp:12
void draw() const override
Render the widget to the screen.
void setShader(const shader_oneframe_t &shader)
Set the image shader to one that only requires rendering once.
void setRender(const Renderable &renderable)
Change the current rendered object.
void update(time_t time_ms) override
Update any internal state of the widget, and check if it needs to be re-rendered.
void removeShader()
Remove the shader from the image, if any exists.
Size size() const override
Get the size of the widget.
void setShader(const shader_animated_t &shader)
Set the image shader to a new one that requires re-rendering every frame.
Image(const Renderable &renderable, const Position &pos={0, 0}, const Alignment &align={ALIGN_LEFT, ALIGN_TOP})
Construct an image from some renderable data.
The common interface for all UI objects.
Definition widget.hpp:27
std::function< color_t(color_t color, const Coords &coords, const Size &size, time_t time)> shader_animated_t
A pixel shader that may update based on the current time.
Definition renderable.hpp:35
shader_animated_t shader_t
A pixel shader that may or may not update based on the current time.
Definition renderable.hpp:48
std::function< color_t(color_t color, const Coords &coords, const Size &size)> shader_oneframe_t
A pixel shader that's independent of the current time.
Definition renderable.hpp:22
A struct that holds a widget's vertical and horizontal alignment.
Definition alignment.hpp:22
A struct that holds the normalized position of a widget.
Definition position.hpp:15
An abstract interface for arbitrary renderable objects.
Definition renderable.hpp:55
A struct that holds the number of pixels that a widget would take up on the screen.
Definition size.hpp:17