💿🐜 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.

61 lines
1.4 KiB

  1. #ifndef TOOLBAR_HPP
  2. #define TOOLBAR_HPP
  3. #include "ui.hpp"
  4. #include <functional>
  5. #include <emergent/emergent.hpp>
  6. using namespace Emergent;
  7. class Toolbar
  8. {
  9. public:
  10. Toolbar();
  11. void setToolbarTopTexture(Texture2D* texture);
  12. void setToolbarBottomTexture(Texture2D* texture);
  13. void setToolbarMiddleTexture(Texture2D* texture);
  14. void setButtonRaisedTexture(Texture2D* texture);
  15. void setButtonDepressedTexture(Texture2D* texture);
  16. void resize();
  17. void addButton(Texture2D* iconTexture, std::function<void()> pressCallback, std::function<void()> releaseCallback);
  18. void pressButton(std::size_t index);
  19. void releaseButton(std::size_t index);
  20. const UIContainer* getContainer() const;
  21. UIContainer* getContainer();
  22. private:
  23. Texture2D* toolbarTopTexture;
  24. Texture2D* toolbarBottomTexture;
  25. Texture2D* toolbarMiddleTexture;
  26. Texture2D* buttonRaisedTexture;
  27. Texture2D* buttonDepressedTexture;
  28. UIContainer toolbarContainer;
  29. UIImage toolbarTopImage;
  30. UIImage toolbarBottomImage;
  31. UIImage toolbarMiddleImage;
  32. std::vector<UIImage*> buttons;
  33. std::vector<UIImage*> icons;
  34. std::vector<std::function<void()>> pressCallbacks;
  35. std::vector<std::function<void()>> releaseCallbacks;
  36. std::size_t depressedButtonIndex;
  37. };
  38. inline const UIContainer* Toolbar::getContainer() const
  39. {
  40. return &toolbarContainer;
  41. }
  42. inline UIContainer* Toolbar::getContainer()
  43. {
  44. return &toolbarContainer;
  45. }
  46. #endif // TOOLBAR_HPP