From 769e2a72d168a1d7dc70b6eb192d1790b04aa114 Mon Sep 17 00:00:00 2001 From: jules Date: Fri, 19 Oct 2012 18:44:44 +0100 Subject: [PATCH] Added a notification mode to Scrollbar::setCurrentRange() --- modules/juce_gui_basics/layout/juce_ScrollBar.cpp | 10 ++++++++-- modules/juce_gui_basics/layout/juce_ScrollBar.h | 6 +++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/modules/juce_gui_basics/layout/juce_ScrollBar.cpp b/modules/juce_gui_basics/layout/juce_ScrollBar.cpp index c8458e5c80..b6e697c808 100644 --- a/modules/juce_gui_basics/layout/juce_ScrollBar.cpp +++ b/modules/juce_gui_basics/layout/juce_ScrollBar.cpp @@ -95,7 +95,8 @@ void ScrollBar::setRangeLimits (const double newMinimum, const double newMaximum setRangeLimits (Range (newMinimum, newMaximum)); } -bool ScrollBar::setCurrentRange (const Range& newRange) +bool ScrollBar::setCurrentRange (const Range& newRange, + const NotificationType notification) { const Range constrainedRange (totalRange.constrainRange (newRange)); @@ -104,7 +105,12 @@ bool ScrollBar::setCurrentRange (const Range& newRange) visibleRange = constrainedRange; updateThumbPosition(); - triggerAsyncUpdate(); + + if (notification != dontSendNotification) + triggerAsyncUpdate(); + + if (notification == sendNotificationSync) + handleUpdateNowIfNeeded(); return true; } diff --git a/modules/juce_gui_basics/layout/juce_ScrollBar.h b/modules/juce_gui_basics/layout/juce_ScrollBar.h index 9c791d912b..2ce48b9908 100644 --- a/modules/juce_gui_basics/layout/juce_ScrollBar.h +++ b/modules/juce_gui_basics/layout/juce_ScrollBar.h @@ -137,10 +137,14 @@ public: asynchronous call to ScrollBar::Listener::scrollBarMoved() for all the listeners that are registered. + The notification parameter can be used to optionally send or inhibit a callback to + any scrollbar listeners. + @returns true if the range was changed, or false if nothing was changed. @see getCurrentRange. setCurrentRangeStart */ - bool setCurrentRange (const Range& newRange); + bool setCurrentRange (const Range& newRange, + NotificationType notification = sendNotificationAsync); /** Changes the position of the scrollbar's 'thumb'.