DISTRHO Plugin Framework
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.6KB

  1. /*
  2. * Copyright (C) 2018-2019 Rob van den Berg <rghvdberg at gmail dot org>
  3. *
  4. * This file is part of CharacterCompressor
  5. *
  6. * Nnjas2 is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * CharacterCompressor is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with CharacterCompressor. If not, see <https://www.gnu.org/licenses/>.
  18. */
  19. #ifndef BUTTON_HPP_INCLUDED
  20. #define BUTTON_HPP_INCLUDED
  21. #include "Widget.hpp"
  22. #include "NanoVG.hpp"
  23. #include <string>
  24. START_NAMESPACE_DISTRHO
  25. class Button : public NanoWidget
  26. {
  27. public:
  28. class Callback
  29. {
  30. public:
  31. virtual ~Callback() {}
  32. virtual void buttonClicked(Button *button, bool value) = 0;
  33. };
  34. explicit Button(Widget *parent, Callback *cb);
  35. void setLabel(std::string label);
  36. void setLabelColor(Color color);
  37. void setBackgroundColor(Color color);
  38. protected:
  39. void onNanoDisplay() override;
  40. bool onMouse(const MouseEvent &ev) override;
  41. private:
  42. std::string Label;
  43. Color labelColor,backgroundColor,borderColor;
  44. Callback *const fCallback;
  45. bool buttonActive;
  46. FontId fNanoFont;
  47. DISTRHO_LEAK_DETECTOR(Button)
  48. };
  49. END_NAMESPACE_DISTRHO
  50. #endif