Button.h 508 B

123456789101112131415161718192021222324252627282930
  1. #pragma once
  2. #include "Text.h"
  3. class Button : public Text
  4. {
  5. private:
  6. typedef void(*action_function)(Button* b);
  7. float width, height;
  8. Vec3f background;
  9. Vec2f planePosition;
  10. bool cursorOnButton;
  11. float alfa;
  12. action_function action = nullptr;
  13. public:
  14. Button(const std::string &text, Vec2f position, float width, float height);
  15. ~Button();
  16. void draw();
  17. void update(int x, int y);
  18. void addAction(action_function action);
  19. void setForeground(Vec3f color);
  20. void setBackground(Vec3f color);
  21. };