GuiTriangle.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /**
  2. * Triangles
  3. * Copyright (C) 2016 POSITIVE MENTAL ATTITUDE
  4. *
  5. * This program is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, version 3 of the License.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #pragma once
  18. #include "Triangle.hpp"
  19. /**
  20. * @class GuiTriangle
  21. * @author POSITIVE MENTAL ATTITUDE
  22. * @date 05/05/16
  23. * @file Triangle.hpp
  24. * @brief All these (not so) fancy main menu triangles are GUI triangles.
  25. */
  26. class GuiTriangle: public Triangle
  27. {
  28. public:
  29. GuiTriangle();
  30. /**
  31. * @brief Returns the width of the triangle when it stands on its arm (rotated by 92.5°)
  32. */
  33. float getWidth();
  34. /**
  35. * @brief Checks if the cursor is inside of the triangle
  36. * @return boolean
  37. */
  38. bool mouseIntersection(sf::Vector2i mouseXY);
  39. void click(sf::Vector2i mouseXY);
  40. void update(sf::Vector2i mouseXY, sf::Time delta);
  41. void bind(const std::function<void()>& lambda);
  42. protected:
  43. virtual void redraw();
  44. private:
  45. float _scale;
  46. std::function<void()> onClick;
  47. };