| 133 | |
| 134 | struct EditButton : MenuButton { |
| 135 | void onAction(const ActionEvent& e) override { |
| 136 | ui::Menu* menu = createMenu(); |
| 137 | menu->cornerFlags = BND_CORNER_TOP; |
| 138 | menu->box.pos = getAbsoluteOffset(math::Vec(0, box.size.y)); |
| 139 | |
| 140 | struct UndoItem : ui::MenuItem { |
| 141 | void step() override { |
| 142 | bool canUndo = APP->history->canUndo(); |
| 143 | text = canUndo ? string::f(string::translate("MenuBar.edit.undoAction"), APP->history->getUndoName()) : string::translate("MenuBar.edit.undo"); |
| 144 | disabled = !canUndo; |
| 145 | MenuItem::step(); |
| 146 | } |
| 147 | void onAction(const ActionEvent& e) override { |
| 148 | APP->history->undo(); |
| 149 | } |
| 150 | }; |
| 151 | menu->addChild(createMenuItem<UndoItem>("", widget::getKeyCommandName(GLFW_KEY_Z, RACK_MOD_CTRL))); |
| 152 | |
| 153 | struct RedoItem : ui::MenuItem { |
| 154 | void step() override { |
| 155 | bool canRedo = APP->history->canRedo(); |
| 156 | text = canRedo ? string::f(string::translate("MenuBar.edit.redoAction"), APP->history->getRedoName()) : string::translate("MenuBar.edit.redo"); |
| 157 | disabled = !canRedo; |
| 158 | MenuItem::step(); |
| 159 | } |
| 160 | void onAction(const ActionEvent& e) override { |
| 161 | APP->history->redo(); |
| 162 | } |
| 163 | }; |
| 164 | menu->addChild(createMenuItem<RedoItem>("", widget::getKeyCommandName(GLFW_KEY_Z, RACK_MOD_CTRL | GLFW_MOD_SHIFT))); |
| 165 | |
| 166 | menu->addChild(createMenuItem(string::translate("MenuBar.edit.clearCables"), "", [=]() { |
| 167 | APP->patch->disconnectDialog(); |
| 168 | })); |
| 169 | |
| 170 | menu->addChild(new ui::MenuSeparator); |
| 171 | |
| 172 | APP->scene->rack->appendSelectionContextMenu(menu); |
| 173 | } |
| 174 | }; |
| 175 | |
| 176 |
nothing calls this directly
no test coverage detected