Browse Source

Don't propagate Hover and DragHover events on ModuleWidget if selected.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
9cbf65f48c
2 changed files with 29 additions and 8 deletions
  1. +2
    -0
      include/app/ModuleWidget.hpp
  2. +27
    -8
      src/app/ModuleWidget.cpp

+ 2
- 0
include/app/ModuleWidget.hpp View File

@@ -70,11 +70,13 @@ struct ModuleWidget : widget::OpaqueWidget {
*/
virtual void appendContextMenu(ui::Menu* menu) {}

void onHover(const HoverEvent& e) override;
void onHoverKey(const HoverKeyEvent& e) override;
void onButton(const ButtonEvent& e) override;
void onDragStart(const DragStartEvent& e) override;
void onDragEnd(const DragEndEvent& e) override;
void onDragMove(const DragMoveEvent& e) override;
void onDragHover(const DragHoverEvent& e) override;

json_t* toJson();
void fromJson(json_t* rootJ);


+ 27
- 8
src/app/ModuleWidget.cpp View File

@@ -309,6 +309,14 @@ void ModuleWidget::drawShadow(const DrawArgs& args) {
nvgFill(args.vg);
}

void ModuleWidget::onHover(const HoverEvent& e) {
if (internal->selected) {
e.consume(this);
}

OpaqueWidget::onHover(e);
}

void ModuleWidget::onHoverKey(const HoverKeyEvent& e) {
OpaqueWidget::onHoverKey(e);
if (e.isConsumed())
@@ -372,6 +380,15 @@ void ModuleWidget::onHoverKey(const HoverKeyEvent& e) {
}

void ModuleWidget::onButton(const ButtonEvent& e) {
if (internal->selected) {
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) {
ui::Menu* menu = createMenu();
APP->scene->rack->appendSelectionContextMenu(menu);
}

e.consume(this);
}

OpaqueWidget::onButton(e);

if (e.getTarget() == this) {
@@ -385,16 +402,10 @@ void ModuleWidget::onButton(const ButtonEvent& e) {
}
}

if (!e.isConsumed()) {
if (!e.isConsumed() && !internal->selected) {
// Open context menu on right-click
if (e.action == GLFW_PRESS && e.button == GLFW_MOUSE_BUTTON_RIGHT) {
if (internal->selected) {
ui::Menu* menu = createMenu();
APP->scene->rack->appendSelectionContextMenu(menu);
}
else {
createContextMenu();
}
createContextMenu();
e.consume(this);
}
}
@@ -465,6 +476,14 @@ void ModuleWidget::onDragMove(const DragMoveEvent& e) {
}
}

void ModuleWidget::onDragHover(const DragHoverEvent& e) {
if (internal->selected) {
e.consume(this);
}

OpaqueWidget::onDragHover(e);
}

json_t* ModuleWidget::toJson() {
json_t* moduleJ = APP->engine->moduleToJson(module);
return moduleJ;


Loading…
Cancel
Save