Browse Source

Added a notification mode to Scrollbar::setCurrentRange()

tags/2021-05-28
jules 13 years ago
parent
commit
769e2a72d1
2 changed files with 13 additions and 3 deletions
  1. +8
    -2
      modules/juce_gui_basics/layout/juce_ScrollBar.cpp
  2. +5
    -1
      modules/juce_gui_basics/layout/juce_ScrollBar.h

+ 8
- 2
modules/juce_gui_basics/layout/juce_ScrollBar.cpp View File

@@ -95,7 +95,8 @@ void ScrollBar::setRangeLimits (const double newMinimum, const double newMaximum
setRangeLimits (Range<double> (newMinimum, newMaximum)); setRangeLimits (Range<double> (newMinimum, newMaximum));
} }
bool ScrollBar::setCurrentRange (const Range<double>& newRange)
bool ScrollBar::setCurrentRange (const Range<double>& newRange,
const NotificationType notification)
{ {
const Range<double> constrainedRange (totalRange.constrainRange (newRange)); const Range<double> constrainedRange (totalRange.constrainRange (newRange));
@@ -104,7 +105,12 @@ bool ScrollBar::setCurrentRange (const Range<double>& newRange)
visibleRange = constrainedRange; visibleRange = constrainedRange;
updateThumbPosition(); updateThumbPosition();
triggerAsyncUpdate();
if (notification != dontSendNotification)
triggerAsyncUpdate();
if (notification == sendNotificationSync)
handleUpdateNowIfNeeded();
return true; return true;
} }


+ 5
- 1
modules/juce_gui_basics/layout/juce_ScrollBar.h View File

@@ -137,10 +137,14 @@ public:
asynchronous call to ScrollBar::Listener::scrollBarMoved() for all the listeners that asynchronous call to ScrollBar::Listener::scrollBarMoved() for all the listeners that
are registered. 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. @returns true if the range was changed, or false if nothing was changed.
@see getCurrentRange. setCurrentRangeStart @see getCurrentRange. setCurrentRangeStart
*/ */
bool setCurrentRange (const Range<double>& newRange);
bool setCurrentRange (const Range<double>& newRange,
NotificationType notification = sendNotificationAsync);
/** Changes the position of the scrollbar's 'thumb'. /** Changes the position of the scrollbar's 'thumb'.


Loading…
Cancel
Save