button_element.h 632 B

12345678910111213141516171819202122232425262728
  1. #pragma once
  2. #include "generic_element.h"
  3. typedef void (*ButtonElementCallback)(void* context);
  4. class ButtonElement : public GenericElement {
  5. public:
  6. ButtonElement();
  7. ~ButtonElement() final;
  8. void draw(Canvas* canvas) final;
  9. bool input(InputEvent* event) final;
  10. enum class Type : uint8_t {
  11. Left,
  12. Center,
  13. Right,
  14. };
  15. void set_type(Type type, const char* text);
  16. void set_callback(void* context, ButtonElementCallback callback);
  17. private:
  18. Type type = Type::Left;
  19. const char* text = nullptr;
  20. void* context = nullptr;
  21. ButtonElementCallback callback = nullptr;
  22. };