diff options
Diffstat (limited to 'ui/button.hpp')
-rw-r--r-- | ui/button.hpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/ui/button.hpp b/ui/button.hpp new file mode 100644 index 0000000..4a0a9f5 --- /dev/null +++ b/ui/button.hpp @@ -0,0 +1,37 @@ +#ifndef MBUOY_UI_BUTTON_HPP +#define MBUOY_UI_BUTTON_HPP + +#include "attr/dimensions.hpp" +#include "attr/ondraw.hpp" +#include "attr/position.hpp" +#include "attr/string.hpp" +#include "find.hpp" +#include "port.hpp" + +namespace mbuoy { + +template<auto... Attr> +struct button +{ + static constexpr auto point = find<position>(Attr...); + static constexpr auto dims = find<dimensions>(Attr...); + static constexpr auto text = find<const char *>(Attr...); + static constexpr auto draw = find<ondraw>(Attr...); + + static consteval void init(unsigned char *(&ptr)) { + *ptr++ = 0; // pressed? + } + + static void render() { + (*draw)(*point, *dims); + } + + static consteval int size() { + return 1; + } +}; + +} // namespace mbuoy + +#endif // MBUOY_UI_BUTTON_HPP + |