Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

33 řádky
1.2 KiB

  1. #ifndef SDL_CLICKY_CLICKABLE_H_
  2. #define SDL_CLICKY_CLICKABLE_H_
  3. #include <SDL.h>
  4. #include <stdbool.h>
  5. typedef struct {
  6. SDL_Rect dimensions;
  7. bool isdown; //When clicked and held.
  8. void (*clickFunc)(void*, int, int); //The function to call when the clickable is registered as clicked. The arg should be set to be a pointer to the clicked clickable. Makes sense when the clickable is the first member (not as pointer) of an "inheriting" type.
  9. void (*releaseFunc)(void*, int, int); //Same as above for when the button is released.
  10. void (*drawFunc)(void*, SDL_Renderer*);
  11. } Clickable;
  12. typedef struct {
  13. Clickable super;
  14. SDL_Rect *boundaries; //Don't go outside these bounds. May be NULL.
  15. SDL_Rect *coordinatesToDrag; //The dragable may be inside a container to be moved around.
  16. } Dragable;
  17. bool Clickable_CheckBounds(Clickable *c, int x, int y);
  18. bool Clicky_ClickClickable(void *c_, int x, int y);
  19. void Clicky_ReleaseClickable(void *c_, int x, int y);
  20. void Clicky_ReleaseHeldClickable(int x, int y);
  21. void Clicky_DragUpdate(int x, int y); //Updates the dragging.
  22. void Dragable_ClickFunc(void *dragable, int x, int y);
  23. void Dragable_ReleaseFunc(void *dragable, int x, int y);
  24. #endif // SDL_CLICKY_CLICKABLE_H_