You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
784 B
C++
38 lines
784 B
C++
2 months ago
|
#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
|
||
|
|