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.

60 lines
1.7KB

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