From a37ad4eeb5b85fdd580c5095195e6d53b1ad1489 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Wed, 1 Sep 2021 05:31:19 -0400 Subject: [PATCH] Rename EventState::setHovered() etc to setHoveredWidget() etc. --- include/widget/event.hpp | 12 ++++++++---- src/app/Browser.cpp | 4 ++-- src/app/ParamWidget.cpp | 2 +- src/core/MIDI_Map.cpp | 4 ++-- src/core/plugin.hpp | 4 ++-- src/ui/TextField.cpp | 12 ++++++------ src/widget/event.cpp | 32 ++++++++++++++++---------------- 7 files changed, 37 insertions(+), 33 deletions(-) diff --git a/include/widget/event.hpp b/include/widget/event.hpp index 73aef35b..4a31bd5a 100644 --- a/include/widget/event.hpp +++ b/include/widget/event.hpp @@ -141,10 +141,14 @@ struct EventState { return selectedWidget; } - void setHovered(Widget* w); - void setDragged(Widget* w, int button); - void setDragHovered(Widget* w); - void setSelected(Widget* w); + void setHoveredWidget(Widget* w); + void setDraggedWidget(Widget* w, int button); + void setDragHoveredWidget(Widget* w); + void setSelectedWidget(Widget* w); + DEPRECATED void setHovered(Widget* w) {setHoveredWidget(w);} + DEPRECATED void setDragged(Widget* w, int button) {setDraggedWidget(w, button);} + DEPRECATED void setDragHovered(Widget* w) {setDragHoveredWidget(w);} + DEPRECATED void setSelected(Widget* w) {setSelectedWidget(w);} /** Prepares a widget for deletion */ void finalizeWidget(Widget* w); diff --git a/src/app/Browser.cpp b/src/app/Browser.cpp index 8e2caffd..3f4c2601 100644 --- a/src/app/Browser.cpp +++ b/src/app/Browser.cpp @@ -315,7 +315,7 @@ struct BrowserSearchField : ui::TextField { void step() override { // Steal focus when step is called - APP->event->setSelected(this); + APP->event->setSelectedWidget(this); TextField::step(); } @@ -324,7 +324,7 @@ struct BrowserSearchField : ui::TextField { void onAction(const ActionEvent& e) override; void onHide(const HideEvent& e) override { - APP->event->setSelected(NULL); + APP->event->setSelectedWidget(NULL); ui::TextField::onHide(e); } diff --git a/src/app/ParamWidget.cpp b/src/app/ParamWidget.cpp index 0506cf8f..083e9bba 100644 --- a/src/app/ParamWidget.cpp +++ b/src/app/ParamWidget.cpp @@ -20,7 +20,7 @@ struct ParamField : ui::TextField { void step() override { // Keep selected - APP->event->setSelected(this); + APP->event->setSelectedWidget(this); TextField::step(); } diff --git a/src/core/MIDI_Map.cpp b/src/core/MIDI_Map.cpp index 4d4c7041..9a4ac19c 100644 --- a/src/core/MIDI_Map.cpp +++ b/src/core/MIDI_Map.cpp @@ -351,14 +351,14 @@ struct MIDI_MapChoice : LedDisplayChoice { // HACK if (APP->event->selectedWidget != this) - APP->event->setSelected(this); + APP->event->setSelectedWidget(this); } else { bgColor = nvgRGBA(0, 0, 0, 0); // HACK if (APP->event->selectedWidget == this) - APP->event->setSelected(NULL); + APP->event->setSelectedWidget(NULL); } // Set text diff --git a/src/core/plugin.hpp b/src/core/plugin.hpp index dbac2b8d..251eaad0 100644 --- a/src/core/plugin.hpp +++ b/src/core/plugin.hpp @@ -91,7 +91,7 @@ struct CcChoice : LedDisplayChoice { // Cancel focus if no longer learning if (APP->event->getSelectedWidget() == this) - APP->event->setSelected(NULL); + APP->event->setSelectedWidget(NULL); } // Set text @@ -178,7 +178,7 @@ struct NoteChoice : LedDisplayChoice { // Cancel focus if no longer learning if (APP->event->getSelectedWidget() == this) - APP->event->setSelected(NULL); + APP->event->setSelectedWidget(NULL); } // Set text diff --git a/src/ui/TextField.cpp b/src/ui/TextField.cpp index 3bc62b1a..0e3bd60a 100644 --- a/src/ui/TextField.cpp +++ b/src/ui/TextField.cpp @@ -13,7 +13,7 @@ struct TextFieldCopyItem : ui::MenuItem { if (!textField) return; textField->copyClipboard(); - APP->event->setSelected(textField); + APP->event->setSelectedWidget(textField); } }; @@ -24,7 +24,7 @@ struct TextFieldCutItem : ui::MenuItem { if (!textField) return; textField->cutClipboard(); - APP->event->setSelected(textField); + APP->event->setSelectedWidget(textField); } }; @@ -35,7 +35,7 @@ struct TextFieldPasteItem : ui::MenuItem { if (!textField) return; textField->pasteClipboard(); - APP->event->setSelected(textField); + APP->event->setSelectedWidget(textField); } }; @@ -46,7 +46,7 @@ struct TextFieldSelectAllItem : ui::MenuItem { if (!textField) return; textField->selectAll(); - APP->event->setSelected(textField); + APP->event->setSelectedWidget(textField); } }; @@ -223,13 +223,13 @@ void TextField::onSelectKey(const SelectKeyEvent& e) { // Tab if (e.key == GLFW_KEY_TAB && (e.mods & RACK_MOD_MASK) == 0) { if (nextField) - APP->event->setSelected(nextField); + APP->event->setSelectedWidget(nextField); e.consume(this); } // Shift-Tab if (e.key == GLFW_KEY_TAB && (e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) { if (prevField) - APP->event->setSelected(prevField); + APP->event->setSelectedWidget(prevField); e.consume(this); } // Consume all printable keys diff --git a/src/widget/event.cpp b/src/widget/event.cpp index ccdb0554..582879a2 100644 --- a/src/widget/event.cpp +++ b/src/widget/event.cpp @@ -9,7 +9,7 @@ namespace rack { namespace widget { -void EventState::setHovered(widget::Widget* w) { +void EventState::setHoveredWidget(widget::Widget* w) { if (w == hoveredWidget) return; @@ -31,7 +31,7 @@ void EventState::setHovered(widget::Widget* w) { } } -void EventState::setDragged(widget::Widget* w, int button) { +void EventState::setDraggedWidget(widget::Widget* w, int button) { if (w == draggedWidget) return; @@ -57,7 +57,7 @@ void EventState::setDragged(widget::Widget* w, int button) { } } -void EventState::setDragHovered(widget::Widget* w) { +void EventState::setDragHoveredWidget(widget::Widget* w) { if (w == dragHoveredWidget) return; @@ -83,7 +83,7 @@ void EventState::setDragHovered(widget::Widget* w) { } } -void EventState::setSelected(widget::Widget* w) { +void EventState::setSelectedWidget(widget::Widget* w) { if (w == selectedWidget) return; @@ -107,13 +107,13 @@ void EventState::setSelected(widget::Widget* w) { void EventState::finalizeWidget(widget::Widget* w) { if (hoveredWidget == w) - setHovered(NULL); + setHoveredWidget(NULL); if (draggedWidget == w) - setDragged(NULL, 0); + setDraggedWidget(NULL, 0); if (dragHoveredWidget == w) - setDragHovered(NULL); + setDragHoveredWidget(NULL); if (selectedWidget == w) - setSelected(NULL); + setSelectedWidget(NULL); if (lastClickedWidget == w) lastClickedWidget = NULL; } @@ -136,11 +136,11 @@ bool EventState::handleButton(math::Vec pos, int button, int action, int mods) { } if (action == GLFW_PRESS) { - setDragged(clickedWidget, button); + setDraggedWidget(clickedWidget, button); } if (action == GLFW_RELEASE) { - setDragHovered(NULL); + setDragHoveredWidget(NULL); if (clickedWidget && draggedWidget) { // Dispatch DragDropEvent @@ -150,12 +150,12 @@ bool EventState::handleButton(math::Vec pos, int button, int action, int mods) { clickedWidget->onDragDrop(eDragDrop); } - setDragged(NULL, 0); + setDraggedWidget(NULL, 0); } if (button == GLFW_MOUSE_BUTTON_LEFT) { if (action == GLFW_PRESS) { - setSelected(clickedWidget); + setSelectedWidget(clickedWidget); } if (action == GLFW_PRESS) { @@ -206,7 +206,7 @@ bool EventState::handleHover(math::Vec pos, math::Vec mouseDelta) { eDragHover.origin = draggedWidget; rootWidget->onDragHover(eDragHover); - setDragHovered(cDragHover.target); + setDragHoveredWidget(cDragHover.target); // If consumed, don't continue after DragMoveEvent so HoverEvent is not triggered. if (cDragHover.target) dragHovered = true; @@ -230,7 +230,7 @@ bool EventState::handleHover(math::Vec pos, math::Vec mouseDelta) { eHover.mouseDelta = mouseDelta; rootWidget->onHover(eHover); - setHovered(cHover.target); + setHoveredWidget(cHover.target); if (cHover.target) return true; } @@ -240,8 +240,8 @@ bool EventState::handleHover(math::Vec pos, math::Vec mouseDelta) { bool EventState::handleLeave() { heldKeys.clear(); // When leaving the window, don't un-hover widgets because the mouse might be dragging. - // setDragHovered(NULL); - // setHovered(NULL); + // setDragHoveredWidget(NULL); + // setHoveredWidget(NULL); return true; }