diff --git a/currentGitHash.txt b/currentGitHash.txt index 0a0baa1473..841f148ce0 100644 --- a/currentGitHash.txt +++ b/currentGitHash.txt @@ -1 +1 @@ -4d39c10811fdff150c2fd0c8552997dac2a177f2 +9551adf7f1319bdfce3706472a58ff70143d7f4d diff --git a/hi_backend/backend/currentGit.h b/hi_backend/backend/currentGit.h index e1e1c7365d..3c235a204a 100644 --- a/hi_backend/backend/currentGit.h +++ b/hi_backend/backend/currentGit.h @@ -1 +1 @@ -#define PREVIOUS_HISE_COMMIT "4d39c10811fdff150c2fd0c8552997dac2a177f2" +#define PREVIOUS_HISE_COMMIT "9551adf7f1319bdfce3706472a58ff70143d7f4d" diff --git a/hi_scripting/scripting/components/ScriptingContentOverlay.cpp b/hi_scripting/scripting/components/ScriptingContentOverlay.cpp index 6e443c0df4..ef8663396d 100644 --- a/hi_scripting/scripting/components/ScriptingContentOverlay.cpp +++ b/hi_scripting/scripting/components/ScriptingContentOverlay.cpp @@ -561,6 +561,7 @@ void ScriptingContentOverlay::mouseUp(const MouseEvent &e) { lasso.setVisible(false); lasso.endLasso(); + ZoomableViewport::checkDragScroll(e, true); lassoActive = false; repaint(); } @@ -818,6 +819,7 @@ void ScriptingContentOverlay::mouseDrag(const MouseEvent& e) if (lasso.isVisible()) { + ZoomableViewport::checkDragScroll(e, false); lasso.dragLasso(e); repaint(); } @@ -983,7 +985,11 @@ void ScriptingContentOverlay::Dragger::mouseDrag(const MouseEvent& e) dragDistance = constrainer.getPosition().getTopLeft() - startBounds.getTopLeft(); if (e.eventComponent == this) + { + ZoomableViewport::checkDragScroll(e, false); dragger.dragComponent(this, e, &constrainer); + } + @@ -1027,6 +1033,7 @@ void ScriptingContentOverlay::Dragger::mouseUp(const MouseEvent& e) if (!parent->enableMouseDragging) return; + ZoomableViewport::checkDragScroll(e, true); findParentComponentOfClass()->smw.endDragging(); snapShot = Image(); diff --git a/hi_scripting/scripting/scriptnode/api/ModulationSourceNode.cpp b/hi_scripting/scripting/scriptnode/api/ModulationSourceNode.cpp index f0d8e7b62f..01db3a5fc3 100644 --- a/hi_scripting/scripting/scriptnode/api/ModulationSourceNode.cpp +++ b/hi_scripting/scripting/scriptnode/api/ModulationSourceNode.cpp @@ -197,6 +197,8 @@ void ModulationSourceBaseComponent::mouseDrag(const MouseEvent& e) container->startDragging(var(details), this, ScaledImage(createDragImage())); + ZoomableViewport::checkDragScroll(e, false); + findParentComponentOfClass()->dragOverlay.setEnabled(true); } } @@ -206,6 +208,8 @@ void ModulationSourceBaseComponent::mouseUp(const MouseEvent& e) { CHECK_MIDDLE_MOUSE_UP(e); + ZoomableViewport::checkDragScroll(e, true); + findParentComponentOfClass()->dragOverlay.setEnabled(false); } diff --git a/hi_scripting/scripting/scriptnode/dynamic_elements/DynamicParameterList.cpp b/hi_scripting/scripting/scriptnode/dynamic_elements/DynamicParameterList.cpp index 045cf03ae8..a9953326ca 100644 --- a/hi_scripting/scripting/scriptnode/dynamic_elements/DynamicParameterList.cpp +++ b/hi_scripting/scripting/scriptnode/dynamic_elements/DynamicParameterList.cpp @@ -791,6 +791,7 @@ namespace ui details->setProperty(PropertyIds::SwitchTarget, true); container->startDragging(var(details), this, ScaledImage(ModulationSourceBaseComponent::createDragImageStatic(false))); + ZoomableViewport::checkDragScroll(e, false); findParentComponentOfClass()->repaint(); } } @@ -799,6 +800,7 @@ namespace ui { CHECK_MIDDLE_MOUSE_UP(event); + ZoomableViewport::checkDragScroll(event, true); findParentComponentOfClass()->repaint(); } diff --git a/hi_scripting/scripting/scriptnode/dynamic_elements/DynamicRoutingNodes.cpp b/hi_scripting/scripting/scriptnode/dynamic_elements/DynamicRoutingNodes.cpp index 562132c527..05227d7a4e 100644 --- a/hi_scripting/scripting/scriptnode/dynamic_elements/DynamicRoutingNodes.cpp +++ b/hi_scripting/scripting/scriptnode/dynamic_elements/DynamicRoutingNodes.cpp @@ -749,12 +749,16 @@ void dynamic::editor::mouseUp(const MouseEvent& e) fc->repaint(); }); + ZoomableViewport::checkDragScroll(e, true); findParentComponentOfClass()->repaint(); } void dynamic::editor::mouseDrag(const MouseEvent& event) { CHECK_MIDDLE_MOUSE_DRAG(event); + + ZoomableViewport::checkDragScroll(event, false); + findParentComponentOfClass()->repaint(); } diff --git a/hi_scripting/scripting/scriptnode/ui/NodeContainerComponent.h b/hi_scripting/scripting/scriptnode/ui/NodeContainerComponent.h index bb1f93bb78..479bd43170 100644 --- a/hi_scripting/scripting/scriptnode/ui/NodeContainerComponent.h +++ b/hi_scripting/scripting/scriptnode/ui/NodeContainerComponent.h @@ -635,6 +635,15 @@ class ContainerComponent : public NodeComponent, g.setColour(Colours::black.withAlpha(0.1f)); g.fillRoundedRectangle(b, 10.0f); + + if(sliders.isEmpty()) + { + auto f = GLOBAL_BOLD_FONT(); + String t = "No parameters"; + g.setColour(Colours::white.withAlpha(0.3f)); + g.setFont(f); + g.drawText(t, getLocalBounds().toFloat(), Justification::centred); + } } ContainerComponent& parent; diff --git a/hi_scripting/scripting/scriptnode/ui/ParameterSlider.cpp b/hi_scripting/scripting/scriptnode/ui/ParameterSlider.cpp index 3d65ad7c1e..37e567b091 100644 --- a/hi_scripting/scripting/scriptnode/ui/ParameterSlider.cpp +++ b/hi_scripting/scripting/scriptnode/ui/ParameterSlider.cpp @@ -1770,6 +1770,11 @@ void MacroParameterSlider::mouseDrag(const MouseEvent& e) container->startDragging(details, &slider, ScaledImage(ModulationSourceBaseComponent::createDragImageStatic(false))); + ZoomableViewport::checkDragScroll(e, false); + + + + slider.repaintParentGraph(); } } @@ -1779,6 +1784,8 @@ void MacroParameterSlider::mouseUp(const MouseEvent& e) { CHECK_MIDDLE_MOUSE_UP(e); + ZoomableViewport::checkDragScroll(e, true); + slider.repaintParentGraph(); } diff --git a/hi_tools/hi_standalone_components/ZoomableViewport.cpp b/hi_tools/hi_standalone_components/ZoomableViewport.cpp index 8cdfcb3033..f53a0e2bcc 100644 --- a/hi_tools/hi_standalone_components/ZoomableViewport.cpp +++ b/hi_tools/hi_standalone_components/ZoomableViewport.cpp @@ -62,6 +62,7 @@ ZoomableViewport::ZoomableViewport(Component* n) : hBar(false), vBar(true), content(n), + dragScrollTimer(*this), mouseWatcher(new MouseWatcher(*this)) { sf.addScrollBarToAnimate(hBar); @@ -108,6 +109,16 @@ ZoomableViewport::~ZoomableViewport() content = nullptr; } +bool ZoomableViewport::checkDragScroll(const MouseEvent& e, bool isMouseUp) +{ + if(auto vp = e.eventComponent->findParentComponentOfClass()) + { + vp->dragScrollTimer.setPosition(e, isMouseUp); + } + + return false; +} + bool ZoomableViewport::checkViewportScroll(const MouseEvent& e, const MouseWheelDetails& wheel) { if (wheel.deltaX > 0.0 || wheel.deltaY > 0.0) @@ -622,6 +633,80 @@ void SubmenuComboBox::rebuildPopupMenu() refreshTickState(); } +void ZoomableViewport::DragScrollTimer::timerCallback() +{ + auto factor = JUCE_LIVE_CONSTANT_OFF(0.03); + auto expo = JUCE_LIVE_CONSTANT_OFF(1.2); + + auto dx = jlimit(-1.0, 1.0, (double)xDelta / (double)(parent.getWidth() / 5)); + auto dy = jlimit(-1.0, 1.0, (double)yDelta / (double)(parent.getHeight() / 5)); + + dx = hmath::sign(dx) * std::pow(hmath::abs(dx), expo); + dy = hmath::sign(dy) * std::pow(hmath::abs(dy), expo); + + auto a = JUCE_LIVE_CONSTANT_OFF(0.74); + + dx = lx * a + dx * (1.0 - a); + dy = ly * a + dy * (1.0 - a); + + lx = dx; + ly = dy; + + dx *= factor; + dy *= factor; + + parent.hBar.setCurrentRangeStart(jlimit(0.0, 1.0, parent.hBar.getCurrentRangeStart() + dx)); + parent.vBar.setCurrentRangeStart(jlimit(0.0, 1.0, parent.vBar.getCurrentRangeStart() + dy)); +} + +void ZoomableViewport::DragScrollTimer::setPosition(const MouseEvent& e, bool isMouseUp) +{ + if(isMouseUp) + { + wasInCentre = false; + lx = 0.0; + ly = 0.0; + stopTimer(); + return; + } + + auto vpos = parent.getLocalPoint(e.eventComponent, e.getPosition()); + auto vb = parent.getLocalBounds(); + auto padding = jmin(vb.getWidth(), vb.getHeight()) / 6; + + vb = vb.reduced(padding); + + if(vpos.getX() > vb.getRight()) + xDelta = vpos.getX() - vb.getRight(); + else if (vpos.getX() < vb.getX()) + xDelta = vpos.getX() - vb.getX(); + else + xDelta = 0; + + if(vpos.getY() > vb.getBottom()) + yDelta = vpos.getY() - vb.getBottom(); + else if (vpos.getY() < vb.getY()) + yDelta = vpos.getY() - vb.getY(); + else + yDelta = 0; + + if(xDelta == 0 && yDelta == 0) + wasInCentre = true; + + auto shouldScroll = wasInCentre && (xDelta != 0 || yDelta != 0); + + if(shouldScroll != isTimerRunning()) + { + if(shouldScroll) + startTimer(30); + else + { + if(hmath::abs(lx) < 0.005 && hmath::abs(ly) < 0.005) + stopTimer(); + } + } +} + ZoomableViewport::MouseWatcher::MouseWatcher(ZoomableViewport& p): parent(p) { diff --git a/hi_tools/hi_standalone_components/ZoomableViewport.h b/hi_tools/hi_standalone_components/ZoomableViewport.h index fc1df63dcb..609f6ff83c 100644 --- a/hi_tools/hi_standalone_components/ZoomableViewport.h +++ b/hi_tools/hi_standalone_components/ZoomableViewport.h @@ -167,6 +167,29 @@ struct ZoomableViewport : public Component, public Timer, public DragAnimator::Listener { + struct DragScrollTimer: public Timer + { + DragScrollTimer(ZoomableViewport& parent_): + parent(parent_) + {}; + + void timerCallback() override; + + void setPosition(const MouseEvent& e, bool isMouseUp); + + bool wasInCentre = false; + int xDelta = 0; + int yDelta = 0; + + double lx = 0.0; + double ly = 0.0; + + ZoomableViewport& parent; + + } dragScrollTimer; + + + enum ColourIds { backgroundColourId = 9000 @@ -198,6 +221,8 @@ struct ZoomableViewport : public Component, virtual ~ZoomableViewport(); + static bool checkDragScroll(const MouseEvent& e, bool isMouseUp); + static bool checkViewportScroll(const MouseEvent& e, const MouseWheelDetails& details); static bool checkMiddleMouseDrag(const MouseEvent& e, MouseEventFlags type);