ui_button.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. *** :: UI Button ::
  3. ***
  4. *** Clickable UI button that retains state
  5. ***
  6. **/
  7. #ifndef ui_button_h
  8. #define ui_button_h
  9. #include "cengine.h"
  10. #include "ui/ui_text.h"
  11. #include "ui/ui_rectangle.h"
  12. typedef struct ui_button {
  13. ui_rectangle* back;
  14. ui_text* label;
  15. vec4 up_color;
  16. vec4 down_color;
  17. void (*onclick)(struct ui_button*, void* data);
  18. void* onclick_data;
  19. bool active;
  20. bool enabled;
  21. bool pressed;
  22. } ui_button;
  23. ui_button* ui_button_new();
  24. void ui_button_delete(ui_button* b);
  25. void ui_button_move(ui_button* b, vec2 pos);
  26. void ui_button_resize(ui_button* b, vec2 size);
  27. void ui_button_set_label(ui_button* b, char* label);
  28. void ui_button_set_label_color(ui_button* b, vec4 color);
  29. void ui_button_set_font(ui_button* b, asset_hndl f);
  30. void ui_button_set_onclick(ui_button* b, void(*onclick)(ui_button*, void*));
  31. void ui_button_set_onclick_data(ui_button* b, void* data);
  32. void ui_button_set_active(ui_button* b, bool active);
  33. void ui_button_set_enabled(ui_button* b, bool enabled);
  34. void ui_button_set_texture(ui_button* b, asset_hndl tex, int width, int height, bool tile);
  35. void ui_button_disable(ui_button* b);
  36. void ui_button_enable(ui_button* b);
  37. vec2 ui_button_position(ui_button* b);
  38. vec2 ui_button_size(ui_button* b);
  39. void ui_button_event(ui_button* b, SDL_Event e);
  40. void ui_button_update(ui_button* b);
  41. void ui_button_render(ui_button* b);
  42. bool ui_button_contains_point(ui_button* b, vec2 pos);
  43. #endif