03b6d2c2ef
Parameter exposure (AU/iOS AUv3/VST/VST3) for host automation. iOS Universal build with iPhone support. Enhanced AUv3 GUI window display fit. AUv3 GUI scrolling using left and right border sides.
65 lines
1.5 KiB
C++
65 lines
1.5 KiB
C++
/*
|
|
==============================================================================
|
|
|
|
ScrollbarManager.cpp
|
|
Created: 1 Jul 2020 2:59:58am
|
|
Author: discoDSP
|
|
|
|
==============================================================================
|
|
*/
|
|
|
|
#include "ScrollbarManager.h"
|
|
|
|
ScrollbarManager::ScrollbarManager(Viewport& vp) : viewport(vp)
|
|
{
|
|
viewport.addMouseListener(this, true);
|
|
viewport.setScrollBarsShown(false, false, true, false);
|
|
scrollEnabled(false);
|
|
|
|
};
|
|
|
|
ScrollbarManager::~ScrollbarManager()
|
|
{
|
|
viewport.removeMouseListener(this);
|
|
};
|
|
|
|
void ScrollbarManager::mouseDown(const MouseEvent& event)
|
|
{
|
|
jassert(constraints.size() != 0);
|
|
|
|
auto e = event.getEventRelativeTo(&viewport);
|
|
|
|
auto position = e.getMouseDownPosition();
|
|
|
|
for (auto rectangle : constraints)
|
|
{
|
|
if (rectangle.contains(position))
|
|
{
|
|
scrollEnabled(true);
|
|
break;
|
|
}
|
|
}
|
|
};
|
|
|
|
void ScrollbarManager::mouseUp(const MouseEvent& event)
|
|
{
|
|
if (viewport.isScrollOnDragEnabled())
|
|
scrollEnabled(false);
|
|
};
|
|
|
|
void ScrollbarManager::addConstraint(int initialX, int initialY, int width, int height)
|
|
{
|
|
constraints.emplace_back(initialX, initialY, width, height);
|
|
};
|
|
|
|
void ScrollbarManager::removeAllConstraints()
|
|
{
|
|
if (!constraints.empty())
|
|
constraints.clear();
|
|
};
|
|
|
|
void ScrollbarManager::scrollEnabled(bool enabled)
|
|
{
|
|
viewport.setScrollOnDragEnabled(enabled);
|
|
}
|
|
|