💿🐜 Antkeeper source code https://antkeeper.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.4 KiB

  1. #ifndef PIE_MENU_HPP
  2. #define PIE_MENU_HPP
  3. #include "ui.hpp"
  4. #include "tween.hpp"
  5. #include <functional>
  6. #include <vector>
  7. #include <emergent/emergent.hpp>
  8. using namespace Emergent;
  9. class PieMenu
  10. {
  11. public:
  12. PieMenu(Tweener* tweener);
  13. void resize();
  14. void addOption(Texture* backgroundTexture, Texture* iconTexture, std::function<void()> selectedCallback, std::function<void()> deselectedCallback);
  15. void select(std::size_t index);
  16. void deselect(std::size_t index);
  17. const UIContainer* getContainer() const;
  18. UIContainer* getContainer();
  19. void mouseMoved(int x, int y);
  20. void mouseButtonPressed(int button, int x, int y);
  21. void mouseButtonReleased(int button, int x, int y);
  22. void setScale(float scale);
  23. private:
  24. void highlight(std::size_t index);
  25. void unhighlight(std::size_t index);
  26. Tweener* tweener;
  27. Tween<float>* scaleUpTween;
  28. Tween<float>* scaleDownTween;
  29. float scale;
  30. UIContainer fullscreenContainer;
  31. UIContainer croppedContainer;
  32. UIContainer scalingContainer;
  33. std::vector<UIImage*> options;
  34. std::vector<UIImage*> icons;
  35. std::vector<std::function<void()>> selectedCallbacks;
  36. std::vector<std::function<void()>> deselectedCallbacks;
  37. std::size_t selectionIndex;
  38. bool dragging;
  39. Vector2 dragStart;
  40. std::size_t highlightedIndex;
  41. };
  42. inline const UIContainer* PieMenu::getContainer() const
  43. {
  44. return &fullscreenContainer;
  45. }
  46. inline UIContainer* PieMenu::getContainer()
  47. {
  48. return &fullscreenContainer;
  49. }
  50. #endif // PIE_MENU_HPP