@@ -141,10 +141,14 @@ struct EventState { | |||||
return selectedWidget; | 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 */ | /** Prepares a widget for deletion */ | ||||
void finalizeWidget(Widget* w); | void finalizeWidget(Widget* w); | ||||
@@ -315,7 +315,7 @@ struct BrowserSearchField : ui::TextField { | |||||
void step() override { | void step() override { | ||||
// Steal focus when step is called | // Steal focus when step is called | ||||
APP->event->setSelected(this); | |||||
APP->event->setSelectedWidget(this); | |||||
TextField::step(); | TextField::step(); | ||||
} | } | ||||
@@ -324,7 +324,7 @@ struct BrowserSearchField : ui::TextField { | |||||
void onAction(const ActionEvent& e) override; | void onAction(const ActionEvent& e) override; | ||||
void onHide(const HideEvent& e) override { | void onHide(const HideEvent& e) override { | ||||
APP->event->setSelected(NULL); | |||||
APP->event->setSelectedWidget(NULL); | |||||
ui::TextField::onHide(e); | ui::TextField::onHide(e); | ||||
} | } | ||||
@@ -20,7 +20,7 @@ struct ParamField : ui::TextField { | |||||
void step() override { | void step() override { | ||||
// Keep selected | // Keep selected | ||||
APP->event->setSelected(this); | |||||
APP->event->setSelectedWidget(this); | |||||
TextField::step(); | TextField::step(); | ||||
} | } | ||||
@@ -351,14 +351,14 @@ struct MIDI_MapChoice : LedDisplayChoice { | |||||
// HACK | // HACK | ||||
if (APP->event->selectedWidget != this) | if (APP->event->selectedWidget != this) | ||||
APP->event->setSelected(this); | |||||
APP->event->setSelectedWidget(this); | |||||
} | } | ||||
else { | else { | ||||
bgColor = nvgRGBA(0, 0, 0, 0); | bgColor = nvgRGBA(0, 0, 0, 0); | ||||
// HACK | // HACK | ||||
if (APP->event->selectedWidget == this) | if (APP->event->selectedWidget == this) | ||||
APP->event->setSelected(NULL); | |||||
APP->event->setSelectedWidget(NULL); | |||||
} | } | ||||
// Set text | // Set text | ||||
@@ -91,7 +91,7 @@ struct CcChoice : LedDisplayChoice { | |||||
// Cancel focus if no longer learning | // Cancel focus if no longer learning | ||||
if (APP->event->getSelectedWidget() == this) | if (APP->event->getSelectedWidget() == this) | ||||
APP->event->setSelected(NULL); | |||||
APP->event->setSelectedWidget(NULL); | |||||
} | } | ||||
// Set text | // Set text | ||||
@@ -178,7 +178,7 @@ struct NoteChoice : LedDisplayChoice { | |||||
// Cancel focus if no longer learning | // Cancel focus if no longer learning | ||||
if (APP->event->getSelectedWidget() == this) | if (APP->event->getSelectedWidget() == this) | ||||
APP->event->setSelected(NULL); | |||||
APP->event->setSelectedWidget(NULL); | |||||
} | } | ||||
// Set text | // Set text | ||||
@@ -13,7 +13,7 @@ struct TextFieldCopyItem : ui::MenuItem { | |||||
if (!textField) | if (!textField) | ||||
return; | return; | ||||
textField->copyClipboard(); | textField->copyClipboard(); | ||||
APP->event->setSelected(textField); | |||||
APP->event->setSelectedWidget(textField); | |||||
} | } | ||||
}; | }; | ||||
@@ -24,7 +24,7 @@ struct TextFieldCutItem : ui::MenuItem { | |||||
if (!textField) | if (!textField) | ||||
return; | return; | ||||
textField->cutClipboard(); | textField->cutClipboard(); | ||||
APP->event->setSelected(textField); | |||||
APP->event->setSelectedWidget(textField); | |||||
} | } | ||||
}; | }; | ||||
@@ -35,7 +35,7 @@ struct TextFieldPasteItem : ui::MenuItem { | |||||
if (!textField) | if (!textField) | ||||
return; | return; | ||||
textField->pasteClipboard(); | textField->pasteClipboard(); | ||||
APP->event->setSelected(textField); | |||||
APP->event->setSelectedWidget(textField); | |||||
} | } | ||||
}; | }; | ||||
@@ -46,7 +46,7 @@ struct TextFieldSelectAllItem : ui::MenuItem { | |||||
if (!textField) | if (!textField) | ||||
return; | return; | ||||
textField->selectAll(); | textField->selectAll(); | ||||
APP->event->setSelected(textField); | |||||
APP->event->setSelectedWidget(textField); | |||||
} | } | ||||
}; | }; | ||||
@@ -223,13 +223,13 @@ void TextField::onSelectKey(const SelectKeyEvent& e) { | |||||
// Tab | // Tab | ||||
if (e.key == GLFW_KEY_TAB && (e.mods & RACK_MOD_MASK) == 0) { | if (e.key == GLFW_KEY_TAB && (e.mods & RACK_MOD_MASK) == 0) { | ||||
if (nextField) | if (nextField) | ||||
APP->event->setSelected(nextField); | |||||
APP->event->setSelectedWidget(nextField); | |||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
// Shift-Tab | // Shift-Tab | ||||
if (e.key == GLFW_KEY_TAB && (e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) { | if (e.key == GLFW_KEY_TAB && (e.mods & RACK_MOD_MASK) == GLFW_MOD_SHIFT) { | ||||
if (prevField) | if (prevField) | ||||
APP->event->setSelected(prevField); | |||||
APP->event->setSelectedWidget(prevField); | |||||
e.consume(this); | e.consume(this); | ||||
} | } | ||||
// Consume all printable keys | // Consume all printable keys | ||||
@@ -9,7 +9,7 @@ namespace rack { | |||||
namespace widget { | namespace widget { | ||||
void EventState::setHovered(widget::Widget* w) { | |||||
void EventState::setHoveredWidget(widget::Widget* w) { | |||||
if (w == hoveredWidget) | if (w == hoveredWidget) | ||||
return; | 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) | if (w == draggedWidget) | ||||
return; | 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) | if (w == dragHoveredWidget) | ||||
return; | 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) | if (w == selectedWidget) | ||||
return; | return; | ||||
@@ -107,13 +107,13 @@ void EventState::setSelected(widget::Widget* w) { | |||||
void EventState::finalizeWidget(widget::Widget* w) { | void EventState::finalizeWidget(widget::Widget* w) { | ||||
if (hoveredWidget == w) | if (hoveredWidget == w) | ||||
setHovered(NULL); | |||||
setHoveredWidget(NULL); | |||||
if (draggedWidget == w) | if (draggedWidget == w) | ||||
setDragged(NULL, 0); | |||||
setDraggedWidget(NULL, 0); | |||||
if (dragHoveredWidget == w) | if (dragHoveredWidget == w) | ||||
setDragHovered(NULL); | |||||
setDragHoveredWidget(NULL); | |||||
if (selectedWidget == w) | if (selectedWidget == w) | ||||
setSelected(NULL); | |||||
setSelectedWidget(NULL); | |||||
if (lastClickedWidget == w) | if (lastClickedWidget == w) | ||||
lastClickedWidget = NULL; | lastClickedWidget = NULL; | ||||
} | } | ||||
@@ -136,11 +136,11 @@ bool EventState::handleButton(math::Vec pos, int button, int action, int mods) { | |||||
} | } | ||||
if (action == GLFW_PRESS) { | if (action == GLFW_PRESS) { | ||||
setDragged(clickedWidget, button); | |||||
setDraggedWidget(clickedWidget, button); | |||||
} | } | ||||
if (action == GLFW_RELEASE) { | if (action == GLFW_RELEASE) { | ||||
setDragHovered(NULL); | |||||
setDragHoveredWidget(NULL); | |||||
if (clickedWidget && draggedWidget) { | if (clickedWidget && draggedWidget) { | ||||
// Dispatch DragDropEvent | // Dispatch DragDropEvent | ||||
@@ -150,12 +150,12 @@ bool EventState::handleButton(math::Vec pos, int button, int action, int mods) { | |||||
clickedWidget->onDragDrop(eDragDrop); | clickedWidget->onDragDrop(eDragDrop); | ||||
} | } | ||||
setDragged(NULL, 0); | |||||
setDraggedWidget(NULL, 0); | |||||
} | } | ||||
if (button == GLFW_MOUSE_BUTTON_LEFT) { | if (button == GLFW_MOUSE_BUTTON_LEFT) { | ||||
if (action == GLFW_PRESS) { | if (action == GLFW_PRESS) { | ||||
setSelected(clickedWidget); | |||||
setSelectedWidget(clickedWidget); | |||||
} | } | ||||
if (action == GLFW_PRESS) { | if (action == GLFW_PRESS) { | ||||
@@ -206,7 +206,7 @@ bool EventState::handleHover(math::Vec pos, math::Vec mouseDelta) { | |||||
eDragHover.origin = draggedWidget; | eDragHover.origin = draggedWidget; | ||||
rootWidget->onDragHover(eDragHover); | rootWidget->onDragHover(eDragHover); | ||||
setDragHovered(cDragHover.target); | |||||
setDragHoveredWidget(cDragHover.target); | |||||
// If consumed, don't continue after DragMoveEvent so HoverEvent is not triggered. | // If consumed, don't continue after DragMoveEvent so HoverEvent is not triggered. | ||||
if (cDragHover.target) | if (cDragHover.target) | ||||
dragHovered = true; | dragHovered = true; | ||||
@@ -230,7 +230,7 @@ bool EventState::handleHover(math::Vec pos, math::Vec mouseDelta) { | |||||
eHover.mouseDelta = mouseDelta; | eHover.mouseDelta = mouseDelta; | ||||
rootWidget->onHover(eHover); | rootWidget->onHover(eHover); | ||||
setHovered(cHover.target); | |||||
setHoveredWidget(cHover.target); | |||||
if (cHover.target) | if (cHover.target) | ||||
return true; | return true; | ||||
} | } | ||||
@@ -240,8 +240,8 @@ bool EventState::handleHover(math::Vec pos, math::Vec mouseDelta) { | |||||
bool EventState::handleLeave() { | bool EventState::handleLeave() { | ||||
heldKeys.clear(); | heldKeys.clear(); | ||||
// When leaving the window, don't un-hover widgets because the mouse might be dragging. | // 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; | return true; | ||||
} | } | ||||