Button.hxx 573 B

12345678910111213141516171819202122232425262728293031323334
  1. #pragma once
  2. #ifndef SNAKE_BUTTON_HXX
  3. #define SNAKE_BUTTON_HXX
  4. #include <SDL.h>
  5. #include <SDL_ttf.h>
  6. #include <future>
  7. #include <string>
  8. class SDLRenderer;
  9. class Button final {
  10. public:
  11. Button(std::string title, int x, int y, int w, int h);
  12. void set_pressed(bool pressed);
  13. bool is_pressed() const;
  14. void render(SDLRenderer& renderer);
  15. private:
  16. std::string title_;
  17. int x_, y_, w_, h_;
  18. bool pressed_;
  19. std::shared_future<SDL_Texture*> up_;
  20. std::shared_future<SDL_Texture*> down_;
  21. std::shared_future<TTF_Font*> font_;
  22. };
  23. #endif // SNAKE_BUTTON_HXX