80 updateThumbPosition();
98 updateThumbPosition();
155 if (upButton !=
nullptr)
165 listeners.add (listener);
170 listeners.remove (listener);
173void ScrollBar::handleAsyncUpdate()
175 auto start = visibleRange.
getStart();
176 listeners.call ([
this, start] (Listener&
l) {
l.scrollBarMoved (
this, start); });
180void ScrollBar::updateThumbPosition()
222 if (upButton !=
nullptr)
224 upButton->direction = vertical ? 0 : 3;
225 downButton->direction = vertical ? 2 : 1;
228 updateThumbPosition();
235 updateThumbPosition();
246 if (thumbAreaSize > 0)
250 auto thumb = (thumbAreaSize >
lf.getMinimumScrollbarThumbSize (*
this))
254 lf.drawScrollbar (g, *
this, 0, thumbAreaStart,
getWidth(), thumbAreaSize,
257 lf.drawScrollbar (g, *
this, thumbAreaStart, 0, thumbAreaSize,
getHeight(),
280 if (upButton ==
nullptr)
288 setButtonRepeatSpeed (initialDelayInMillisecs, repeatDelayInMillisecs, minimumDelayInMillisecs);
291 buttonSize =
jmin (
lf.getScrollbarButtonSize (*
this), length / 2);
299 if (length < 32 +
lf.getMinimumScrollbarThumbSize (*
this))
301 thumbAreaStart = length / 2;
306 thumbAreaStart = buttonSize;
307 thumbAreaSize = length - 2 * buttonSize;
310 if (upButton !=
nullptr)
316 upButton->setBounds (r.removeFromTop (buttonSize));
317 downButton->setBounds (r.removeFromBottom (buttonSize));
321 upButton->setBounds (r.removeFromLeft (buttonSize));
322 downButton->setBounds (r.removeFromRight (buttonSize));
326 updateThumbPosition();
336 isDraggingThumb =
false;
337 lastMousePos = vertical ? e.
y : e.
x;
338 dragStartMousePos = lastMousePos;
339 dragStartRange = visibleRange.
getStart();
341 if (dragStartMousePos < thumbStart)
346 else if (dragStartMousePos >= thumbStart + thumbSize)
354 && (thumbAreaSize > thumbSize);
362 if (isDraggingThumb && lastMousePos !=
mousePos && thumbAreaSize > thumbSize)
368 / (thumbAreaSize - thumbSize));
376 isDraggingThumb =
false;
383 float increment = 10.0f * (vertical ?
wheel.deltaY :
wheel.deltaX);
386 increment =
jmin (increment, -1.0f);
387 else if (increment > 0)
388 increment =
jmax (increment, 1.0f);
393void ScrollBar::timerCallback()
399 if (lastMousePos < thumbStart)
401 else if (lastMousePos > thumbStart + thumbSize)
434bool ScrollBar::getVisibility()
const noexcept
436 if (! userVisibilityFlag)
449 explicit ValueInterface (
ScrollBar& scrollBarToWrap) : scrollBar (scrollBarToWrap) {}
451 bool isReadOnly()
const override {
return false; }
453 double getCurrentValue()
const override {
return scrollBar.getCurrentRangeStart(); }
454 void setValue (
double newValue)
override { scrollBar.setCurrentRangeStart (newValue); }
456 AccessibleValueRange getRange()
const override
458 if (scrollBar.getRangeLimit().isEmpty())
461 return { { scrollBar.getMinimumRangeLimit(), scrollBar.getMaximumRangeLimit() },
462 scrollBar.getSingleStepSize() };
471 return std::make_unique<AccessibilityHandler> (*
this,
472 AccessibilityRole::scrollBar,
A simple wrapper for building a collection of supported accessibility actions and corresponding callb...
A value interface that represents a ranged numeric value.
void handleUpdateNowIfNeeded()
If an update has been triggered and is pending, this will invoke it synchronously.
void triggerAsyncUpdate()
Causes the callback to be triggered at a later time.
bool isMouseButtonDown(bool includeChildren=false) const
Returns true if the mouse button is currently held down in this component.
void setRepaintsOnMouseActivity(bool shouldRepaint) noexcept
Causes automatic repaints when the mouse enters or exits this component.
bool isVisible() const noexcept
Tests whether the component is visible or not.
void setFocusContainerType(FocusContainerType containerType) noexcept
Sets whether this component is a container for components that can have their focus traversed,...
int getHeight() const noexcept
Returns the component's height in pixels.
void addAndMakeVisible(Component *child, int zOrder=-1)
Adds a child component to this one, and also makes the child visible if it isn't already.
void repaint()
Marks the whole component as needing to be redrawn.
@ keyboardFocusContainer
The component will act as a top-level component within which keyboard focus is passed around.
void setWantsKeyboardFocus(bool wantsFocus) noexcept
Sets a flag to indicate whether this component wants keyboard focus or not.
bool isMouseOver(bool includeChildren=false) const
Returns true if the mouse is currently over this component.
int getWidth() const noexcept
Returns the component's width in pixels.
LookAndFeel & getLookAndFeel() const noexcept
Finds the appropriate look-and-feel to use for this component.
Rectangle< int > getLocalBounds() const noexcept
Returns the component's bounds, relative to its own origin.
void setComponentEffect(ImageEffectFilter *newEffect)
Adds an effect filter to alter the component's appearance.
virtual void setVisible(bool shouldBeVisible)
Makes the component visible or invisible.
A graphics context, used for drawing a component or image.
Represents a key press, including any modifier keys that are needed.
static const int homeKey
key-code for the home key
static const int upKey
key-code for the cursor-up key
static const int endKey
key-code for the end key
static const int rightKey
key-code for the cursor-right key
static const int downKey
key-code for the cursor-down key
static const int leftKey
key-code for the cursor-left key
static const int pageUpKey
key-code for the page-up key
static const int pageDownKey
key-code for the page-down key
Contains position and status information about a mouse event.
const int x
The x-position of the mouse when the event occurred.
const int y
The y-position of the mouse when the event occurred.
A general-purpose range object, that simply represents any linear range with a start and end point.
Range constrainRange(Range rangeToConstrain) const noexcept
Returns a given range, after moving it forwards or backwards to fit it within this range.
constexpr ValueType getStart() const noexcept
Returns the start of the range.
constexpr ValueType getEnd() const noexcept
Returns the end of the range.
constexpr Range movedToStartAt(const ValueType newStart) const noexcept
Returns a range with the same length as this one, but moved to have the given start position.
constexpr ValueType getLength() const noexcept
Returns the length of the range.
constexpr Range movedToEndAt(const ValueType newEnd) const noexcept
Returns a range with the same length as this one, but moved to have the given end position.
void stopTimer() noexcept
Stops the timer.
void startTimer(int intervalInMilliseconds) noexcept
Starts the timer and sets the length of interval required.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
constexpr Type jmax(Type a, Type b)
Returns the larger of two values.
NotificationType
These enums are used in various classes to indicate whether a notification event should be sent out.
@ sendNotificationSync
Requests a synchronous notification.
@ dontSendNotification
No notification message should be sent.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
int roundToInt(const FloatType value) noexcept
Fast floating-point-to-integer conversion.
Contains status information about a mouse wheel event.
Utility struct which holds one or more accessibility interfaces.