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.

44 lines
1.0KB

  1. #pragma once
  2. #include <ui/common.hpp>
  3. #include <ui/Menu.hpp>
  4. #include <ui/MenuEntry.hpp>
  5. #include <context.hpp>
  6. namespace rack {
  7. namespace ui {
  8. struct MenuItem : MenuEntry {
  9. std::string text;
  10. std::string rightText;
  11. bool disabled = false;
  12. void draw(const DrawArgs& args) override;
  13. PRIVATE void drawOffset(NVGcontext* vg, float offset = 0);
  14. void step() override;
  15. void onEnter(const EnterEvent& e) override;
  16. void onDragDrop(const DragDropEvent& e) override;
  17. void doAction(bool consume = true);
  18. virtual Menu* createChildMenu() {
  19. return NULL;
  20. }
  21. /** Override to handle behavior when user clicks the menu item.
  22. Event is consumed by default. Unconsume to prevent the menu from being closed.
  23. If Ctrl (Cmd on Mac) is held, the event is *not* pre-consumed, so if your menu must be closed, always consume the event.
  24. */
  25. void onAction(const ActionEvent& e) override;
  26. };
  27. struct ColorDotMenuItem : MenuItem {
  28. NVGcolor color;
  29. void draw(const DrawArgs& args) override;
  30. void step() override;
  31. };
  32. } // namespace ui
  33. } // namespace rack