From b2e00b2b06456998f916ebe81463dab98a2fe421 Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Fri, 4 Jun 2021 12:32:03 -0400 Subject: [PATCH] Add menu separator to switch param tooltip. Fix bug when ParamWidget tooltip is not appearing when Light is placed above it. --- src/app/ModuleLightWidget.cpp | 7 +++++-- src/app/ParamWidget.cpp | 7 ++++++- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/app/ModuleLightWidget.cpp b/src/app/ModuleLightWidget.cpp index 48652f69..6239d067 100644 --- a/src/app/ModuleLightWidget.cpp +++ b/src/app/ModuleLightWidget.cpp @@ -70,8 +70,6 @@ void ModuleLightWidget::createTooltip() { return; if (this->tooltip) return; - if (!module) - return; // If the LightInfo is null, don't show a tooltip if (!getLightInfo()) return; @@ -123,6 +121,11 @@ void ModuleLightWidget::step() { void ModuleLightWidget::onHover(const HoverEvent& e) { // Adapted from OpaqueWidget::onHover() Widget::onHover(e); + + // If the LightInfo is null, don't consume Hover event + if (!getLightInfo()) + return; + e.stopPropagating(); // Consume if not consumed by child if (!e.isConsumed()) diff --git a/src/app/ParamWidget.cpp b/src/app/ParamWidget.cpp index 92ab4dea..e93acc1c 100644 --- a/src/app/ParamWidget.cpp +++ b/src/app/ParamWidget.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -249,7 +250,8 @@ void ParamWidget::createContextMenu() { if (switchQuantity) { int index = (int) std::floor(pq->getValue()); - for (int i = 0; i < (int) switchQuantity->labels.size(); i++) { + int numStates = switchQuantity->labels.size(); + for (int i = 0; i < numStates; i++) { std::string label = switchQuantity->labels[i]; ParamValueItem* paramValueItem = new ParamValueItem; paramValueItem->text = label; @@ -258,6 +260,9 @@ void ParamWidget::createContextMenu() { paramValueItem->value = i; menu->addChild(paramValueItem); } + if (numStates > 0) { + menu->addChild(new ui::MenuSeparator); + } } else { ParamField* paramField = new ParamField;