- updated
git-svn-id: http://moon:8086/svn/software/trunk/projects/mpsk_rx_gui@117 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -94,7 +94,7 @@ public:
|
||||
*/
|
||||
void endDrag()
|
||||
{
|
||||
startTimer (1000 / 60);
|
||||
startTimerHz (60);
|
||||
}
|
||||
|
||||
/** Called outside of a drag operation to cause a nudge in the specified direction.
|
||||
@@ -102,7 +102,7 @@ public:
|
||||
*/
|
||||
void nudge (double deltaFromCurrentPosition)
|
||||
{
|
||||
startTimer (100);
|
||||
startTimerHz (10);
|
||||
moveTo (position + deltaFromCurrentPosition);
|
||||
}
|
||||
|
||||
@@ -197,7 +197,7 @@ private:
|
||||
if (behaviour.isStopped (newPos))
|
||||
stopTimer();
|
||||
else
|
||||
startTimer (1000 / 60);
|
||||
startTimerHz (60);
|
||||
|
||||
setPositionAndSendChange (newPos);
|
||||
}
|
||||
|
||||
@@ -25,9 +25,7 @@
|
||||
class ComponentAnimator::AnimationTask
|
||||
{
|
||||
public:
|
||||
AnimationTask (Component* const comp) noexcept : component (comp)
|
||||
{
|
||||
}
|
||||
AnimationTask (Component* c) noexcept : component (c) {}
|
||||
|
||||
void reset (const Rectangle<int>& finalBounds,
|
||||
float finalAlpha,
|
||||
@@ -65,8 +63,8 @@ public:
|
||||
|
||||
bool useTimeslice (const int elapsed)
|
||||
{
|
||||
if (Component* const c = proxy != nullptr ? static_cast <Component*> (proxy)
|
||||
: static_cast <Component*> (component))
|
||||
if (Component* const c = proxy != nullptr ? static_cast<Component*> (proxy)
|
||||
: static_cast<Component*> (component))
|
||||
{
|
||||
msElapsed += elapsed;
|
||||
double newProgress = msElapsed / (double) msTotal;
|
||||
@@ -149,7 +147,10 @@ public:
|
||||
else
|
||||
jassertfalse; // seem to be trying to animate a component that's not visible..
|
||||
|
||||
image = c.createComponentSnapshot (c.getLocalBounds(), false, getDesktopScaleFactor());
|
||||
const float scale = (float) Desktop::getInstance().getDisplays()
|
||||
.getDisplayContaining (getScreenBounds().getCentre()).scale;
|
||||
|
||||
image = c.createComponentSnapshot (c.getLocalBounds(), false, scale);
|
||||
|
||||
setVisible (true);
|
||||
toBehind (&c);
|
||||
@@ -189,14 +190,8 @@ private:
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
ComponentAnimator::ComponentAnimator()
|
||||
: lastTime (0)
|
||||
{
|
||||
}
|
||||
|
||||
ComponentAnimator::~ComponentAnimator()
|
||||
{
|
||||
}
|
||||
ComponentAnimator::ComponentAnimator() : lastTime (0) {}
|
||||
ComponentAnimator::~ComponentAnimator() {}
|
||||
|
||||
//==============================================================================
|
||||
ComponentAnimator::AnimationTask* ComponentAnimator::findTaskFor (Component* const component) const noexcept
|
||||
@@ -236,7 +231,7 @@ void ComponentAnimator::animateComponent (Component* const component,
|
||||
if (! isTimerRunning())
|
||||
{
|
||||
lastTime = Time::getMillisecondCounter();
|
||||
startTimer (1000 / 50);
|
||||
startTimerHz (50);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ Viewport::Viewport (const String& name)
|
||||
Viewport::~Viewport()
|
||||
{
|
||||
deleteContentComp();
|
||||
mouseWheelTimer = nullptr;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
@@ -357,6 +358,30 @@ static int rescaleMouseWheelDistance (float distance, int singleStepSize) noexce
|
||||
: jmax (distance, 1.0f));
|
||||
}
|
||||
|
||||
// This puts a temporary component overlay over the content component, to prevent
|
||||
// wheel events from reaching components inside it, so that while spinning a wheel
|
||||
// with momentum, it won't accidentally scroll any subcomponents of the viewport.
|
||||
struct Viewport::MouseWheelTimer : public Timer
|
||||
{
|
||||
MouseWheelTimer (Viewport& v) : viewport (v)
|
||||
{
|
||||
viewport.contentHolder.addAndMakeVisible (dummyOverlay);
|
||||
dummyOverlay.setAlwaysOnTop (true);
|
||||
dummyOverlay.setPaintingIsUnclipped (true);
|
||||
dummyOverlay.setBounds (viewport.contentHolder.getLocalBounds());
|
||||
}
|
||||
|
||||
void timerCallback() override
|
||||
{
|
||||
viewport.mouseWheelTimer = nullptr;
|
||||
}
|
||||
|
||||
Component dummyOverlay;
|
||||
Viewport& viewport;
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MouseWheelTimer)
|
||||
};
|
||||
|
||||
bool Viewport::useMouseWheelMoveIfNeeded (const MouseEvent& e, const MouseWheelDetails& wheel)
|
||||
{
|
||||
if (! (e.mods.isAltDown() || e.mods.isCtrlDown() || e.mods.isCommandDown()))
|
||||
@@ -387,6 +412,11 @@ bool Viewport::useMouseWheelMoveIfNeeded (const MouseEvent& e, const MouseWheelD
|
||||
|
||||
if (pos != getViewPosition())
|
||||
{
|
||||
if (mouseWheelTimer == nullptr)
|
||||
mouseWheelTimer = new MouseWheelTimer (*this);
|
||||
|
||||
mouseWheelTimer->startTimer (300);
|
||||
|
||||
setViewPosition (pos);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -267,6 +267,9 @@ private:
|
||||
bool allowScrollingWithoutScrollbarV, allowScrollingWithoutScrollbarH;
|
||||
Component contentHolder;
|
||||
ScrollBar verticalScrollBar, horizontalScrollBar;
|
||||
struct MouseWheelTimer;
|
||||
ScopedPointer<Timer> mouseWheelTimer;
|
||||
|
||||
Point<int> viewportPosToCompPos (Point<int>) const;
|
||||
|
||||
void updateVisibleArea();
|
||||
|
||||
Reference in New Issue
Block a user